selftests/bpf: Add testcase for static kfunc with unused arg
authorDavid Vernet <void@manifault.com>
Wed, 1 Feb 2023 17:30:16 +0000 (11:30 -0600)
committerDaniel Borkmann <daniel@iogearbox.net>
Wed, 1 Feb 2023 23:25:14 +0000 (00:25 +0100)
commit6aed15e330bfec6a423f40582b2a8b53d9ce1757
tree7ba09ec45bc7c8865844287480a39f8f5984dd3d
parent400031e05adfcef9e80eca80bdfc3f4b63658be4
selftests/bpf: Add testcase for static kfunc with unused arg

kfuncs are allowed to be static, or not use one or more of their
arguments. For example, bpf_xdp_metadata_rx_hash() in net/core/xdp.c is
meant to be implemented by drivers, with the default implementation just
returning -EOPNOTSUPP. As described in [0], such kfuncs can have their
arguments elided, which can cause BTF encoding to be skipped. The new
__bpf_kfunc macro should address this, and this patch adds a selftest
which verifies that a static kfunc with at least one unused argument can
still be encoded and invoked by a BPF program.

Signed-off-by: David Vernet <void@manifault.com>
Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
Link: https://lore.kernel.org/bpf/20230201173016.342758-5-void@manifault.com
net/bpf/test_run.c
tools/testing/selftests/bpf/prog_tests/kfunc_call.c
tools/testing/selftests/bpf/progs/kfunc_call_test.c