TC-SIMPLE(8)

๐Ÿ“ฆ
version 7.3.0 ยท 2 versions
  • 7.3.0 ยท alpine 3.22, alpine 3.23, alpine 3.24, arch rolling, centos-stream 10, centos-stream 9, debian trixie, fedora 43, fedora 44, nixos 26.05, nixpkgs unstable, opensuse-leap 16.0, ubuntu questing, ubuntu resolute, ubuntu stonking (latest)
  • 6.1.0 ยท debian bookworm, ubuntu jammy, ubuntu noble
, in alpine 3.22, alpine 3.23, alpine 3.24, arch rolling, centos-stream 10, centos-stream 9, debian trixie, fedora 43, fedora 44, nixos 26.05, nixpkgs unstable, opensuse-leap 16.0, ubuntu questing, ubuntu resolute, ubuntu stonking

โœจ TC-SIMPLE(8) โœจ

Simple action in tc(8) ๐Ÿ’– the bestie of tc actions, fr

๐ŸŽ€ NAME

simple - basic example action ๐Ÿงš

๐ŸŒธ SYNOPSIS

tc ... action simple [ sdata STRING ] [ index INDEX ] [ CONTROL ]

CONTROL := { reclassify | pipe | drop | continue | ok }

๐Ÿ’… DESCRIPTION

okay so this one is a pedagogical example, aka it's literally here to teach you how actions work, not to be useful in your daily life ๐Ÿ˜ญ no shade tho. Every single time it gets accessed, it prints the STRING you gave it, and that string can be any length you want ๐Ÿซถ

โœจ OPTIONS โœจ

  • sdata STRING โ€” the actual string it prints ๐Ÿ–จ๏ธ
  • index INDEX โ€” an optional action index value ๐Ÿ”ข
  • CONTROL โ€” tells tc what to do next once the action is done running. For the full tea on the possible CONTROL values, peep tc-actions(8) ๐Ÿ‘€

๐Ÿฆ‹ EXAMPLES

this example makes the kernel yell "Incoming ICMP!" every time it spots an incoming ICMP packet on eth0. The vibe check goes like this:

  1. Add an ingress qdisc point to eth0 ๐ŸŒˆ
  2. Start a chain on ingress of eth0 that first matches ICMP, then calls the simple action to shout ๐Ÿ“ข
  3. Display stats and show that no packet has been seen by the action (zero, bestie, zero) ๐Ÿ™ˆ
  4. Send one ping packet to google (expect to get a response back) ๐Ÿ“
  5. Grep the logs to see the logged message ๐Ÿ”
  6. Display stats again and observe the increment by 1 โญ
$ tc qdisc add dev eth0 ingress
$ tc filter add dev eth0 parent ffff: protocol ip prio 5 \
    u32 match ip protocol 1 0xff flowid 1:1 action simple sdata "Incoming ICMP"

$ sudo tc -s filter ls dev eth0 parent ffff:
 filter protocol ip pref 5 u32
 filter protocol ip pref 5 u32 fh 800: ht divisor 1
 filter protocol ip pref 5 u32 fh 800::800 order 2048 key ht 800 bkt 0 flowid 1:1
   match 00010000/00ff0000 at 8
   action order 1: Simple <Incoming ICMP>
    index 4 ref 1 bind 1 installed 29 sec used 29 sec
    Action statistics:
        Sent 0 bytes 0 pkt (dropped 0, overlimits 0 requeues 0)
        backlog 0b 0p requeues 0

$ ping -c 1 www.google.ca
PING www.google.ca (74.125.225.120) 56(84) bytes of data.
64 bytes from ord08s08-in-f24.1e100.net (74.125.225.120): icmp_req=1 ttl=53 time=31.3 ms

--- www.google.ca ping statistics ---
1 packets transmitted, 1 received, 0% packet loss, time 0ms
rtt min/avg/max/mdev = 31.316/31.316/31.316/0.000 ms

$ dmesg | grep simple
[135354.473951] simple: Incoming ICMP_1

$ sudo tc/tc -s filter ls dev eth0 parent ffff:
filter protocol ip pref 5 u32
filter protocol ip pref 5 u32 fh 800: ht divisor 1
filter protocol ip pref 5 u32 fh 800::800 order 2048 key ht 800 bkt 0 flowid 1:1
  match 00010000/00ff0000 at 8
   action order 1: Simple <Incoming ICMP>
    index 4 ref 1 bind 1 installed 206 sec used 67 sec
   Action statistics:
   Sent 84 bytes 1 pkt (dropped 0, overlimits 0 requeues 0)
   backlog 0b 0p requeues 0

๐Ÿซถ SEE ALSO

tc(8) tc-actions(8)


iproute2 ยท 12 Jan 2015 ยท Linux ๐Ÿ’œ that's a wrap, bestie, you're literally a Unix legend now ๐Ÿ‘‘โœจ