TC-SKBMOD(8)
โจ skbmod action in tc(8) โจ
okay bestie, this is the manual page for skbmod, the action that makes packet editing way less painful ๐
๐ NAME
skbmod - user-friendly packet editor action
๐ง SYNOPSIS
tc ... action skbmod { set SETTABLE | swap SWAPPABLE | ecn } [ CONTROL
] [ index INDEX ]
SETTABLE := [ dmac DMAC ] [ smac SMAC ] [ etype ETYPE ]
SWAPPABLE := mac
CONTROL := { reclassify | pipe | drop | shot | continue | pass }
๐ฆ DESCRIPTION
so the skbmod action is basically a glow-up of the existing pedit action ๐
instead of hand-editing 8-, 16-, or 32-bit chunks of an ethernet header like it's 1999, skbmod lets you swap out whole supported elements in one go ๐ซถ
you pick one of three actions: set, swap, or ecn. set and swap only touch Ethernet packets, while ecn only touches IP packets ๐ธ
๐ OPTIONS
dmac DMACโ change the destination mac to whatever address you give it ๐smac SMACโ change the source mac to the specified address ๐etype ETYPEโ change the ethertype to the specified value โจmacโ swaps the mac addresses ๐ecnโ marks ECN Capable Transport (ECT) IP packets as Congestion Encountered (CE) ๐ it does not touch Non ECN-Capable Transport (Non-ECT) packets, so those stay exactly as they are ๐CONTROLโ these keywords decide how the tree of qdisc, classes, filters and actions gets traversed after this action runs ๐งญreclassifyโ restart with the first filter in the current list ๐pipeโ continue with the next action attached to the same filter โก๏ธdroporshotโ drop the packet ๐continueโ continue classification with the next filter in line ๐โโ๏ธpassโ finish classification and return to the calling qdisc for further packet processing. this is the default ๐
๐ EXAMPLES
okay so first, let's look at a filter using the pedit action:
tc filter add dev eth1 parent 1: protocol ip prio 10 \
u32 match ip protocol 1 0xff flowid 1:2 \
action pedit munge offset -14 u8 set 0x02 \
munge offset -13 u8 set 0x15 \
munge offset -12 u8 set 0x15 \
munge offset -11 u8 set 0x15 \
munge offset -10 u16 set 0x1515 \
pipe
with skbmod, that whole mess becomes:
tc filter add dev eth1 parent 1: protocol ip prio 10 \
u32 match ip protocol 1 0xff flowid 1:2 \
action skbmod set dmac 02:15:15:15:15:15 \
pipe
it gets a little more involved if you also edit the source mac and ethertype. if all three fields are changing with skbmod:
tc filter add dev eth5 parent 1: protocol ip prio 10 \
u32 match ip protocol 1 0xff flowid 1:2 \
action skbmod \
set etype 0xBEEF \
set dmac 02:12:13:14:15:16 \
set smac 02:22:23:24:25:26
to swap the destination and source mac addresses in the Ethernet header:
tc filter add dev eth3 parent 1: protocol ip prio 10 \
u32 match ip protocol 1 0xff flowid 1:2 \
action skbmod \
swap mac
and finally, to mark the CE codepoint in the IP header for ECN Capable Transport (ECT) packets:
tc filter add dev eth0 parent 1: protocol ip prio 10 \
u32 match ip protocol 1 0xff flowid 1:2 \
action skbmod \
ecn
โ ๏ธ bestie, listen up: only one ofset,swapandecncan be used in a single command. trying to use more than one in the same command is undefined behavior ๐ if you need multiple, pipe multiple commands together instead ๐ซถ
๐ SEE ALSO
tc(8), tc-u32(8), tc-pedit(8) ๐ฆ
that's a wrap, bestie ๐ this page is from iproute2, dated 21 Sep 2016, titled skbmod action in tc(8) โจ๐
๐ฆ where this page comes from
- alpine 3.22: iproute2-doc 6.15.0-r0 ยท GPL-2.0-or-later
- alpine 3.23: iproute2-doc 6.17.0-r0 ยท GPL-2.0-or-later
- alpine 3.24: iproute2-doc 7.0.0-r0 ยท GPL-2.0-or-later
- arch rolling: iproute2 7.2.0-1
- arch rolling: iproute2 7.3.0-1 ยท GPL-2.0-or-later
- centos-stream 10: iproute-tc 7.0.0-2.el10 ยท GPL-2.0-or-later
- centos-stream 9: iproute-tc 6.17.0-3.el9 ยท GPL-2.0-or-later
- debian bookworm: iproute2 6.1.0-3 ยท GPL-2.0-only
- debian trixie: iproute2 6.15.0-1 ยท GPL-2.0-only
- fedora 43: iproute-tc 6.14.0-2.fc43 ยท GPL-2.0-or-later
- fedora 44: iproute-tc 6.17.0-2.fc44 ยท GPL-2.0-or-later
- nixos 26.05: iproute2 7.0.0
- nixpkgs unstable: iproute2 7.2.0
- opensuse-leap 16.0: iproute2 6.12-160000.4.1 ยท GPL-2.0-only
- opensuse-leap 16.0: iproute2 6.12-160000.4.1 ยท GPL-2.0-only
- opensuse-leap 16.0: iproute2 6.12-160000.4.1 ยท GPL-2.0-only
- opensuse-leap 16.0: iproute2 6.12-160000.4.1 ยท GPL-2.0-only
- ubuntu noble: iproute2 6.1.0-1ubuntu6 ยท GPL-2.0-only
- ubuntu noble: iproute2 6.1.0-1ubuntu6.4 ยท GPL-2.0-only
- ubuntu questing: iproute2 6.16.0-1ubuntu2
- ubuntu questing: iproute2 6.16.0-1ubuntu2.1 ยท GPL-2.0-only
- ubuntu questing: iproute2 6.16.0-1ubuntu2.2
- ubuntu resolute: iproute2 6.19.0-1ubuntu1 ยท GPL-2.0-only
- ubuntu resolute: iproute2 6.19.0-1ubuntu1.1 ยท GPL-2.0-only
- ubuntu stonking: iproute2 7.2.0-1ubuntu1 ยท GPL-2.0-only
- ๐ girlified by anthropic/claude-haiku-5.5 on : a language model's rewrite of the original, under its terms