From patchwork Tue Apr 2 09:28:41 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Rybchenko X-Patchwork-Id: 52082 X-Patchwork-Delegate: ferruh.yigit@amd.com Return-Path: X-Original-To: patchwork@dpdk.org Delivered-To: patchwork@dpdk.org Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id E889958C4; Tue, 2 Apr 2019 11:29:15 +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 0D1FC5A for ; Tue, 2 Apr 2019 11:29:00 +0200 (CEST) X-Virus-Scanned: Proofpoint Essentials engine Received: from webmail.solarflare.com (webmail.solarflare.com [12.187.104.26]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-SHA384 (256/256 bits)) (No client certificate requested) by mx1-us1.ppe-hosted.com (Proofpoint Essentials ESMTP Server) with ESMTPS id BEFB810008E; Tue, 2 Apr 2019 09:28:58 +0000 (UTC) Received: from ocex03.SolarFlarecom.com (10.20.40.36) by ocex03.SolarFlarecom.com (10.20.40.36) with Microsoft SMTP Server (TLS) id 15.0.1395.4; Tue, 2 Apr 2019 02:28:55 -0700 Received: from opal.uk.solarflarecom.com (10.17.10.1) by ocex03.SolarFlarecom.com (10.20.40.36) with Microsoft SMTP Server (TLS) id 15.0.1395.4 via Frontend Transport; Tue, 2 Apr 2019 02:28:55 -0700 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 x329SssK028275; Tue, 2 Apr 2019 10:28:54 +0100 Received: from ukv-loginhost.uk.solarflarecom.com (localhost [127.0.0.1]) by ukv-loginhost.uk.solarflarecom.com (Postfix) with ESMTP id F2EA3161610; Tue, 2 Apr 2019 10:28:53 +0100 (BST) From: Andrew Rybchenko To: CC: Igor Romanov Date: Tue, 2 Apr 2019 10:28:41 +0100 Message-ID: <1554197324-32391-10-git-send-email-arybchenko@solarflare.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1554197324-32391-1-git-send-email-arybchenko@solarflare.com> References: <1554197324-32391-1-git-send-email-arybchenko@solarflare.com> MIME-Version: 1.0 X-TM-AS-Product-Ver: SMEX-12.5.0.1300-8.5.1010-24526.005 X-TM-AS-Result: No-1.716900-4.000000-10 X-TMASE-MatchedRID: HvGoI+Dr3CX+MzVaeoq/RQwfhKwa9GwDKx5ICGp/WtHJBgQYFTMaLYcy Ea0magMiRHLRFcKKZXfbCHv011Gy9WA2IAXETeuKzGZPOh8RY45n+sA9+u1YLUjOHl23BrYWGwF k9khvYZ2WdOnmuZ5t7wTlbNtY2Qg0Nyl1nd9CIt0URSScn+QSXt0H8LFZNFG7CKFCmhdu5cUGmY cR2dt5xfObjDrdFi4ndoFrH4AtRCDbm8MK6jYvZYpBbtTS/Yc/zBdsH+aMnyaE0MGbfO0iYoeZl Be5U2OoMqfDlsOKP1APXLxHfxLeXVRHOSKs7RDUXmH0pBaurgG+4xOvsJAknp6oP1a0mRIj X-TM-AS-User-Approved-Sender: No X-TM-AS-User-Blocked-Sender: No X-TMASE-Result: 10--1.716900-4.000000 X-TMASE-Version: SMEX-12.5.0.1300-8.5.1010-24526.005 X-MDID: 1554197339-Iow6duJ2z47z Subject: [dpdk-dev] [PATCH 09/12] net/sfc: add TSO header length check to Tx prepare 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" From: Igor Romanov Make Tx prepare function able to detect packets with invalid header size when header linearization is required. Signed-off-by: Igor Romanov Signed-off-by: Andrew Rybchenko --- drivers/net/sfc/sfc_dp_tx.h | 11 ++++++++++- drivers/net/sfc/sfc_ef10_tx.c | 2 ++ drivers/net/sfc/sfc_tso.c | 2 ++ 3 files changed, 14 insertions(+), 1 deletion(-) diff --git a/drivers/net/sfc/sfc_dp_tx.h b/drivers/net/sfc/sfc_dp_tx.h index ebc941857..ae5524f24 100644 --- a/drivers/net/sfc/sfc_dp_tx.h +++ b/drivers/net/sfc/sfc_dp_tx.h @@ -14,6 +14,7 @@ #include "sfc_dp.h" #include "sfc_debug.h" +#include "sfc_tso.h" #ifdef __cplusplus extern "C" { @@ -230,8 +231,16 @@ sfc_dp_tx_prepare_pkt(struct rte_mbuf *m, * Extra descriptor that is required when a packet header * is separated from remaining content of the first segment. */ - if (rte_pktmbuf_data_len(m) > header_len) + if (rte_pktmbuf_data_len(m) > header_len) { descs_required++; + } else if (rte_pktmbuf_data_len(m) < header_len && + unlikely(header_len > SFC_TSOH_STD_LEN)) { + /* + * Header linearization is required and + * the header is too big to be linearized + */ + return EINVAL; + } } /* diff --git a/drivers/net/sfc/sfc_ef10_tx.c b/drivers/net/sfc/sfc_ef10_tx.c index e7ab993dd..959408449 100644 --- a/drivers/net/sfc/sfc_ef10_tx.c +++ b/drivers/net/sfc/sfc_ef10_tx.c @@ -447,6 +447,8 @@ sfc_ef10_xmit_tso_pkt(struct sfc_ef10_txq * const txq, struct rte_mbuf *m_seg, /* * Discard a packet if header linearization is needed but * the header is too big. + * Duplicate Tx prepare check here to avoid spoil of + * memory if Tx prepare is skipped. */ if (unlikely(header_len > SFC_TSOH_STD_LEN)) return EMSGSIZE; diff --git a/drivers/net/sfc/sfc_tso.c b/drivers/net/sfc/sfc_tso.c index f46c0e912..a882e64dd 100644 --- a/drivers/net/sfc/sfc_tso.c +++ b/drivers/net/sfc/sfc_tso.c @@ -119,6 +119,8 @@ sfc_efx_tso_do(struct sfc_efx_txq *txq, unsigned int idx, /* * Discard a packet if header linearization is needed but * the header is too big. + * Duplicate Tx prepare check here to avoid spoil of + * memory if Tx prepare is skipped. */ if (unlikely(header_len > SFC_TSOH_STD_LEN)) return EMSGSIZE;