1skbmod action in tc(8) Linux skbmod action in tc(8)
2
3
4
6 skbmod - user-friendly packet editor action
7
9 tc ... action skbmod { set SETTABLE | swap SWAPPABLE | ecn } [ CONTROL
10 ] [ index INDEX ]
11
12 SETTABLE := [ dmac DMAC ] [ smac SMAC ] [ etype ETYPE ]
13
14 SWAPPABLE := mac
15
16 CONTROL := { reclassify | pipe | drop | shot | continue | pass }
17
19 The skbmod action is intended as a usability upgrade to the existing
20 pedit action. Instead of having to manually edit 8-, 16-, or 32-bit
21 chunks of an ethernet header, skbmod allows complete substitution of
22 supported elements. Action must be one of set, swap and ecn. set and
23 swap only affect Ethernet packets, while ecn only affects IP packets.
24
26 dmac DMAC
27 Change the destination mac to the specified address.
28
29 smac SMAC
30 Change the source mac to the specified address.
31
32 etype ETYPE
33 Change the ethertype to the specified value.
34
35 mac Used to swap mac addresses.
36
37 ecn Used to mark ECN Capable Transport (ECT) IP packets as Conges‐
38 tion Encountered (CE). Does not affect Non ECN-Capable Trans‐
39 port (Non-ECT) packets.
40
41 CONTROL
42 The following keywords allow one to control how the tree of
43 qdisc, classes, filters and actions is further traversed after
44 this action.
45
46 reclassify
47 Restart with the first filter in the current list.
48
49 pipe Continue with the next action attached to the same fil‐
50 ter.
51
52 drop
53 shot Drop the packet.
54
55 continue
56 Continue classification with the next filter in line.
57
58 pass Finish classification process and return to calling qdisc
59 for further packet processing. This is the default.
60
62 To start, observe the following filter with a pedit action:
63
64 tc filter add dev eth1 parent 1: protocol ip prio 10 \
65 u32 match ip protocol 1 0xff flowid 1:2 \
66 action pedit munge offset -14 u8 set 0x02 \
67 munge offset -13 u8 set 0x15 \
68 munge offset -12 u8 set 0x15 \
69 munge offset -11 u8 set 0x15 \
70 munge offset -10 u16 set 0x1515 \
71 pipe
72
73 Using the skbmod action, this command can be simplified to:
74
75 tc filter add dev eth1 parent 1: protocol ip prio 10 \
76 u32 match ip protocol 1 0xff flowid 1:2 \
77 action skbmod set dmac 02:15:15:15:15:15 \
78 pipe
79
80 Complexity will increase if source mac and ethertype are also being
81 edited as part of the action. If all three fields are to be changed
82 with skbmod:
83
84 tc filter add dev eth5 parent 1: protocol ip prio 10 \
85 u32 match ip protocol 1 0xff flowid 1:2 \
86 action skbmod \
87 set etype 0xBEEF \
88 set dmac 02:12:13:14:15:16 \
89 set smac 02:22:23:24:25:26
90
91 To swap the destination and source mac addresses in the Ethernet
92 header:
93
94 tc filter add dev eth3 parent 1: protocol ip prio 10 \
95 u32 match ip protocol 1 0xff flowid 1:2 \
96 action skbmod \
97 swap mac
98
99 Finally, to mark the CE codepoint in the IP header for ECN Capable
100 Transport (ECT) packets:
101
102 tc filter add dev eth0 parent 1: protocol ip prio 10 \
103 u32 match ip protocol 1 0xff flowid 1:2 \
104 action skbmod \
105 ecn
106
107 Only one of set, swap and ecn shall be used in a single command. Try‐
108 ing to use more than one of them in a single command is considered un‐
109 defined behavior; pipe multiple commands together instead.
110
111
113 tc(8), tc-u32(8), tc-pedit(8)
114
115
116
117iproute2 21 Sep 2016 skbmod action in tc(8)