diff mbox series

[v1] net: fix TSO packet checksum incorrect

Message ID 20200728085531.204296-1-yuying.zhang@intel.com (mailing list archive)
State Superseded, archived
Delegated to: Ferruh Yigit
Headers show
Series [v1] net: fix TSO packet checksum incorrect | expand

Checks

Context Check Description
ci/iol-mellanox-Performance success Performance Testing PASS
ci/iol-testing success Testing PASS
ci/iol-intel-Performance success Performance Testing PASS
ci/iol-broadcom-Performance success Performance Testing PASS
ci/Intel-compilation success Compilation OK
ci/travis-robot success Travis build: passed
ci/checkpatch success coding style OK

Commit Message

Yuying Zhang July 28, 2020, 8:55 a.m. UTC
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")

Signed-off-by: Yuying Zhang <yuying.zhang@intel.com>
---
 lib/librte_net/rte_net.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Olivier Matz July 28, 2020, 9:29 a.m. UTC | #1
Hi,

On Tue, Jul 28, 2020 at 08:55:31AM +0000, Yuying Zhang wrote:
> 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")
> 
> Signed-off-by: Yuying Zhang <yuying.zhang@intel.com>
> ---
>  lib/librte_net/rte_net.h | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/lib/librte_net/rte_net.h b/lib/librte_net/rte_net.h
> index 1edc283a4..4b617ab4c 100644
> --- a/lib/librte_net/rte_net.h
> +++ b/lib/librte_net/rte_net.h
> @@ -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))
> -- 
> 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
Andrew Rybchenko July 29, 2020, 3:58 p.m. UTC | #2
On 7/28/20 12:29 PM, Olivier Matz wrote:
> Hi,
> 
> On Tue, Jul 28, 2020 at 08:55:31AM +0000, Yuying Zhang wrote:
>> 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")
>>
>> Signed-off-by: Yuying Zhang <yuying.zhang@intel.com>
>> ---
>>  lib/librte_net/rte_net.h | 2 +-
>>  1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/lib/librte_net/rte_net.h b/lib/librte_net/rte_net.h
>> index 1edc283a4..4b617ab4c 100644
>> --- a/lib/librte_net/rte_net.h
>> +++ b/lib/librte_net/rte_net.h
>> @@ -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))
>> -- 
>> 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).

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.

> 
> Thanks for spotting this. Can you please submit a v2 with
> PKT_TX_TCP_SEG?
> 
> Olivier
>
diff mbox series

Patch

diff --git a/lib/librte_net/rte_net.h b/lib/librte_net/rte_net.h
index 1edc283a4..4b617ab4c 100644
--- a/lib/librte_net/rte_net.h
+++ b/lib/librte_net/rte_net.h
@@ -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))