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

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>
Acked-by: Stephen Hemminger <stephen@networkplumber.org>
Reviewed-by: Ferruh Yigit <ferruh.yigit@xilinx.com>
This commit is contained in:
Long Li 2022-03-24 10:46:08 -07:00 committed by Ferruh Yigit
parent b14e8a57b9
commit 559a1f2eea

View File

@ -1346,8 +1346,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;
@ -1361,9 +1364,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);
}