Skip to content

Commit

Permalink
test: fix buffer overflow in Tx burst
Browse files Browse the repository at this point in the history
[ upstream commit 58325f0 ]

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

Fixes: 002ade7 ("app/test: measure cycles per packet in Rx/Tx")

Signed-off-by: Alvin Zhang <alvinx.zhang@intel.com>
Acked-by: Jeff Guo <jia.guo@intel.com>
Tested-by: Wei Ling <weix.ling@intel.com>
  • Loading branch information
Alvin Zhang authored and bluca committed Feb 4, 2021
1 parent 77ce48c commit 3f39b91
Showing 1 changed file with 8 additions and 10 deletions.
18 changes: 8 additions & 10 deletions app/test/test_pmd_perf.c
Original file line number Diff line number Diff line change
Expand Up @@ -606,10 +606,10 @@ poll_burst(void *args)
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];
Expand All @@ -628,16 +628,14 @@ exec_burst(uint32_t flags, int lcore)
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);
Expand Down

0 comments on commit 3f39b91

Please sign in to comment.