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 C8AC0A034E; Wed, 27 May 2020 16:33:12 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 4ADAA1DAA0; Wed, 27 May 2020 16:33:10 +0200 (CEST) Received: from dispatch1-us1.ppe-hosted.com (dispatch1-us1.ppe-hosted.com [67.231.154.164]) by dpdk.org (Postfix) with ESMTP id 2DC591DA97 for ; Wed, 27 May 2020 16:33:08 +0200 (CEST) Received: from mx1-us1.ppe-hosted.com (unknown [10.110.50.144]) by dispatch1-us1.ppe-hosted.com (PPE Hosted ESMTP Server) with ESMTP id 9CA17200D7; Wed, 27 May 2020 14:33:07 +0000 (UTC) Received: from us4-mdac16-68.at1.mdlocal (unknown [10.110.50.185]) by mx1-us1.ppe-hosted.com (PPE Hosted ESMTP Server) with ESMTP id 9BE23800A9; Wed, 27 May 2020 14:33:07 +0000 (UTC) X-Virus-Scanned: Proofpoint Essentials engine Received: from mx1-us1.ppe-hosted.com (unknown [10.110.49.107]) by mx1-us1.ppe-hosted.com (PPE Hosted ESMTP Server) with ESMTPS id 269634007A; Wed, 27 May 2020 14:33:07 +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 DB91628009B; Wed, 27 May 2020 14:33:06 +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; Wed, 27 May 2020 15:32:59 +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; Wed, 27 May 2020 15:32:59 +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 04REWxcP003099; Wed, 27 May 2020 15:32:59 +0100 Received: from ukv-loginhost.uk.solarflarecom.com (localhost [127.0.0.1]) by ukv-loginhost.uk.solarflarecom.com (Postfix) with ESMTP id 607DE16139D; Wed, 27 May 2020 15:32:59 +0100 (BST) From: Andrew Rybchenko To: Olivier Matz CC: Date: Wed, 27 May 2020 15:32:56 +0100 Message-ID: <1590589976-2915-1-git-send-email-arybchenko@solarflare.com> X-Mailer: git-send-email 1.8.3.1 MIME-Version: 1.0 Content-Type: text/plain X-TM-AS-Product-Ver: SMEX-12.5.0.1300-8.5.1020-25444.002 X-TM-AS-Result: No-0.433200-8.000000-10 X-TMASE-MatchedRID: W3Uy/33lI/lv3B7lPyZaTNUcSZdVkdtzG0Oe0T+pTlEjRiu1AuxJTAFj SbXUOo8BnIqnRXCrHEDGGaT2q8Ozu+kfPO9/GUD1skWRiD8RKtcEbATG004AD7jOUXWmQ3OWPo+ GPoN9kISt2gtuWr1Lmta2jLiNPKhQQnjvc9+azIPiNGQgiadfQ4LFgHaE9Li9RjHvrQ40NxaF8W WpfUgUVS3hWfSfReGaPIHPzepwWEkYB2fOueQzjxRFJJyf5BJe3QfwsVk0UbsIoUKaF27lxY59w 9uEj9dwgIuzoxouibcs6flz7HGvFLkiUvfyGnHTNrk2L2cEOA6peSaXDAuHdNyWepmzmTnpUXbf FcDsfPRW4hORKEjRJw9cvEd/Et5dVEc5IqztENReYfSkFq6uAb7jE6+wkCSenqg/VrSZEiM= X-TM-AS-User-Approved-Sender: Yes X-TM-AS-User-Blocked-Sender: No X-TMASE-Result: 10--0.433200-8.000000 X-TMASE-Version: SMEX-12.5.0.1300-8.5.1020-25444.002 X-MDID: 1590589987-Y5SuIvMBY8w4 Subject: [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" 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 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; -#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