]> git.proxmox.com Git - mirror_iproute2.git/commit - tc/m_action.c
actions: Add support for user cookies
authorJamal Hadi Salim <jhs@mojatatu.com>
Sat, 22 Apr 2017 12:36:23 +0000 (08:36 -0400)
committerStephen Hemminger <stephen@networkplumber.org>
Sun, 23 Apr 2017 16:10:02 +0000 (09:10 -0700)
commitfd8b3d2c1b9b6dde3adf88662d1d72a68e5d3c63
treeadb8a0d290210bdd952bb4644c9e9a02b98e876a
parentf443565f8df65e7d3b3e7cb5f4e94aec1e12d067
actions: Add support for user cookies

Make use of 128b user cookies

Introduce optional 128-bit action cookie.
Like all other cookie schemes in the networking world (eg in protocols
like http or existing kernel fib protocol field, etc) the idea is to
save user state that when retrieved serves as a correlator. The kernel
_should not_ intepret it. The user can store whatever they wish in the
128 bits.

Sample exercise(showing variable length use of cookie)

.. create an accept action with cookie a1b2c3d4
sudo $TC actions add action ok index 1 cookie a1b2c3d4

.. dump all gact actions..
sudo $TC -s actions ls action gact

    action order 0: gact action pass
     random type none pass val 0
     index 1 ref 1 bind 0 installed 5 sec used 5 sec
    Action statistics:
    Sent 0 bytes 0 pkt (dropped 0, overlimits 0 requeues 0)
    backlog 0b 0p requeues 0
    cookie a1b2c3d4

.. bind the accept action to a filter..
sudo $TC filter add dev lo parent ffff: protocol ip prio 1 \
u32 match ip dst 127.0.0.1/32 flowid 1:1 action gact index 1

... send some traffic..
$ ping 127.0.0.1 -c 3
PING 127.0.0.1 (127.0.0.1) 56(84) bytes of data.
64 bytes from 127.0.0.1: icmp_seq=1 ttl=64 time=0.020 ms
64 bytes from 127.0.0.1: icmp_seq=2 ttl=64 time=0.027 ms
64 bytes from 127.0.0.1: icmp_seq=3 ttl=64 time=0.038 ms

Signed-off-by: Jamal Hadi Salim <jhs@mojatatu.com>
tc/m_action.c