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 > [...] > + /* 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; > +} >