Re: [PATCH bpf-next] selftests/bpf: Add a test for attaching a bpf fentry/fexit trace to an XDP program

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 





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


[...]

+       /* 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.


Trying to do this, however, I’m getting the following when trying to execute the test:

test_xdp_bpf2bpf:PASS:pkt_skel_load 0 nsec
libbpf: fentry/_xdp_tx_iptunnel is not found in vmlinux BTF
libbpf: failed to load object 'test_xdp_bpf2bpf'
libbpf: failed to load BPF skeleton 'test_xdp_bpf2bpf': -2
test_xdp_bpf2bpf:FAIL:ftrace_skel_load ftrace skeleton failed


My program is straight forward following the fentry_fexit.c example:

    pkt_skel = test_xdp__open_and_load();
if (CHECK(!pkt_skel, "pkt_skel_load", "test_xdp skeleton failed\n"))
        return;

    map_fd = bpf_map__fd(pkt_skel->maps.vip2tnl);
    bpf_map_update_elem(map_fd, &key4, &value4, 0);

    /* Load eBPF trace program */
    ftrace_skel = test_xdp_bpf2bpf__open_and_load();
if (CHECK(!ftrace_skel, "ftrace_skel_load", "ftrace skeleton failed\n"))
        goto out;

I assume this is due to the missing link from the XDP program to the eBPF trace program.
Previously I did this trough:

+	DECLARE_LIBBPF_OPTS(bpf_object_open_opts, opts,
+			    .attach_prog_fd = prog_fd,
+			   );
+
+	tracer_obj = bpf_object__open_file("./test_xdp_bpf2bpf.o", &opts);


If I use this approach as before it works, i.e.:

        DECLARE_LIBBPF_OPTS(bpf_object_open_opts, opts,
                            .attach_prog_fd = pkt_fd,
                           );

        ftrace_skel = test_xdp_bpf2bpf__open_opts(&opts);
if (CHECK(!ftrace_skel, "__open_opts”, "ftrace skeleton failed\n"))
          goto out;
if (CHECK(test_xdp_bpf2bpf__load(ftrace_skel), "__load", "ftrace skeleton failed\n"))
          goto out;

But I do not see this in the fentry_fexit.c example, guess I might be missing something that is right in front of me :(


[...]





[Index of Archives]     [Linux Samsung SoC]     [Linux Rockchip SoC]     [Linux Actions SoC]     [Linux for Synopsys ARC Processors]     [Linux NFS]     [Linux NILFS]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]


  Powered by Linux