* [dpdk-stable] [PATCH] test: fix buffer overflow
@ 2020-11-25 9:46 Zhang,Alvin
2020-11-26 9:30 ` [dpdk-stable] [dpdk-dev] " Ling, WeiX
2021-01-15 8:31 ` Guo, Jia
0 siblings, 2 replies; 5+ messages in thread
From: Zhang,Alvin @ 2020-11-25 9:46 UTC (permalink / raw)
To: cunming.liang; +Cc: dev, Alvin Zhang, stable
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
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [dpdk-stable] [dpdk-dev] [PATCH] test: fix buffer overflow
2020-11-25 9:46 [dpdk-stable] [PATCH] test: fix buffer overflow Zhang,Alvin
@ 2020-11-26 9:30 ` Ling, WeiX
2021-01-15 8:31 ` Guo, Jia
1 sibling, 0 replies; 5+ messages in thread
From: Ling, WeiX @ 2020-11-26 9:30 UTC (permalink / raw)
To: Zhang, AlvinX, Liang, Cunming; +Cc: dev, Zhang, AlvinX, stable
Tested-by: Wei Ling <weix.ling@intel.com>
Regards,
Ling Wei
> -----Original Message-----
> From: dev <dev-bounces@dpdk.org> On Behalf Of Zhang,Alvin
> Sent: Wednesday, November 25, 2020 05:46 PM
> To: Liang, Cunming <cunming.liang@intel.com>
> Cc: dev@dpdk.org; Zhang, AlvinX <alvinx.zhang@intel.com>;
> stable@dpdk.org
> Subject: [dpdk-dev] [PATCH] test: fix buffer overflow
>
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [dpdk-stable] [dpdk-dev] [PATCH] test: fix buffer overflow
2020-11-25 9:46 [dpdk-stable] [PATCH] test: fix buffer overflow Zhang,Alvin
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
1 sibling, 1 reply; 5+ messages in thread
From: Guo, Jia @ 2021-01-15 8:31 UTC (permalink / raw)
To: Zhang, AlvinX, Liang, Cunming; +Cc: dev, Zhang, AlvinX, stable
Hi, Alvin
> -----Original Message-----
> From: dev <dev-bounces@dpdk.org> On Behalf Of Zhang,Alvin
> Sent: Wednesday, November 25, 2020 5:46 PM
> To: Liang, Cunming <cunming.liang@intel.com>
> Cc: dev@dpdk.org; Zhang, AlvinX <alvinx.zhang@intel.com>;
> stable@dpdk.org
> Subject: [dpdk-dev] [PATCH] test: fix buffer overflow
>
> 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);
If conf->nb_ports = 1, after the above assign, the i should be 1 and is that your expected?
> }
>
> sleep(5);
> --
> 1.8.3.1
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [dpdk-stable] [dpdk-dev] [PATCH] test: fix buffer overflow
2021-01-15 8:31 ` Guo, Jia
@ 2021-01-15 8:59 ` Guo, Jia
2021-01-19 10:38 ` Thomas Monjalon
0 siblings, 1 reply; 5+ messages in thread
From: Guo, Jia @ 2021-01-15 8:59 UTC (permalink / raw)
To: Zhang, AlvinX, Liang, Cunming; +Cc: dev, Zhang, AlvinX, stable
Acked-by: Jeff Guo <jia.guo@intel.com>
> -----Original Message-----
> From: Guo, Jia
> Sent: Friday, January 15, 2021 4:31 PM
> To: 'Zhang,Alvin' <alvinx.zhang@intel.com>; Liang, Cunming
> <cunming.liang@intel.com>
> Cc: dev@dpdk.org; Zhang, AlvinX <alvinx.zhang@intel.com>;
> stable@dpdk.org
> Subject: RE: [dpdk-dev] [PATCH] test: fix buffer overflow
>
> Hi, Alvin
>
> > -----Original Message-----
> > From: dev <dev-bounces@dpdk.org> On Behalf Of Zhang,Alvin
> > Sent: Wednesday, November 25, 2020 5:46 PM
> > To: Liang, Cunming <cunming.liang@intel.com>
> > Cc: dev@dpdk.org; Zhang, AlvinX <alvinx.zhang@intel.com>;
> > stable@dpdk.org
> > Subject: [dpdk-dev] [PATCH] test: fix buffer overflow
> >
> > 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);
>
> If conf->nb_ports = 1, after the above assign, the i should be 1 and is that
> your expected?
Please ignore above comment, this code should be works.
>
> > }
> >
> > sleep(5);
> > --
> > 1.8.3.1
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [dpdk-stable] [dpdk-dev] [PATCH] test: fix buffer overflow
2021-01-15 8:59 ` Guo, Jia
@ 2021-01-19 10:38 ` Thomas Monjalon
0 siblings, 0 replies; 5+ messages in thread
From: Thomas Monjalon @ 2021-01-19 10:38 UTC (permalink / raw)
To: Zhang, AlvinX; +Cc: Liang, Cunming, dev, stable, Guo, Jia
> > > 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
> Acked-by: Jeff Guo <jia.guo@intel.com>
Applied, thanks
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2021-01-19 10:38 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-11-25 9:46 [dpdk-stable] [PATCH] test: fix buffer overflow Zhang,Alvin
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
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).