mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: "zhudi (E)" <zhudi2@huawei.com>
To: Alexei Starovoitov <alexei.starovoitov@gmail.com>
Cc: Andrii Nakryiko <andrii.nakryiko@gmail.com>,
	Alexei Starovoitov <ast@kernel.org>,
	"David S. Miller" <davem@davemloft.net>,
	Daniel Borkmann <daniel@iogearbox.net>,
	Andrii Nakryiko <andrii@kernel.org>,
	Martin KaFai Lau <kafai@fb.com>, Song Liu <songliubraving@fb.com>,
	Yonghong Song <yhs@fb.com>,
	John Fastabend <john.fastabend@gmail.com>,
	KP Singh <kpsingh@kernel.org>,
	Jakub Sitnicki <jakub@cloudflare.com>, bpf <bpf@vger.kernel.org>,
	LKML <linux-kernel@vger.kernel.org>,
	"Luzhihao (luzhihao, Euler)" <luzhihao@huawei.com>,
	"Chenxiang (EulerOS)" <rose.chen@huawei.com>
Subject: Re: [PATCH bpf-next v6 2/2] selftests: bpf: test BPF_PROG_QUERY for progs attached to sockmap
Date: Fri, 21 Jan 2022 06:19:19 +0000	[thread overview]
Message-ID: <6853c9b97c334daeb7c2c1b35661f5a2@huawei.com> (raw)

> > Add test for querying progs attached to sockmap. we use an existing
> > libbpf query interface to query prog cnt before and after progs
> > attaching to sockmap and check whether the queried prog id is right.
> >
> > Signed-off-by: Di Zhu <zhudi2@huawei.com>
> > Acked-by: Yonghong Song <yhs@fb.com>
> > ---
> >  .../selftests/bpf/prog_tests/sockmap_basic.c  | 66 +++++++++++++++++++
> >  .../bpf/progs/test_sockmap_progs_query.c      | 24 +++++++
> >  2 files changed, 90 insertions(+)
> >  create mode 100644
> tools/testing/selftests/bpf/progs/test_sockmap_progs_query.c
> >
> > diff --git a/tools/testing/selftests/bpf/prog_tests/sockmap_basic.c
> b/tools/testing/selftests/bpf/prog_tests/sockmap_basic.c
> > index 85db0f4cdd95..1ab57cdc4ae4 100644
> > --- a/tools/testing/selftests/bpf/prog_tests/sockmap_basic.c
> > +++ b/tools/testing/selftests/bpf/prog_tests/sockmap_basic.c
> > @@ -8,6 +8,7 @@
> >  #include "test_sockmap_update.skel.h"
> >  #include "test_sockmap_invalid_update.skel.h"
> >  #include "test_sockmap_skb_verdict_attach.skel.h"
> > +#include "test_sockmap_progs_query.skel.h"
> >  #include "bpf_iter_sockmap.skel.h"
> >
> >  #define TCP_REPAIR             19      /* TCP sock is under repair
> right now */
> > @@ -315,6 +316,63 @@ static void test_sockmap_skb_verdict_attach(enum
> bpf_attach_type first,
> >         test_sockmap_skb_verdict_attach__destroy(skel);
> >  }
> >
> > +static __u32 query_prog_id(int prog_fd)
> > +{
> > +       struct bpf_prog_info info = {};
> > +       __u32 info_len = sizeof(info);
> > +       int err;
> > +
> > +       err = bpf_obj_get_info_by_fd(prog_fd, &info, &info_len);
> > +       if (!ASSERT_OK(err, "bpf_obj_get_info_by_fd") ||
> > +           !ASSERT_EQ(info_len, sizeof(info), "bpf_obj_get_info_by_fd"))
> > +               return 0;
> > +
> > +       return info.id;
> > +}
> > +
> > +static void test_sockmap_progs_query(enum bpf_attach_type attach_type)
> > +{
> > +       struct test_sockmap_progs_query *skel;
> > +       int err, map_fd, verdict_fd, duration = 0;
> 
> The 'duration' is unused.
> You should have seen a warning while compiling the selftests?
> 
> Anyway. I've fixed it while applying.

Thank you. I'll be more careful next time.


             reply	other threads:[~2022-01-21  6:19 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-01-21  6:19 zhudi (E) [this message]
  -- strict thread matches above, loose matches on Subject: below --
2022-01-19  1:40 [PATCH bpf-next v6 1/2] bpf: support " Di Zhu
2022-01-19  1:40 ` [PATCH bpf-next v6 2/2] selftests: bpf: test " Di Zhu
2022-01-20 18:49   ` Jakub Sitnicki
2022-01-21  5:36   ` 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=6853c9b97c334daeb7c2c1b35661f5a2@huawei.com \
    --to=zhudi2@huawei.com \
    --cc=alexei.starovoitov@gmail.com \
    --cc=andrii.nakryiko@gmail.com \
    --cc=andrii@kernel.org \
    --cc=ast@kernel.org \
    --cc=bpf@vger.kernel.org \
    --cc=daniel@iogearbox.net \
    --cc=davem@davemloft.net \
    --cc=jakub@cloudflare.com \
    --cc=john.fastabend@gmail.com \
    --cc=kafai@fb.com \
    --cc=kpsingh@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=luzhihao@huawei.com \
    --cc=rose.chen@huawei.com \
    --cc=songliubraving@fb.com \
    --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

all inboxes | Powered by JetHome®