Skip to contentSkip to conversation

net: fix TSO packet checksum incorrect

PATCH Superseded Yuying Zhang 6 participants 11 messages Jul 28, 2020 – Jul 30, 2020

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 net: fix TSO packet checksum incorrect

The ol_flags check lacks of PKT_TX_IPV6 which causes checksum flag configuration error while IPv6/TCP TSO packet is sent. This patch fixes the issue using PKT_TX_OFFLOAD_MASK.

Fixes 520059a41aa9 ("net: check fragmented headers in non-debug as well")
---
 lib/librte_net/rte_net.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
lib/librte_net/rte_net.h +1 -1
index 1edc283a4..4b617ab4c 100644
@@ -125,7 +125,7 @@ rte_net_intel_cksum_flags_prepare(struct rte_mbuf *m, uint64_t ol_flags)
 	 * Mainly it is required to avoid fragmented headers check if
 	 * no offloads are requested.
 	 */
-	if (!(ol_flags & (PKT_TX_IP_CKSUM | PKT_TX_L4_MASK)))
+	if (!(ol_flags & PKT_TX_OFFLOAD_MASK))
 		return 0;
 
 	if (ol_flags & (PKT_TX_OUTER_IPV4 | PKT_TX_OUTER_IPV6))
Signature · 1 line
2.25.1
#1 lore raw

Hi,

Quoted 27 lines · Yuying Zhang

The ol_flags check lacks of PKT_TX_IPV6 which causes checksum flag configuration error while IPv6/TCP TSO packet is sent. This patch fixes the issue using PKT_TX_OFFLOAD_MASK.

Fixes 520059a41aa9 ("net: check fragmented headers in non-debug as well")
---
 lib/librte_net/rte_net.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
lib/librte_net/rte_net.h +1 -1
index 1edc283a4..4b617ab4c 100644
@@ -125,7 +125,7 @@ rte_net_intel_cksum_flags_prepare(struct rte_mbuf *m, uint64_t ol_flags)
 	 * Mainly it is required to avoid fragmented headers check if
 	 * no offloads are requested.
 	 */
-	if (!(ol_flags & (PKT_TX_IP_CKSUM | PKT_TX_L4_MASK)))
+	if (!(ol_flags & PKT_TX_OFFLOAD_MASK))
 		return 0;
 
 	if (ol_flags & (PKT_TX_OUTER_IPV4 | PKT_TX_OUTER_IPV6))
Signature · 1 line
2.25.1

I think the PKT_TX_TCP_SEG flag is missing in the test above, it should be like this:

if (!(ol_flags & (PKT_TX_IP_CKSUM | PKT_TX_L4_MASK | PKT_TX_TCP_SEG)))

It would be more precise than having the whole list of offload flags.

The reason is because in case of TSOv4, there is always the flag PKT_TX_IP_CKSUM, so this test is always wrong and we continue in the function. In case of TSOv6, there is neither PKT_TX_IP_CKSUM nor PKT_TX_L4_TCP (which is not mandatory, the doc says that PKT_TX_TCP_SEG implies PKT_TX_L4_TCP).

Thanks for spotting this. Can you please submit a v2 with PKT_TX_TCP_SEG?

Olivier

#2 lore raw
Quoted 36 lines · Olivier Matz

Hi,

Quoted 27 lines · Yuying Zhang

The ol_flags check lacks of PKT_TX_IPV6 which causes checksum flag configuration error while IPv6/TCP TSO packet is sent. This patch fixes the issue using PKT_TX_OFFLOAD_MASK.

Fixes 520059a41aa9 ("net: check fragmented headers in non-debug as well")
---
 lib/librte_net/rte_net.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
lib/librte_net/rte_net.h +1 -1
index 1edc283a4..4b617ab4c 100644
@@ -125,7 +125,7 @@ rte_net_intel_cksum_flags_prepare(struct rte_mbuf *m, uint64_t ol_flags)
 	 * Mainly it is required to avoid fragmented headers check if
 	 * no offloads are requested.
 	 */
-	if (!(ol_flags & (PKT_TX_IP_CKSUM | PKT_TX_L4_MASK)))
+	if (!(ol_flags & PKT_TX_OFFLOAD_MASK))
 		return 0;
 
 	if (ol_flags & (PKT_TX_OUTER_IPV4 | PKT_TX_OUTER_IPV6))
Signature · 1 line
2.25.1

I think the PKT_TX_TCP_SEG flag is missing in the test above, it should be like this:

if (!(ol_flags & (PKT_TX_IP_CKSUM | PKT_TX_L4_MASK | PKT_TX_TCP_SEG)))

Quoted 7 lines

It would be more precise than having the whole list of offload flags.

The reason is because in case of TSOv4, there is always the flag PKT_TX_IP_CKSUM, so this test is always wrong and we continue in the function. In case of TSOv6, there is neither PKT_TX_IP_CKSUM nor PKT_TX_L4_TCP (which is not mandatory, the doc says that PKT_TX_TCP_SEG implies PKT_TX_L4_TCP).

I thought that PKT_TX_L4_TCP is required anyway and missed the fact that PKT_TX_TCP_SEG implies PKT_TX_L4_TCP. Thanks.

Quoted 6 lines

Thanks for spotting this. Can you please submit a v2 with PKT_TX_TCP_SEG?

Olivier

#3 lore raw

PATCH v2 1/1 net: fix TSO packets checksum incorrect

In reply to Yuying Zhang

The ol_flags check lacks of flag for IPv6 which causes checksum flag configuration error while IPv6/TCP TSO packet is sent. This patch fixes the issue by adding PKT_TX_TCP_SEG flag.

Fixes 520059a41aa9 ("net: check fragmented headers in non-debug as well")
---
 lib/librte_net/rte_net.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
lib/librte_net/rte_net.h +1 -1
index 1edc283a4..94b06d9ee 100644
@@ -125,7 +125,7 @@ rte_net_intel_cksum_flags_prepare(struct rte_mbuf *m, uint64_t ol_flags)
 	 * Mainly it is required to avoid fragmented headers check if
 	 * no offloads are requested.
 	 */
-	if (!(ol_flags & (PKT_TX_IP_CKSUM | PKT_TX_L4_MASK)))
+	if (!(ol_flags & (PKT_TX_IP_CKSUM | PKT_TX_L4_MASK | PKT_TX_TCP_SEG)))
 		return 0;
 
 	if (ol_flags & (PKT_TX_OUTER_IPV4 | PKT_TX_OUTER_IPV6))
Signature · 1 line
2.25.1
Tested-by Zhang, XiX on v2 1/1
#4 lore raw

Re: [dpdk-dev] [PATCH v2 1/1] net: fix TSO packets checksum incorrect

Regards,
Xie Wei

-----Original Message-----
From: dev [mailto:[email protected]] On Behalf Of Yuying Zhang
Sent: Wednesday, July 29, 2020 1:10 AM
To: [email protected]; [email protected]; Zhang, Qi Z <[email protected]>; Yang, Qiming <[email protected]>
Cc: Zhang, Yuying <[email protected]>
Subject: [dpdk-dev] [PATCH v2 1/1] net: fix TSO packets checksum incorrect

The ol_flags check lacks of flag for IPv6 which causes checksum flag configuration error while IPv6/TCP TSO packet is sent. This patch fixes the issue by adding PKT_TX_TCP_SEG flag.

Fixes 520059a41aa9 ("net: check fragmented headers in non-debug as well")
---
 lib/librte_net/rte_net.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
lib/librte_net/rte_net.h +1 -1
@@ -125,7 +125,7 @@ rte_net_intel_cksum_flags_prepare(struct rte_mbuf *m, uint64_t ol_flags)
 	 * Mainly it is required to avoid fragmented headers check if
 	 * no offloads are requested.
 	 */
-	if (!(ol_flags & (PKT_TX_IP_CKSUM | PKT_TX_L4_MASK)))
+	if (!(ol_flags & (PKT_TX_IP_CKSUM | PKT_TX_L4_MASK | PKT_TX_TCP_SEG)))
 		return 0;
 
 	if (ol_flags & (PKT_TX_OUTER_IPV4 | PKT_TX_OUTER_IPV6))

--
2.25.1

Acked-by on v2 1/1
#5 lore raw

Re: [dpdk-dev] [PATCH v2 1/1] net: fix TSO packets checksum incorrect

In reply to Yuying Zhang
Quoted 3 lines · Yuying Zhang

The ol_flags check lacks of flag for IPv6 which causes checksum flag configuration error while IPv6/TCP TSO packet is sent. This patch fixes the issue by adding PKT_TX_TCP_SEG flag.

Thanks Yuying for the new version. I have another suggestion for the title/commit log:

net: fix bad checksum in offloaded TSOv6 packets

The rte_net_intel_cksum_flags_prepare() function prepares the pseudoheader checksum in packet data when doing checksum or TSO offload.

It does nothing when no checksum offload flag is set in mbuf. But in case of a IPv6/TCP TSO packet, it is not mandatory to have a checksum flag. We also need to check the PKT_TX_TCP_SEG flag in addition to checksum flags to fix offload preparation for such packets.

Quoted 3 lines
Fixes 520059a41aa9 ("net: check fragmented headers in non-debug as well")
Quoted 20 lines
---
 lib/librte_net/rte_net.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
lib/librte_net/rte_net.h +1 -1
index 1edc283a4..94b06d9ee 100644
@@ -125,7 +125,7 @@ rte_net_intel_cksum_flags_prepare(struct rte_mbuf *m, uint64_t ol_flags)
 	 * Mainly it is required to avoid fragmented headers check if
 	 * no offloads are requested.
 	 */
-	if (!(ol_flags & (PKT_TX_IP_CKSUM | PKT_TX_L4_MASK)))
+	if (!(ol_flags & (PKT_TX_IP_CKSUM | PKT_TX_L4_MASK | PKT_TX_TCP_SEG)))
 		return 0;
 
 	if (ol_flags & (PKT_TX_OUTER_IPV4 | PKT_TX_OUTER_IPV6))
Signature · 1 line
2.25.1
#6 lore raw

Re: [dpdk-dev] [PATCH v2 1/1] net: fix TSO packets checksum incorrect

Quoted 19 lines · Olivier Matz
Quoted 3 lines · Yuying Zhang

The ol_flags check lacks of flag for IPv6 which causes checksum flag configuration error while IPv6/TCP TSO packet is sent. This patch fixes the issue by adding PKT_TX_TCP_SEG flag.

Thanks Yuying for the new version. I have another suggestion for the title/commit log:

net: fix bad checksum in offloaded TSOv6 packets

The rte_net_intel_cksum_flags_prepare() function prepares the pseudoheader checksum in packet data when doing checksum or TSO offload.

It does nothing when no checksum offload flag is set in mbuf. But in case of a IPv6/TCP TSO packet, it is not mandatory to have a checksum flag. We also need to check the PKT_TX_TCP_SEG flag in addition to checksum flags to fix offload preparation for such packets.

Quoted 5 lines
Quoted 3 lines
Fixes 520059a41aa9 ("net: check fragmented headers in non-debug as well")
Quoted 21 lines
Quoted 21 lines
---
 lib/librte_net/rte_net.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
lib/librte_net/rte_net.h +1 -1
index 1edc283a4..94b06d9ee 100644
@@ -125,7 +125,7 @@ rte_net_intel_cksum_flags_prepare(struct rte_mbuf *m, uint64_t ol_flags)
 	 * Mainly it is required to avoid fragmented headers check if
 	 * no offloads are requested.
 	 */
-	if (!(ol_flags & (PKT_TX_IP_CKSUM | PKT_TX_L4_MASK)))
+	if (!(ol_flags & (PKT_TX_IP_CKSUM | PKT_TX_L4_MASK | PKT_TX_TCP_SEG)))
 		return 0;
 
 	if (ol_flags & (PKT_TX_OUTER_IPV4 | PKT_TX_OUTER_IPV6))
Signature · 1 line
2.25.1
Reviewed-by on v2 1/1
#7 lore raw

Re: [dpdk-dev] [PATCH v2 1/1] net: fix TSO packets checksum incorrect

In reply to Yuying Zhang
Quoted 26 lines · Yuying Zhang

The ol_flags check lacks of flag for IPv6 which causes checksum flag configuration error while IPv6/TCP TSO packet is sent. This patch fixes the issue by adding PKT_TX_TCP_SEG flag.

Fixes 520059a41aa9 ("net: check fragmented headers in non-debug as well")
---
 lib/librte_net/rte_net.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
lib/librte_net/rte_net.h +1 -2
index 1edc283a4..94b06d9ee 100644
@@ -125,7 +125,7 @@ rte_net_intel_cksum_flags_prepare(struct rte_mbuf *m, uint64_t ol_flags)
         * Mainly it is required to avoid fragmented headers check if
         * no offloads are requested.
         */
-       if (!(ol_flags & (PKT_TX_IP_CKSUM | PKT_TX_L4_MASK)))
+       if (!(ol_flags & (PKT_TX_IP_CKSUM | PKT_TX_L4_MASK | PKT_TX_TCP_SEG)))
                return 0;
 
        if (ol_flags & (PKT_TX_OUTER_IPV4 | PKT_TX_OUTER_IPV6))
--
Quoted 2 lines

2.25.1

Olivier suggestion on the commitlog/title looks fine to me.

Signature · 1 line
David Marchand
Applied
#8 lore raw

Re: [dpdk-dev] [PATCH v2 1/1] net: fix TSO packets checksum incorrect

Quoted 6 lines · David Marchand
Quoted 5 lines · Yuying Zhang

The ol_flags check lacks of flag for IPv6 which causes checksum flag configuration error while IPv6/TCP TSO packet is sent. This patch fixes the issue by adding PKT_TX_TCP_SEG flag.

Quoted 8 lines
Quoted 3 lines
Fixes 520059a41aa9 ("net: check fragmented headers in non-debug as well")

Applied to dpdk-next-net/master, thanks.

(Used the suggested commit log)

#9 lore raw

PATCH v3 1/1 net: fix bad checksum in offloaded TSOv6 packets

In reply to Yuying Zhang

The rte_net_intel_cksum_flags_prepare() function prepares the pseudoheader checksum in packet data when doing checksum or TSO offload.

It does nothing when no checksum offload flag is set in mbuf. But in case of a IPv6/TCP TSO packet, it is not mandatory to have a checksum flag. We also need to check the PKT_TX_TCP_SEG flag in addition to checksum flags to fix offload preparation for such packets.

Fixes 520059a41aa9 ("net: check fragmented headers in non-debug as well")
---
 lib/librte_net/rte_net.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
lib/librte_net/rte_net.h +1 -1
index 1edc283a4..94b06d9ee 100644
@@ -125,7 +125,7 @@ rte_net_intel_cksum_flags_prepare(struct rte_mbuf *m, uint64_t ol_flags)
 	 * Mainly it is required to avoid fragmented headers check if
 	 * no offloads are requested.
 	 */
-	if (!(ol_flags & (PKT_TX_IP_CKSUM | PKT_TX_L4_MASK)))
+	if (!(ol_flags & (PKT_TX_IP_CKSUM | PKT_TX_L4_MASK | PKT_TX_TCP_SEG)))
 		return 0;
 
 	if (ol_flags & (PKT_TX_OUTER_IPV4 | PKT_TX_OUTER_IPV6))
Signature · 1 line
2.25.1
#10 lore raw

Re: [dpdk-dev] [PATCH v3 1/1] net: fix bad checksum in offloaded TSOv6 packets

Quoted 40 lines

-----Original Message-----
From: Zhang, Yuying <[email protected]>
Sent: 2020年7月30日 10:01
To: [email protected]; [email protected]; Zhang, Qi Z <[email protected]>; Yang, Qiming <[email protected]>
Cc: Zhang, Yuying <[email protected]>; David Marchand <[email protected]>
Subject: [PATCH v3 1/1] net: fix bad checksum in offloaded TSOv6 packets

The rte_net_intel_cksum_flags_prepare() function prepares the pseudoheader checksum in packet data when doing checksum or TSO offload.

It does nothing when no checksum offload flag is set in mbuf. But in case of a IPv6/TCP TSO packet, it is not mandatory to have a checksum flag. We also need to check the PKT_TX_TCP_SEG flag in addition to checksum flags to fix offload preparation for such packets.

Fixes 520059a41aa9 ("net: check fragmented headers in non-debug as well")
---
 lib/librte_net/rte_net.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
lib/librte_net/rte_net.h index renamed from lib/librte_net/rte_net.h +0 -0

1edc283a4..94b06d9ee 100644

lib/librte_net/rte_net.h +1 -1
@@ -125,7 +125,7 @@ rte_net_intel_cksum_flags_prepare(struct rte_mbuf *m,
 uint64_t ol_flags)
 	 * Mainly it is required to avoid fragmented headers check if
 	 * no offloads are requested.
 	 */
-	if (!(ol_flags & (PKT_TX_IP_CKSUM | PKT_TX_L4_MASK)))
+	if (!(ol_flags & (PKT_TX_IP_CKSUM | PKT_TX_L4_MASK |
 PKT_TX_TCP_SEG)))
 		return 0;
Quoted 3 lines

if (ol_flags & (PKT_TX_OUTER_IPV4 | PKT_TX_OUTER_IPV6))
--
2.25.1

Please drop this patch since it has been merged into dpdk-next-net/master. I am so sorry.