{"id":3781,"date":"2022-12-20T17:20:03","date_gmt":"2022-12-20T20:20:03","guid":{"rendered":"http:\/\/lode.uno\/linux-man\/index.php\/2022\/12\/20\/mpls-manipulation-action-in-tc-man8\/"},"modified":"2022-12-20T17:20:03","modified_gmt":"2022-12-20T20:20:03","slug":"mpls-manipulation-action-in-tc-man8","status":"publish","type":"post","link":"https:\/\/lode.uno\/linux-man\/2022\/12\/20\/mpls-manipulation-action-in-tc-man8\/","title":{"rendered":"MPLS manipulation action in tc (man8)"},"content":{"rendered":"<h1 align=\"center\">MPLS manipulation action in tc<\/h1>\n<p> <a href=\"#NAME\">NAME<\/a><br \/> <a href=\"#SYNOPSIS\">SYNOPSIS<\/a><br \/> <a href=\"#DESCRIPTION\">DESCRIPTION<\/a><br \/> <a href=\"#OPTIONS\">OPTIONS<\/a><br \/> <a href=\"#EXAMPLES\">EXAMPLES<\/a><br \/> <a href=\"#SEE ALSO\">SEE ALSO<\/a> <\/p>\n<hr>\n<h2>NAME <a name=\"NAME\"><\/a> <\/h2>\n<p style=\"margin-left:11%; margin-top: 1em\">mpls &#8211; mpls manipulation module<\/p>\n<h2>SYNOPSIS <a name=\"SYNOPSIS\"><\/a> <\/h2>\n<p style=\"margin-left:23%; margin-top: 1em\"><b>tc<\/b> &#8230; <b>action mpls<\/b> { <i>POP<\/i> | <i>PUSH<\/i> | <i>MODIFY<\/i> | <b>dec_ttl<\/b> } [ <i>CONTROL<\/i> ]<\/p>\n<p style=\"margin-left:23%; margin-top: 1em\"><i>POP<\/i> := <b>pop protocol<\/b> <i>MPLS_PROTO<\/i><\/p>\n<p style=\"margin-left:23%; margin-top: 1em\"><i>PUSH<\/i> := { <b>push<\/b> | <b>mac_push<\/b> } [ <b>protocol<\/b> <i>MPLS_PROTO<\/i> ] [ <b>tc<\/b> <i>MPLS_TC<\/i> ] [ <b>ttl<\/b> <i>MPLS_TTL<\/i> ] [ <b>bos<\/b> <i>MPLS_BOS<\/i> ] <b>label<\/b> <i>MPLS_LABEL<\/i><\/p>\n<p style=\"margin-left:23%; margin-top: 1em\"><i>MODIFY<\/i> := <b>modify<\/b> [ <b>label<\/b> <i>MPLS_LABEL<\/i> ] [ <b>tc<\/b> <i>MPLS_TC<\/i> ] [ <b>ttl<\/b> <i>MPLS_TTL<\/i> ]<\/p>\n<p style=\"margin-left:23%; margin-top: 1em\"><i>CONTROL<\/i> := { <b>reclassify<\/b> | <b>pipe<\/b> | <b>drop<\/b> | <b>continue<\/b> | <b>pass<\/b> | <b>goto chain CHAIN_INDEX<\/b> }<\/p>\n<h2>DESCRIPTION <a name=\"DESCRIPTION\"><\/a> <\/h2>\n<p style=\"margin-left:11%; margin-top: 1em\">The <b>mpls<\/b> action performs mpls encapsulation or decapsulation on a packet, reflected by the operation modes <i>POP<\/i>, <i>PUSH<\/i>, <i>MODIFY<\/i> and <i>DEC_TTL<\/i>. The <i>POP<\/i> mode requires the ethertype of the header that follows the MPLS header (e.g. IPv4 or another MPLS). It will remove the outer MPLS header and replace the ethertype in the MAC header with that passed. The <i>PUSH<\/i> and <i>MODIFY<\/i> modes update the current MPLS header information or add a new header. <i>PUSH<\/i> requires at least an <i>MPLS_LABEL<\/i>. <i>DEC_TTL<\/i> requires no arguments and simply subtracts 1 from the MPLS header TTL field.<\/p>\n<h2>OPTIONS <a name=\"OPTIONS\"><\/a> <\/h2>\n<table width=\"100%\" border=\"0\" rules=\"none\" frame=\"void\" cellspacing=\"0\" cellpadding=\"0\">\n<tr valign=\"top\" align=\"left\">\n<td width=\"11%\"><\/td>\n<td width=\"6%\">\n<p style=\"margin-top: 1em\"><b>pop<\/b><\/p>\n<\/td>\n<td width=\"5%\"><\/td>\n<td width=\"78%\">\n<p style=\"margin-top: 1em\">Decapsulation mode. Requires the protocol of the next header.<\/p>\n<\/td>\n<\/tr>\n<tr valign=\"top\" align=\"left\">\n<td width=\"11%\"><\/td>\n<td width=\"6%\">\n<p><b>push<\/b><\/p>\n<\/td>\n<td width=\"5%\"><\/td>\n<td width=\"78%\">\n<p>Encapsulation mode. Adds the MPLS header between the MAC and the network headers. Requires at least the <b>label<\/b> option.<\/p>\n<\/td>\n<\/tr>\n<\/table>\n<p style=\"margin-left:11%;\"><b>mac_push<\/b><\/p>\n<p style=\"margin-left:22%;\">Encapsulation mode. Adds the MPLS header before the MAC header. Requires at least the <b>label<\/b> option.<\/p>\n<table width=\"100%\" border=\"0\" rules=\"none\" frame=\"void\" cellspacing=\"0\" cellpadding=\"0\">\n<tr valign=\"top\" align=\"left\">\n<td width=\"11%\"><\/td>\n<td width=\"9%\">\n<p><b>modify<\/b><\/p>\n<\/td>\n<td width=\"2%\"><\/td>\n<td width=\"78%\">\n<p>Replace mode. Existing MPLS tag is replaced. <b>label<\/b>, <b>tc<\/b>, and <b>ttl<\/b> are all optional.<\/p>\n<\/td>\n<\/tr>\n<\/table>\n<p style=\"margin-left:11%;\"><b>dec_ttl<\/b><\/p>\n<p style=\"margin-left:22%;\">Decrement the TTL field on the outer most MPLS header.<\/p>\n<p style=\"margin-left:11%;\"><b>label<\/b> <i>MPLS_LABEL<\/i><\/p>\n<p style=\"margin-left:22%;\">Specify the MPLS LABEL for the outer MPLS header. <i>MPLS_LABEL<\/i> is an unsigned 20bit integer, the format is detected automatically (e.g. prefix with \u2019<b>0x<\/b>\u2019 for hexadecimal interpretation, etc.).<\/p>\n<p style=\"margin-left:11%;\"><b>protocol<\/b> <i>MPLS_PROTO<\/i><\/p>\n<p style=\"margin-left:22%;\">Choose the protocol to use. For push actions this must be <b>mpls_uc<\/b> or <b>mpls_mc<\/b> (<b>mpls_uc<\/b> is the default). For pop actions it should be the protocol of the next header. This option cannot be used with modify.<\/p>\n<p style=\"margin-left:11%;\"><b>tc<\/b> <i>MPLS_TC<\/i><\/p>\n<p style=\"margin-left:22%;\">Choose the TC value for the outer MPLS header. Decimal number in range of 0-7. Defaults to 0.<\/p>\n<p style=\"margin-left:11%;\"><b>ttl<\/b> <i>MPLS_TTL<\/i><\/p>\n<p style=\"margin-left:22%;\">Choose the TTL value for the outer MPLS header. Number in range of 0-255. A non-zero default value will be selected if this is not explicitly set.<\/p>\n<p style=\"margin-left:11%;\"><b>bos<\/b> <i>MPLS_BOS<\/i><\/p>\n<p style=\"margin-left:22%;\">Manually configure the bottom of stack bit for an MPLS header push. The default is for TC to automatically set (or unset) the bit based on the next header of the packet.<\/p>\n<p style=\"margin-left:11%;\"><i>CONTROL<\/i><\/p>\n<p style=\"margin-left:22%;\">How to continue after executing this action. <b><br \/> reclassify<\/b><\/p>\n<p style=\"margin-left:32%;\">Restarts classification by jumping back to the first filter attached to this action\u2019s parent.<\/p>\n<table width=\"100%\" border=\"0\" rules=\"none\" frame=\"void\" cellspacing=\"0\" cellpadding=\"0\">\n<tr valign=\"top\" align=\"left\">\n<td width=\"22%\"><\/td>\n<td width=\"6%\">\n<p><b>pipe<\/b><\/p>\n<\/td>\n<td width=\"4%\"><\/td>\n<td width=\"68%\">\n<p>Continue with the next action, this is the default.<\/p>\n<\/td>\n<\/tr>\n<tr valign=\"top\" align=\"left\">\n<td width=\"22%\"><\/td>\n<td width=\"6%\">\n<p><b>drop<\/b><\/p>\n<\/td>\n<td width=\"4%\"><\/td>\n<td width=\"68%\">\n<p>Packet will be dropped without running further actions.<\/p>\n<\/td>\n<\/tr>\n<\/table>\n<p style=\"margin-left:22%;\"><b>continue<\/b><\/p>\n<p style=\"margin-left:32%;\">Continue classification with next filter in line.<\/p>\n<table width=\"100%\" border=\"0\" rules=\"none\" frame=\"void\" cellspacing=\"0\" cellpadding=\"0\">\n<tr valign=\"top\" align=\"left\">\n<td width=\"22%\"><\/td>\n<td width=\"6%\">\n<p><b>pass<\/b><\/p>\n<\/td>\n<td width=\"4%\"><\/td>\n<td width=\"68%\">\n<p>Return to calling qdisc for packet processing. This ends the classification process.<\/p>\n<\/td>\n<\/tr>\n<\/table>\n<h2>EXAMPLES <a name=\"EXAMPLES\"><\/a> <\/h2>\n<p style=\"margin-left:11%; margin-top: 1em\">The following example encapsulates incoming IP packets on eth0 into MPLS with a label 123 and sends them out eth1:<\/p>\n<p style=\"margin-left:22%; margin-top: 1em\">#tc qdisc add dev eth0 handle ffff: ingress <br \/> #tc filter add dev eth0 protocol ip parent ffff: flower <\/p>\n<table width=\"100%\" border=\"0\" rules=\"none\" frame=\"void\" cellspacing=\"0\" cellpadding=\"0\">\n<tr valign=\"top\" align=\"left\">\n<td width=\"8%\"><\/td>\n<td width=\"92%\">\n<p>action mpls push protocol mpls_uc label 123 <\/p>\n<\/td>\n<\/tr>\n<tr valign=\"top\" align=\"left\">\n<td width=\"8%\"><\/td>\n<td width=\"92%\">\n<p>action mirred egress redirect dev eth1<\/p>\n<\/td>\n<\/tr>\n<\/table>\n<p style=\"margin-left:11%; margin-top: 1em\">In this example, incoming MPLS unicast packets on eth0 are decapsulated and redirected to eth1:<\/p>\n<p style=\"margin-left:22%; margin-top: 1em\">#tc qdisc add dev eth0 handle ffff: ingress <br \/> #tc filter add dev eth0 protocol mpls_uc parent ffff: flower <\/p>\n<table width=\"100%\" border=\"0\" rules=\"none\" frame=\"void\" cellspacing=\"0\" cellpadding=\"0\">\n<tr valign=\"top\" align=\"left\">\n<td width=\"8%\"><\/td>\n<td width=\"92%\">\n<p>action mpls pop protocol ipv4 <\/p>\n<\/td>\n<\/tr>\n<tr valign=\"top\" align=\"left\">\n<td width=\"8%\"><\/td>\n<td width=\"92%\">\n<p>action mirred egress redirect dev eth1<\/p>\n<\/td>\n<\/tr>\n<\/table>\n<p style=\"margin-left:11%; margin-top: 1em\">Here is another example, where incoming Ethernet frames are 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:<\/p>\n<p style=\"margin-left:22%; margin-top: 1em\">#tc qdisc add dev eth0 ingress <br \/> #tc filter add dev eth0 ingress matchall <\/p>\n<table width=\"100%\" border=\"0\" rules=\"none\" frame=\"void\" cellspacing=\"0\" cellpadding=\"0\">\n<tr valign=\"top\" align=\"left\">\n<td width=\"8%\"><\/td>\n<td width=\"7%\"><\/td>\n<td width=\"8%\"><\/td>\n<td width=\"77%\">\n<p>action mpls mac_push label 123 ttl 64 <\/p>\n<\/td>\n<\/tr>\n<tr valign=\"top\" align=\"left\">\n<td width=\"8%\"><\/td>\n<td width=\"7%\"><\/td>\n<td width=\"8%\"><\/td>\n<td width=\"77%\">\n<p>action vlan push_eth <\/p>\n<\/td>\n<\/tr>\n<tr valign=\"top\" align=\"left\">\n<td width=\"8%\"><\/td>\n<td width=\"7%\"><\/td>\n<td width=\"8%\"> <\/td>\n<td width=\"77%\"> <\/td>\n<\/tr>\n<tr valign=\"top\" align=\"left\">\n<td width=\"8%\"><\/td>\n<td width=\"7%\"><\/td>\n<td width=\"8%\"><\/td>\n<td width=\"77%\">\n<p>dst_mac 02:00:00:00:00:02 <\/p>\n<\/td>\n<\/tr>\n<tr valign=\"top\" align=\"left\">\n<td width=\"8%\"><\/td>\n<td width=\"7%\"><\/td>\n<td width=\"8%\"> <\/td>\n<td width=\"77%\"> <\/td>\n<\/tr>\n<tr valign=\"top\" align=\"left\">\n<td width=\"8%\"><\/td>\n<td width=\"7%\"><\/td>\n<td width=\"8%\"><\/td>\n<td width=\"77%\">\n<p>src_mac 02:00:00:00:00:01 <\/p>\n<\/td>\n<\/tr>\n<tr valign=\"top\" align=\"left\">\n<td width=\"8%\"><\/td>\n<td width=\"7%\"><\/td>\n<td width=\"8%\"><\/td>\n<td width=\"77%\">\n<p>action mirred egress redirect dev eth1<\/p>\n<\/td>\n<\/tr>\n<\/table>\n<p style=\"margin-left:11%; margin-top: 1em\">The following example assumes that incoming MPLS packets with label 123 transport Ethernet frames. The outer Ethernet and the MPLS headers are stripped, then the inner Ethernet frame is sent on eth1:<\/p>\n<p style=\"margin-left:22%; margin-top: 1em\">#tc qdisc add dev eth0 ingress <br \/> #tc filter add dev eth0 ingress protocol mpls_uc <\/p>\n<table width=\"100%\" border=\"0\" rules=\"none\" frame=\"void\" cellspacing=\"0\" cellpadding=\"0\">\n<tr valign=\"top\" align=\"left\">\n<td width=\"8%\"><\/td>\n<td width=\"92%\">\n<p>flower mpls_label 123 mpls_bos 1 <\/p>\n<\/td>\n<\/tr>\n<tr valign=\"top\" align=\"left\">\n<td width=\"8%\"><\/td>\n<td width=\"92%\">\n<p>action vlan pop_eth <\/p>\n<\/td>\n<\/tr>\n<tr valign=\"top\" align=\"left\">\n<td width=\"8%\"><\/td>\n<td width=\"92%\">\n<p>action mpls pop protocol teb <\/p>\n<\/td>\n<\/tr>\n<tr valign=\"top\" align=\"left\">\n<td width=\"8%\"><\/td>\n<td width=\"92%\">\n<p>action mirred egress redirect dev eth1<\/p>\n<\/td>\n<\/tr>\n<\/table>\n<h2>SEE ALSO <a name=\"SEE ALSO\"><\/a> <\/h2>\n<p style=\"margin-left:11%; margin-top: 1em\"><b>tc<\/b>(8), <b>tc-mirred<\/b>(8), <b>tc-vlan<\/b>(8)<\/p>\n<hr>\n","protected":false},"excerpt":{"rendered":"<p>  mpls &#8211; mpls manipulation module <\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[2],"tags":[5,52,4,882],"class_list":["post-3781","post","type-post","status-publish","format-standard","hentry","category-8-administracion-del-sistema","tag-5","tag-administracion","tag-man8","tag-tc-mpls"],"gutentor_comment":0,"_links":{"self":[{"href":"https:\/\/lode.uno\/linux-man\/wp-json\/wp\/v2\/posts\/3781","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/lode.uno\/linux-man\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/lode.uno\/linux-man\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/lode.uno\/linux-man\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/lode.uno\/linux-man\/wp-json\/wp\/v2\/comments?post=3781"}],"version-history":[{"count":0,"href":"https:\/\/lode.uno\/linux-man\/wp-json\/wp\/v2\/posts\/3781\/revisions"}],"wp:attachment":[{"href":"https:\/\/lode.uno\/linux-man\/wp-json\/wp\/v2\/media?parent=3781"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/lode.uno\/linux-man\/wp-json\/wp\/v2\/categories?post=3781"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/lode.uno\/linux-man\/wp-json\/wp\/v2\/tags?post=3781"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}