From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 62FF0A0543 for ; Fri, 11 Nov 2022 09:25:52 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 5E6C142D0D; Fri, 11 Nov 2022 09:25:52 +0100 (CET) Received: from mga04.intel.com (mga04.intel.com [192.55.52.120]) by mails.dpdk.org (Postfix) with ESMTP id 419B3427F2; Fri, 11 Nov 2022 09:25:49 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1668155149; x=1699691149; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=KoMUevh09EYNFVygp5OHvZjp7pW6XaCaAOPByHG1kVg=; b=dkLPJbmMJXuDWnwXyDnCee0S74oShJWc+KVB3vEafz/coqbC62APejiJ fzs6yvM+wyQSKfx3SVFrBza+TslRavkoVIXFNBfEa0PUcVujtObjDD7bf 1vJd6nmw2POi06gjxfJUSXMXxGb/S7zh6xG3gRD1ztEUO1tRxO36VarQx ukJ0tmwQAdUS3JlJy/xt+dWqht5F6BWKXIA9w7NFPUKoTb6Xb3m20Jw0T eKqv4pMp8EYuFOUJKFosJR90I6QhFOIJsbUp1xPZ2Xzsx/I+ieN4l27Ch mCeU90ourNksXz40lgOmSPJSLc3VlSxle7vf48HozMKS4/wDWKw/FicJ0 Q==; X-IronPort-AV: E=McAfee;i="6500,9779,10527"; a="310267900" X-IronPort-AV: E=Sophos;i="5.96,156,1665471600"; d="scan'208";a="310267900" Received: from fmsmga008.fm.intel.com ([10.253.24.58]) by fmsmga104.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 11 Nov 2022 00:25:48 -0800 X-IronPort-AV: E=McAfee;i="6500,9779,10527"; a="701143908" X-IronPort-AV: E=Sophos;i="5.96,156,1665471600"; d="scan'208";a="701143908" Received: from unknown (HELO yemj..) ([10.239.252.253]) by fmsmga008-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 11 Nov 2022 00:25:46 -0800 From: Mingjin Ye To: dev@dpdk.org Cc: qiming.yang@intel.com, stable@dpdk.org, yidingx.zhou@intel.com, Mingjin Ye , Qi Zhang , Jingjing Wu , Ferruh Yigit , Wenzhuo Lu , Kevin Liu Subject: [PATCH v4 2/2] net/ice: fix scalar Tx path segment Date: Fri, 11 Nov 2022 16:12:41 +0000 Message-Id: <20221111161241.861732-2-mingjinx.ye@intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20221111161241.861732-1-mingjinx.ye@intel.com> References: <20221111120401.802805-2-mingjinx.ye@intel.com> <20221111161241.861732-1-mingjinx.ye@intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-BeenThere: stable@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: patches for DPDK stable branches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: stable-bounces@dpdk.org The scalar Tx path would send empty buffer that causes the Tx queue to overflow. This patch adds the last buffer length judgment in tx_prepare to fix this issue, rte_errno will be set to EINVAL and returned if the last buffer is empty. Fixes: 17c7d0f9d6a4 ("net/ice: support basic Rx/Tx") Fixes: ccf33dccf7aa ("net/ice: check illegal packet sizes") Cc: stable@dpdk.org Signed-off-by: Mingjin Ye v3: * delete unused variable. * Full detection of mbufs. --- drivers/net/ice/ice_rxtx.c | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/drivers/net/ice/ice_rxtx.c b/drivers/net/ice/ice_rxtx.c index e6ddd2513d..9017353943 100644 --- a/drivers/net/ice/ice_rxtx.c +++ b/drivers/net/ice/ice_rxtx.c @@ -3643,6 +3643,22 @@ ice_set_tx_function_flag(struct rte_eth_dev *dev, struct ice_tx_queue *txq) #define ICE_MIN_TSO_MSS 64 #define ICE_MAX_TSO_MSS 9728 #define ICE_MAX_TSO_FRAME_SIZE 262144 + +/*Check for empty mbuf*/ +static inline uint16_t +ice_check_empty_mbuf(struct rte_mbuf *tx_pkt) +{ + struct rte_mbuf *txd = tx_pkt; + + while (txd != NULL) { + if (txd->data_len == 0) + return -1; + txd = txd->next; + } + + return 0; +} + uint16_t ice_prep_pkts(__rte_unused void *tx_queue, struct rte_mbuf **tx_pkts, uint16_t nb_pkts) @@ -3689,6 +3705,12 @@ ice_prep_pkts(__rte_unused void *tx_queue, struct rte_mbuf **tx_pkts, rte_errno = -ret; return i; } + + if (ice_check_empty_mbuf(m) != 0) { + rte_errno = EINVAL; + PMD_DRV_LOG(ERR, "INVALID mbuf: last mbuf data_len=[0]"); + return i; + } } return i; } -- 2.34.1