Thread (14 messages) flat view 14 messages, 4 authors, 2026-02-26
STALE167d REVIEWED: 1 (1M)

1 review trailer.

[RFC PATCH bpf-next 3/9] selftests/bpf: fib_lookup: Allow parametrizing ifindex

From: Ido Schimmel <idosch@nvidia.com>
Date: 2026-02-26 08:01:11
Also in: bpf
Subsystem: bpf [general] (safe dynamic programs and tools), bpf [selftests] (test runners & infrastructure), kernel selftest framework, the rest · Maintainers: Alexei Starovoitov, Daniel Borkmann, Andrii Nakryiko, Eduard Zingerman, Kumar Kartikeya Dwivedi, Shuah Khan, Shuah Khan, Linus Torvalds

Currently, the ifindex passed to the bpf_fib_lookup() helper is always
that of veth1. In preparation for output route tests, allow test cases
to specify an alternative ifindex. Default to that of veth1 when ifindex
is not specified.

Reviewed-by: Petr Machata <petrm@nvidia.com>
Signed-off-by: Ido Schimmel <idosch@nvidia.com>
---
 tools/testing/selftests/bpf/prog_tests/fib_lookup.c | 9 ++++-----
 1 file changed, 4 insertions(+), 5 deletions(-)
diff --git a/tools/testing/selftests/bpf/prog_tests/fib_lookup.c b/tools/testing/selftests/bpf/prog_tests/fib_lookup.c
index 14a6515a453d..cd306bd4819a 100644
--- a/tools/testing/selftests/bpf/prog_tests/fib_lookup.c
+++ b/tools/testing/selftests/bpf/prog_tests/fib_lookup.c
@@ -54,6 +54,7 @@ struct fib_lookup_test {
 	__u32 tbid;
 	__u8 dmac[6];
 	__u32 mark;
+	int ifindex;
 };
 
 static const struct fib_lookup_test tests[] = {
@@ -221,15 +222,14 @@ static int setup_netns(void)
 }
 
 static int set_lookup_params(struct bpf_fib_lookup *params,
-			     const struct fib_lookup_test *test,
-			     int ifindex)
+			     const struct fib_lookup_test *test)
 {
 	int ret;
 
 	memset(params, 0, sizeof(*params));
 
 	params->l4_protocol = IPPROTO_TCP;
-	params->ifindex = ifindex;
+	params->ifindex = test->ifindex ? : IFINDEX_VETH1;
 	params->tbid = test->tbid;
 	params->mark = test->mark;
 
@@ -335,13 +335,12 @@ void test_fib_lookup(void)
 	if (setup_netns())
 		goto fail;
 
-	skb.ifindex = IFINDEX_VETH1;
 	fib_params = &skel->bss->fib_params;
 
 	for (i = 0; i < ARRAY_SIZE(tests); i++) {
 		printf("Testing %s ", tests[i].desc);
 
-		if (set_lookup_params(fib_params, &tests[i], skb.ifindex))
+		if (set_lookup_params(fib_params, &tests[i]))
 			continue;
 
 		skel->bss->fib_lookup_ret = -1;
-- 
2.53.0
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help