[v2] net/netvsc: fix the calculation of checksums based on mbuf flag

Message ID 1648143968-17947-1-git-send-email-longli@linuxonhyperv.com (mailing list archive)
State Accepted, archived
Delegated to: Ferruh Yigit
Headers
Series [v2] net/netvsc: fix the calculation of checksums based on mbuf flag |

Checks

Context Check Description
ci/checkpatch warning coding style issues
ci/iol-mellanox-Performance success Performance Testing PASS
ci/iol-intel-Performance success Performance Testing PASS
ci/iol-aarch64-unit-testing success Testing PASS
ci/iol-intel-Functional success Functional Testing PASS
ci/github-robot: build success github build: passed
ci/iol-x86_64-compile-testing success Testing PASS
ci/iol-aarch64-compile-testing success Testing PASS
ci/iol-x86_64-unit-testing success Testing PASS
ci/iol-abi-testing success Testing PASS
ci/iol-broadcom-Functional fail Functional Testing issues
ci/Intel-compilation success Compilation OK
ci/intel-Testing success Testing PASS

Commit Message

Long Li March 24, 2022, 5:46 p.m. UTC
  From: Long Li <longli@microsoft.com>

The netvsc should use RTE_MBUF_F_TX_L4_MASK and check the masked value to
decide the correct way to calculate checksums.

Not checking for RTE_MBUF_F_TX_L4_MASK results in incorrect RNDIS packets
sent to VSP and incorrect checksums calculated by the VSP.

Fixes: 4e9c73e96e ("net/netvsc: add Hyper-V network device")
Cc: stable@dpdk.org
Signed-off-by: Long Li <longli@microsoft.com>
---
 drivers/net/netvsc/hn_rxtx.c | 13 +++++++++----
 1 file changed, 9 insertions(+), 4 deletions(-)
  

Comments

Ferruh Yigit April 26, 2022, 9:56 p.m. UTC | #1
On 3/24/2022 5:46 PM, longli@linuxonhyperv.com wrote:
> From: Long Li <longli@microsoft.com>
> 
> The netvsc should use RTE_MBUF_F_TX_L4_MASK and check the masked value to
> decide the correct way to calculate checksums.
> 
> Not checking for RTE_MBUF_F_TX_L4_MASK results in incorrect RNDIS packets
> sent to VSP and incorrect checksums calculated by the VSP.
> 
> Fixes: 4e9c73e96e ("net/netvsc: add Hyper-V network device")
> Cc: stable@dpdk.org

> Signed-off-by: Long Li <longli@microsoft.com>

Reviewed-by: Ferruh Yigit <ferruh.yigit@xilinx.com>

Moving ack from previous version:
Acked-by: Stephen Hemminger <stephen@networkplumber.org>

Applied to dpdk-next-net/main, thanks.
  
Ferruh Yigit April 26, 2022, 9:56 p.m. UTC | #2
On 3/24/2022 5:46 PM, longli@linuxonhyperv.com wrote:
> From: Long Li <longli@microsoft.com>
> 
> The netvsc should use RTE_MBUF_F_TX_L4_MASK and check the masked value to
> decide the correct way to calculate checksums.
> 
> Not checking for RTE_MBUF_F_TX_L4_MASK results in incorrect RNDIS packets
> sent to VSP and incorrect checksums calculated by the VSP.
> 
> Fixes: 4e9c73e96e ("net/netvsc: add Hyper-V network device")
> Cc: stable@dpdk.org
> Signed-off-by: Long Li <longli@microsoft.com>
> ---
>   drivers/net/netvsc/hn_rxtx.c | 13 +++++++++----
>   1 file changed, 9 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/net/netvsc/hn_rxtx.c b/drivers/net/netvsc/hn_rxtx.c
> index 028f176c7e..34f40be5b8 100644
> --- a/drivers/net/netvsc/hn_rxtx.c
> +++ b/drivers/net/netvsc/hn_rxtx.c
> @@ -1348,8 +1348,11 @@ static void hn_encap(struct rndis_packet_msg *pkt,
>   			*pi_data = NDIS_LSO2_INFO_MAKEIPV4(hlen,
>   							   m->tso_segsz);
>   		}
> -	} else if (m->ol_flags &
> -		   (RTE_MBUF_F_TX_TCP_CKSUM | RTE_MBUF_F_TX_UDP_CKSUM | RTE_MBUF_F_TX_IP_CKSUM)) {
> +	} else if ((m->ol_flags & RTE_MBUF_F_TX_L4_MASK) ==
> +			RTE_MBUF_F_TX_TCP_CKSUM ||
> +		   (m->ol_flags & RTE_MBUF_F_TX_L4_MASK) ==
> +			RTE_MBUF_F_TX_UDP_CKSUM ||
> +		   (m->ol_flags & RTE_MBUF_F_TX_IP_CKSUM)) {

As far as I can see following drivers also has similar issue, can 
maintainers (cc'ed) of below drivers check:

bnxt
dpaa
hnic
ionic
liquidio
mlx4
mvneta
mvpp2
qede
  
Ajit Khaparde April 26, 2022, 10:09 p.m. UTC | #3
On Tue, Apr 26, 2022 at 2:57 PM Ferruh Yigit <ferruh.yigit@xilinx.com> wrote:
>
> On 3/24/2022 5:46 PM, longli@linuxonhyperv.com wrote:
> > From: Long Li <longli@microsoft.com>
> >
> > The netvsc should use RTE_MBUF_F_TX_L4_MASK and check the masked value to
> > decide the correct way to calculate checksums.
> >
> > Not checking for RTE_MBUF_F_TX_L4_MASK results in incorrect RNDIS packets
> > sent to VSP and incorrect checksums calculated by the VSP.
> >
> > Fixes: 4e9c73e96e ("net/netvsc: add Hyper-V network device")
> > Cc: stable@dpdk.org
> > Signed-off-by: Long Li <longli@microsoft.com>
> > ---
> >   drivers/net/netvsc/hn_rxtx.c | 13 +++++++++----
> >   1 file changed, 9 insertions(+), 4 deletions(-)
> >
> > diff --git a/drivers/net/netvsc/hn_rxtx.c b/drivers/net/netvsc/hn_rxtx.c
> > index 028f176c7e..34f40be5b8 100644
> > --- a/drivers/net/netvsc/hn_rxtx.c
> > +++ b/drivers/net/netvsc/hn_rxtx.c
> > @@ -1348,8 +1348,11 @@ static void hn_encap(struct rndis_packet_msg *pkt,
> >                       *pi_data = NDIS_LSO2_INFO_MAKEIPV4(hlen,
> >                                                          m->tso_segsz);
> >               }
> > -     } else if (m->ol_flags &
> > -                (RTE_MBUF_F_TX_TCP_CKSUM | RTE_MBUF_F_TX_UDP_CKSUM | RTE_MBUF_F_TX_IP_CKSUM)) {
> > +     } else if ((m->ol_flags & RTE_MBUF_F_TX_L4_MASK) ==
> > +                     RTE_MBUF_F_TX_TCP_CKSUM ||
> > +                (m->ol_flags & RTE_MBUF_F_TX_L4_MASK) ==
> > +                     RTE_MBUF_F_TX_UDP_CKSUM ||
> > +                (m->ol_flags & RTE_MBUF_F_TX_IP_CKSUM)) {
>
> As far as I can see following drivers also has similar issue, can
> maintainers (cc'ed) of below drivers check:
>
> bnxt
ACK

> dpaa
> hnic
> ionic
> liquidio
> mlx4
> mvneta
> mvpp2
> qede
  

Patch

diff --git a/drivers/net/netvsc/hn_rxtx.c b/drivers/net/netvsc/hn_rxtx.c
index 028f176c7e..34f40be5b8 100644
--- a/drivers/net/netvsc/hn_rxtx.c
+++ b/drivers/net/netvsc/hn_rxtx.c
@@ -1348,8 +1348,11 @@  static void hn_encap(struct rndis_packet_msg *pkt,
 			*pi_data = NDIS_LSO2_INFO_MAKEIPV4(hlen,
 							   m->tso_segsz);
 		}
-	} else if (m->ol_flags &
-		   (RTE_MBUF_F_TX_TCP_CKSUM | RTE_MBUF_F_TX_UDP_CKSUM | RTE_MBUF_F_TX_IP_CKSUM)) {
+	} else if ((m->ol_flags & RTE_MBUF_F_TX_L4_MASK) ==
+			RTE_MBUF_F_TX_TCP_CKSUM ||
+		   (m->ol_flags & RTE_MBUF_F_TX_L4_MASK) ==
+			RTE_MBUF_F_TX_UDP_CKSUM ||
+		   (m->ol_flags & RTE_MBUF_F_TX_IP_CKSUM)) {
 		pi_data = hn_rndis_pktinfo_append(pkt, NDIS_TXCSUM_INFO_SIZE,
 						  NDIS_PKTINFO_TYPE_CSUM);
 		*pi_data = 0;
@@ -1363,9 +1366,11 @@  static void hn_encap(struct rndis_packet_msg *pkt,
 				*pi_data |= NDIS_TXCSUM_INFO_IPCS;
 		}
 
-		if (m->ol_flags & RTE_MBUF_F_TX_TCP_CKSUM)
+		if ((m->ol_flags & RTE_MBUF_F_TX_L4_MASK) ==
+				RTE_MBUF_F_TX_TCP_CKSUM)
 			*pi_data |= NDIS_TXCSUM_INFO_MKTCPCS(hlen);
-		else if (m->ol_flags & RTE_MBUF_F_TX_UDP_CKSUM)
+		else if ((m->ol_flags & RTE_MBUF_F_TX_L4_MASK) ==
+				RTE_MBUF_F_TX_UDP_CKSUM)
 			*pi_data |= NDIS_TXCSUM_INFO_MKUDPCS(hlen);
 	}