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 BA6BE44044; Fri, 17 May 2024 02:14:04 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 625BC4069F; Fri, 17 May 2024 02:13:28 +0200 (CEST) Received: from mail-pj1-f45.google.com (mail-pj1-f45.google.com [209.85.216.45]) by mails.dpdk.org (Postfix) with ESMTP id 0256940285 for ; Fri, 17 May 2024 02:13:18 +0200 (CEST) Received: by mail-pj1-f45.google.com with SMTP id 98e67ed59e1d1-2b5388087f9so632548a91.0 for ; Thu, 16 May 2024 17:13:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=networkplumber-org.20230601.gappssmtp.com; s=20230601; t=1715904797; x=1716509597; darn=dpdk.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=emfW8pqQWo/kkBypu+P+JiAY/UdpbCFtvVnSZa+FuiE=; b=PY0I4K52qLXrBxj5O0bYjldPARJkw1C0kagFuaXT2xsG/9Hdpih7WrdbC1YtkivGwH BW1PLc6GhJdN+mYuXru2MfLUoFow5/RGki0UbBrUgntfPBUI6ZN5UEGRD/G3wvmkvtNX JwI796toUg+gSDoZG3Y2BFBneI214rWhj79tof6Uexysk4RDDiQCwSK9cchPeiIH7ZV8 uNZyKSicjeoHjkWf9fNWeWcYm6LPfnoufmiKp4XtGcwsf4G4XBycWskN+EVXcqnYaiKv HwU2bncA4SSQpF82xRyYvlvr93hHk1IIWy8jaNy+LEjtgdd/oE0uMUqvcmDWOqYvsY/s zcmg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1715904797; x=1716509597; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=emfW8pqQWo/kkBypu+P+JiAY/UdpbCFtvVnSZa+FuiE=; b=lxQiknu0DZVKuT0bv/haD7wGz6zqdd3vibVOOtCOfPdsJyxtEPXe3aBXmfO/h+m04U mZDXGwYOuhsi5cuo+1PHMOlqScre2K9uUBxJ1aAXo/9EmyQgX8xtcvlVSDN5sYk4cJBv bftgIKom4VmoPN1/PeZDlgV55dGGmpZGA/qx0NxB6/p11r+jckVhCnQ892IH4YjIzo4r 6uAulOjLX5CsrdQsR5c6dO5yO/8QkrE/28WkBMImiZ1oBCd9EHxZJDX/aiPrx4Ua295q K2uH53bq18KhtCWcwg+udB3oefabqV9EkqPJ9AVsJN+rD1cOZXv0tNJcipVMnWYjRFm/ p9Sw== X-Gm-Message-State: AOJu0YxQmNLDLt6hhCtWYkrD9XDolPKWwmFswJprNoE5tUdOYfoT3HKx E+42+hstDfxqzBGmii4RApwlXdAhWmHKA6oJNw54cB/IOxnzHHaG9bWerrYo+jZIdT4XPjwMRKn oKy4= X-Google-Smtp-Source: AGHT+IFzZu7xurOSNjuzDQBBjSRK18nJ+hMRk5M6xl7v2dfdvXctfWrF80BTn//5qnXvT5/yO1WFhg== X-Received: by 2002:a17:90a:ce8f:b0:2b4:9e2d:3cab with SMTP id 98e67ed59e1d1-2b6cc76d230mr20756957a91.23.1715904797205; Thu, 16 May 2024 17:13:17 -0700 (PDT) Received: from hermes.local (204-195-96-226.wavecable.com. [204.195.96.226]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-2b9f5820ce9sm3337495a91.56.2024.05.16.17.13.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 16 May 2024 17:13:16 -0700 (PDT) From: Stephen Hemminger To: dev@dpdk.org Cc: Stephen Hemminger , Bruce Richardson Subject: [PATCH v6 6/9] test/pmd_ring: initialize mbufs Date: Thu, 16 May 2024 17:12:06 -0700 Message-ID: <20240517001302.65514-7-stephen@networkplumber.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240517001302.65514-1-stephen@networkplumber.org> References: <20240510050507.14381-1-stephen@networkplumber.org> <20240517001302.65514-1-stephen@networkplumber.org> 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 Do not pass uninitialized data into the ring PMD. The mbufs should be initialized first so that length is zero. Signed-off-by: Stephen Hemminger --- app/test/test_pmd_ring.c | 26 +++++++++++++++++++++----- 1 file changed, 21 insertions(+), 5 deletions(-) diff --git a/app/test/test_pmd_ring.c b/app/test/test_pmd_ring.c index e83b9dd6b8..55455ece7f 100644 --- a/app/test/test_pmd_ring.c +++ b/app/test/test_pmd_ring.c @@ -19,6 +19,14 @@ static struct rte_mempool *mp; struct rte_ring *rxtx[NUM_RINGS]; static int tx_porta, rx_portb, rxtx_portc, rxtx_portd, rxtx_porte; +/* make a valid zero sized mbuf */ +static void +test_mbuf_init(struct rte_mbuf *mbuf) +{ + memset(mbuf, 0, sizeof(*mbuf)); + rte_pktmbuf_reset(mbuf); +} + static int test_ethdev_configure_port(int port) { @@ -68,14 +76,16 @@ test_ethdev_configure_port(int port) static int test_send_basic_packets(void) { - struct rte_mbuf bufs[RING_SIZE]; + struct rte_mbuf bufs[RING_SIZE]; struct rte_mbuf *pbufs[RING_SIZE]; int i; printf("Testing send and receive RING_SIZE/2 packets (tx_porta -> rx_portb)\n"); - for (i = 0; i < RING_SIZE/2; i++) + for (i = 0; i < RING_SIZE / 2; i++) { + test_mbuf_init(&bufs[i]); pbufs[i] = &bufs[i]; + } if (rte_eth_tx_burst(tx_porta, 0, pbufs, RING_SIZE/2) < RING_SIZE/2) { printf("Failed to transmit packet burst port %d\n", tx_porta); @@ -99,14 +109,16 @@ test_send_basic_packets(void) static int test_send_basic_packets_port(int port) { - struct rte_mbuf bufs[RING_SIZE]; + struct rte_mbuf bufs[RING_SIZE]; struct rte_mbuf *pbufs[RING_SIZE]; int i; printf("Testing send and receive RING_SIZE/2 packets (cmdl_port0 -> cmdl_port0)\n"); - for (i = 0; i < RING_SIZE/2; i++) + for (i = 0; i < RING_SIZE / 2; i++) { + test_mbuf_init(&bufs[i]); pbufs[i] = &bufs[i]; + } if (rte_eth_tx_burst(port, 0, pbufs, RING_SIZE/2) < RING_SIZE/2) { printf("Failed to transmit packet burst port %d\n", port); @@ -134,10 +146,11 @@ test_get_stats(int port) struct rte_eth_stats stats; struct rte_mbuf buf, *pbuf = &buf; + test_mbuf_init(&buf); + printf("Testing ring PMD stats_get port %d\n", port); /* check stats of RXTX port, should all be zero */ - rte_eth_stats_get(port, &stats); if (stats.ipackets != 0 || stats.opackets != 0 || stats.ibytes != 0 || stats.obytes != 0 || @@ -173,6 +186,8 @@ test_stats_reset(int port) struct rte_eth_stats stats; struct rte_mbuf buf, *pbuf = &buf; + test_mbuf_init(&buf); + printf("Testing ring PMD stats_reset port %d\n", port); rte_eth_stats_reset(port); @@ -228,6 +243,7 @@ test_pmd_ring_pair_create_attach(void) int ret; memset(&null_conf, 0, sizeof(struct rte_eth_conf)); + test_mbuf_init(&buf); if ((rte_eth_dev_configure(rxtx_portd, 1, 1, &null_conf) < 0) || (rte_eth_dev_configure(rxtx_porte, 1, 1, -- 2.43.0