[RFC PATCH v2 2/7] app/test-fib: fix lookup of the last burst

Vladimir Medvedkin vladimir.medvedkin at intel.com
Wed Oct 14 20:39:16 CEST 2026


The lookup loops process the lookup table in bursts of 64 addresses and
always pass a full burst, reading and comparing past the end of the table
when the number of addresses is not a multiple of the burst size.

Round the number of addresses down to a multiple of the burst size once
they are counted, so that the timed loops keep passing full bursts, and
read only that many addresses from the lookup file.

Fixes: 103809d032cd ("app/test-fib: add test application for FIB")
Cc: stable at dpdk.org

Signed-off-by: Vladimir Medvedkin <vladimir.medvedkin at intel.com>
---
 app/test-fib/main.c | 16 ++++++++++++----
 1 file changed, 12 insertions(+), 4 deletions(-)

diff --git a/app/test-fib/main.c b/app/test-fib/main.c
index dd1a6d7297..d85d94fdd1 100644
--- a/app/test-fib/main.c
+++ b/app/test-fib/main.c
@@ -523,19 +523,21 @@ parse_rt_6(FILE *f)
 static int
 parse_lookup(FILE *f, int af)
 {
-	int ret, i = 0;
+	int ret;
+	uint32_t i;
 	uint8_t *tbl = (uint8_t *)config.lookup_tbl;
 	int step = (af == AF_INET) ? 4 : 16;
 	char *s;
 
-	while (fgets(line, sizeof(line), f) != NULL) {
+	/* Only the addresses of the full bursts are read. */
+	for (i = 0; i < config.nb_lookup_ips &&
+			fgets(line, sizeof(line), f) != NULL; i++) {
 		s = strtok(line, " \t\n");
 		if (s == NULL)
 			return -EINVAL;
-		ret = inet_pton(af, s, &tbl[i]);
+		ret = inet_pton(af, s, &tbl[(size_t)i * step]);
 		if (ret != 1)
 			return -EINVAL;
-		i += step;
 	}
 	return 0;
 }
@@ -1251,6 +1253,12 @@ main(int argc, char **argv)
 		rewind(fl);
 	}
 
+	/* Lookups are done in full bursts, the leftovers are dropped. */
+	config.nb_lookup_ips = RTE_ALIGN_FLOOR(config.nb_lookup_ips, BURST_SZ);
+	if (config.nb_lookup_ips == 0)
+		rte_exit(-EINVAL, "At least %u ip's for lookup are needed\n",
+			BURST_SZ);
+
 	/* Alloc routes table*/
 	config.rt  = rte_malloc(NULL, rt_ent_sz * config.nb_routes, 0);
 	if (config.rt == NULL)
-- 
2.43.0



More information about the dev mailing list