On 20 Dec 2019, at 0:02, Andrii Nakryiko wrote:
On Thu, Dec 19, 2019 at 3:04 AM Eelco Chaudron <echaudro@xxxxxxxxxx>
wrote:
Add a test that will attach a FENTRY and FEXIT program to the XDP
test
program. It will also verify data from the XDP context on FENTRY and
verifies the return code on exit.
Signed-off-by: Eelco Chaudron <echaudro@xxxxxxxxxx>
---
.../testing/selftests/bpf/prog_tests/xdp_bpf2bpf.c | 95
++++++++++++++++++++
.../testing/selftests/bpf/progs/test_xdp_bpf2bpf.c | 44 +++++++++
2 files changed, 139 insertions(+)
create mode 100644
tools/testing/selftests/bpf/prog_tests/xdp_bpf2bpf.c
create mode 100644
tools/testing/selftests/bpf/progs/test_xdp_bpf2bpf.c
[...]
Thanks for the review, updated my kernel to the latest bfp-next, but now
I get the following build issue for the test suite:
GEN-SKEL [test_progs] loop3.skel.h
GEN-SKEL [test_progs] test_skeleton.skel.h
libbpf: failed to find BTF for extern 'CONFIG_BPF_SYSCALL': -2
Error: failed to open BPF object file: 0
make: *** [Makefile:333:
/data/linux_kernel/tools/testing/selftests/bpf/test_skeleton.skel.h]
Error 255
make: *** Deleting file
'/data/linux_kernel/tools/testing/selftests/bpf/test_skeleton.skel.h'
Verified, and I still have all the correct config and CLANG version.
Something else I need to update?
I have pahole v1.15 in my search path…
+ /* Load XDP program to introspect */
+ err = bpf_prog_load(file, BPF_PROG_TYPE_XDP, &obj, &prog_fd);
Please use BPF skeleton for this test. It will make it significantly
shorter and clearer. See other fentry_fexit selftest for example.
+ if (CHECK_FAIL(err))
+ return;
+
[...]
+
+static volatile __u64 test_result_fentry;
no need for static volatile anymore, just use global var
+BPF_TRACE_1("fentry/_xdp_tx_iptunnel", trace_on_entry,
+ struct xdp_buff *, xdp)
+{
+ test_result_fentry = xdp->rxq->dev->ifindex;
+ return 0;
+}
+
+static volatile __u64 test_result_fexit;
same here
+BPF_TRACE_2("fexit/_xdp_tx_iptunnel", trace_on_exit,
+ struct xdp_buff*, xdp, int, ret)
+{
+ test_result_fexit = ret;
+ return 0;
+}