From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id 41B9BA0540; Mon, 13 Jul 2020 15:35:37 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 9993C1D664; Mon, 13 Jul 2020 15:35:36 +0200 (CEST) Received: from mail-wm1-f68.google.com (mail-wm1-f68.google.com [209.85.128.68]) by dpdk.org (Postfix) with ESMTP id B52341D65F for ; Mon, 13 Jul 2020 15:35:34 +0200 (CEST) Received: by mail-wm1-f68.google.com with SMTP id l17so13353315wmj.0 for ; Mon, 13 Jul 2020 06:35:34 -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:user-agent; bh=X9aoYgqaI56+kM6eqZPfZjYvFBaeZYuaWL7q6KVTEwg=; b=YKIoWKTtT4UjhpaRTTMcnPPyIOegc2jRgI182eEFdAABUXNns6VSSoCBXlhQqY0QC8 n3l4FkWTEfJeRvth5L3g21TPsxUhmHGhyZZXU2Wk9F6jW9IFay9BiVToT8eEkC3qY7nB /RDpIsFx1zYfcg8jRH46fMWNG90OcUyzC0EO/Ug4jQUj7lLUFttsv2uxozBaWZgIq1Wq OhGbaZBkJE5hszeMTXwuh0H6O0HnNH2hJdJCGDIkqIEPml4G8HuSM2tBKAeK6bMQz3OV 9DVssKEnsHraadmJKy4We07XpwAs+U/Yien9xpwULLG9PDMVxVzvrKAHDOqaTWjWh+VV xBzw== 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:user-agent; bh=X9aoYgqaI56+kM6eqZPfZjYvFBaeZYuaWL7q6KVTEwg=; b=ta2mMsN6SMEoZWdHCrVXSNNCm1vAlgwJD8NtRZStW1cjUwpKhB0AkgBCJvAe7Y2pVE nbZMYvaWcvPbQ4uFrbTKLtxKv8UTkpRjlks2DWZEXlZ4NeZTn8gm9jcX0NAQk/X0JBej rIjh5UV/w79l2LVml1U8n+7EqUAWAS7QozZ4U35UVRcC+OMUtIf9WNnnjYLwAn+vqTis r6j4jy4OmPTGArp62hzoKcKtopHMe+eh6mJTzJdIQZrAtGO7K1OqQdtWVqfm+r7J2iWW Ne9zjynOSKbvdKvqbfbKQJi6GDvHcUmT6vKXNBhS3hfRWDdJR/T9X56H8Egv/sNoR8Ct uB+Q== X-Gm-Message-State: AOAM533tnbXmIhg340iYobhNYZ03SzwetU1sK/EoHDijrqd6K/h5LdqY 7TfWAZMXjknbrUcBspMxfHomLQ== X-Google-Smtp-Source: ABdhPJwqpplIpn+Q9onU9x/6XxtBEWUlQmfkYEbgEcJN6k/4DMrV3MLTZJx2UoR4YEdqoXw5GLsWsw== X-Received: by 2002:a7b:cf16:: with SMTP id l22mr47516wmg.68.1594647334285; Mon, 13 Jul 2020 06:35:34 -0700 (PDT) Received: from 6wind.com (2a01cb0c0005a600345636f7e65ed1a0.ipv6.abo.wanadoo.fr. [2a01:cb0c:5:a600:3456:36f7:e65e:d1a0]) by smtp.gmail.com with ESMTPSA id d81sm47775wmc.0.2020.07.13.06.35.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 13 Jul 2020 06:35:33 -0700 (PDT) Date: Mon, 13 Jul 2020 15:35:32 +0200 From: Olivier Matz To: Andrew Rybchenko Cc: dev@dpdk.org Message-ID: <20200713133532.GO5869@platinum> References: <1590589976-2915-1-git-send-email-arybchenko@solarflare.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1590589976-2915-1-git-send-email-arybchenko@solarflare.com> User-Agent: Mutt/1.10.1 (2018-07-13) Subject: Re: [dpdk-dev] [PATCH] net: do fragmented headers check in non-debug build as well X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" Hi Andrew, On Wed, May 27, 2020 at 03:32:56PM +0100, Andrew Rybchenko wrote: > Pseudo-header checksum calculation requires contiguous headers. > There is no any formal requirements on data location and mbuf > structure which could be used by the application. > > Make corresponding check to be done in non-debug build as well > to avoid bad accesses, incorrect checksum caclculation and to typo: caclculation -> calculation > return appropriate error from Tx prepare. > > Make no-offloads check more precise and do it in non-debug build > as well to avoid contiguous headers check and Tx prepare failure > if it is not actually required. > > Signed-off-by: Andrew Rybchenko > --- > lib/librte_net/rte_net.h | 6 +----- > 1 file changed, 1 insertion(+), 5 deletions(-) > > diff --git a/lib/librte_net/rte_net.h b/lib/librte_net/rte_net.h > index 1560ecfa46..1edc283a47 100644 > --- a/lib/librte_net/rte_net.h > +++ b/lib/librte_net/rte_net.h > @@ -120,20 +120,17 @@ rte_net_intel_cksum_flags_prepare(struct rte_mbuf *m, uint64_t ol_flags) > struct rte_udp_hdr *udp_hdr; > uint64_t inner_l3_offset = m->l2_len; > > -#ifdef RTE_LIBRTE_ETHDEV_DEBUG > /* > * Does packet set any of available offloads? > * Mainly it is required to avoid fragmented headers check if > * no offloads are requested. > */ > - if (!(ol_flags & PKT_TX_OFFLOAD_MASK)) > + if (!(ol_flags & (PKT_TX_IP_CKSUM | PKT_TX_L4_MASK))) > return 0; Agree, the packet is modified only if one of these flag is set. > -#endif > > if (ol_flags & (PKT_TX_OUTER_IPV4 | PKT_TX_OUTER_IPV6)) > inner_l3_offset += m->outer_l2_len + m->outer_l3_len; > > -#ifdef RTE_LIBRTE_ETHDEV_DEBUG > /* > * Check if headers are fragmented. > * The check could be less strict depending on which offloads are > @@ -142,7 +139,6 @@ rte_net_intel_cksum_flags_prepare(struct rte_mbuf *m, uint64_t ol_flags) > if (unlikely(rte_pktmbuf_data_len(m) < > inner_l3_offset + m->l3_len + m->l4_len)) > return -ENOTSUP; > -#endif Yes, despite the documentation of thus function says that used headers should be in the first data segment of the mbuf, when it is used through the ethdev tx_prepare() API there is no such requirement. So yes, it looks safer to do these checks even if debug is off. They will only be done when doing tx offload, so I guess it is ok in terms of performance. Maybe it is worth mentioning commit dfc6b2fd8da3 ("mbuf: remove Intel offload checks from generic API") in the commit log? > > if (ol_flags & PKT_TX_IPV4) { > ipv4_hdr = rte_pktmbuf_mtod_offset(m, struct rte_ipv4_hdr *, > -- > 2.17.1 > Acked-by: Olivier Matz