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 ] [ CONTROL ]
10 [ index INDEX ] }
11
12 SETTABLE := [ dmac DMAC ] [ smac SMAC ] [ etype ETYPE ]
13
14 SWAPPABLE := mac
15 CONTROL := { reclassify | pipe | drop | shot | continue | pass }
16
18 The skbmod action is intended as a usability upgrade to the existing
19 pedit action. Instead of having to manually edit 8-, 16-, or 32-bit
20 chunks of an ethernet header, skbmod allows complete substitution of
21 supported elements.
22
24 dmac DMAC
25 Change the destination mac to the specified address.
26
27 smac SMAC
28 Change the source mac to the specified address.
29
30 etype ETYPE
31 Change the ethertype to the specified value.
32
33 mac Used to swap mac addresses. The swap mac directive is performed
34 after any outstanding D/SMAC changes.
35
36 CONTROL
37 The following keywords allow to control how the tree of qdisc,
38 classes, filters and actions is further traversed after this
39 action.
40
41 reclassify
42 Restart with the first filter in the current list.
43
44 pipe Continue with the next action attached to the same fil‐
45 ter.
46
47 drop
48 shot Drop the packet.
49
50 continue
51 Continue classification with the next filter in line.
52
53 pass Finish classification process and return to calling qdisc
54 for further packet processing. This is the default.
55
57 To start, observe the following filter with a pedit action:
58
59 tc filter add dev eth1 parent 1: protocol ip prio 10 \
60 u32 match ip protocol 1 0xff flowid 1:2 \
61 action pedit munge offset -14 u8 set 0x02 \
62 munge offset -13 u8 set 0x15 \
63 munge offset -12 u8 set 0x15 \
64 munge offset -11 u8 set 0x15 \
65 munge offset -10 u16 set 0x1515 \
66 pipe
67
68 Using the skbmod action, this command can be simplified to:
69
70 tc filter add dev eth1 parent 1: protocol ip prio 10 \
71 u32 match ip protocol 1 0xff flowid 1:2 \
72 action skbmod set dmac 02:15:15:15:15:15 \
73 pipe
74
75 Complexity will increase if source mac and ethertype are also being
76 edited as part of the action. If all three fields are to be changed
77 with skbmod:
78
79 tc filter add dev eth5 parent 1: protocol ip prio 10 \
80 u32 match ip protocol 1 0xff flowid 1:2 \
81 action skbmod \
82 set etype 0xBEEF \
83 set dmac 02:12:13:14:15:16 \
84 set smac 02:22:23:24:25:26
85
86 Finally, swap the destination and source mac addresses in the header:
87
88 tc filter add dev eth3 parent 1: protocol ip prio 10 \
89 u32 match ip protocol 1 0xff flowid 1:2 \
90 action skbmod \
91 swap mac
92
93 As mentioned above, the swap action will occur after any smac/dmac
94 substitutions are executed, if they are present.
95
96
98 tc(8), tc-u32(8), tc-pedit(8)
99
100
101
102iproute2 21 Sep 2016 skbmod action in tc(8)