The IPv6 lookup table became an array of struct rte_ipv6_addr, but
dump_lookup() still indexes it with i * 16 as if it were an array of
bytes. Writing the lookup addresses with -u in IPv6 mode reads past
the end of the table and crashes.

Index the table by address.

Fixes: e1a06e391ba7 ("lpm6: use IPv6 address structure and utils")
Cc: [email protected]

Signed-off-by: Maxime Leroy <[email protected]>
---
 app/test-fib/main.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/app/test-fib/main.c b/app/test-fib/main.c
index 05f9b9a1c7..e757c0f464 100644
--- a/app/test-fib/main.c
+++ b/app/test-fib/main.c
@@ -562,7 +562,7 @@ dump_lookup(int af)
                        fprintf(f, NIPQUAD_FMT"\n", NIPQUAD(tbl4[i]));
        } else {
                for (i = 0; i < config.nb_lookup_ips; i++)
-                       fprintf(f, RTE_IPV6_ADDR_FMT"\n", 
RTE_IPV6_ADDR_SPLIT(&tbl6[i * 16]));
+                       fprintf(f, RTE_IPV6_ADDR_FMT"\n", 
RTE_IPV6_ADDR_SPLIT(&tbl6[i]));
        }
        fclose(f);
        return 0;
-- 
2.43.0

Reply via email to