* [PATCH] examples/l2fwd: fix port statistics reset inside loop
@ 2026-03-31 4:45 Harsh raj Singh
2026-05-01 22:57 ` Stephen Hemminger
0 siblings, 1 reply; 3+ messages in thread
From: Harsh raj Singh @ 2026-03-31 4:45 UTC (permalink / raw)
To: dev
[-- Attachment #1: Type: text/plain, Size: 119 bytes --]
Hi,
Please find attached my patch for fix port statistics reset inside
loop in l2fwd example
Thanks,
Harsh Raj Singh
[-- Attachment #2: 0001-examples-l2fwd-fix-port-statistics-reset-inside-loop.patch --]
[-- Type: text/x-patch, Size: 1401 bytes --]
From 8b2c5651808b1ea14d3b5e1386ddf67152703ce1 Mon Sep 17 00:00:00 2001
From: harshraj1695 <singhharshraj215@gmail.com>
Date: Tue, 24 Mar 2026 09:28:59 +0530
Subject: [PATCH] examples/l2fwd: fix port statistics reset inside loop
The port_statistics structure was reset inside the per-port
initialization loop, causing previously initialized statistics
to be overwritten on each iteration.
Move the initialization outside the loop to ensure statistics
are correctly maintained for all ports.
Signed-off-by: harshraj1695 <singhharshraj215@gmail.com>
---
examples/l2fwd/main.c | 4 +---
1 file changed, 1 insertion(+), 3 deletions(-)
diff --git a/examples/l2fwd/main.c b/examples/l2fwd/main.c
index 59ea3172ae..c799e8768a 100644
--- a/examples/l2fwd/main.c
+++ b/examples/l2fwd/main.c
@@ -773,6 +773,7 @@ main(int argc, char **argv)
if (l2fwd_pktmbuf_pool == NULL)
rte_exit(EXIT_FAILURE, "Cannot init mbuf pool\n");
/* >8 End of create the mbuf pool. */
+ memset(port_statistics, 0, sizeof(port_statistics));
/* Initialise each port */
RTE_ETH_FOREACH_DEV(portid) {
@@ -889,9 +890,6 @@ main(int argc, char **argv)
printf("Port %u, MAC address: " RTE_ETHER_ADDR_PRT_FMT "\n\n",
portid,
RTE_ETHER_ADDR_BYTES(&l2fwd_ports_eth_addr[portid]));
-
- /* initialize port stats */
- memset(&port_statistics, 0, sizeof(port_statistics));
}
if (!nb_ports_available) {
--
2.43.0
^ permalink raw reply related [flat|nested] 3+ messages in thread* Re: [PATCH] examples/l2fwd: fix port statistics reset inside loop
2026-03-31 4:45 [PATCH] examples/l2fwd: fix port statistics reset inside loop Harsh raj Singh
@ 2026-05-01 22:57 ` Stephen Hemminger
0 siblings, 0 replies; 3+ messages in thread
From: Stephen Hemminger @ 2026-05-01 22:57 UTC (permalink / raw)
To: Harsh raj Singh; +Cc: dev
On Tue, 31 Mar 2026 10:15:32 +0530
Harsh raj Singh <singhharshraj215@gmail.com> wrote:
> Hi,
>
> Please find attached my patch for fix port statistics reset inside
> loop in l2fwd example
>
> Thanks,
> Harsh Raj Singh
What is the problem here. That loop only happens during initialization.
The memset() is redundant and not needed but that is a different reason
to remove it. In current code the port_statistics will start out at all zeros.
If you want, the right fix is to pull the memset entirely.
While your at it look for the same pattern in other variants of l2fwd and l3fwd.
There is a lot of copy/paste here.
^ permalink raw reply [flat|nested] 3+ messages in thread
* [PATCH] examples/l2fwd: fix port statistics reset inside loop
@ 2026-03-24 4:23 Harsh raj Singh
0 siblings, 0 replies; 3+ messages in thread
From: Harsh raj Singh @ 2026-03-24 4:23 UTC (permalink / raw)
To: dev
[-- Attachment #1: Type: text/plain, Size: 1 bytes --]
[-- Attachment #2: 0001-examples-l2fwd-fix-port-statistics-reset-inside-loop.patch --]
[-- Type: text/x-patch, Size: 1401 bytes --]
From 8b2c5651808b1ea14d3b5e1386ddf67152703ce1 Mon Sep 17 00:00:00 2001
From: harshraj1695 <singhharshraj215@gmail.com>
Date: Tue, 24 Mar 2026 09:28:59 +0530
Subject: [PATCH] examples/l2fwd: fix port statistics reset inside loop
The port_statistics structure was reset inside the per-port
initialization loop, causing previously initialized statistics
to be overwritten on each iteration.
Move the initialization outside the loop to ensure statistics
are correctly maintained for all ports.
Signed-off-by: harshraj1695 <singhharshraj215@gmail.com>
---
examples/l2fwd/main.c | 4 +---
1 file changed, 1 insertion(+), 3 deletions(-)
diff --git a/examples/l2fwd/main.c b/examples/l2fwd/main.c
index 59ea3172ae..c799e8768a 100644
--- a/examples/l2fwd/main.c
+++ b/examples/l2fwd/main.c
@@ -773,6 +773,7 @@ main(int argc, char **argv)
if (l2fwd_pktmbuf_pool == NULL)
rte_exit(EXIT_FAILURE, "Cannot init mbuf pool\n");
/* >8 End of create the mbuf pool. */
+ memset(port_statistics, 0, sizeof(port_statistics));
/* Initialise each port */
RTE_ETH_FOREACH_DEV(portid) {
@@ -889,9 +890,6 @@ main(int argc, char **argv)
printf("Port %u, MAC address: " RTE_ETHER_ADDR_PRT_FMT "\n\n",
portid,
RTE_ETHER_ADDR_BYTES(&l2fwd_ports_eth_addr[portid]));
-
- /* initialize port stats */
- memset(&port_statistics, 0, sizeof(port_statistics));
}
if (!nb_ports_available) {
--
2.43.0
^ permalink raw reply related [flat|nested] 3+ messages in thread
end of thread, other threads:[~2026-05-01 22:57 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-03-31 4:45 [PATCH] examples/l2fwd: fix port statistics reset inside loop Harsh raj Singh
2026-05-01 22:57 ` Stephen Hemminger
-- strict thread matches above, loose matches on Subject: below --
2026-03-24 4:23 Harsh raj Singh
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox