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 9CD22A0540; Mon, 13 Jul 2020 16:22:42 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 742431D72A; Mon, 13 Jul 2020 16:22:42 +0200 (CEST) Received: from dispatch1-us1.ppe-hosted.com (dispatch1-us1.ppe-hosted.com [148.163.129.52]) by dpdk.org (Postfix) with ESMTP id 1F8501D705 for ; Mon, 13 Jul 2020 16:22:41 +0200 (CEST) Received: from mx1-us1.ppe-hosted.com (unknown [10.7.65.62]) by dispatch1-us1.ppe-hosted.com (PPE Hosted ESMTP Server) with ESMTP id 9FEC5600DB; Mon, 13 Jul 2020 14:22:40 +0000 (UTC) Received: from us4-mdac16-55.ut7.mdlocal (unknown [10.7.66.26]) by mx1-us1.ppe-hosted.com (PPE Hosted ESMTP Server) with ESMTP id 9E2CF8009E; Mon, 13 Jul 2020 14:22:40 +0000 (UTC) X-Virus-Scanned: Proofpoint Essentials engine Received: from mx1-us1.ppe-hosted.com (unknown [10.7.66.36]) by mx1-us1.ppe-hosted.com (PPE Hosted ESMTP Server) with ESMTPS id 239AF280080; Mon, 13 Jul 2020 14:22:40 +0000 (UTC) Received: from webmail.solarflare.com (uk.solarflare.com [193.34.186.16]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-SHA384 (256/256 bits)) (No client certificate requested) by mx1-us1.ppe-hosted.com (PPE Hosted ESMTP Server) with ESMTPS id C875FB4009F; Mon, 13 Jul 2020 14:22:39 +0000 (UTC) Received: from ukex01.SolarFlarecom.com (10.17.10.4) by ukex01.SolarFlarecom.com (10.17.10.4) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Mon, 13 Jul 2020 15:22:36 +0100 Received: from opal.uk.solarflarecom.com (10.17.10.1) by ukex01.SolarFlarecom.com (10.17.10.4) with Microsoft SMTP Server id 15.0.1497.2 via Frontend Transport; Mon, 13 Jul 2020 15:22:35 +0100 Received: from ukv-loginhost.uk.solarflarecom.com (ukv-loginhost.uk.solarflarecom.com [10.17.10.39]) by opal.uk.solarflarecom.com (8.13.8/8.13.8) with ESMTP id 06DEMZvP026770; Mon, 13 Jul 2020 15:22:35 +0100 Received: from ukv-loginhost.uk.solarflarecom.com (localhost [127.0.0.1]) by ukv-loginhost.uk.solarflarecom.com (Postfix) with ESMTP id BA7771617DC; Mon, 13 Jul 2020 15:22:35 +0100 (BST) From: Andrew Rybchenko To: CC: Olivier Matz Date: Mon, 13 Jul 2020 15:22:34 +0100 Message-ID: <1594650154-31408-1-git-send-email-arybchenko@solarflare.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1590589976-2915-1-git-send-email-arybchenko@solarflare.com> References: <1590589976-2915-1-git-send-email-arybchenko@solarflare.com> MIME-Version: 1.0 Content-Type: text/plain X-TM-AS-Product-Ver: SMEX-12.5.0.1300-8.6.1012-25538.003 X-TM-AS-Result: No-1.082200-8.000000-10 X-TMASE-MatchedRID: kO/+U1LPROFv3B7lPyZaTNUcSZdVkdtzG0Oe0T+pTlEjRiu1AuxJTNxg kcY5rLtQFTBB/IBXpeEd8rHtoCQTOE6L74JlBxByuwdUMMznEA9fyi4Yas3gTd9zZd3pUn7Keb2 OGIQiIG50EKIyG8BOiRQUkzPX5sTWN9rojbjxBkyL6q5RsNhv5Etc8DbogbSElPH7Ysio2a2mIl j92kc9fBG0bHItOzCy6/iHVR2cMfDeToZBOAJHIYdlc1JaOB1TyoUTqBF1E5vs0TvBQBgkUaPFj JEFr+olwXCBO/GKkVqOhzOa6g8KrafRS87+CFLg0N4hyu/jsie7BM20ArOLdIhx9PHF949lBMSl vTxu4bMAo6X8qllCRSWoaT1Z9loEc+xGGnE8fvRkO2AFISDyL4XXmHr+iJs1sqxYnjga4QY83Fq 7f38GK0XAdmaT51YybiPTBhvbLhaUTGVAhB5EbQ== X-TM-AS-User-Approved-Sender: Yes X-TM-AS-User-Blocked-Sender: No X-TMASE-Result: 10--1.082200-8.000000 X-TMASE-Version: SMEX-12.5.0.1300-8.6.1012-25538.003 X-MDID: 1594650160-UTTPV_Ae9IAQ Subject: [dpdk-dev] [PATCH v2] 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" 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. Since commit dfc6b2fd8da3 ("mbuf: remove Intel offload checks from generic API") fragmented headers checks are done inside rte_net_intel_cksum_flags_prepare() in RTE_LIBRTE_ETHDEV_DEBUG build because it is moved from rte_validate_tx_offload() which is called under debug only. Make corresponding check to be done in non-debug build as well to avoid bad accesses, incorrect checksum calculation and to 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 Acked-by: Olivier Matz --- v2: - fix typo in description - mention dfc6b2fd8da3 in the description 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; -#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 if (ol_flags & PKT_TX_IPV4) { ipv4_hdr = rte_pktmbuf_mtod_offset(m, struct rte_ipv4_hdr *, -- 2.17.1