]> git.itanic.dy.fi Git - linux-stable/commit
selftests/bpf: Add bpf_program__attach_netfilter helper test
authorFlorian Westphal <fw@strlen.de>
Wed, 28 Jun 2023 15:27:38 +0000 (17:27 +0200)
committerAndrii Nakryiko <andrii@kernel.org>
Fri, 30 Jun 2023 19:34:38 +0000 (12:34 -0700)
commita94098d490e17d652770f2309fcb9b46bc4cf864
treebcb4b610e51a8ed0ddff16f9019d60969fd2d1e3
parent52364abb10b57074bf724ee2032e688180ed8bde
selftests/bpf: Add bpf_program__attach_netfilter helper test

Call bpf_program__attach_netfilter() with different
protocol/hook/priority combinations.

Test fails if supposedly-illegal attachments work
(e.g., bogus protocol family, illegal priority and so on) or if a
should-work attachment fails.  Expected output:

 ./test_progs -t netfilter_link_attach
 #145/1   netfilter_link_attach/allzero:OK
 #145/2   netfilter_link_attach/invalid-pf:OK
 #145/3   netfilter_link_attach/invalid-hooknum:OK
 #145/4   netfilter_link_attach/invalid-priority-min:OK
 #145/5   netfilter_link_attach/invalid-priority-max:OK
 #145/6   netfilter_link_attach/invalid-flags:OK
 #145/7   netfilter_link_attach/invalid-inet-not-supported:OK
 #145/8   netfilter_link_attach/attach ipv4:OK
 #145/9   netfilter_link_attach/attach ipv6:OK

Signed-off-by: Florian Westphal <fw@strlen.de>
Signed-off-by: Andrii Nakryiko <andrii@kernel.org>
Reviewed-by: Toke Høiland-Jørgensen <toke@redhat.com>
Acked-by: Daniel Xu <dxu@dxuuu.xyz>
Link: https://lore.kernel.org/bpf/20230628152738.22765-3-fw@strlen.de
tools/testing/selftests/bpf/prog_tests/netfilter_link_attach.c [new file with mode: 0644]
tools/testing/selftests/bpf/progs/test_netfilter_link_attach.c [new file with mode: 0644]