<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
</head>
<body>
<style>
    font{
        line-height: 1.6;
    }
    ul,ol{
        padding-left: 20px;
        list-style-position: inside;
    }
</style>
<div style="font-family:微软雅黑,Verdana,&quot;Microsoft Yahei&quot;,SimSun,sans-serif; line-height:1.6;">
<div></div>
<div>
<div><span>Hi, </span></div>
<div><span>&nbsp; &nbsp;&nbsp;</span>If you are careful, you will find that NSH is no problem without using a proxy. Just go through the physical interface without going through the table.</div>
<div>&nbsp; &nbsp;&nbsp;Why is this? Because the ovs code has a checksum, for the NSH check, if encap and decap are used together, there will be problems, this is the need to change the code. The ovs actions have a series of actions, and these actions are checked and executed
 first. Decap checks whether it is an NSH message, but there is encap, so the check fails, so why is there no problem with MPLS? Because MPLS push_mpls is set. The mpls field causes the pop_mpls check to succeed, but push_nsh does not have this setting.</div>
<div><br>
</div>
<div>&nbsp; &nbsp;&nbsp;Recompile the source code and replace openvswitch.ko</div>
<div>&nbsp; &nbsp;&nbsp;If you have any questions, you can always restore your mail.</div>
<div><br>
</div>
<div>code:</div>
<div>vim datapath/flow_netlink.c</div>
<div><br>
</div>
<div>__ovs_nla_copy_actions</div>
<div><br>
</div>
<div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; case OVS_ACTION_ATTR_PUSH_ETH:</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; /* Disallow pushing an Ethernet header if one</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;* is already present */</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if (mac_proto != MAC_PROTO_NONE)</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; return -EINVAL;</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; //mac_proto = MAC_PROTO_NONE;</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; mac_proto = MAC_PROTO_ETHERNET;</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; break;</div>
<div><br>
</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; case OVS_ACTION_ATTR_POP_ETH:</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if (mac_proto != MAC_PROTO_ETHERNET)</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; return -EINVAL;</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if (vlan_tci &amp; htons(VLAN_TAG_PRESENT))</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; return -EINVAL;</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; //mac_proto = MAC_PROTO_ETHERNET;</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; mac_proto = MAC_PROTO_NONE;</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; break;</div>
<div><br>
</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; case OVS_ACTION_ATTR_POP_NSH: {</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; //__be16 inner_proto;</div>
<div><br>
</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; //if (eth_type != htons(ETH_P_NSH))</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; // &nbsp; &nbsp; &nbsp; &nbsp;return -EINVAL;</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; //inner_proto = tun_p_to_eth_p(key-&gt;nsh.base.np);</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; //if (!inner_proto)</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; // &nbsp; &nbsp; &nbsp;return -EINVAL;</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if (key-&gt;nsh.base.np == TUN_P_ETHERNET)</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; mac_proto = MAC_PROTO_ETHERNET;</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; else</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; mac_proto = MAC_PROTO_NONE;</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; break;</div>
</div>
<div><span><br>
</span></div>
<div><span>
<div>validate_set</div>
<div><br>
</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; if (key_type &gt; OVS_KEY_ATTR_MAX ||</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; !check_attr_len(key_len, ovs_key_lens[key_type].len))</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; return -EINVAL;</div>
<div><br>
</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; /************************************************************/</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; if (key_len == 28) {</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; return 0;</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; } else if (key_type == OVS_KEY_ATTR_ETHERNET) {</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; mac_proto = MAC_PROTO_ETHERNET;</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; }</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; /************************************************************/</div>
<div><br>
</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; if (masked &amp;&amp; !validate_masked(nla_data(ovs_key), key_len))</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; return -EINVAL;</div>
<div><br>
</div>
<div><br>
</div>
</span></div>
<div id="ntes-pcmac-signature" style="font-family:'微软雅黑'">
<div style="font-size:14px; padding: 0;  margin:0;line-height:14px;">
<div style="padding-bottom:6px;margin-bottom:10px;border-bottom:1px solid #e6e6e6;display:inline-block;">
<a href="https://maas.mail.163.com/dashi-web-extend/html/proSignature.html?ftlId=1&amp;name=wangjq_china&amp;uid=wangjq_china%40outlook.com&amp;iconUrl=http%3A%2F%2Fmail-online.nosdn.127.net%2Fsmbbd5217c6c1185a0336c405480773143.jpg&amp;items=%5B%22wangjq_china%40outlook.com%22%5D" style="display:block;background:#fff; max-width: 400px; _width: 400px;padding:15px 0 10px 0;text-decoration: none; outline:none;-webkit-tap-highlight-color:transparent;-webkit-text-size-adjust:none !important;text-size-adjust:none !important;">
<table cellpadding="0" style="width: 100%; max-width: 100%; table-layout: fixed; border-collapse: collapse;color: #9b9ea1;font-size: 14px;line-height:1.3;-webkit-text-size-adjust:none !important;text-size-adjust:none !important;">
<tbody style="font-family: 'PingFang SC', 'Hiragino Sans GB','WenQuanYi Micro Hei', 'Microsoft Yahei', '微软雅黑', verdana !important; word-wrap:break-word; word-break:break-all;-webkit-text-size-adjust:none !important;text-size-adjust:none !important;">
<tr class="firstRow">
<td width="38" style="padding:0; box-sizing: border-box; width: 38px;"><img width="38" height="38" style="vertical-align:middle; width: 38px; height: 38px; border-radius:50%;" src="http://mail-online.nosdn.127.net/smbbd5217c6c1185a0336c405480773143.jpg">
</td>
<td style="padding: 0 0 0 10px; color: #31353b;">
<div style="font-size: 16px;font-weight:bold; width:100%; white-space: nowrap; overflow:hidden;text-overflow: ellipsis;">
wangjq_china</div>
</td>
</tr>
<tr width="100%" style="font-size: 14px !important; width: 100%;">
<td colspan="2" style="padding:10px 0 0 0; font-size:14px !important; width: 100%;">
<div style="width: 100%;font-size: 14px !important;word-wrap:break-word;word-break:break-all;">
wangjq_china@outlook.com</div>
</td>
</tr>
</tbody>
</table>
</a></div>
</div>
<div style="font-size:12px;color:#b5b9bd;line-height:18px;"><span>签名由</span> <a style="text-decoration: none;color:#4196ff;padding:0 5px;" href="https://mail.163.com/dashi/dlpro.html?from=mail81">
网易邮箱大师</a> <span>定制</span> </div>
</div>
</div>
<div class="J-reply" style="background-color:#f2f2f2;color:black;padding-top:6px;padding-bottom:6px;border-radius:3px;-moz-border-radius:3px;-webkit-border-radius:3px;margin-top:45px;margin-bottom:20px;font-family:'微软雅黑';">
<div style="font-size:12px;line-height:1.5;word-break:break-all;margin-left:10px;margin-right:10px">
On <span class="mail-date">1/14/2019 09:53</span>,<a class="mail-to" style="text-decoration:none;color:#2a83f2;" href="mailto:hoangphuocbk2.07@gmail.com">Hoàng Công Phước&lt;hoangphuocbk2.07@gmail.com&gt;</a> wrote:
</div>
</div>
<blockquote id="ntes-pcmail-quote" style="margin: 0; padding: 0; font-size: 14px; font-family: '微软雅黑';">
<div dir="ltr">Hi Wang,
<div><br>
</div>
<div>Could you upload your patch to ovs? I would appreciate your help about that case ^^. Thank you.</div>
</div>
<br>
<div class="gmail_quote">
<div dir="ltr">Vào CN, 13 thg 1, 2019 vào lúc 04:36 wang junqiang &lt;<a href="mailto:wangjq_china@outlook.com">wangjq_china@outlook.com</a>&gt; đã viết:<br>
</div>
<blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
<div>
<div>
<div>
<div>
<div style="direction:ltr">Hi,</div>
<div style="direction:ltr">&nbsp;&nbsp;&nbsp;&nbsp;I also encountered this problem, need to change the source code to solve.</div>
</div>
<div><br>
</div>
<div class="gmail-m_5057710210686132458ms-outlook-ios-signature">获取 <a href="https://aka.ms/o0ukef" target="_blank">
Outlook for iOS</a></div>
</div>
<div>&nbsp;</div>
<hr style="display:inline-block;width:98%">
<div id="gmail-m_5057710210686132458divRplyFwdMsg" dir="dir=&quot;ltr&quot;"><font face="Calibri, sans-serif" style="font-size:11pt" color="#000000"><b>发件人:</b>
<a href="mailto:ovs-discuss-bounces@openvswitch.org" target="_blank">ovs-discuss-bounces@openvswitch.org</a> 代表 Hoàng Công Phước &lt;<a href="mailto:hoangphuocbk2.07@gmail.com" target="_blank">hoangphuocbk2.07@gmail.com</a>&gt;<br>
<b>发送时间:</b> 星期六, 一月 12, 2019 11:11<br>
<b>收件人:</b> Ben Pfaff<br>
<b>抄送:</b> <a href="mailto:bugs@openvswitch.org" target="_blank">bugs@openvswitch.org</a><br>
<b>主题:</b> Re: [ovs-discuss] [SFC NSH] Update &quot;eth_dst&quot; for original packet after decap nsh encapsulation packet.
<div>&nbsp;</div>
</font></div>
<div dir="ltr">
<div dir="ltr">here are the document I am following:
<div><a href="https://github.com/openvswitch/ovs/blob/master/tests/nsh.at#L65-L68" target="_blank">https://github.com/openvswitch/ovs/blob/master/tests/nsh.at#L65-L68</a><br>
</div>
<div>My ovs version is 2.9.0 and when I check ovs, in version 2.9.0, NSH is supported.</div>
<div><br>
</div>
</div>
</div>
<br>
<div class="gmail_quote">
<div dir="ltr">Vào Th 7, 12 thg 1, 2019 vào lúc 01:52 Ben Pfaff &lt;<a href="mailto:blp@ovn.org" target="_blank">blp@ovn.org</a>&gt; đã viết:<br>
</div>
<blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
I don't think OVS supports this kind of encapsulation.<br>
<br>
On Fri, Jan 11, 2019 at 10:42:10AM &#43;0900, Hoàng Công Phước wrote:<br>
&gt; Hi Ben, thank for your<br>
&gt; <br>
&gt; I am sorry because I didn't show the encapsulation command. In this case,<br>
&gt; original packet is encapsulated 2 times, with nsh and ethernet headers.<br>
&gt; Here is the flow:<br>
&gt; <br>
&gt; table=0, n_packets=0, n_bytes=0,<br>
&gt; priority=30,tcp,in_port=&quot;tap09d8de0e-20&quot;,nw_src=10.10.0.111,nw_dst=<br>
&gt; <a href="http://10.10.0.0/24,tp_dst=80" rel="noreferrer" target="_blank">10.10.0.0/24,tp_dst=80</a><br>
&gt; actions=encap(nsh),set_field:0x33-&gt;nsh_spi,set_field:255-&gt;nsh_si,encap(ethernet),set_field:fa:16:3e:05:3a:12-&gt;eth_dst,resubmit(,5)<br>
&gt; <br>
&gt; As I known, after using decap() 2 times, I can get the original packet. So,<br>
&gt; I can update eth_dst to it.<br>
&gt; <br>
&gt; <br>
&gt; <br>
&gt; <br>
&gt; <br>
&gt; Vào Th 6, 11 thg 1, 2019 vào lúc 04:32 Ben Pfaff &lt;<a href="mailto:blp@ovn.org" target="_blank">blp@ovn.org</a>&gt; đã viết:<br>
&gt; <br>
&gt; &gt; On Fri, Jan 11, 2019 at 04:26:03AM &#43;0900, Hoàng Công Phước wrote:<br>
&gt; &gt; &gt; Hi experts,<br>
&gt; &gt; &gt;<br>
&gt; &gt; &gt; I am trying to update &quot;eth_dst&quot; for original packet after decap nsh<br>
&gt; &gt; &gt; encapsulation packet. Here is my command about it:<br>
&gt; &gt; &gt;<br>
&gt; &gt; &gt; $ sudo ovs-ofctl add-flow br-int &quot;table=10, priority=1, dl_vlan=4,<br>
&gt; &gt; &gt; dl_dst=fa:16:3e:05:3a:12, dl_type=0x894f, nsh_mdtype=1, nsh_spi=0x33,<br>
&gt; &gt; &gt; nsh_si=254, actions=strip_vlan,<br>
&gt; &gt; &gt; move:NXM_OF_ETH_DST-&gt;OXM_OF_PKT_REG0[0..47], decap(), decap(),<br>
&gt; &gt; &gt; move:OXM_OF_PKT_REG0[0..47]-&gt;NXM_OF_ETH_DST, output:tap62c2fc56-14&quot;<br>
&gt; &gt; &gt;<br>
&gt; &gt; &gt; However, I got an error, that is:<br>
&gt; &gt; &gt; &quot;2019-01-10T19:11:27Z|00001|meta_flow|WARN|destination field eth_dst<br>
&gt; &gt; lacks<br>
&gt; &gt; &gt; correct prerequisites<br>
&gt; &gt; &gt; ovs-ofctl: actions are invalid with specified match<br>
&gt; &gt; &gt; (OFPBAC_MATCH_INCONSISTENT)&quot;<br>
&gt; &gt; &gt;<br>
&gt; &gt; &gt; If I remove &quot;move:NXM_OF_ETH_DST-&gt;OXM_OF_PKT_REG0[0..47]&quot; and<br>
&gt; &gt; &gt; &quot;move:OXM_OF_PKT_REG0[0..47]-&gt;NXM_OF_ETH_DST&quot;, it worked. So there is an<br>
&gt; &gt; &gt; error with copy eth_dst value from outer to inner packet. I am beginner<br>
&gt; &gt; &gt; with Open vSwitch, so it's very helpful if someone can help me to figure<br>
&gt; &gt; &gt; the problem out.<br>
&gt; &gt;<br>
&gt; &gt; It looks to me that the first decap removes the NSH header and the<br>
&gt; &gt; second decap removes the Ethernet header.&nbsp; At that point, there's no<br>
&gt; &gt; Ethernet destination field to set, so the error seems reasonable.<br>
&gt; &gt;<br>
&gt; <br>
&gt; <br>
&gt; -- <br>
&gt; Hoàng Công Phước<br>
</blockquote>
</div>
<br clear="all">
<div><br>
</div>
-- <br>
<div dir="ltr" class="gmail-m_5057710210686132458gmail_signature">
<div dir="ltr">
<div>
<div dir="ltr">Hoàng Công Phước</div>
</div>
</div>
</div>
</div>
</div>
</blockquote>
</div>
<br clear="all">
<div><br>
</div>
-- <br>
<div dir="ltr" class="gmail_signature">
<div dir="ltr">
<div>
<div dir="ltr">Hoàng Công Phước</div>
</div>
</div>
</div>
</blockquote>
<!--😀--></div>
</body>
</html>