In preparation for output route tests, allow test cases to specify an
expected ifindex and verify that it matches the ifindex of the nexthop
device. Default to not verifying the ifindex.
Reviewed-by: Petr Machata <petrm@nvidia.com>
Signed-off-by: Ido Schimmel <idosch@nvidia.com>
---
tools/testing/selftests/bpf/prog_tests/fib_lookup.c | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/tools/testing/selftests/bpf/prog_tests/fib_lookup.c b/tools/testing/selftests/bpf/prog_tests/fib_lookup.c
index cd306bd4819a..0541fd982e63 100644
--- a/tools/testing/selftests/bpf/prog_tests/fib_lookup.c
+++ b/tools/testing/selftests/bpf/prog_tests/fib_lookup.c
@@ -55,6 +55,7 @@ struct fib_lookup_test {
__u8 dmac[6];
__u32 mark;
int ifindex;
+ int expected_ifindex;
};
static const struct fib_lookup_test tests[] = {@@ -359,6 +360,10 @@ void test_fib_lookup(void)
if (tests[i].expected_dst)
assert_dst_ip(fib_params, tests[i].expected_dst);
+ if (tests[i].expected_ifindex)
+ ASSERT_EQ(fib_params->ifindex, tests[i].expected_ifindex,
+ "ifindex does not match");
+
ret = memcmp(tests[i].dmac, fib_params->dmac, sizeof(tests[i].dmac));
if (!ASSERT_EQ(ret, 0, "dmac not match")) {
char expected[18], actual[18];--
2.53.0