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