| 1 |
.TH "skbmod action in tc" 8 "21 Sep 2016" "iproute2" "Linux" |
| 2 |
|
| 3 |
.SH NAME |
| 4 |
skbmod - user-friendly packet editor action |
| 5 |
.SH SYNOPSIS |
| 6 |
.in +8 |
| 7 |
.ti -8 |
| 8 |
.BR tc " ... " "action skbmod " "{ " "set " |
| 9 |
.IR SETTABLE " | " |
| 10 |
.BI swap " SWAPPABLE" |
| 11 |
.RB " | " ecn |
| 12 |
.RI "} [ " CONTROL " ] [ " |
| 13 |
.BI index " INDEX " |
| 14 |
] |
| 15 |
|
| 16 |
.ti -8 |
| 17 |
.IR SETTABLE " := " |
| 18 |
.RB " [ " dmac |
| 19 |
.IR DMAC " ] " |
| 20 |
.RB " [ " smac |
| 21 |
.IR SMAC " ] " |
| 22 |
.RB " [ " etype |
| 23 |
.IR ETYPE " ] " |
| 24 |
|
| 25 |
.ti -8 |
| 26 |
.IR SWAPPABLE " := " |
| 27 |
.B mac |
| 28 |
.ti -8 |
| 29 |
|
| 30 |
.IR CONTROL " := {" |
| 31 |
.BR reclassify " | " pipe " | " drop " | " shot " | " continue " | " pass " }" |
| 32 |
.SH DESCRIPTION |
| 33 |
The |
| 34 |
.B skbmod |
| 35 |
action is intended as a usability upgrade to the existing |
| 36 |
.B pedit |
| 37 |
action. Instead of having to manually edit 8-, 16-, or 32-bit chunks of an |
| 38 |
ethernet header, |
| 39 |
.B skbmod |
| 40 |
allows complete substitution of supported elements. |
| 41 |
Action must be one of |
| 42 |
.BR set ", " swap " and " ecn "." |
| 43 |
.BR set " and " swap |
| 44 |
only affect Ethernet packets, while |
| 45 |
.B ecn |
| 46 |
only affects IP packets. |
| 47 |
.SH OPTIONS |
| 48 |
.TP |
| 49 |
.BI dmac " DMAC" |
| 50 |
Change the destination mac to the specified address. |
| 51 |
.TP |
| 52 |
.BI smac " SMAC" |
| 53 |
Change the source mac to the specified address. |
| 54 |
.TP |
| 55 |
.BI etype " ETYPE" |
| 56 |
Change the ethertype to the specified value. |
| 57 |
.TP |
| 58 |
.BI mac |
| 59 |
Used to swap mac addresses. |
| 60 |
.TP |
| 61 |
.B ecn |
| 62 |
Used to mark ECN Capable Transport (ECT) IP packets as Congestion Encountered (CE). |
| 63 |
Does not affect Non ECN-Capable Transport (Non-ECT) packets. |
| 64 |
.TP |
| 65 |
.I CONTROL |
| 66 |
The following keywords allow one to control how the tree of qdisc, classes, |
| 67 |
filters and actions is further traversed after this action. |
| 68 |
.RS |
| 69 |
.TP |
| 70 |
.B reclassify |
| 71 |
Restart with the first filter in the current list. |
| 72 |
.TP |
| 73 |
.B pipe |
| 74 |
Continue with the next action attached to the same filter. |
| 75 |
.TP |
| 76 |
.B drop |
| 77 |
.TQ |
| 78 |
.B shot |
| 79 |
Drop the packet. |
| 80 |
.TP |
| 81 |
.B continue |
| 82 |
Continue classification with the next filter in line. |
| 83 |
.TP |
| 84 |
.B pass |
| 85 |
Finish classification process and return to calling qdisc for further packet |
| 86 |
processing. This is the default. |
| 87 |
.RE |
| 88 |
.SH EXAMPLES |
| 89 |
To start, observe the following filter with a pedit action: |
| 90 |
|
| 91 |
.RS |
| 92 |
.EX |
| 93 |
tc filter add dev eth1 parent 1: protocol ip prio 10 \\ |
| 94 |
u32 match ip protocol 1 0xff flowid 1:2 \\ |
| 95 |
action pedit munge offset -14 u8 set 0x02 \\ |
| 96 |
munge offset -13 u8 set 0x15 \\ |
| 97 |
munge offset -12 u8 set 0x15 \\ |
| 98 |
munge offset -11 u8 set 0x15 \\ |
| 99 |
munge offset -10 u16 set 0x1515 \\ |
| 100 |
pipe |
| 101 |
.EE |
| 102 |
.RE |
| 103 |
|
| 104 |
Using the skbmod action, this command can be simplified to: |
| 105 |
|
| 106 |
.RS |
| 107 |
.EX |
| 108 |
tc filter add dev eth1 parent 1: protocol ip prio 10 \\ |
| 109 |
u32 match ip protocol 1 0xff flowid 1:2 \\ |
| 110 |
action skbmod set dmac 02:15:15:15:15:15 \\ |
| 111 |
pipe |
| 112 |
.EE |
| 113 |
.RE |
| 114 |
|
| 115 |
Complexity will increase if source mac and ethertype are also being edited |
| 116 |
as part of the action. If all three fields are to be changed with skbmod: |
| 117 |
|
| 118 |
.RS |
| 119 |
.EX |
| 120 |
tc filter add dev eth5 parent 1: protocol ip prio 10 \\ |
| 121 |
u32 match ip protocol 1 0xff flowid 1:2 \\ |
| 122 |
action skbmod \\ |
| 123 |
set etype 0xBEEF \\ |
| 124 |
set dmac 02:12:13:14:15:16 \\ |
| 125 |
set smac 02:22:23:24:25:26 |
| 126 |
.EE |
| 127 |
.RE |
| 128 |
|
| 129 |
To swap the destination and source mac addresses in the Ethernet header: |
| 130 |
|
| 131 |
.RS |
| 132 |
.EX |
| 133 |
tc filter add dev eth3 parent 1: protocol ip prio 10 \\ |
| 134 |
u32 match ip protocol 1 0xff flowid 1:2 \\ |
| 135 |
action skbmod \\ |
| 136 |
swap mac |
| 137 |
.EE |
| 138 |
.RE |
| 139 |
|
| 140 |
Finally, to mark the CE codepoint in the IP header for ECN Capable Transport (ECT) packets: |
| 141 |
|
| 142 |
.RS |
| 143 |
.EX |
| 144 |
tc filter add dev eth0 parent 1: protocol ip prio 10 \\ |
| 145 |
u32 match ip protocol 1 0xff flowid 1:2 \\ |
| 146 |
action skbmod \\ |
| 147 |
ecn |
| 148 |
.EE |
| 149 |
.RE |
| 150 |
|
| 151 |
Only one of |
| 152 |
.BR set ", " swap " and " ecn |
| 153 |
shall be used in a single command. |
| 154 |
Trying to use more than one of them in a single command is considered undefined behavior; pipe |
| 155 |
multiple commands together instead. |
| 156 |
|
| 157 |
.SH SEE ALSO |
| 158 |
.BR tc (8), |
| 159 |
.BR tc-u32 (8), |
| 160 |
.BR tc-pedit (8) |