patches for DPDK stable branches
 help / color / mirror / Atom feed
From: "Zhang,Alvin" <alvinx.zhang@intel.com>
To: cunming.liang@intel.com
Cc: dev@dpdk.org, Alvin Zhang <alvinx.zhang@intel.com>, stable@dpdk.org
Subject: [dpdk-stable] [PATCH] test: fix buffer overflow
Date: Wed, 25 Nov 2020 17:46:22 +0800
Message-ID: <20201125094622.12064-1-alvinx.zhang@intel.com> (raw)

From: Alvin Zhang <alvinx.zhang@intel.com>

The Tx buffer may overflow when there is more than one port.

Signed-off-by: Alvin Zhang <alvinx.zhang@intel.com>

Fixes: 002ade70e933 ("app/test: measure cycles per packet in Rx/Tx")
Cc: stable@dpdk.org
---
 app/test/test_pmd_perf.c | 18 ++++++++----------
 1 file changed, 8 insertions(+), 10 deletions(-)

diff --git a/app/test/test_pmd_perf.c b/app/test/test_pmd_perf.c
index 4db816a..3a248d5 100644
--- a/app/test/test_pmd_perf.c
+++ b/app/test/test_pmd_perf.c
@@ -606,10 +606,10 @@ enum {
 static int
 exec_burst(uint32_t flags, int lcore)
 {
-	unsigned i, portid, nb_tx = 0;
+	unsigned int portid, nb_tx = 0;
 	struct lcore_conf *conf;
 	uint32_t pkt_per_port;
-	int num, idx = 0;
+	int num, i, idx = 0;
 	int diff_tsc;
 
 	conf = &lcore_conf[lcore];
@@ -628,16 +628,14 @@ enum {
 		rte_atomic64_set(&start, 1);
 
 	/* start xmit */
+	i = 0;
 	while (num) {
 		nb_tx = RTE_MIN(MAX_PKT_BURST, num);
-		for (i = 0; i < conf->nb_ports; i++) {
-			portid = conf->portlist[i];
-			nb_tx = rte_eth_tx_burst(portid, 0,
-					 &tx_burst[idx], nb_tx);
-			idx += nb_tx;
-			num -= nb_tx;
-		}
-
+		portid = conf->portlist[i];
+		nb_tx = rte_eth_tx_burst(portid, 0, &tx_burst[idx], nb_tx);
+		idx += nb_tx;
+		num -= nb_tx;
+		i = (i >= conf->nb_ports - 1) ? 0 : (i + 1);
 	}
 
 	sleep(5);
-- 
1.8.3.1


             reply	other threads:[~2020-11-25  9:46 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-11-25  9:46 Zhang,Alvin [this message]
2020-11-26  9:30 ` [dpdk-stable] [dpdk-dev] " Ling, WeiX
2021-01-15  8:31 ` Guo, Jia
2021-01-15  8:59   ` Guo, Jia
2021-01-19 10:38     ` Thomas Monjalon

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20201125094622.12064-1-alvinx.zhang@intel.com \
    --to=alvinx.zhang@intel.com \
    --cc=cunming.liang@intel.com \
    --cc=dev@dpdk.org \
    --cc=stable@dpdk.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

patches for DPDK stable branches

This inbox may be cloned and mirrored by anyone:

	git clone --mirror https://inbox.dpdk.org/stable/0 stable/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 stable stable/ https://inbox.dpdk.org/stable \
		stable@dpdk.org
	public-inbox-index stable

Example config snippet for mirrors.
Newsgroup available over NNTP:
	nntp://inbox.dpdk.org/inbox.dpdk.stable


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git