[<prev] [next>] [day] [month] [year] [list]
Message-ID: <6853c9b97c334daeb7c2c1b35661f5a2@huawei.com>
Date: Fri, 21 Jan 2022 06:19:19 +0000
From: "zhudi (E)" <zhudi2@...wei.com>
To: Alexei Starovoitov <alexei.starovoitov@...il.com>
CC: Andrii Nakryiko <andrii.nakryiko@...il.com>,
Alexei Starovoitov <ast@...nel.org>,
"David S. Miller" <davem@...emloft.net>,
Daniel Borkmann <daniel@...earbox.net>,
Andrii Nakryiko <andrii@...nel.org>,
Martin KaFai Lau <kafai@...com>,
Song Liu <songliubraving@...com>, Yonghong Song <yhs@...com>,
John Fastabend <john.fastabend@...il.com>,
KP Singh <kpsingh@...nel.org>,
Jakub Sitnicki <jakub@...udflare.com>,
bpf <bpf@...r.kernel.org>, LKML <linux-kernel@...r.kernel.org>,
"Luzhihao (luzhihao, Euler)" <luzhihao@...wei.com>,
"Chenxiang (EulerOS)" <rose.chen@...wei.com>
Subject: Re: [PATCH bpf-next v6 2/2] selftests: bpf: test BPF_PROG_QUERY for
progs attached to sockmap
> > 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@...wei.com>
> > Acked-by: Yonghong Song <yhs@...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.
Powered by blists - more mailing lists