In the original logic, when the Layer 3 protocol is IPv4, hlen equals
sizeof(struct eth_header) + IP_HEADER_LEN. For IPv6, hlen equals
sizeof(struct eth_header) + packet->l4_ofs - packet->l3_ofs. However, in
the VLAN over VXLAN scenario, the hlen length does not include the VLAN
length, leading to errors in popping the header. Now, hlen is uniformly
modified to packet->l4_ofs, which includes the total length of both
Layer 2 and Layer 3 headers, thereby correctly removing the tunnel
header.

Signed-off-by: Sunyang Wu <[email protected]>
---
 lib/netdev-native-tnl.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/lib/netdev-native-tnl.c b/lib/netdev-native-tnl.c
index 16c56608d..1db258daf 100644
--- a/lib/netdev-native-tnl.c
+++ b/lib/netdev-native-tnl.c
@@ -117,7 +117,7 @@ netdev_tnl_ip_extract_tnl_md(struct dp_packet *packet, 
struct flow_tnl *tnl,
         tnl->ip_tos = ip->ip_tos;
         tnl->ip_ttl = ip->ip_ttl;
 
-        *hlen += IP_HEADER_LEN;
+        *hlen += packet->l4_ofs - sizeof(struct eth_header);
 
     } else if (IP_VER(ip->ip_ihl_ver) == 6) {
         ovs_be32 tc_flow = get_16aligned_be32(&ip6->ip6_flow);
@@ -128,7 +128,7 @@ netdev_tnl_ip_extract_tnl_md(struct dp_packet *packet, 
struct flow_tnl *tnl,
         tnl->ip_tos = ntohl(tc_flow) >> 20;
         tnl->ip_ttl = ip6->ip6_hlim;
 
-        *hlen += packet->l4_ofs - packet->l3_ofs;
+        *hlen += packet->l4_ofs - sizeof(struct eth_header);
 
     } else {
         VLOG_WARN_RL(&err_rl, "ipv4 packet has invalid version (%d)",
-- 
2.19.0.rc0.windows.1

_______________________________________________
dev mailing list
[email protected]
https://mail.openvswitch.org/mailman/listinfo/ovs-dev

Reply via email to