bpf.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Andrii Nakryiko <andrii.nakryiko@gmail.com>
To: Carlos Antonio Neira Bustos <cneirabustos@gmail.com>
Cc: Yonghong Song <yhs@fb.com>,
	"netdev@vger.kernel.org" <netdev@vger.kernel.org>,
	"ebiederm@xmission.com" <ebiederm@xmission.com>,
	"brouer@redhat.com" <brouer@redhat.com>,
	"bpf@vger.kernel.org" <bpf@vger.kernel.org>
Subject: Re: [PATCH v14 4/5] tools/testing/selftests/bpf: Add self-tests for new helper.
Date: Mon, 21 Oct 2019 12:18:33 -0700	[thread overview]
Message-ID: <CAEf4BzY5ZMQJYwU5p-r4bnOcZLGsR1_1iY3-0KKnZyttRbyr6g@mail.gmail.com> (raw)
In-Reply-To: <20191021191449.GA16484@ebpf00.byteswizards.com>

On Mon, Oct 21, 2019 at 12:14 PM Carlos Antonio Neira Bustos
<cneirabustos@gmail.com> wrote:
>
> On Mon, Oct 21, 2019 at 11:20:01AM -0700, Andrii Nakryiko wrote:
> > On Sat, Oct 19, 2019 at 1:58 AM Yonghong Song <yhs@fb.com> wrote:
> > >
> > >
> > >
> > > On 10/17/19 8:00 AM, Carlos Neira wrote:
> > > > Self tests added for new helper
> > > >
> > > > Signed-off-by: Carlos Neira <cneirabustos@gmail.com>
> > > > ---
> > > >   .../bpf/prog_tests/get_ns_current_pid_tgid.c  | 96 +++++++++++++++++++
> > > >   .../bpf/progs/get_ns_current_pid_tgid_kern.c  | 53 ++++++++++
> >
> > It looks like typical naming convention is:
> >
> > prog_test/<something>.c
> > progs/test_<something>.c
> >
> > Let's keep this consistent. I'm about to do a bit smarter Makefile
> > that will capture this convention, so it's good to have less exception
> > to create. Thanks!
> >
> > Otherwise, besides what Yonghong mentioned, this look good to me.
> >
> >
> > > >   2 files changed, 149 insertions(+)
> > > >   create mode 100644 tools/testing/selftests/bpf/prog_tests/get_ns_current_pid_tgid.c
> > > >   create mode 100644 tools/testing/selftests/bpf/progs/get_ns_current_pid_tgid_kern.c
> > > >
> >
> > [...]
> >
> > > > +     prog = bpf_object__find_program_by_title(obj, probe_name);
> > > > +     if (CHECK(!prog, "find_probe",
> > > > +               "prog '%s' not found\n", probe_name))
> > > > +             goto cleanup;
> > > > +
> > > > +     bpf_program__set_type(prog, BPF_PROG_TYPE_RAW_TRACEPOINT);
> > >
> > > Do we need this? I thought libbpf should automatically
> > > infer program type from section name?
> >
> > We used to, until the patch set that Daniel landed today. Now it can be dropped.
> >
> > >
> > > > +
> > > > +     load_attr.obj = obj;
> > > > +     load_attr.log_level = 0;
> > > > +     load_attr.target_btf_path = NULL;
> > > > +     err = bpf_object__load_xattr(&load_attr);
> > > > +     if (CHECK(err, "obj_load",
> > > > +               "failed to load prog '%s': %d\n",
> > > > +               probe_name, err))
> > > > +             goto cleanup;
> > >
> >
> > [...]
>
> Thanks Andrii,
> I have a doubt, I don't find in prog_tests/rdonly_map.c  where is "test_rdo.bss" defined ?, is called in line 43 but I'm missing how to is it used as I don't see it defined.
>

This map is created by libbpf implicitly from global variables used by
BPF object. You just look it up by name, set its value to whatever you
need global variables to be set up to, and that value will be
available to BPF program. From BPF program side, when you update
global variable, that value can be read from user space using that
same test_rdo.bss map. Does it make sense?

> Bests

  reply	other threads:[~2019-10-21 19:18 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-10-17 15:00 [PATCH v14 0/5] BPF: New helper to obtain namespace data from current task Carlos Neira
2019-10-17 15:00 ` [PATCH v14 1/5] fs/nsfs.c: added ns_match Carlos Neira
2019-10-18  9:24   ` Simon Horman
2019-10-17 15:00 ` [PATCH v14 2/5] bpf: added new helper bpf_get_ns_current_pid_tgid Carlos Neira
2019-10-18 17:10   ` Yonghong Song
2019-10-17 15:00 ` [PATCH v14 3/5] tools: Added bpf_get_ns_current_pid_tgid helper Carlos Neira
2019-10-18 17:11   ` Yonghong Song
2019-10-17 15:00 ` [PATCH v14 4/5] tools/testing/selftests/bpf: Add self-tests for new helper Carlos Neira
2019-10-18 17:33   ` Yonghong Song
2019-10-21 18:20     ` Andrii Nakryiko
2019-10-21 19:14       ` Carlos Antonio Neira Bustos
2019-10-21 19:18         ` Andrii Nakryiko [this message]
2019-10-22 16:50           ` Carlos Antonio Neira Bustos
2019-10-17 15:00 ` [PATCH v14 5/5] bpf_helpers_doc.py: Add struct bpf_pidns_info to known types Carlos Neira
2019-10-18 17:34   ` Yonghong Song

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=CAEf4BzY5ZMQJYwU5p-r4bnOcZLGsR1_1iY3-0KKnZyttRbyr6g@mail.gmail.com \
    --to=andrii.nakryiko@gmail.com \
    --cc=bpf@vger.kernel.org \
    --cc=brouer@redhat.com \
    --cc=cneirabustos@gmail.com \
    --cc=ebiederm@xmission.com \
    --cc=netdev@vger.kernel.org \
    --cc=yhs@fb.com \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).