DPDK patches and discussions
 help / color / mirror / Atom feed
* [dpdk-dev] [PATCH] net/tap: Allow all-zero checksum for UDP over IPv4
@ 2020-11-09 14:22 Michael Pfeiffer
  2020-11-10 14:46 ` Ferruh Yigit
  2020-11-10 15:59 ` Ferruh Yigit
  0 siblings, 2 replies; 12+ messages in thread
From: Michael Pfeiffer @ 2020-11-09 14:22 UTC (permalink / raw)
  To: Keith Wiles; +Cc: dev, Michael Pfeiffer

Unlike TCP, UDP checksums are optional and may be zero to indicate "not
set" [RFC 768] (except for IPv6, where this prohibited [RFC 8200]). Add
this special case to the checksum offload emulation in net/tap.

Signed-off-by: Michael Pfeiffer <michael.pfeiffer@tu-ilmenau.de>
---
 drivers/net/tap/rte_eth_tap.c | 13 +++++++++++--
 1 file changed, 11 insertions(+), 2 deletions(-)

diff --git a/drivers/net/tap/rte_eth_tap.c b/drivers/net/tap/rte_eth_tap.c
index 2f8abb12c..e486b41c5 100644
--- a/drivers/net/tap/rte_eth_tap.c
+++ b/drivers/net/tap/rte_eth_tap.c
@@ -303,6 +303,7 @@ tap_verify_csum(struct rte_mbuf *mbuf)
 	uint16_t cksum = 0;
 	void *l3_hdr;
 	void *l4_hdr;
+	struct rte_udp_hdr *udp_hdr;
 
 	if (l2 == RTE_PTYPE_L2_ETHER_VLAN)
 		l2_len += 4;
@@ -349,10 +350,18 @@ tap_verify_csum(struct rte_mbuf *mbuf)
 		/* Don't verify checksum for multi-segment packets. */
 		if (mbuf->nb_segs > 1)
 			return;
-		if (l3 == RTE_PTYPE_L3_IPV4)
+		if (l3 == RTE_PTYPE_L3_IPV4) {
+			if (l4 == RTE_PTYPE_L4_UDP) {
+				udp_hdr = (struct rte_udp_hdr *)l4_hdr;
+				if (udp_hdr->dgram_cksum == 0) {
+					mbuf->ol_flags |= PKT_RX_L4_CKSUM_NONE;
+					return;
+				}
+			}
 			cksum = ~rte_ipv4_udptcp_cksum(l3_hdr, l4_hdr);
-		else if (l3 == RTE_PTYPE_L3_IPV6)
+		} else if (l3 == RTE_PTYPE_L3_IPV6) {
 			cksum = ~rte_ipv6_udptcp_cksum(l3_hdr, l4_hdr);
+		}
 		mbuf->ol_flags |= cksum ?
 			PKT_RX_L4_CKSUM_BAD :
 			PKT_RX_L4_CKSUM_GOOD;
-- 
2.29.2


^ permalink raw reply	[flat|nested] 12+ messages in thread

end of thread, other threads:[~2020-11-13 14:49 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-11-09 14:22 [dpdk-dev] [PATCH] net/tap: Allow all-zero checksum for UDP over IPv4 Michael Pfeiffer
2020-11-10 14:46 ` Ferruh Yigit
2020-11-10 15:56   ` Ferruh Yigit
2020-11-10 16:01   ` Morten Brørup
2020-11-10 17:42     ` Ferruh Yigit
2020-11-11  7:06       ` Morten Brørup
2020-11-10 15:59 ` Ferruh Yigit
2020-11-11  7:23   ` Michael Pfeiffer
2020-11-11  9:31     ` Ferruh Yigit
2020-11-13 13:02       ` Ferruh Yigit
2020-11-13 14:03         ` [dpdk-dev] [PATCH v2] " Michael Pfeiffer
2020-11-13 14:49           ` Ferruh Yigit

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).