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 A4B9E44052; Fri, 17 May 2024 19:41:31 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 075F74069F; Fri, 17 May 2024 19:40:58 +0200 (CEST) Received: from mail-pl1-f173.google.com (mail-pl1-f173.google.com [209.85.214.173]) by mails.dpdk.org (Postfix) with ESMTP id 11E5740689 for ; Fri, 17 May 2024 19:40:53 +0200 (CEST) Received: by mail-pl1-f173.google.com with SMTP id d9443c01a7336-1ec41d82b8bso19064605ad.2 for ; Fri, 17 May 2024 10:40:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=networkplumber-org.20230601.gappssmtp.com; s=20230601; t=1715967652; x=1716572452; 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=jsAf8g5s7eKgn/8mR5FUy6CUUz+y4fV0gRYZmusX1bm9twicnVchk4zqeqA6TFFaK+ 8pKb9cLZysB7sfzUCCSvuMVcWqCb2mli6zjllFxHryoHJSGjlQIqlDHxVvvpXDfjNMx+ dKBh9uwnVtFvOKsdLMTH4xUeeY/HlOb7Bt0JWeTTIXL5IK402MFATvY5JH3zz6OgeCV+ bc5Ks3+BZBcjLyH8d4Dchou0oJ90s7soYkjXWoUmL43Z60jfryjsr6arCxI5ZovbT13e 0iqPUoz9igQ9s18JMJqEvCaVpvoApSfxvxESuYh2RFsADSywGk+Wea0uhjQfTVa4PqOX kHIA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1715967652; x=1716572452; 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=fKvSFbEYfmuZl1TY62sWsF084gM2C/bsTPDP/uqYfIcDoqiP1vqK+x/+nwDhvmuIVa Bi2lwH0RRH7YrQwsSd/KC+2rZK2FdqbbO3hawkveuDJo/S0kI1LsgKUG9NKyS8q6WMBI TjeCHz6+7yPEc5lnErPEYqoBv6T5UGnXOuBkoqn+o8DIsontTWpid4OTLhKUdz+45zp9 3ZUbVGyRKWVOmGCt4GWM9xL7ZtugG48LbSnEageFqbFkv3/WNN7BjITkwUXB8pck9nQT EE7q5arsW166cmbMwYPbJXFJh+Ugt2gvMuc2XxsA6Bd5N9uQYeRfrqPLiOwNSfal0rJq f2+A== X-Gm-Message-State: AOJu0YzGV3Yq7gDqRn9KRTx3LP57y4hM4BSBiuY1oIPNeqa2wBfiGJN6 MtNgtKf/ofTtcHtLlB7DZClATKmdSN92RSrDpkcEfqiXJ1ME3hMMxUjyc8b3+37FrHXgewMI9lW TW5I= X-Google-Smtp-Source: AGHT+IGZKEzGHAkzv2n28S9NoaKcdrhnPjLayp8QyPL66E+m1yDhyOERcs9eeh0CYjhOj0tvfRf2EA== X-Received: by 2002:a17:902:e80d:b0:1e3:d4a2:3882 with SMTP id d9443c01a7336-1ef43d0ad97mr296814685ad.2.1715967652181; Fri, 17 May 2024 10:40:52 -0700 (PDT) Received: from hermes.lan (204-195-96-226.wavecable.com. [204.195.96.226]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-1ef0bf31032sm158830485ad.131.2024.05.17.10.40.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 17 May 2024 10:40:51 -0700 (PDT) From: Stephen Hemminger To: dev@dpdk.org Cc: Stephen Hemminger , Bruce Richardson Subject: [PATCH v7 6/9] test/pmd_ring: initialize mbufs Date: Fri, 17 May 2024 10:35:13 -0700 Message-ID: <20240517174044.90952-7-stephen@networkplumber.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240517174044.90952-1-stephen@networkplumber.org> References: <20240510050507.14381-1-stephen@networkplumber.org> <20240517174044.90952-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