1MPLS manipulation action in tc(8) Linux MPLS manipulation action in tc(8)
2
3
4
6 mpls - mpls manipulation module
7
9 tc ... action mpls { POP | PUSH | MODIFY | dec_ttl } [ CONTROL ]
10
11 POP := pop protocol MPLS_PROTO
12
13 PUSH := { push | mac_push } [ protocol MPLS_PROTO ] [ tc MPLS_TC ] [
14 ttl MPLS_TTL ] [ bos MPLS_BOS ] label MPLS_LABEL
15
16 MODIFY := modify [ label MPLS_LABEL ] [ tc MPLS_TC ] [ ttl MPLS_TTL ]
17
18 CONTROL := { reclassify | pipe | drop | continue | pass | goto chain
19 CHAIN_INDEX }
20
22 The mpls action performs mpls encapsulation or decapsulation on a
23 packet, reflected by the operation modes POP, PUSH, MODIFY and DEC_TTL.
24 The POP mode requires the ethertype of the header that follows the MPLS
25 header (e.g. IPv4 or another MPLS). It will remove the outer MPLS
26 header and replace the ethertype in the MAC header with that passed.
27 The PUSH and MODIFY modes update the current MPLS header information or
28 add a new header. PUSH requires at least an MPLS_LABEL. DEC_TTL re‐
29 quires no arguments and simply subtracts 1 from the MPLS header TTL
30 field.
31
32
34 pop Decapsulation mode. Requires the protocol of the next header.
35
36 push Encapsulation mode. Adds the MPLS header between the MAC and the
37 network headers. Requires at least the label option.
38
39 mac_push
40 Encapsulation mode. Adds the MPLS header before the MAC header.
41 Requires at least the label option.
42
43 modify Replace mode. Existing MPLS tag is replaced. label, tc, and ttl
44 are all optional.
45
46 dec_ttl
47 Decrement the TTL field on the outer most MPLS header.
48
49 label MPLS_LABEL
50 Specify the MPLS LABEL for the outer MPLS header. MPLS_LABEL is
51 an unsigned 20bit integer, the format is detected automatically
52 (e.g. prefix with '0x' for hexadecimal interpretation, etc.).
53
54 protocol MPLS_PROTO
55 Choose the protocol to use. For push actions this must be
56 mpls_uc or mpls_mc (mpls_uc is the default). For pop actions it
57 should be the protocol of the next header. This option cannot
58 be used with modify.
59
60 tc MPLS_TC
61 Choose the TC value for the outer MPLS header. Decimal number in
62 range of 0-7. Defaults to 0.
63
64 ttl MPLS_TTL
65 Choose the TTL value for the outer MPLS header. Number in range
66 of 0-255. A non-zero default value will be selected if this is
67 not explicitly set.
68
69 bos MPLS_BOS
70 Manually configure the bottom of stack bit for an MPLS header
71 push. The default is for TC to automatically set (or unset) the
72 bit based on the next header of the packet.
73
74 CONTROL
75 How to continue after executing this action.
76
77 reclassify
78 Restarts classification by jumping back to the first fil‐
79 ter attached to this action's parent.
80
81 pipe Continue with the next action, this is the default.
82
83 drop Packet will be dropped without running further actions.
84
85 continue
86 Continue classification with next filter in line.
87
88 pass Return to calling qdisc for packet processing. This ends
89 the classification process.
90
92 The following example encapsulates incoming IP packets on eth0 into
93 MPLS with a label 123 and sends them out eth1:
94
95 #tc qdisc add dev eth0 handle ffff: ingress
96 #tc filter add dev eth0 protocol ip parent ffff: flower \
97 action mpls push protocol mpls_uc label 123 \
98 action mirred egress redirect dev eth1
99
100 In this example, incoming MPLS unicast packets on eth0 are decapsulated
101 and redirected to eth1:
102
103 #tc qdisc add dev eth0 handle ffff: ingress
104 #tc filter add dev eth0 protocol mpls_uc parent ffff: flower \
105 action mpls pop protocol ipv4 \
106 action mirred egress redirect dev eth1
107
108 Here is another example, where incoming Ethernet frames are encapsu‐
109 lated into MPLS with label 123 and TTL 64. Then, an outer Ethernet
110 header is added and the resulting frame is finally sent on eth1:
111
112 #tc qdisc add dev eth0 ingress
113 #tc filter add dev eth0 ingress matchall \
114 action mpls mac_push label 123 ttl 64 \
115 action vlan push_eth \
116 dst_mac 02:00:00:00:00:02 \
117 src_mac 02:00:00:00:00:01 \
118 action mirred egress redirect dev eth1
119
120 The following example assumes that incoming MPLS packets with label 123
121 transport Ethernet frames. The outer Ethernet and the MPLS headers are
122 stripped, then the inner Ethernet frame is sent on eth1:
123
124 #tc qdisc add dev eth0 ingress
125 #tc filter add dev eth0 ingress protocol mpls_uc \
126 flower mpls_label 123 mpls_bos 1 \
127 action vlan pop_eth \
128 action mpls pop protocol teb \
129 action mirred egress redirect dev eth1
130
131
133 tc(8), tc-mirred(8), tc-vlan(8)
134
135
136
137iproute2 22 May 2019MPLS manipulation action in tc(8)