From mboxrd@z Thu Jan  1 00:00:00 1970
Return-Path: <stable-bounces@dpdk.org>
Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124])
	by inbox.dpdk.org (Postfix) with ESMTP id 2669BA0C41
	for <public@inbox.dpdk.org>; Tue,  8 Jun 2021 16:30:41 +0200 (CEST)
Received: from [217.70.189.124] (localhost [127.0.0.1])
	by mails.dpdk.org (Postfix) with ESMTP id 12221410EF;
	Tue,  8 Jun 2021 16:30:41 +0200 (CEST)
Received: from mail-wm1-f53.google.com (mail-wm1-f53.google.com
 [209.85.128.53]) by mails.dpdk.org (Postfix) with ESMTP id 31C8240689
 for <stable@dpdk.org>; Tue,  8 Jun 2021 16:30:39 +0200 (CEST)
Received: by mail-wm1-f53.google.com with SMTP id
 t4-20020a1c77040000b029019d22d84ebdso2103915wmi.3
 for <stable@dpdk.org>; Tue, 08 Jun 2021 07:30:39 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=6wind.com; s=google;
 h=date:from:to:cc:subject:message-id:references:mime-version
 :content-disposition:in-reply-to;
 bh=Y5XDpRrgUeu0Ofyd5hYLmDnLfV+k4tg7BZ8vBT2DE4o=;
 b=cLQIEWK6u14x0bbYkIMjvcSZB6xO01y5HG0/euf2mJ2bngKFrlfPi01U+Ozsr5f23z
 6q9PJ4zUCixyQpkoDpgKpKJijs5zJxIvOfAzfrHO2f5+md6DA01pNVCFIF29lwt4if5R
 SXb1frgu3/g4ypigR0/n/mf7NAxy6ZCmC11TYntBRiE/kGdHAhOn5vGSqBajkacvLyX1
 /S49LJ1RtUxLXR9wdxEV8tSypLSpxT7+jndKzxHyVvA87NKSqpPx1fVEdm22/NtsM/g0
 28RPWLNVrbtjRGohz0RqTh0+DWqb3ScsaAU4G0XnNNbQS+DYvfqCgpwavVjjxeQW62qB
 E7bw==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=1e100.net; s=20161025;
 h=x-gm-message-state:date:from:to:cc:subject:message-id:references
 :mime-version:content-disposition:in-reply-to;
 bh=Y5XDpRrgUeu0Ofyd5hYLmDnLfV+k4tg7BZ8vBT2DE4o=;
 b=H1N+WJGFyW5Pks7yj33fq7fr8pk+JWeSktP5OkWnuu12/qEUWlWcjiZae+UFoDlKPB
 hmXFT4IW6siKvuo+QjCDD0NCN2EfY6vTkfxe8tLAu4AVSQjwZqeJeHVoxf7sjM+i8pRk
 b/30pd59NRss/fqxrPgvOBQYRVga8E2Z+wzxq37u93o7zjpG1DOKKwNZRS4KwKbIbdKG
 o2V6u0sDbq8tkz8+URPKCzyAyHWDyL5h6U2U6o8cbxkRDD3mKuoFl3dGNzNU3r8k5zza
 ig1CNneF0rekbyQ6Z4rqShKx85S49+QI5ZK+08N/ttNwsiduTLYtag8H4pic091EMpXE
 vvcg==
X-Gm-Message-State: AOAM531KijONRG+w/920/qfWj5DjUh39UCIt+ODeHEpfGGXHOQ/Pj3Oh
 F3L5ObkzgA1K0x6xpkDTEe8uuA==
X-Google-Smtp-Source: ABdhPJyRXjPA6A+KyGmW0mUcmWlykTqbyVYiyRMuhhQ39TZUTe7E1SRsURQmeVcQt5GN75a3OWT8Hg==
X-Received: by 2002:a05:600c:2216:: with SMTP id
 z22mr19352605wml.66.1623162638774; 
 Tue, 08 Jun 2021 07:30:38 -0700 (PDT)
Received: from 6wind.com ([2a01:e0a:5ac:6460:c065:401d:87eb:9b25])
 by smtp.gmail.com with ESMTPSA id 25sm3149186wmk.20.2021.06.08.07.30.37
 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);
 Tue, 08 Jun 2021 07:30:38 -0700 (PDT)
Date: Tue, 8 Jun 2021 16:30:37 +0200
From: Olivier Matz <olivier.matz@6wind.com>
To: Andrew Rybchenko <andrew.rybchenko@oktetlabs.ru>
Cc: Ferruh Yigit <ferruh.yigit@intel.com>, dev@dpdk.org,
 Keith Wiles <keith.wiles@intel.com>, Hongzhi Guo <guohongzhi1@huawei.com>,
 Morten =?iso-8859-1?Q?Br=F8rup?= <mb@smartsharesystems.com>,
 Thomas Monjalon <thomas@monjalon.net>, stable@dpdk.org
Message-ID: <YL9/De6PInNpHljE@platinum>
References: <20210427135755.927-1-olivier.matz@6wind.com>
 <20210427135755.927-2-olivier.matz@6wind.com>
 <5fa9bc52-0862-983e-3e38-33a937872571@intel.com>
 <39a8a8bb-d246-3377-607c-3c2387b73fe0@oktetlabs.ru>
 <YL9iqT8mp+gjVlfY@platinum>
 <359f754b-6ee3-d3e4-5cfc-06f399db9617@oktetlabs.ru>
 <YL9nVghVbKKtRd/d@platinum>
 <5be5ae7d-7e7f-51d0-9bf0-4bd558788ca6@oktetlabs.ru>
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
In-Reply-To: <5be5ae7d-7e7f-51d0-9bf0-4bd558788ca6@oktetlabs.ru>
Subject: Re: [dpdk-stable] [dpdk-dev] [PATCH 1/4] net/tap: fix Rx cksum
 flags on IP options packets
X-BeenThere: stable@dpdk.org
X-Mailman-Version: 2.1.29
Precedence: list
List-Id: patches for DPDK stable branches <stable.dpdk.org>
List-Unsubscribe: <https://mails.dpdk.org/options/stable>,
 <mailto:stable-request@dpdk.org?subject=unsubscribe>
List-Archive: <http://mails.dpdk.org/archives/stable/>
List-Post: <mailto:stable@dpdk.org>
List-Help: <mailto:stable-request@dpdk.org?subject=help>
List-Subscribe: <https://mails.dpdk.org/listinfo/stable>,
 <mailto:stable-request@dpdk.org?subject=subscribe>
Errors-To: stable-bounces@dpdk.org
Sender: "stable" <stable-bounces@dpdk.org>

On Tue, Jun 08, 2021 at 04:57:00PM +0300, Andrew Rybchenko wrote:
> On 6/8/21 3:49 PM, Olivier Matz wrote:
> > On Tue, Jun 08, 2021 at 03:34:36PM +0300, Andrew Rybchenko wrote:
> >> On 6/8/21 3:29 PM, Olivier Matz wrote:
> >>> Hi Ferruh, Andrew,
> >>>
> >>> On Tue, Jun 08, 2021 at 01:13:59PM +0300, Andrew Rybchenko wrote:
> >>>> On 4/30/21 5:48 PM, Ferruh Yigit wrote:
> >>>>> On 4/27/2021 2:57 PM, Olivier Matz wrote:
> >>>>>> When packet type is IPV4_EXT, the checksum is always marked as good in
> >>>>>> the mbuf offload flags.
> >>>>>>
> >>>>>> Since we know the header lengths, we can easily call
> >>>>>> rte_ipv4_udptcp_cksum() in this case too.
> >>>>>>
> >>>>>> Fixes: 8ae3023387e9 ("net/tap: add Rx/Tx checksum offload support")
> >>>>>> Cc: stable@dpdk.org
> >>>>>>
> >>>>>> Signed-off-by: Olivier Matz <olivier.matz@6wind.com>
> >>>>>> ---
> >>>>>>  drivers/net/tap/rte_eth_tap.c | 4 ++--
> >>>>>>  1 file changed, 2 insertions(+), 2 deletions(-)
> >>>>>>
> >>>>>> diff --git a/drivers/net/tap/rte_eth_tap.c b/drivers/net/tap/rte_eth_tap.c
> >>>>>> index 68baa18523..e7b185a4b5 100644
> >>>>>> --- a/drivers/net/tap/rte_eth_tap.c
> >>>>>> +++ b/drivers/net/tap/rte_eth_tap.c
> >>>>>> @@ -350,7 +350,7 @@ 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 || l3 == RTE_PTYPE_L3_IPV4_EXT) {
> >>>>>
> >>>>> Should we take 'RTE_PTYPE_L3_IPV4_EXT_UNKNOWN' into account?
> >>>>
> >>>> I think we should.
> >>>
> >>> I think 'RTE_PTYPE_L3_IPV4_EXT_UNKNOWN' cannot happen here:
> >>>
> >>> - mbuf->packet_type is generated by 
> >>
> >> (), which cannot
> >>>   return 'RTE_PTYPE_L3_IPV4_EXT_UNKNOWN'
> >>
> >> My question if it is guaranteed and the only possible branch.
> >> Can application set packet_type itself and do not call
> >> rte_net_get_ptype(). Yes, typically application knows
> >> if it has IPv4 options in the header or not, but theoretically
> >> could be unaware as well.
> > 
> > This function is called on the Rx path from pmd_rx_burst(), so
> > the application does not have access to the mbuf.
> > 
> > The software parser that sets the packet type returns either
> > RTE_PTYPE_L3_IPV4 if there is no option, or RTE_PTYPE_L3_IPV4_EXT
> > else. The value RTE_PTYPE_L3_IPV4_EXT_UNKNOWN is used by PMDs that don't
> > know if there are options.
> 
> I see. What I'm trying to say that there are non
> obvious assumptions here on rte_net_get_ptype()
> behaviour which can be changed. May be it makes
> sense to add comments here to highlight it.

Ok, I'll add some words about it.

Thanks!

> 
> > 
> >>> - right above this code, we already returned if l3 is not in
> >>>   (RTE_PTYPE_L3_IPV4, RTE_PTYPE_L3_IPV4_EXT, RTE_PTYPE_L3_IPV6)
> >>
> >> If so, it sounds like it should be allowed above as well.
> >>
> >>>
> >>>>>
> >>>>>>  			if (l4 == RTE_PTYPE_L4_UDP) {
> >>>>>>  				udp_hdr = (struct rte_udp_hdr *)l4_hdr;
> >>>>>>  				if (udp_hdr->dgram_cksum == 0) {
> >>>>>> @@ -364,7 +364,7 @@ tap_verify_csum(struct rte_mbuf *mbuf)
> >>>>>>  				}
> >>>>>>  			}
> >>>>>>  			cksum = ~rte_ipv4_udptcp_cksum(l3_hdr, l4_hdr);
> >>>>>> -		} else if (l3 == RTE_PTYPE_L3_IPV6) {
> >>>>>> +		} else { /* l3 == RTE_PTYPE_L3_IPV6, checked above */
> >>>>>>  			cksum = ~rte_ipv6_udptcp_cksum(l3_hdr, l4_hdr);
> >>>>>>  		}
> >>>>>>  		mbuf->ol_flags |= cksum ?
> >>>>>>
> >>>>
> >>
>