From patchwork Thu Jun 7 09:39:38 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yanglong Wu X-Patchwork-Id: 40740 X-Patchwork-Delegate: qi.z.zhang@intel.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 3B0ED1B1A6; Thu, 7 Jun 2018 11:47:25 +0200 (CEST) Received: from mga14.intel.com (mga14.intel.com [192.55.52.115]) by dpdk.org (Postfix) with ESMTP id 385B81B167 for ; Thu, 7 Jun 2018 11:47:23 +0200 (CEST) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga008.fm.intel.com ([10.253.24.58]) by fmsmga103.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 07 Jun 2018 02:47:22 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.49,486,1520924400"; d="scan'208";a="45964552" Received: from wuyanglong.sh.intel.com ([10.67.111.123]) by fmsmga008.fm.intel.com with ESMTP; 07 Jun 2018 02:47:20 -0700 From: Yanglong Wu To: dev@dpdk.org Cc: qi.z.zhang@intel.com, konstantin.ananyev@intel.com, Yanglong Wu Date: Thu, 7 Jun 2018 17:39:38 +0800 Message-Id: <20180607093938.62579-1-yanglong.wu@intel.com> X-Mailer: git-send-email 2.11.0 Subject: [dpdk-dev] [PATCH] net/i40e: illagel pactket checking 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" Some illegal packets will lead to TX/RX hang and can't recover automatically. This pacth check those illegal packets and protect TX/RX from hanging. Signed-off-by: Yanglong Wu --- drivers/net/i40e/i40e_rxtx.c | 10 ++++++++++ drivers/net/i40e/i40e_rxtx.h | 2 ++ 2 files changed, 12 insertions(+) diff --git a/drivers/net/i40e/i40e_rxtx.c b/drivers/net/i40e/i40e_rxtx.c index 6032d5541..be00b898e 100644 --- a/drivers/net/i40e/i40e_rxtx.c +++ b/drivers/net/i40e/i40e_rxtx.c @@ -1458,6 +1458,16 @@ i40e_prep_pkts(__rte_unused void *tx_queue, struct rte_mbuf **tx_pkts, return i; } + /*check the size of pkt len*/ + if (m->pkt_len > ETHER_MAX_LEN || m->pkt_len < I40E_TX_MIN_PKT_LEN){ + rte_errno = -EINVAL; + return i;} + + /*check the number of mbuf segments*/ + if(m->nb_segs > I40E_TX_MAX_MTU_SEG){ + rte_errno = -EINVAL; + return i;} + #ifdef RTE_LIBRTE_ETHDEV_DEBUG ret = rte_validate_tx_offload(m); if (ret != 0) { diff --git a/drivers/net/i40e/i40e_rxtx.h b/drivers/net/i40e/i40e_rxtx.h index ea73a8a1b..3fc619af9 100644 --- a/drivers/net/i40e/i40e_rxtx.h +++ b/drivers/net/i40e/i40e_rxtx.h @@ -30,6 +30,8 @@ #define I40E_TX_MAX_SEG UINT8_MAX #define I40E_TX_MAX_MTU_SEG 8 +#define I40E_TX_MIN_PKT_LEN 17 + #undef container_of #define container_of(ptr, type, member) ({ \ typeof(((type *)0)->member)(*__mptr) = (ptr); \