TC-IFE(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

๐Ÿ’– IFE action in tc(8) ๐Ÿ’–

okay bestie, this is the manual page for IFE action in tc(8) on Linux ๐Ÿฆ‹ it's the tc action for IFE, which is short for encapsulate/decapsulate metadata. let's get into it โœจ


โœจ NAME โœจ

IFE โ€” encapsulate/decapsulate metadata ๐Ÿงš

๐ŸŽ€ SYNOPSIS ๐ŸŽ€

tc ...  action ife DIRECTION [ ACTION ] [ dst DMAC ] [ src SMAC ] [ type
        TYPE ] [ CONTROL ] [ index INDEX ]

DIRECTION := { decode | encode }

ACTION := { allow ATTR | use ATTR value }

ATTR := { mark | prio | tcindex }

CONTROL := { reclassify | use | pipe | drop | continue | ok | goto chain
        CHAIN_INDEX }

๐ŸŒธ DESCRIPTION ๐ŸŒธ

okay so the ife action lets the sending side encapsulate arbitrary metadata ๐Ÿ’… and then the receiving end decapsulates it and gets to use it. the sender runs in encoding mode and the receiver runs in decode mode. ๐Ÿซถ

the big rule: both sender and receiver have to specify the same ethertype ๐Ÿ™ˆ no cap, if they don't match it's not gonna work. in the future a registered ethertype may be available as a default, so keep an eye out ๐Ÿ‘€

๐Ÿ‘‘ OPTIONS ๐Ÿ‘‘

  • decode โ€” this one's for the receiving side ๐Ÿ“ฅ it decodes the metadata if the packet matches.
  • encode โ€” this one's for the sending side ๐Ÿ“ค it encodes the specified metadata if the packet matches.
  • allow โ€” encode direction only ๐Ÿ’œ it allows encoding the specified metadata.
  • use โ€” encode direction only ๐Ÿ”’ it enforces static encoding of the specified metadata.
  • mark [ u32_value ] โ€” sets the value for the skb mark ๐Ÿท๏ธ the u32 value is only required when use is specified. if the mark value is zero it won't be encoded, instead the "overlimits" statistics increment and the CONTROL action gets taken ๐Ÿ˜ญ
  • prio [ u32_value ] โ€” sets the priority in the skb structure ๐Ÿ”ฅ the u32 value is only required when use is specified.
  • tcindex [ u16_value ] โ€” the value to set for the traffic control index in the skb structure ๐Ÿ“ the u16 value is only required when use is specified.
  • dmac DMAC, smac SMAC โ€” optional six byte destination or source MAC address to encode ๐Ÿ’Œ
  • type TYPE โ€” optional 16-bit ethertype to encode ๐ŸŒˆ if you don't specify one, 0xED3E gets used as the default.
  • CONTROL โ€” the action to take right after an encode/decode ๐Ÿฆ‹
  • index INDEX โ€” gives this action a unique ID instead of letting the kernel pick one automatically โœจ INDEX is a 32bit unsigned integer greater than zero.

๐Ÿงš EXAMPLES ๐Ÿงš

okay so the first one: on the receiving side, we match packets with ethertype 0xdead and restart classification so it'll match ICMP on the next rule, at prio 3 ๐Ÿ”ฅ

# tc qdisc add dev eth0 handle ffff: ingress
# tc filter add dev eth0 parent ffff: prio 2 protocol 0xdead \
     u32 match u32 0 0 flowid 1:1 \
     action ife decode reclassify
# tc filter add dev eth0 parent ffff: prio 3 protocol ip \
     u32 match ip protocol 0xff flowid 1:1 \
     action continue

next up, matching with an skb mark of 17 ๐ŸŽ€

# tc filter add dev eth0 parent ffff: prio 4 protocol ip \
     handle 0x11 fw flowid 1:1 \
     action ok

and now the sending side ๐Ÿ“ค this one is giving main character energy. we're configuring it to encode for the filters above. it uses a destination IP address of 192.168.122.237/24, then tags with an skb mark of decimal 17. the packet gets encoded with ethertype 0xdead, we add skb->mark to the allowed list of metadata to send, and we rewrite the destination MAC address to 02:15:15:15:15:15 ๐Ÿ’–

# tc qdisc add dev eth0 root handle 1: prio
# tc filter add dev eth0 parent 1: protocol ip prio 10 u32 \
     match ip dst 192.168.122.237/24 \
     match ip protocol 1 0xff \
     flowid 1:2 \
     action skbedit mark 17 \
     action ife encode \
     type 0xDEAD \
     allow mark \
     dst 02:15:15:15:15:15

๐Ÿฆ‹ SEE ALSO ๐Ÿฆ‹

tc(8), tc-u32(8) ๐Ÿซถ


bestie that's the whole IFE page ๐Ÿ’… it's from iproute2, dated 22 Apr 2016, and it's the IFE action in tc(8) manual ๐Ÿ’œ go be iconic ๐ŸŒธ