Skip to contentSkip to conversation

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

PATCH Applied [email protected] 3 participants 4 messages Mar 24, 2022 – Apr 26, 2022 Network drivers

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 net/netvsc: fix the calculation of checksums based on mbuf flag

From: Long Li <[email protected]>

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")
---
 drivers/net/netvsc/hn_rxtx.c | 13 +++++++++----
 1 file changed, 9 insertions(+), 4 deletions(-)
drivers/net/netvsc/hn_rxtx.c +9 -4
index 028f176c7e..34f40be5b8 100644
@@ -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);
 	}
 
Signature · 1 line
2.32.0
Reviewed-by Acked-by Stephen Hemminger on v2 1/1 Applied
#1 lore raw
Quoted 5 lines · On 3/24/2022 5:46 PM, [email protected] wrote:

From: Long Li <[email protected]>

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

Quoted 7 lines

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")

Moving ack from previous version:

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

#2 lore raw
In reply to [email protected]
Quoted 20 lines · On 3/24/2022 5:46 PM, [email protected] wrote:

From: Long Li <[email protected]>

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")
---
  drivers/net/netvsc/hn_rxtx.c | 13 +++++++++----
  1 file changed, 9 insertions(+), 4 deletions(-)
drivers/net/netvsc/hn_rxtx.c +0 -0
index 028f176c7e..34f40be5b8 100644

drivers/net/netvsc/hn_rxtx.c static void hn_encap(struct rndis_packet_msg *pkt, · line 1355

Quoted 10 lines
drivers/net/netvsc/hn_rxtx.c +5 -2
@@ -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

#3 lore raw
Quoted 36 lines · Ferruh Yigit
Quoted 20 lines · On 3/24/2022 5:46 PM, [email protected] wrote:

From: Long Li <[email protected]>

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")
---
  drivers/net/netvsc/hn_rxtx.c | 13 +++++++++----
  1 file changed, 9 insertions(+), 4 deletions(-)
drivers/net/netvsc/hn_rxtx.c +0 -0
index 028f176c7e..34f40be5b8 100644

drivers/net/netvsc/hn_rxtx.c static void hn_encap(struct rndis_packet_msg *pkt, · line 1355

Quoted 10 lines
drivers/net/netvsc/hn_rxtx.c +5 -2
@@ -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:

Quoted 1 line

bnxt

ACK

Quoted 8 lines

dpaa
hnic
ionic
liquidio
mlx4
mvneta
mvpp2
qede