| 1 |
.TH "VLAN manipulation action in tc" 8 "12 Jan 2015" "iproute2" "Linux" |
| 2 |
|
| 3 |
.SH NAME |
| 4 |
vlan - vlan manipulation module |
| 5 |
.SH SYNOPSIS |
| 6 |
.in +8 |
| 7 |
.ti -8 |
| 8 |
.BR tc " ... " "action vlan" " { " pop " | " pop_eth " |" |
| 9 |
.IR PUSH " | " MODIFY " | " PUSH_ETH " } [ " CONTROL " ]" |
| 10 |
|
| 11 |
.ti -8 |
| 12 |
.IR PUSH " := " |
| 13 |
.BR push " [ " protocol |
| 14 |
.IR VLANPROTO " ]" |
| 15 |
.BR " [ " priority |
| 16 |
.IR VLANPRIO " ] " |
| 17 |
.BI id " VLANID" |
| 18 |
|
| 19 |
.ti -8 |
| 20 |
.IR MODIFY " := " |
| 21 |
.BR modify " [ " protocol |
| 22 |
.IR VLANPROTO " ]" |
| 23 |
.BR " [ " priority |
| 24 |
.IR VLANPRIO " ] " |
| 25 |
.BI id " VLANID" |
| 26 |
|
| 27 |
.ti -8 |
| 28 |
.IR PUSH_ETH " := " |
| 29 |
.B push_eth |
| 30 |
.BI dst_mac " LLADDR " src_mac " LLADDR " |
| 31 |
|
| 32 |
.ti -8 |
| 33 |
.IR CONTROL " := { " |
| 34 |
.BR reclassify " | " pipe " | " drop " | " continue " | " pass " | " goto " " chain " " CHAIN_INDEX " }" |
| 35 |
.SH DESCRIPTION |
| 36 |
The |
| 37 |
.B vlan |
| 38 |
action allows one to perform 802.1Q en- or decapsulation on a packet, reflected by |
| 39 |
the operation modes |
| 40 |
.IR POP ", " PUSH " and " MODIFY . |
| 41 |
The |
| 42 |
.I POP |
| 43 |
mode is simple, as no further information is required to just drop the |
| 44 |
outer-most VLAN encapsulation. The |
| 45 |
.IR PUSH " and " MODIFY |
| 46 |
modes require at least a |
| 47 |
.I VLANID |
| 48 |
and allow one to optionally choose the |
| 49 |
.I VLANPROTO |
| 50 |
to use. |
| 51 |
|
| 52 |
The |
| 53 |
.B vlan |
| 54 |
action can also be used to add or remove the base Ethernet header. The |
| 55 |
.B pop_eth |
| 56 |
mode, which takes no argument, is used to remove the base Ethernet header. All |
| 57 |
existing VLANs must have been previously dropped. The opposite operation, |
| 58 |
adding a base Ethernet header, is done with the |
| 59 |
.B push_eth |
| 60 |
mode. In that case, the packet must have no MAC header (stacking MAC headers is |
| 61 |
not permitted). This mode is mostly useful when a previous action has |
| 62 |
encapsulated the whole original frame behind a network header and one needs |
| 63 |
to prepend an Ethernet header before forwarding the resulting packet. |
| 64 |
|
| 65 |
.SH OPTIONS |
| 66 |
.TP |
| 67 |
.B pop |
| 68 |
Decapsulation mode, no further arguments allowed. |
| 69 |
.TP |
| 70 |
.B push |
| 71 |
Encapsulation mode. Requires at least |
| 72 |
.B id |
| 73 |
option. |
| 74 |
.TP |
| 75 |
.B modify |
| 76 |
Replace mode. Existing 802.1Q tag is replaced. Requires at least |
| 77 |
.B id |
| 78 |
option. |
| 79 |
.TP |
| 80 |
.B pop_eth |
| 81 |
Ethernet header decapsulation mode. Only works on a plain Ethernet header: |
| 82 |
VLANs, if any, must be removed first. |
| 83 |
.TP |
| 84 |
.B push_eth |
| 85 |
Ethernet header encapsulation mode. The Ethertype is automatically set |
| 86 |
using the network header type. Chaining Ethernet headers is not allowed: the |
| 87 |
packet must have no MAC header when using this mode. Requires the |
| 88 |
.BR "dst_mac " and " src_mac " options. |
| 89 |
.TP |
| 90 |
.BI id " VLANID" |
| 91 |
Specify the VLAN ID to encapsulate into. |
| 92 |
.I VLANID |
| 93 |
is an unsigned 16bit integer, the format is detected automatically (e.g. prefix |
| 94 |
with |
| 95 |
.RB ' 0x ' |
| 96 |
for hexadecimal interpretation, etc.). |
| 97 |
.TP |
| 98 |
.BI protocol " VLANPROTO" |
| 99 |
Choose the VLAN protocol to use. At the time of writing, the kernel accepts only |
| 100 |
.BR 802.1Q " or " 802.1ad . |
| 101 |
.TP |
| 102 |
.BI priority " VLANPRIO" |
| 103 |
Choose the VLAN priority to use. Decimal number in range of 0-7. |
| 104 |
.TP |
| 105 |
.BI dst_mac " LLADDR" |
| 106 |
Choose the destination MAC address to use. |
| 107 |
.TP |
| 108 |
.BI src_mac " LLADDR" |
| 109 |
Choose the source MAC address to use. |
| 110 |
.TP |
| 111 |
.I CONTROL |
| 112 |
How to continue after executing this action. |
| 113 |
.RS |
| 114 |
.TP |
| 115 |
.B reclassify |
| 116 |
Restarts classification by jumping back to the first filter attached to this |
| 117 |
action's parent. |
| 118 |
.TP |
| 119 |
.B pipe |
| 120 |
Continue with the next action, this is the default. |
| 121 |
.TP |
| 122 |
.B drop |
| 123 |
Packet will be dropped without running further actions. |
| 124 |
.TP |
| 125 |
.B continue |
| 126 |
Continue classification with next filter in line. |
| 127 |
.TP |
| 128 |
.B pass |
| 129 |
Return to calling qdisc for packet processing. This ends the classification |
| 130 |
process. |
| 131 |
.RE |
| 132 |
.SH EXAMPLES |
| 133 |
The following example encapsulates incoming ICMP packets on eth0 from 10.0.0.2 |
| 134 |
into VLAN ID 123: |
| 135 |
|
| 136 |
.RS |
| 137 |
.EX |
| 138 |
#tc qdisc add dev eth0 handle ffff: ingress |
| 139 |
#tc filter add dev eth0 parent ffff: pref 11 protocol ip \\ |
| 140 |
u32 match ip protocol 1 0xff flowid 1:1 \\ |
| 141 |
match ip src 10.0.0.2 flowid 1:1 \\ |
| 142 |
action vlan push id 123 |
| 143 |
.EE |
| 144 |
.RE |
| 145 |
|
| 146 |
Here is an example of the |
| 147 |
.B pop |
| 148 |
function: Incoming VLAN packets on eth0 are decapsulated and the classification |
| 149 |
process then restarted for the plain packet: |
| 150 |
|
| 151 |
.RS |
| 152 |
.EX |
| 153 |
#tc qdisc add dev eth0 handle ffff: ingress |
| 154 |
#tc filter add dev $ETH parent ffff: pref 1 protocol 802.1Q \\ |
| 155 |
u32 match u32 0 0 flowid 1:1 \\ |
| 156 |
action vlan pop reclassify |
| 157 |
.EE |
| 158 |
.RE |
| 159 |
|
| 160 |
For an example of the |
| 161 |
.BR pop_eth " and " push_eth " modes, see " tc-mpls (8). |
| 162 |
|
| 163 |
.SH SEE ALSO |
| 164 |
.BR tc "(8), " tc-mpls (8) |