summaryrefslogtreecommitdiff
path: root/tools/testing/selftests/bpf/progs/test_bpf_nf.c
diff options
context:
space:
mode:
authorDaniel Xu <dxu@dxuuu.xyz>2022-08-12 00:55:26 +0300
committerDaniel Borkmann <daniel@iogearbox.net>2022-08-15 21:53:25 +0300
commit99799de2cba2d399acf65f49a986b3d5cf0732ab (patch)
treea3a8f5bce96785ee7ee1274135b4287131dc8613 /tools/testing/selftests/bpf/progs/test_bpf_nf.c
parente81fbd4c1ba7b128a198c2843665e1186db449b6 (diff)
downloadlinux-99799de2cba2d399acf65f49a986b3d5cf0732ab.tar.xz
selftests/bpf: Add connmark read test
Test that the prog can read from the connection mark. This test is nice because it ensures progs can interact with netfilter subsystem correctly. Signed-off-by: Daniel Xu <dxu@dxuuu.xyz> Signed-off-by: Daniel Borkmann <daniel@iogearbox.net> Acked-by: Kumar Kartikeya Dwivedi <memxor@gmail.com> Link: https://lore.kernel.org/bpf/d3bc620a491e4c626c20d80631063922cbe13e2b.1660254747.git.dxu@dxuuu.xyz
Diffstat (limited to 'tools/testing/selftests/bpf/progs/test_bpf_nf.c')
-rw-r--r--tools/testing/selftests/bpf/progs/test_bpf_nf.c3
1 files changed, 3 insertions, 0 deletions
diff --git a/tools/testing/selftests/bpf/progs/test_bpf_nf.c b/tools/testing/selftests/bpf/progs/test_bpf_nf.c
index 84e0fd479794..2722441850cc 100644
--- a/tools/testing/selftests/bpf/progs/test_bpf_nf.c
+++ b/tools/testing/selftests/bpf/progs/test_bpf_nf.c
@@ -28,6 +28,7 @@ __be16 sport = 0;
__be32 daddr = 0;
__be16 dport = 0;
int test_exist_lookup = -ENOENT;
+u32 test_exist_lookup_mark = 0;
struct nf_conn;
@@ -174,6 +175,8 @@ nf_ct_test(struct nf_conn *(*lookup_fn)(void *, struct bpf_sock_tuple *, u32,
sizeof(opts_def));
if (ct) {
test_exist_lookup = 0;
+ if (ct->mark == 42)
+ test_exist_lookup_mark = 43;
bpf_ct_release(ct);
} else {
test_exist_lookup = opts_def.error;