IS_IPV4_TCP() and IS_IPV4_UDP() do not check the tunnel type bits.
A tunnel packet that does not match any of the tunnel cases (IPIP,
GENEVE, IPv6 outer header, VXLAN or GRE without its type in gso_types)
is segmented as a plain TCP/IPv4 or UDP/IPv4 packet. For a tunnel
packet, l2_len, l3_len and l4_len describe the inner headers, so the
segments get wrong header boundaries, and the IPv4 and TCP header
updates overwrite the outer Ethernet and IPv4 headers. When the bytes
read as fragment offset are not zero, the packet is returned
unsegmented instead.

Return -ENOTSUP for such packets, as documented for protocols that
can not be segmented.

Fixes: 119583797b6a ("gso: support TCP/IPv4 GSO")
Fixes: b166d4f30b66 ("gso: support UDP/IPv4 fragmentation")
Cc: [email protected]

Signed-off-by: Andrey Mokrushin <[email protected]>
---
 lib/gso/gso_common.h | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/lib/gso/gso_common.h b/lib/gso/gso_common.h
index d1c1b73..cbc6b1b 100644
--- a/lib/gso/gso_common.h
+++ b/lib/gso/gso_common.h
@@ -17,7 +17,8 @@
 #define TCP_HDR_PSH_MASK ((uint8_t)0x08)
 #define TCP_HDR_FIN_MASK ((uint8_t)0x01)
 
-#define IS_IPV4_TCP(flag) (((flag) & (RTE_MBUF_F_TX_TCP_SEG | 
RTE_MBUF_F_TX_IPV4)) == \
+#define IS_IPV4_TCP(flag) (((flag) & (RTE_MBUF_F_TX_TCP_SEG | 
RTE_MBUF_F_TX_IPV4 | \
+                               RTE_MBUF_F_TX_TUNNEL_MASK)) == \
                (RTE_MBUF_F_TX_TCP_SEG | RTE_MBUF_F_TX_IPV4))
 
 #define IS_IPV4_VXLAN_TCP4(flag) (((flag) & (RTE_MBUF_F_TX_TCP_SEG | 
RTE_MBUF_F_TX_IPV4 | \
@@ -35,7 +36,8 @@
                (RTE_MBUF_F_TX_TCP_SEG | RTE_MBUF_F_TX_IPV4 | 
RTE_MBUF_F_TX_OUTER_IPV4 | \
                 RTE_MBUF_F_TX_TUNNEL_GRE))
 
-#define IS_IPV4_UDP(flag) (((flag) & (RTE_MBUF_F_TX_UDP_SEG | 
RTE_MBUF_F_TX_IPV4)) == \
+#define IS_IPV4_UDP(flag) (((flag) & (RTE_MBUF_F_TX_UDP_SEG | 
RTE_MBUF_F_TX_IPV4 | \
+                               RTE_MBUF_F_TX_TUNNEL_MASK)) == \
                (RTE_MBUF_F_TX_UDP_SEG | RTE_MBUF_F_TX_IPV4))
 
 /**
-- 
2.56.0


Reply via email to