Blame man/man8/tc-simple.8

Packit Service 3880ab
.TH "Simple action in tc" 8 "12 Jan 2015" "iproute2" "Linux"
Packit Service 3880ab
Packit Service 3880ab
.SH NAME
Packit Service 3880ab
simple - basic example action
Packit Service 3880ab
.SH SYNOPSIS
Packit Service 3880ab
.in +8
Packit Service 3880ab
.ti -8
Packit Service 3880ab
.BR tc " ... " "action simple"
Packit Service 3880ab
[
Packit Service 3880ab
.BI sdata " STRING"
Packit Service 3880ab
] [
Packit Service 3880ab
.BI index " INDEX"
Packit Service 3880ab
] [
Packit Service 3880ab
.I CONTROL
Packit Service 3880ab
]
Packit Service 3880ab
Packit Service 3880ab
.ti -8
Packit Service 3880ab
.IR CONTROL " := {"
Packit Service 3880ab
.BR reclassify " | " pipe " | " drop " | " continue " | " ok " }"
Packit Service 3880ab
Packit Service 3880ab
.SH DESCRIPTION
Packit Service 3880ab
This is a pedagogical example rather than an actually useful action. Upon every access, it prints the given
Packit Service 3880ab
.I STRING
Packit Service 3880ab
which may be of arbitrary length.
Packit Service 3880ab
.SH OPTIONS
Packit Service 3880ab
.TP
Packit Service 3880ab
.BI sdata " STRING"
Packit Service 3880ab
The actual string to print.
Packit Service 3880ab
.TP
Packit Service 3880ab
.BI index " INDEX"
Packit Service 3880ab
Optional action index value.
Packit Service 3880ab
.TP
Packit Service 3880ab
.I CONTROL
Packit Service 3880ab
Indicate how
Packit Service 3880ab
.B tc
Packit Service 3880ab
should proceed after executing the action. For a description of the possible
Packit Service 3880ab
.I CONTROL
Packit Service 3880ab
values, see
Packit Service 3880ab
.BR tc-actions (8).
Packit Service 3880ab
.SH EXAMPLES
Packit Service 3880ab
The following example makes the kernel yell "Incoming ICMP!" every time it sees
Packit Service 3880ab
an incoming ICMP on eth0. Steps are:
Packit Service 3880ab
.IP 1) 4
Packit Service 3880ab
Add an ingress qdisc point to eth0
Packit Service 3880ab
.IP 2) 4
Packit Service 3880ab
Start a chain on ingress of eth0 that first matches ICMP then invokes the
Packit Service 3880ab
simple action to shout.
Packit Service 3880ab
.IP 3) 4
Packit Service 3880ab
display stats and show that no packet has been seen by the action
Packit Service 3880ab
.IP 4) 4
Packit Service 3880ab
Send one ping packet to google (expect to receive a response back)
Packit Service 3880ab
.IP 5) 4
Packit Service 3880ab
grep the logs to see the logged message
Packit Service 3880ab
.IP 6) 4
Packit Service 3880ab
display stats again and observe increment by 1
Packit Service 3880ab
Packit Service 3880ab
.EX
Packit Service 3880ab
  hadi@noma1:$ tc qdisc add dev eth0 ingress
Packit Service 3880ab
  hadi@noma1:$tc filter add dev eth0 parent ffff: protocol ip prio 5 \\
Packit Service 3880ab
	 u32 match ip protocol 1 0xff flowid 1:1 action simple sdata "Incoming ICMP"
Packit Service 3880ab
Packit Service 3880ab
  hadi@noma1:$ sudo tc -s filter ls  dev eth0 parent ffff:
Packit Service 3880ab
   filter protocol ip pref 5 u32
Packit Service 3880ab
   filter protocol ip pref 5 u32 fh 800: ht divisor 1
Packit Service 3880ab
   filter protocol ip pref 5 u32 fh 800::800 order 2048 key ht 800 bkt 0 flowid 1:1
Packit Service 3880ab
     match 00010000/00ff0000 at 8
Packit Service 3880ab
	action order 1: Simple <Incoming ICMP>
Packit Service 3880ab
	 index 4 ref 1 bind 1 installed 29 sec used 29 sec
Packit Service 3880ab
	 Action statistics:
Packit Service 3880ab
		Sent 0 bytes 0 pkt (dropped 0, overlimits 0 requeues 0)
Packit Service 3880ab
		backlog 0b 0p requeues 0
Packit Service 3880ab
Packit Service 3880ab
Packit Service 3880ab
  hadi@noma1$ ping -c 1 www.google.ca
Packit Service 3880ab
  PING www.google.ca (74.125.225.120) 56(84) bytes of data.
Packit Service 3880ab
  64 bytes from ord08s08-in-f24.1e100.net (74.125.225.120): icmp_req=1 ttl=53 time=31.3 ms
Packit Service 3880ab
Packit Service 3880ab
  --- www.google.ca ping statistics ---
Packit Service 3880ab
  1 packets transmitted, 1 received, 0% packet loss, time 0ms
Packit Service 3880ab
  rtt min/avg/max/mdev = 31.316/31.316/31.316/0.000 ms
Packit Service 3880ab
Packit Service 3880ab
  hadi@noma1$ dmesg | grep simple
Packit Service 3880ab
  [135354.473951] simple: Incoming ICMP_1
Packit Service 3880ab
Packit Service 3880ab
  hadi@noma1$ sudo tc/tc -s filter ls  dev eth0 parent ffff:
Packit Service 3880ab
  filter protocol ip pref 5 u32
Packit Service 3880ab
  filter protocol ip pref 5 u32 fh 800: ht divisor 1
Packit Service 3880ab
  filter protocol ip pref 5 u32 fh 800::800 order 2048 key ht 800 bkt 0 flowid 1:1
Packit Service 3880ab
    match 00010000/00ff0000 at 8
Packit Service 3880ab
	action order 1: Simple <Incoming ICMP>
Packit Service 3880ab
	 index 4 ref 1 bind 1 installed 206 sec used 67 sec
Packit Service 3880ab
	Action statistics:
Packit Service 3880ab
	Sent 84 bytes 1 pkt (dropped 0, overlimits 0 requeues 0)
Packit Service 3880ab
	backlog 0b 0p requeues 0
Packit Service 3880ab
.EE
Packit Service 3880ab
.SH SEE ALSO
Packit Service 3880ab
.BR tc (8)
Packit Service 3880ab
.BR tc-actions (8)