From patchwork Fri Feb 14 07:19:45 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Xiao Zhang X-Patchwork-Id: 65811 X-Patchwork-Delegate: xiaolong.ye@intel.com Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id F417FA0546; Fri, 14 Feb 2020 08:26:40 +0100 (CET) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id C90221BDAE; Fri, 14 Feb 2020 08:26:39 +0100 (CET) Received: from mga14.intel.com (mga14.intel.com [192.55.52.115]) by dpdk.org (Postfix) with ESMTP id 030391BC25; Fri, 14 Feb 2020 08:26:37 +0100 (CET) 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; 13 Feb 2020 23:26:37 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.70,439,1574150400"; d="scan'208";a="228398146" Received: from npg-dpdk-zhangxiao.sh.intel.com ([10.67.110.218]) by fmsmga008.fm.intel.com with ESMTP; 13 Feb 2020 23:26:36 -0800 From: Xiao Zhang To: dev@dpdk.org Cc: wenzhuo.lu@intel.com, konstantin.ananyev@intel.com, Xiao Zhang , stable@dpdk.org Date: Fri, 14 Feb 2020 15:19:45 +0800 Message-Id: <1581664785-67507-1-git-send-email-xiao.zhang@intel.com> X-Mailer: git-send-email 2.7.4 Subject: [dpdk-dev] net/ixgbe: check illegal packets 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 hang. This patch checks those illegal packets and protects TX from hanging. Fixes: 7829b8d52be0 ("net/ixgbe: add Tx preparation") Cc: stable@dpdk.org Signed-off-by: Xiao Zhang --- drivers/net/ixgbe/ixgbe_rxtx.c | 6 ++++++ drivers/net/ixgbe/ixgbe_rxtx.h | 2 ++ 2 files changed, 8 insertions(+) diff --git a/drivers/net/ixgbe/ixgbe_rxtx.c b/drivers/net/ixgbe/ixgbe_rxtx.c index 7b398f1..f839bca 100644 --- a/drivers/net/ixgbe/ixgbe_rxtx.c +++ b/drivers/net/ixgbe/ixgbe_rxtx.c @@ -986,6 +986,12 @@ ixgbe_prep_pkts(void *tx_queue, struct rte_mbuf **tx_pkts, uint16_t nb_pkts) return i; } + /* check the size of packet */ + if (m->pkt_len < IXGBE_TX_MIN_PKT_LEN) { + rte_errno = EINVAL; + return i; + } + #ifdef RTE_LIBRTE_ETHDEV_DEBUG ret = rte_validate_tx_offload(m); if (ret != 0) { diff --git a/drivers/net/ixgbe/ixgbe_rxtx.h b/drivers/net/ixgbe/ixgbe_rxtx.h index 000c5b1..31dbdfc 100644 --- a/drivers/net/ixgbe/ixgbe_rxtx.h +++ b/drivers/net/ixgbe/ixgbe_rxtx.h @@ -53,6 +53,8 @@ #define IXGBE_TX_MAX_SEG 40 +#define IXGBE_TX_MIN_PKT_LEN 17 + #define IXGBE_PACKET_TYPE_MASK_82599 0X7F #define IXGBE_PACKET_TYPE_MASK_X550 0X10FF #define IXGBE_PACKET_TYPE_MASK_TUNNEL 0XFF