diff options
author | Martin KaFai Lau <martin.lau@kernel.org> | 2023-02-17 12:55:15 -0800 |
---|---|---|
committer | Daniel Borkmann <daniel@iogearbox.net> | 2023-02-17 22:12:04 +0100 |
commit | 168de0233586fb06c5c5c56304aa9a928a09b0ba (patch) | |
tree | 5704b8b4453664107faf69ab5f6129df8572041c /tools/testing/selftests/bpf/progs | |
parent | 31de4105f00d64570139bc5494a201b0bd57349f (diff) | |
download | linux-stable-168de0233586fb06c5c5c56304aa9a928a09b0ba.tar.gz linux-stable-168de0233586fb06c5c5c56304aa9a928a09b0ba.tar.bz2 linux-stable-168de0233586fb06c5c5c56304aa9a928a09b0ba.zip |
selftests/bpf: Add bpf_fib_lookup test
This patch tests the bpf_fib_lookup helper when looking up
a neigh in NUD_FAILED and NUD_STALE state. It also adds test
for the new BPF_FIB_LOOKUP_SKIP_NEIGH flag.
Signed-off-by: Martin KaFai Lau <martin.lau@kernel.org>
Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
Link: https://lore.kernel.org/bpf/20230217205515.3583372-2-martin.lau@linux.dev
Diffstat (limited to 'tools/testing/selftests/bpf/progs')
-rw-r--r-- | tools/testing/selftests/bpf/progs/fib_lookup.c | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/tools/testing/selftests/bpf/progs/fib_lookup.c b/tools/testing/selftests/bpf/progs/fib_lookup.c new file mode 100644 index 000000000000..c4514dd58c62 --- /dev/null +++ b/tools/testing/selftests/bpf/progs/fib_lookup.c @@ -0,0 +1,22 @@ +// SPDX-License-Identifier: GPL-2.0 +/* Copyright (c) 2023 Meta Platforms, Inc. and affiliates. */ + +#include <linux/types.h> +#include <linux/bpf.h> +#include <bpf/bpf_helpers.h> +#include "bpf_tracing_net.h" + +struct bpf_fib_lookup fib_params = {}; +int fib_lookup_ret = 0; +int lookup_flags = 0; + +SEC("tc") +int fib_lookup(struct __sk_buff *skb) +{ + fib_lookup_ret = bpf_fib_lookup(skb, &fib_params, sizeof(fib_params), + lookup_flags); + + return TC_ACT_SHOT; +} + +char _license[] SEC("license") = "GPL"; |