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 602BAA034F; Tue, 1 Mar 2022 08:29:22 +0100 (CET) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id D47EF411EB; Tue, 1 Mar 2022 08:29:21 +0100 (CET) Received: from mga09.intel.com (mga09.intel.com [134.134.136.24]) by mails.dpdk.org (Postfix) with ESMTP id D13B6407FF; Tue, 1 Mar 2022 08:29:20 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1646119761; x=1677655761; h=from:to:cc:subject:date:message-id:mime-version: content-transfer-encoding; bh=7YuL0NKtyA9kU2C3j1iEEXW3bS+4q6QJ0Avwjc8Inm4=; b=Majy0ruj/8dwDFvmlzA03TSj2/M6bMjx/wJ7em5ErKFK4eo4wkBSa2cb /4QWnyXSuDEMIljX1iYUUGdGlisBT3a3shYGps5nRiiR2sYAsvBIIvaUm T41uxsEE/yAdmbqetCdwNX2/jx5iTqhiyd3QndSCdnoVgKCoeskkH77TT /guvjrAutbmZvkSqoWW0V+R2FD5AzMQPDM1hW3imQ0V/GJVKLIQL75apd cNmUENPCq1uerbwue/tgaszCwZP/tXtcUzN80lotmUZVxIRWiQe/QCHlI GytNrG4Sg5pV+UEhSow7G53yx6Mczf/0+kuDjT1jRcgOKqRBQKUonJFhJ Q==; X-IronPort-AV: E=McAfee;i="6200,9189,10272"; a="252809656" X-IronPort-AV: E=Sophos;i="5.90,145,1643702400"; d="scan'208";a="252809656" Received: from orsmga007.jf.intel.com ([10.7.209.58]) by orsmga102.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 28 Feb 2022 23:29:19 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.90,145,1643702400"; d="scan'208";a="534788342" Received: from dpdk-yuyingzh-icelake.sh.intel.com ([10.67.116.254]) by orsmga007.jf.intel.com with ESMTP; 28 Feb 2022 23:29:18 -0800 From: Yuying Zhang To: dev@dpdk.org, maxime.coquelin@redhat.com, chenbo.xia@intel.com Cc: Yuying Zhang , stable@dpdk.org Subject: [PATCH v1] net/vhost: clear data of packet mbuf after sending pkts Date: Tue, 1 Mar 2022 07:28:02 +0000 Message-Id: <20220301072802.1349736-1-yuying.zhang@intel.com> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org The PMD frees a packet mbuf back into its original mempool after sending a packet. However, old data is not cleaned up which causes error in payload of new packets. This patch clear data of packet mbuf before freeing mbuf. Fixes: ee584e9710b9 ("vhost: add driver on top of the library") Cc: stable@dpdk.org Signed-off-by: Yuying Zhang --- drivers/net/vhost/rte_eth_vhost.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/drivers/net/vhost/rte_eth_vhost.c b/drivers/net/vhost/rte_eth_vhost.c index 070f0e6dfd..92ed07a334 100644 --- a/drivers/net/vhost/rte_eth_vhost.c +++ b/drivers/net/vhost/rte_eth_vhost.c @@ -417,10 +417,11 @@ static uint16_t eth_vhost_tx(void *q, struct rte_mbuf **bufs, uint16_t nb_bufs) { struct vhost_queue *r = q; - uint16_t i, nb_tx = 0; + uint16_t i, j, nb_tx = 0; uint16_t nb_send = 0; uint64_t nb_bytes = 0; uint64_t nb_missed = 0; + void *data = NULL; if (unlikely(rte_atomic32_read(&r->allow_queuing) == 0)) return 0; @@ -483,8 +484,13 @@ eth_vhost_tx(void *q, struct rte_mbuf **bufs, uint16_t nb_bufs) for (i = nb_tx; i < nb_bufs; i++) vhost_count_xcast_packets(r, bufs[i]); - for (i = 0; likely(i < nb_tx); i++) + for (i = 0; likely(i < nb_tx); i++) { + for (j = 0; j < bufs[i]->nb_segs; j++) { + data = rte_pktmbuf_mtod(bufs[i], void *); + memset(data, 0, bufs[i]->data_len); + } rte_pktmbuf_free(bufs[i]); + } out: rte_atomic32_set(&r->while_queuing, 0); -- 2.25.1