DPDK patches and discussions
 help / color / mirror / Atom feed
From: Morten Brørup <mb@smartsharesystems.com>
To: "Ferruh Yigit" <ferruh.yigit@intel.com>,
	"Michael Pfeiffer" <michael.pfeiffer@tu-ilmenau.de>,
	"Keith Wiles" <keith.wiles@intel.com>
Cc: <dev@dpdk.org>
Subject: Re: [dpdk-dev] [PATCH] net/tap: Allow all-zero checksum for UDP over IPv4
Date: Wed, 11 Nov 2020 08:06:39 +0100
Message-ID: <98CBD80474FA8B44BF855DF32C47DC35C61416@smartserver.smartshare.dk> (raw)
In-Reply-To: <22b7290c-7b65-68c8-5eea-1db8f90f78f7@intel.com>

> From: Ferruh Yigit [mailto:ferruh.yigit@intel.com]
> Sent: Tuesday, November 10, 2020 6:43 PM
> 
> On 11/10/2020 4:01 PM, Morten Brørup wrote:
> >> From: dev [mailto:dev-bounces@dpdk.org] On Behalf Of Ferruh Yigit
> >> Sent: Tuesday, November 10, 2020 3:47 PM
> >>
> >> On 11/9/2020 2:22 PM, Michael Pfeiffer wrote:
> >>> 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;
> >>>
> >>
> >> While checking this I stuck with following part:
> >>
> >>    cksum = ~rte_ipv6_udptcp_cksum(l3_hdr, l4_hdr);
> >>    ...
> >>     mbuf->ol_flags |= cksum ?
> >>     	PKT_RX_L4_CKSUM_BAD :
> >>    	PKT_RX_L4_CKSUM_GOOD;
> >>
> >>
> >> Is this correct, or am I missing something, can intention be '!'
> here
> >> instead of
> >> '~' ?
> >
> > It is correct. The packet's checksum is calculated by
> rte_ipv6_udptcp_cksum(), and it should be 0xFFFF. The '~' operation
> makes cksum 0 iff the calculated checksum is 0xFFFF.
> >
> 
> Yep, figure that out late,
> as far as I understand when the checksum value is zero,
> 'rte_ipv6_udptcp_cksum()' will return the checksum value and when
> checksum is
> correct in the packet, function will return 0xFFFF, this is based on
> checksum
> calculation, is this right?

Exactly.


  reply	other threads:[~2020-11-11  7:06 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-11-09 14:22 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 [this message]
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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=98CBD80474FA8B44BF855DF32C47DC35C61416@smartserver.smartshare.dk \
    --to=mb@smartsharesystems.com \
    --cc=dev@dpdk.org \
    --cc=ferruh.yigit@intel.com \
    --cc=keith.wiles@intel.com \
    --cc=michael.pfeiffer@tu-ilmenau.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

DPDK patches and discussions

This inbox may be cloned and mirrored by anyone:

	git clone --mirror https://inbox.dpdk.org/dev/0 dev/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 dev dev/ https://inbox.dpdk.org/dev \
		dev@dpdk.org
	public-inbox-index dev

Example config snippet for mirrors.
Newsgroup available over NNTP:
	nntp://inbox.dpdk.org/inbox.dpdk.dev


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git