Blame man/man8/tc-skbmod.8

Packit d3f73b
.TH "skbmod action in tc" 8 "21 Sep 2016" "iproute2" "Linux"
Packit d3f73b
Packit d3f73b
.SH NAME
Packit d3f73b
skbmod - user-friendly packet editor action
Packit d3f73b
.SH SYNOPSIS
Packit d3f73b
.in +8
Packit d3f73b
.ti -8
Packit d3f73b
.BR tc " ... " "action skbmod " "{ [ " "set "
Packit d3f73b
.IR SETTABLE " ] [ "
Packit d3f73b
.BI swap " SWAPPABLE"
Packit d3f73b
.RI " ] [ " CONTROL " ] [ "
Packit d3f73b
.BI index " INDEX "
Packit d3f73b
] }
Packit d3f73b
Packit d3f73b
.ti -8
Packit d3f73b
.IR SETTABLE " := "
Packit d3f73b
.RB " [ " dmac
Packit d3f73b
.IR DMAC " ] "
Packit d3f73b
.RB " [ " smac
Packit d3f73b
.IR SMAC " ] "
Packit d3f73b
.RB " [ " etype
Packit d3f73b
.IR ETYPE " ] "
Packit d3f73b
Packit d3f73b
.ti -8
Packit d3f73b
.IR SWAPPABLE " := "
Packit d3f73b
.B mac
Packit d3f73b
.ti -8
Packit d3f73b
.IR CONTROL " := {"
Packit d3f73b
.BR reclassify " | " pipe " | " drop " | " shot " | " continue " | " pass " }"
Packit d3f73b
.SH DESCRIPTION
Packit d3f73b
The
Packit d3f73b
.B skbmod
Packit d3f73b
action is intended as a usability upgrade to the existing
Packit d3f73b
.B pedit
Packit d3f73b
action. Instead of having to manually edit 8-, 16-, or 32-bit chunks of an
Packit d3f73b
ethernet header,
Packit d3f73b
.B skbmod
Packit d3f73b
allows complete substitution of supported elements.
Packit d3f73b
.SH OPTIONS
Packit d3f73b
.TP
Packit d3f73b
.BI dmac " DMAC"
Packit d3f73b
Change the destination mac to the specified address.
Packit d3f73b
.TP
Packit d3f73b
.BI smac " SMAC"
Packit d3f73b
Change the source mac to the specified address.
Packit d3f73b
.TP
Packit d3f73b
.BI etype " ETYPE"
Packit d3f73b
Change the ethertype to the specified value.
Packit d3f73b
.TP
Packit d3f73b
.BI mac
Packit d3f73b
Used to swap mac addresses. The
Packit d3f73b
.B swap mac
Packit d3f73b
directive is performed
Packit d3f73b
after any outstanding D/SMAC changes.
Packit d3f73b
.TP
Packit d3f73b
.I CONTROL
Packit d3f73b
The following keywords allow to control how the tree of qdisc, classes,
Packit d3f73b
filters and actions is further traversed after this action.
Packit d3f73b
.RS
Packit d3f73b
.TP
Packit d3f73b
.B reclassify
Packit d3f73b
Restart with the first filter in the current list.
Packit d3f73b
.TP
Packit d3f73b
.B pipe
Packit d3f73b
Continue with the next action attached to the same filter.
Packit d3f73b
.TP
Packit d3f73b
.B drop
Packit d3f73b
.TQ
Packit d3f73b
.B shot
Packit d3f73b
Drop the packet.
Packit d3f73b
.TP
Packit d3f73b
.B continue
Packit d3f73b
Continue classification with the next filter in line.
Packit d3f73b
.TP
Packit d3f73b
.B pass
Packit d3f73b
Finish classification process and return to calling qdisc for further packet
Packit d3f73b
processing. This is the default.
Packit d3f73b
.SH EXAMPLES
Packit d3f73b
To start, observe the following filter with a pedit action:
Packit d3f73b
Packit d3f73b
.RS
Packit d3f73b
.EX
Packit d3f73b
tc filter add dev eth1 parent 1: protocol ip prio 10 \\
Packit d3f73b
	u32 match ip protocol 1 0xff flowid 1:2 \\
Packit d3f73b
	action pedit munge offset -14 u8 set 0x02 \\
Packit d3f73b
	munge offset -13 u8 set 0x15 \\
Packit d3f73b
	munge offset -12 u8 set 0x15 \\
Packit d3f73b
	munge offset -11 u8 set 0x15 \\
Packit d3f73b
	munge offset -10 u16 set 0x1515 \\
Packit d3f73b
	pipe
Packit d3f73b
.EE
Packit d3f73b
.RE
Packit d3f73b
Packit d3f73b
Using the skbmod action, this command can be simplified to:
Packit d3f73b
Packit d3f73b
.RS
Packit d3f73b
.EX
Packit d3f73b
tc filter add dev eth1 parent 1: protocol ip prio 10 \\
Packit d3f73b
	u32 match ip protocol 1 0xff flowid 1:2 \\
Packit d3f73b
	action skbmod set dmac 02:15:15:15:15:15 \\
Packit d3f73b
	pipe
Packit d3f73b
.EE
Packit d3f73b
.RE
Packit d3f73b
Packit d3f73b
Complexity will increase if source mac and ethertype are also being edited
Packit d3f73b
as part of the action. If all three fields are to be changed with skbmod:
Packit d3f73b
Packit d3f73b
.RS
Packit d3f73b
.EX
Packit d3f73b
tc filter add dev eth5 parent 1: protocol ip prio 10 \\
Packit d3f73b
	u32 match ip protocol 1 0xff flowid 1:2 \\
Packit d3f73b
	action skbmod \\
Packit d3f73b
	set etype 0xBEEF \\
Packit d3f73b
	set dmac 02:12:13:14:15:16 \\
Packit d3f73b
	set smac 02:22:23:24:25:26
Packit d3f73b
.EE
Packit d3f73b
.RE
Packit d3f73b
Packit d3f73b
Finally, swap the destination and source mac addresses in the header:
Packit d3f73b
Packit d3f73b
.RS
Packit d3f73b
.EX
Packit d3f73b
tc filter add dev eth3 parent 1: protocol ip prio 10 \\
Packit d3f73b
	u32 match ip protocol 1 0xff flowid 1:2 \\
Packit d3f73b
	action skbmod \\
Packit d3f73b
	swap mac
Packit d3f73b
.EE
Packit d3f73b
.RE
Packit d3f73b
Packit d3f73b
As mentioned above, the swap action will occur after any
Packit d3f73b
.B " smac/dmac "
Packit d3f73b
substitutions are executed, if they are present.
Packit d3f73b
Packit d3f73b
.SH SEE ALSO
Packit d3f73b
.BR tc (8),
Packit d3f73b
.BR tc-u32 (8),
Packit d3f73b
.BR tc-pedit (8)