All of lore.kernel.org
 help / color / mirror / Atom feed
From: Andrii Nakryiko <andrii.nakryiko@gmail.com>
To: Eelco Chaudron <echaudro@redhat.com>
Cc: bpf <bpf@vger.kernel.org>,
	"David S. Miller" <davem@davemloft.net>,
	Alexei Starovoitov <ast@kernel.org>,
	Networking <netdev@vger.kernel.org>,
	maciej.fijalkowski@intel.com
Subject: Re: [PATCH bpf-next v3] selftests/bpf: Add a test for attaching a bpf fentry/fexit trace to an XDP program
Date: Wed, 15 Jan 2020 09:04:08 -0800	[thread overview]
Message-ID: <CAEf4BzZmF6TUtGkmcWAP8T5+JH=CEqAvu-q=LntsoYbuZbePgw@mail.gmail.com> (raw)
In-Reply-To: <157909410480.47481.11202505690938004673.stgit@xdp-tutorial>

On Wed, Jan 15, 2020 at 5:15 AM Eelco Chaudron <echaudro@redhat.com> 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@redhat.com>
> ---

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@fb.com>

> 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;
> +

[...]

  reply	other threads:[~2020-01-15 17:04 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-01-15 13:15 [PATCH bpf-next v3] selftests/bpf: Add a test for attaching a bpf fentry/fexit trace to an XDP program Eelco Chaudron
2020-01-15 17:04 ` Andrii Nakryiko [this message]
2020-01-15 21:26   ` Alexei Starovoitov

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='CAEf4BzZmF6TUtGkmcWAP8T5+JH=CEqAvu-q=LntsoYbuZbePgw@mail.gmail.com' \
    --to=andrii.nakryiko@gmail.com \
    --cc=ast@kernel.org \
    --cc=bpf@vger.kernel.org \
    --cc=davem@davemloft.net \
    --cc=echaudro@redhat.com \
    --cc=maciej.fijalkowski@intel.com \
    --cc=netdev@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.