Re: [PATCH bpf-next v3] 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 Wed, Jan 15, 2020 at 5:15 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>
> ---

Looks good, thanks! You are just missing one CHECK() for
bpf_map_update_elem below, please add it. With that:

Acked-by: Andrii Nakryiko <andriin@xxxxxx>

> v2 -> v3:
>   - Incorporated review comments from Andrii and Maciej
>
> v1 -> v2:
>   - Changed code to use the BPF skeleton
>   - Replace static volatile with global variable in eBPF code
>
>  .../testing/selftests/bpf/prog_tests/xdp_bpf2bpf.c |   65 ++++++++++++++++++++
>  .../testing/selftests/bpf/progs/test_xdp_bpf2bpf.c |   44 ++++++++++++++
>  2 files changed, 109 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
>
> diff --git a/tools/testing/selftests/bpf/prog_tests/xdp_bpf2bpf.c b/tools/testing/selftests/bpf/prog_tests/xdp_bpf2bpf.c
> new file mode 100644
> index 000000000000..6b56bdc73ebc
> --- /dev/null
> +++ b/tools/testing/selftests/bpf/prog_tests/xdp_bpf2bpf.c
> @@ -0,0 +1,65 @@
> +// SPDX-License-Identifier: GPL-2.0
> +#include <test_progs.h>
> +#include <net/if.h>
> +#include "test_xdp.skel.h"
> +#include "test_xdp_bpf2bpf.skel.h"
> +
> +void test_xdp_bpf2bpf(void)
> +{
> +       __u32 duration = 0, retval, size;
> +       char buf[128];
> +       int err, pkt_fd, map_fd;
> +       struct iphdr *iph = (void *)buf + sizeof(struct ethhdr);
> +       struct iptnl_info value4 = {.family = AF_INET};
> +       struct test_xdp *pkt_skel = NULL;
> +       struct test_xdp_bpf2bpf *ftrace_skel = NULL;
> +       struct vip key4 = {.protocol = 6, .family = AF_INET};
> +       DECLARE_LIBBPF_OPTS(bpf_object_open_opts, opts);
> +
> +       /* Load XDP program to introspect */
> +       pkt_skel = test_xdp__open_and_load();
> +       if (CHECK(!pkt_skel, "pkt_skel_load", "test_xdp skeleton failed\n"))
> +               return;
> +
> +       pkt_fd = bpf_program__fd(pkt_skel->progs._xdp_tx_iptunnel);
> +
> +       map_fd = bpf_map__fd(pkt_skel->maps.vip2tnl);
> +       bpf_map_update_elem(map_fd, &key4, &value4, 0);

CHECK()? Sorry, didn't spot first time.


> +
> +       /* Load trace program */
> +       opts.attach_prog_fd = pkt_fd,
> +       ftrace_skel = test_xdp_bpf2bpf__open_opts(&opts);
> +       if (CHECK(!ftrace_skel, "__open", "ftrace skeleton failed\n"))
> +               goto out;
> +

[...]



[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