TC-MPLS(8)
๐ MPLS manipulation action in tc(8) ๐
Bestie, this is the manual for the mpls action, which is part of tc(8). It's the manual name, so you're reading it right now ๐
โจ NAME โจ
mpls is the mpls manipulation module ๐ฆ
๐ SYNOPSIS ๐
tc ... action mpls { POP | PUSH | MODIFY | dec_ttl } [ CONTROL ]
POP := pop protocol MPLS_PROTO
PUSH := { push | mac_push } [ protocol MPLS_PROTO ] [ tc MPLS_TC ] [
ttl MPLS_TTL ] [ bos MPLS_BOS ] label MPLS_LABEL
MODIFY := modify [ label MPLS_LABEL ] [ tc MPLS_TC ] [ ttl MPLS_TTL ]
CONTROL := { reclassify | pipe | drop | continue | pass | goto chain
CHAIN_INDEX }
๐ธ DESCRIPTION ๐ธ
Okay so the mpls action does MPLS encapsulation or decapsulation on a packet ๐ฅ You pick one of four vibes: POP, PUSH, MODIFY, or DEC_TTL.
POP is the decapsulation mode, and it needs the ethertype of whatever header comes after the MPLS header (like IPv4, or another MPLS). It strips the outer MPLS header and swaps the ethertype in the MAC header for the one you passed in ๐ซถ
PUSH and MODIFY either update the MPLS header that's already there or add a brand-new one. PUSH needs at least an MPLS_LABEL.
DEC_TTL needs no arguments at all. It just subtracts 1 from the MPLS header's TTL field. Simple, iconic โจ
๐ OPTIONS ๐
popโ Decapsulation mode. You have to give it the protocol of the next header ๐pushโ Encapsulation mode. It slides the MPLS header in between the MAC and network headers. You need at least thelabeloption.mac_pushโ Encapsulation mode, but this one adds the MPLS header before the MAC header. You need at least thelabeloption.modifyโ Replace mode, where the existing MPLS tag gets swapped out.label,tc, andttlare all optional here ๐ฆdec_ttlโ Decrements the TTL field on the outermost MPLS header ๐งlabel MPLS_LABELโ Sets the MPLS label for the outer MPLS header.MPLS_LABELis an unsigned 20-bit integer, and the format gets detected automatically. Prefix it with0xif you want hexadecimal, for example ๐protocol MPLS_PROTOโ Picks the protocol to use. For push actions it has to bempls_ucormpls_mc, andmpls_ucis the default. For pop actions it should be the protocol of the next header. This option can't be used withmodify๐tc MPLS_TCโ Sets the TC value for the outer MPLS header. It's a decimal number from 0-7, and it defaults to 0 ๐ttl MPLS_TTLโ Sets the TTL value for the outer MPLS header. It's a number from 0-255. If you don't set it explicitly, a non-zero default gets picked for you ๐bos MPLS_BOSโ Lets you manually set the bottom of stack bit for an MPLS header push. By default,tcsets (or unsets) that bit automatically, based on the next header of the packet โญ
๐ CONTROL ๐
This is all about how things keep going after the action runs. It's the CONTROL part, bestie ๐ซถ
reclassifyโ Restarts classification by jumping back to the first filter attached to this action's parent ๐pipeโ Continues with the next action. This is the default โจdropโ The packet gets dropped without running any further actions ๐continueโ Continues classification with the next filter in line ๐ฆpassโ Hands the packet back to the calling qdisc for processing. This ends the classification process ๐ธ
๐ง EXAMPLES ๐ง
Okay, first one. This encapsulates incoming IP packets on eth0 into MPLS with label 123 and sends them out eth1 ๐
#tc qdisc add dev eth0 handle ffff: ingress
#tc filter add dev eth0 protocol ip parent ffff: flower \
action mpls push protocol mpls_uc label 123 \
action mirred egress redirect dev eth1
Next, incoming MPLS unicast packets on eth0 get decapsulated and redirected to eth1. Main character energy ๐
#tc qdisc add dev eth0 handle ffff: ingress
#tc filter add dev eth0 protocol mpls_uc parent ffff: flower \
action mpls pop protocol ipv4 \
action mirred egress redirect dev eth1
Here's another one ๐ Incoming Ethernet frames get encapsulated into MPLS with label 123 and TTL 64. Then an outer Ethernet header is added, and the resulting frame is finally sent on eth1:
#tc qdisc add dev eth0 ingress
#tc filter add dev eth0 ingress matchall \
action mpls mac_push label 123 ttl 64 \
action vlan push_eth \
dst_mac 02:00:00:00:00:02 \
src_mac 02:00:00:00:00:01 \
action mirred egress redirect dev eth1
Last one, and it's a good one ๐ญ This assumes incoming MPLS packets with label 123 are carrying Ethernet frames. The outer Ethernet and MPLS headers get stripped, and then the inner Ethernet frame is sent on eth1:
#tc qdisc add dev eth0 ingress
#tc filter add dev eth0 ingress protocol mpls_uc \
flower mpls_label 123 mpls_bos 1 \
action vlan pop_eth \
action mpls pop protocol teb \
action mirred egress redirect dev eth1
๐ SEE ALSO ๐
tc(8), tc-mirred(8), tc-vlan(8) ๐
Okay that's the whole page, bestie ๐ซถ It came from iproute2, dated 22 May 2019, with the Linux source, and it's the MPLS manipulation action in tc(8) ๐โจ
๐ฆ where this page comes from
- alpine 3.22: iproute2-doc 6.15.0-r0 ยท GPL-2.0-or-later
- alpine 3.23: iproute2-doc 6.17.0-r0 ยท GPL-2.0-or-later
- alpine 3.24: iproute2-doc 7.0.0-r0 ยท GPL-2.0-or-later
- arch rolling: iproute2 7.2.0-1
- arch rolling: iproute2 7.3.0-1 ยท GPL-2.0-or-later
- centos-stream 10: iproute-tc 7.0.0-2.el10 ยท GPL-2.0-or-later
- centos-stream 9: iproute-tc 6.17.0-3.el9 ยท GPL-2.0-or-later
- debian bookworm: iproute2 6.1.0-3 ยท GPL-2.0-only
- debian trixie: iproute2 6.15.0-1 ยท GPL-2.0-only
- fedora 43: iproute-tc 6.14.0-2.fc43 ยท GPL-2.0-or-later
- fedora 44: iproute-tc 6.17.0-2.fc44 ยท GPL-2.0-or-later
- nixos 26.05: iproute2 7.0.0
- nixpkgs unstable: iproute2 7.2.0
- opensuse-leap 16.0: iproute2 6.12-160000.4.1 ยท GPL-2.0-only
- opensuse-leap 16.0: iproute2 6.12-160000.4.1 ยท GPL-2.0-only
- opensuse-leap 16.0: iproute2 6.12-160000.4.1 ยท GPL-2.0-only
- opensuse-leap 16.0: iproute2 6.12-160000.4.1 ยท GPL-2.0-only
- ubuntu jammy: iproute2 5.15.0-1ubuntu2 ยท GPL-2.0-only
- ubuntu jammy: iproute2 5.15.0-1ubuntu2.2 ยท GPL-2.0-only
- ubuntu noble: iproute2 6.1.0-1ubuntu6 ยท GPL-2.0-only
- ubuntu noble: iproute2 6.1.0-1ubuntu6.4 ยท GPL-2.0-only
- ubuntu questing: iproute2 6.16.0-1ubuntu2
- ubuntu questing: iproute2 6.16.0-1ubuntu2.1 ยท GPL-2.0-only
- ubuntu questing: iproute2 6.16.0-1ubuntu2.2
- ubuntu resolute: iproute2 6.19.0-1ubuntu1 ยท GPL-2.0-only
- ubuntu resolute: iproute2 6.19.0-1ubuntu1.1 ยท GPL-2.0-only
- ubuntu stonking: iproute2 7.2.0-1ubuntu1 ยท GPL-2.0-only
- ๐ girlified by anthropic/claude-haiku-5.5 on : a language model's rewrite of the original, under its terms