{"id":3740,"date":"2022-12-20T17:19:55","date_gmt":"2022-12-20T20:19:55","guid":{"rendered":"http:\/\/lode.uno\/linux-man\/index.php\/2022\/12\/20\/tunnel-metadata-manipulation-action-in-tc-man8\/"},"modified":"2022-12-20T17:19:55","modified_gmt":"2022-12-20T20:19:55","slug":"tunnel-metadata-manipulation-action-in-tc-man8","status":"publish","type":"post","link":"https:\/\/lode.uno\/linux-man\/2022\/12\/20\/tunnel-metadata-manipulation-action-in-tc-man8\/","title":{"rendered":"Tunnel metadata manipulation action in tc (man8)"},"content":{"rendered":"<h1 align=\"center\">Tunnel metadata 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\">tunnel_key &#8211; Tunnel metadata manipulation<\/p>\n<h2>SYNOPSIS <a name=\"SYNOPSIS\"><\/a> <\/h2>\n<p style=\"margin-left:23%; margin-top: 1em\"><b>tc<\/b> &#8230; <b>action tunnel_key<\/b> { <b>unset<\/b> | <i>SET<\/i> }<\/p>\n<p style=\"margin-left:23%; margin-top: 1em\"><i>SET<\/i> := <b>set src_ip<\/b> <i>ADDRESS<\/i> <b>dst_ip<\/b> <i>ADDRESS<\/i> <b>id<\/b> <i>KEY_ID<\/i> <b>dst_port<\/b> <i>UDP_PORT<\/i> <b>tos<\/b> <i>TOS<\/i> <b>ttl<\/b> <i>TTL<\/i> [ <b>csum<\/b> | <b>nocsum<\/b> ]<\/p>\n<h2>DESCRIPTION <a name=\"DESCRIPTION\"><\/a> <\/h2>\n<p style=\"margin-left:11%; margin-top: 1em\">The <b>tunnel_key<\/b> action combined with a shared IP tunnel device, allows to perform IP tunnel en- or decapsulation on a packet, reflected by the operation modes <i>UNSET<\/i> and <i>SET<\/i>. The <i>UNSET<\/i> mode is optional &#8211; even without using it, the metadata information will be released automatically when packet processing will be finished. <i>UNSET<\/i> function could be used in cases when traffic is forwarded between two tunnels, where the metadata from the first tunnel will be used for encapsulation done by the second tunnel. <i>SET<\/i> mode requires the source and destination ip <i>ADDRESS<\/i> and the tunnel key id <i>KEY_ID<\/i> which will be used by the ip tunnel shared device to create the tunnel header. The <b>tunnel_key<\/b> action is useful only in combination with a <b>mirred redirect<\/b> action to a shared IP tunnel device which will use the metadata (for <i>SET<\/i> ) and unset the metadata created by it (for <i>UNSET<\/i> ).<\/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=\"7%\">\n<p style=\"margin-top: 1em\"><b>unset<\/b><\/p>\n<\/td>\n<td width=\"4%\"><\/td>\n<td width=\"78%\">\n<p style=\"margin-top: 1em\">Unset the tunnel metadata created by the IP tunnel device. This function is not mandatory and might be used only in some specific use cases (as explained above).<\/p>\n<\/td>\n<\/tr>\n<tr valign=\"top\" align=\"left\">\n<td width=\"11%\"><\/td>\n<td width=\"7%\">\n<p><b>set<\/b><\/p>\n<\/td>\n<td width=\"4%\"><\/td>\n<td width=\"78%\">\n<p>Set tunnel metadata to be used by the IP tunnel device. Requires <b>src_ip<\/b> and <b>dst_ip<\/b> options. <b>id<\/b> , <b>dst_port<\/b> , <b>geneve_opts<\/b> , <b>vxlan_opts<\/b> and <b>erspan_opts<\/b> are optional.<\/p>\n<\/td>\n<\/tr>\n<\/table>\n<p style=\"margin-left:22%;\"><b>id<\/b><\/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=\"9%\"><\/td>\n<td width=\"1%\"><\/td>\n<td width=\"68%\">\n<p style=\"margin-top: 1em\">Tunnel ID (for example VNI in VXLAN tunnel)<\/p>\n<\/td>\n<\/tr>\n<tr valign=\"top\" align=\"left\">\n<td width=\"22%\"><\/td>\n<td width=\"9%\">\n<p><b>src_ip<\/b><\/p>\n<\/td>\n<td width=\"1%\"><\/td>\n<td width=\"68%\">\n<p>Outer header source IP address (IPv4 or IPv6)<\/p>\n<\/td>\n<\/tr>\n<tr valign=\"top\" align=\"left\">\n<td width=\"22%\"><\/td>\n<td width=\"9%\">\n<p><b>dst_ip<\/b><\/p>\n<\/td>\n<td width=\"1%\"><\/td>\n<td width=\"68%\">\n<p>Outer header destination IP address (IPv4 or IPv6)<\/p>\n<\/td>\n<\/tr>\n<\/table>\n<p style=\"margin-left:22%;\"><b>dst_port<\/b><\/p>\n<p style=\"margin-left:32%;\">Outer header destination UDP port<\/p>\n<p style=\"margin-left:22%;\"><b>geneve_opts<\/b><\/p>\n<p style=\"margin-left:32%;\">Geneve variable length options. <b>geneve_opts<\/b> is specified in the form CLASS:TYPE:DATA, where CLASS is represented as a 16bit hexadecimal value, TYPE as an 8bit hexadecimal value and DATA as a variable length hexadecimal value. Additionally multiple options may be listed using a comma delimiter.<\/p>\n<p style=\"margin-left:22%;\"><b>vxlan_opts<\/b><\/p>\n<p style=\"margin-left:32%;\">Vxlan metadata options. <b>vxlan_opts<\/b> is specified in the form GBP, as a 32bit number. Multiple options is not supported.<\/p>\n<p style=\"margin-left:22%;\"><b>erspan_opts<\/b><\/p>\n<p style=\"margin-left:32%;\">Erspan metadata options. <b>erspan_opts<\/b> is specified in the form VERSION:INDEX:DIR:HWID, where VERSION is represented as a 8bit number, INDEX as an 32bit number, DIR and HWID as a 8bit number. Multiple options is not supported. Note INDEX is used when VERSION is 1, and DIR and HWID are used when VERSION is 2.<\/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=\"4%\">\n<p><b>tos<\/b><\/p>\n<\/td>\n<td width=\"6%\"><\/td>\n<td width=\"25%\">\n<p>Outer header TOS<\/p>\n<\/td>\n<td width=\"43%\"> <\/td>\n<\/tr>\n<tr valign=\"top\" align=\"left\">\n<td width=\"22%\"><\/td>\n<td width=\"4%\">\n<p><b>ttl<\/b><\/p>\n<\/td>\n<td width=\"6%\"><\/td>\n<td width=\"25%\">\n<p>Outer header TTL<\/p>\n<\/td>\n<td width=\"43%\"> <\/td>\n<\/tr>\n<\/table>\n<p style=\"margin-left:22%;\">[<b>no<\/b>]<b>csum<\/b><\/p>\n<p style=\"margin-left:32%;\">Controls outer UDP checksum. When set to <b>csum<\/b> (which is default), the outer UDP checksum is calculated and included in the packets. When set to <b>nocsum<\/b>, outer UDP checksum is zero. Note that when using zero UDP checksums with IPv6, the other tunnel endpoint must be configured to accept such packets. In Linux, this would be the <b>udp6zerocsumrx<\/b> option for the VXLAN tunnel interface.<\/p>\n<p style=\"margin-left:32%; margin-top: 1em\">If using <b>nocsum<\/b> with IPv6, be sure you know what you are doing. Zero UDP checksums provide weaker protection against corrupted packets. See RFC6935 for details.<\/p>\n<h2>EXAMPLES <a name=\"EXAMPLES\"><\/a> <\/h2>\n<p style=\"margin-left:11%; margin-top: 1em\">The following example encapsulates incoming ICMP packets on eth0 into a vxlan tunnel, by setting metadata to VNI 11, source IP 11.11.0.1 and destination IP 11.11.0.2, and by redirecting the packet with the metadata to device vxlan0, which will do the actual encapsulation using the metadata:<\/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:  <br \/> flower  <br \/> ip_proto icmp  <br \/> action tunnel_key set  <br \/> src_ip 11.11.0.1  <br \/> dst_ip 11.11.0.2  <br \/> id 11  <br \/> action mirred egress redirect dev vxlan0<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">Here is an example of the <b>unset<\/b> function: Incoming VXLAN traffic with outer IP\u2019s and VNI 11 is decapsulated by vxlan0 and metadata is unset before redirecting to tunl1 device:<\/p>\n<p style=\"margin-left:22%; margin-top: 1em\">#tc qdisc add dev eth0 handle ffff: ingress <br \/> #tc filter add dev vxlan0 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<p>enc_src_ip 11.11.0.2 enc_dst_ip 11.11.0.1 enc_key_id 11 action tunnel_key unset<\/p>\n<td width=\"138%\"><\/td>\n<td width=\"-130%\"><\/td>\n<td width=\"7%\"><\/td>\n<td width=\"85%\"><\/td>\n<p>action mirred egress redirect dev tunl1<\/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)<\/p>\n<hr>\n","protected":false},"excerpt":{"rendered":"<p>  tunnel_key &#8211; Tunnel metadata manipulation <\/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,846],"class_list":["post-3740","post","type-post","status-publish","format-standard","hentry","category-8-administracion-del-sistema","tag-5","tag-administracion","tag-man8","tag-tc-tunnel_key"],"gutentor_comment":0,"_links":{"self":[{"href":"https:\/\/lode.uno\/linux-man\/wp-json\/wp\/v2\/posts\/3740","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=3740"}],"version-history":[{"count":0,"href":"https:\/\/lode.uno\/linux-man\/wp-json\/wp\/v2\/posts\/3740\/revisions"}],"wp:attachment":[{"href":"https:\/\/lode.uno\/linux-man\/wp-json\/wp\/v2\/media?parent=3740"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/lode.uno\/linux-man\/wp-json\/wp\/v2\/categories?post=3740"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/lode.uno\/linux-man\/wp-json\/wp\/v2\/tags?post=3740"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}