1Simple action in tc(8) Linux Simple action in tc(8)
2
3
4
6 simple - basic example action
7
9 tc ... action simple [ sdata STRING ] [ index INDEX ] [ CONTROL ]
10
11 CONTROL := { reclassify | pipe | drop | continue | ok }
12
13
15 This is a pedagogical example rather than an actually useful action.
16 Upon every access, it prints the given STRING which may be of arbitrary
17 length.
18
20 sdata STRING
21 The actual string to print.
22
23 index INDEX
24 Optional action index value.
25
26 CONTROL
27 Indicate how tc should proceed after executing the action. For a
28 description of the possible CONTROL values, see tc-pedit(8).
29
31 The following example makes the kernel yell "Incoming ICMP!" every time
32 it sees an incoming ICMP on eth0. Steps are:
33
34 1) Add an ingress qdisc point to eth0
35
36 2) Start a chain on ingress of eth0 that first matches ICMP then
37 invokes the simple action to shout.
38
39 3) display stats and show that no packet has been seen by the action
40
41 4) Send one ping packet to google (expect to receive a response back)
42
43 5) grep the logs to see the logged message
44
45 6) display stats again and observe increment by 1
46
47 hadi@noma1:$ tc qdisc add dev eth0 ingress
48 hadi@noma1:$tc filter add dev eth0 parent ffff: protocol ip prio 5 \
49 u32 match ip protocol 1 0xff flowid 1:1 action simple sdata "Incoming ICMP"
50
51 hadi@noma1:$ sudo tc -s filter ls dev eth0 parent ffff:
52 filter protocol ip pref 5 u32
53 filter protocol ip pref 5 u32 fh 800: ht divisor 1
54 filter protocol ip pref 5 u32 fh 800::800 order 2048 key ht 800 bkt 0 flowid 1:1
55 match 00010000/00ff0000 at 8
56 action order 1: Simple <Incoming ICMP>
57 index 4 ref 1 bind 1 installed 29 sec used 29 sec
58 Action statistics:
59 Sent 0 bytes 0 pkt (dropped 0, overlimits 0 requeues 0)
60 backlog 0b 0p requeues 0
61
62
63 hadi@noma1$ ping -c 1 www.google.ca
64 PING www.google.ca (74.125.225.120) 56(84) bytes of data.
65 64 bytes from ord08s08-in-f24.1e100.net (74.125.225.120): icmp_req=1 ttl=53 time=31.3 ms
66
67 --- www.google.ca ping statistics ---
68 1 packets transmitted, 1 received, 0% packet loss, time 0ms
69 rtt min/avg/max/mdev = 31.316/31.316/31.316/0.000 ms
70
71 hadi@noma1$ dmesg | grep simple
72 [135354.473951] simple: Incoming ICMP_1
73
74 hadi@noma1$ sudo tc/tc -s filter ls dev eth0 parent ffff:
75 filter protocol ip pref 5 u32
76 filter protocol ip pref 5 u32 fh 800: ht divisor 1
77 filter protocol ip pref 5 u32 fh 800::800 order 2048 key ht 800 bkt 0 flowid 1:1
78 match 00010000/00ff0000 at 8
79 action order 1: Simple <Incoming ICMP>
80 index 4 ref 1 bind 1 installed 206 sec used 67 sec
81 Action statistics:
82 Sent 84 bytes 1 pkt (dropped 0, overlimits 0 requeues 0)
83 backlog 0b 0p requeues 0
84
86 tc(8) tc-pedit(8)
87
88
89
90iproute2 12 Jan 2015 Simple action in tc(8)