From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga18.intel.com (mga18.intel.com [134.134.136.126]) by dpdk.org (Postfix) with ESMTP id D57E3235 for ; Fri, 27 Jul 2018 06:49:32 +0200 (CEST) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga007.jf.intel.com ([10.7.209.58]) by orsmga106.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 26 Jul 2018 21:49:29 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.51,407,1526367600"; d="scan'208";a="59884202" Received: from wuyanglong.sh.intel.com ([10.67.111.89]) by orsmga007.jf.intel.com with ESMTP; 26 Jul 2018 21:49:28 -0700 From: Yanglong Wu To: dev@dpdk.org Cc: qi.z.zhang@intel.com, konstantin.ananyev@intel.com, lei.a.yao@intel.com, Yanglong Wu Date: Fri, 27 Jul 2018 12:40:00 +0800 Message-Id: <20180727044000.64068-1-yanglong.wu@intel.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20180726064602.157850-1-yanglong.wu@intel.com> References: <20180726064602.157850-1-yanglong.wu@intel.com> Subject: [dpdk-dev] [PATCH v2] net/i40e: fix max frame size 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: , X-List-Received-Date: Fri, 27 Jul 2018 04:49:34 -0000 Check patcket size according to TSO or no-TSO. Fixes: bfeed0262b0c ("net/i40e: check illegal packets") Signed-off-by: Yanglong Wu --- v2: change as comments. --- drivers/net/i40e/i40e_ethdev.h | 1 + drivers/net/i40e/i40e_rxtx.c | 9 +++++---- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/drivers/net/i40e/i40e_ethdev.h b/drivers/net/i40e/i40e_ethdev.h index cb5e5b5d8..3fffe5a55 100644 --- a/drivers/net/i40e/i40e_ethdev.h +++ b/drivers/net/i40e/i40e_ethdev.h @@ -28,6 +28,7 @@ #define I40E_NUM_DESC_ALIGN 32 #define I40E_BUF_SIZE_MIN 1024 #define I40E_FRAME_SIZE_MAX 9728 +#define I40E_TSO_FRAME_SIZE_MAX 262144 #define I40E_QUEUE_BASE_ADDR_UNIT 128 /* number of VSIs and queue default setting */ #define I40E_MAX_QP_NUM_PER_VF 16 diff --git a/drivers/net/i40e/i40e_rxtx.c b/drivers/net/i40e/i40e_rxtx.c index 3be87fe6a..1bbc0340b 100644 --- a/drivers/net/i40e/i40e_rxtx.c +++ b/drivers/net/i40e/i40e_rxtx.c @@ -1439,13 +1439,15 @@ i40e_prep_pkts(__rte_unused void *tx_queue, struct rte_mbuf **tx_pkts, /* Check for m->nb_segs to not exceed the limits. */ if (!(ol_flags & PKT_TX_TCP_SEG)) { - if (m->nb_segs > I40E_TX_MAX_MTU_SEG) { + if (m->nb_segs > I40E_TX_MAX_MTU_SEG || + m->pkt_len > I40E_FRAME_SIZE_MAX) { rte_errno = -EINVAL; return i; } } else if (m->nb_segs > I40E_TX_MAX_SEG || m->tso_segsz < I40E_MIN_TSO_MSS || - m->tso_segsz > I40E_MAX_TSO_MSS) { + m->tso_segsz > I40E_MAX_TSO_MSS || + m->pkt_len > I40E_TSO_FRAME_SIZE_MAX) { /* MSS outside the range (256B - 9674B) are considered * malicious */ @@ -1459,8 +1461,7 @@ i40e_prep_pkts(__rte_unused void *tx_queue, struct rte_mbuf **tx_pkts, } /* check the size of packet */ - if (m->pkt_len > I40E_FRAME_SIZE_MAX || - m->pkt_len < I40E_TX_MIN_PKT_LEN) { + if (m->pkt_len < I40E_TX_MIN_PKT_LEN) { rte_errno = -EINVAL; return i; } -- 2.11.0