* [PATCH bpf-next] selftests/bpf: skip lsm_cgroup when don't have trampolines
@ 2022-06-30 22:42 Stanislav Fomichev
2022-06-30 23:48 ` Hao Luo
2022-07-01 13:20 ` patchwork-bot+netdevbpf
0 siblings, 2 replies; 7+ messages in thread
From: Stanislav Fomichev @ 2022-06-30 22:42 UTC (permalink / raw)
To: bpf
Cc: ast, daniel, andrii, martin.lau, song, yhs, john.fastabend,
kpsingh, sdf, haoluo, jolsa
With arch_prepare_bpf_trampoline removed on x86:
#98/1 lsm_cgroup/functional:SKIP
#98 lsm_cgroup:SKIP
Summary: 1/0 PASSED, 1 SKIPPED, 0 FAILED
Fixes: dca85aac8895 ("selftests/bpf: lsm_cgroup functional test")
Signed-off-by: Stanislav Fomichev <sdf@google.com>
---
tools/testing/selftests/bpf/prog_tests/lsm_cgroup.c | 8 ++++++++
1 file changed, 8 insertions(+)
diff --git a/tools/testing/selftests/bpf/prog_tests/lsm_cgroup.c b/tools/testing/selftests/bpf/prog_tests/lsm_cgroup.c
index d40810a742fa..c542d7e80a5b 100644
--- a/tools/testing/selftests/bpf/prog_tests/lsm_cgroup.c
+++ b/tools/testing/selftests/bpf/prog_tests/lsm_cgroup.c
@@ -9,6 +9,10 @@
#include "cgroup_helpers.h"
#include "network_helpers.h"
+#ifndef ENOTSUPP
+#define ENOTSUPP 524
+#endif
+
static struct btf *btf;
static __u32 query_prog_cnt(int cgroup_fd, const char *attach_func)
@@ -100,6 +104,10 @@ static void test_lsm_cgroup_functional(void)
ASSERT_EQ(query_prog_cnt(cgroup_fd, "bpf_lsm_sk_alloc_security"), 0, "prog count");
ASSERT_EQ(query_prog_cnt(cgroup_fd, NULL), 0, "total prog count");
err = bpf_prog_attach(alloc_prog_fd, cgroup_fd, BPF_LSM_CGROUP, 0);
+ if (err == -ENOTSUPP) {
+ test__skip();
+ goto close_cgroup;
+ }
if (!ASSERT_OK(err, "attach alloc_prog_fd"))
goto detach_cgroup;
ASSERT_EQ(query_prog_cnt(cgroup_fd, "bpf_lsm_sk_alloc_security"), 1, "prog count");
--
2.37.0.rc0.161.g10f37bed90-goog
^ permalink raw reply related [flat|nested] 7+ messages in thread* Re: [PATCH bpf-next] selftests/bpf: skip lsm_cgroup when don't have trampolines
2022-06-30 22:42 [PATCH bpf-next] selftests/bpf: skip lsm_cgroup when don't have trampolines Stanislav Fomichev
@ 2022-06-30 23:48 ` Hao Luo
2022-07-01 0:16 ` Stanislav Fomichev
2022-07-01 13:20 ` patchwork-bot+netdevbpf
1 sibling, 1 reply; 7+ messages in thread
From: Hao Luo @ 2022-06-30 23:48 UTC (permalink / raw)
To: Stanislav Fomichev
Cc: bpf, ast, daniel, andrii, martin.lau, song, yhs, john.fastabend,
kpsingh, jolsa
Hi Stan,
On Thu, Jun 30, 2022 at 3:42 PM Stanislav Fomichev <sdf@google.com> wrote:
>
> With arch_prepare_bpf_trampoline removed on x86:
>
> #98/1 lsm_cgroup/functional:SKIP
> #98 lsm_cgroup:SKIP
> Summary: 1/0 PASSED, 1 SKIPPED, 0 FAILED
>
> Fixes: dca85aac8895 ("selftests/bpf: lsm_cgroup functional test")
> Signed-off-by: Stanislav Fomichev <sdf@google.com>
> ---
> tools/testing/selftests/bpf/prog_tests/lsm_cgroup.c | 8 ++++++++
> 1 file changed, 8 insertions(+)
>
> diff --git a/tools/testing/selftests/bpf/prog_tests/lsm_cgroup.c b/tools/testing/selftests/bpf/prog_tests/lsm_cgroup.c
> index d40810a742fa..c542d7e80a5b 100644
> --- a/tools/testing/selftests/bpf/prog_tests/lsm_cgroup.c
> +++ b/tools/testing/selftests/bpf/prog_tests/lsm_cgroup.c
> @@ -9,6 +9,10 @@
> #include "cgroup_helpers.h"
> #include "network_helpers.h"
>
> +#ifndef ENOTSUPP
> +#define ENOTSUPP 524
> +#endif
> +
> static struct btf *btf;
>
> static __u32 query_prog_cnt(int cgroup_fd, const char *attach_func)
> @@ -100,6 +104,10 @@ static void test_lsm_cgroup_functional(void)
> ASSERT_EQ(query_prog_cnt(cgroup_fd, "bpf_lsm_sk_alloc_security"), 0, "prog count");
> ASSERT_EQ(query_prog_cnt(cgroup_fd, NULL), 0, "total prog count");
> err = bpf_prog_attach(alloc_prog_fd, cgroup_fd, BPF_LSM_CGROUP, 0);
> + if (err == -ENOTSUPP) {
> + test__skip();
> + goto close_cgroup;
> + }
It seems ENOTSUPP is only used in the kernel. I wonder whether we
should let libbpf map ENOTSUPP to ENOTSUP, which is the errno used in
userspace and has been used in libbpf.
Maybe the right thing is having bpf syscall return EOPNOTSUPP.
But, anyway, this fix looks good to me.
Acked-by: Hao Luo <haoluo@google.com>
> if (!ASSERT_OK(err, "attach alloc_prog_fd"))
> goto detach_cgroup;
> ASSERT_EQ(query_prog_cnt(cgroup_fd, "bpf_lsm_sk_alloc_security"), 1, "prog count");
> --
> 2.37.0.rc0.161.g10f37bed90-goog
>
^ permalink raw reply [flat|nested] 7+ messages in thread* Re: [PATCH bpf-next] selftests/bpf: skip lsm_cgroup when don't have trampolines
2022-06-30 23:48 ` Hao Luo
@ 2022-07-01 0:16 ` Stanislav Fomichev
2022-07-01 13:21 ` Daniel Borkmann
0 siblings, 1 reply; 7+ messages in thread
From: Stanislav Fomichev @ 2022-07-01 0:16 UTC (permalink / raw)
To: Hao Luo
Cc: bpf, ast, daniel, andrii, martin.lau, song, yhs, john.fastabend,
kpsingh, jolsa
On Thu, Jun 30, 2022 at 4:48 PM Hao Luo <haoluo@google.com> wrote:
>
> Hi Stan,
>
> On Thu, Jun 30, 2022 at 3:42 PM Stanislav Fomichev <sdf@google.com> wrote:
> >
> > With arch_prepare_bpf_trampoline removed on x86:
> >
> > #98/1 lsm_cgroup/functional:SKIP
> > #98 lsm_cgroup:SKIP
> > Summary: 1/0 PASSED, 1 SKIPPED, 0 FAILED
> >
> > Fixes: dca85aac8895 ("selftests/bpf: lsm_cgroup functional test")
> > Signed-off-by: Stanislav Fomichev <sdf@google.com>
> > ---
> > tools/testing/selftests/bpf/prog_tests/lsm_cgroup.c | 8 ++++++++
> > 1 file changed, 8 insertions(+)
> >
> > diff --git a/tools/testing/selftests/bpf/prog_tests/lsm_cgroup.c b/tools/testing/selftests/bpf/prog_tests/lsm_cgroup.c
> > index d40810a742fa..c542d7e80a5b 100644
> > --- a/tools/testing/selftests/bpf/prog_tests/lsm_cgroup.c
> > +++ b/tools/testing/selftests/bpf/prog_tests/lsm_cgroup.c
> > @@ -9,6 +9,10 @@
> > #include "cgroup_helpers.h"
> > #include "network_helpers.h"
> >
> > +#ifndef ENOTSUPP
> > +#define ENOTSUPP 524
> > +#endif
> > +
> > static struct btf *btf;
> >
> > static __u32 query_prog_cnt(int cgroup_fd, const char *attach_func)
> > @@ -100,6 +104,10 @@ static void test_lsm_cgroup_functional(void)
> > ASSERT_EQ(query_prog_cnt(cgroup_fd, "bpf_lsm_sk_alloc_security"), 0, "prog count");
> > ASSERT_EQ(query_prog_cnt(cgroup_fd, NULL), 0, "total prog count");
> > err = bpf_prog_attach(alloc_prog_fd, cgroup_fd, BPF_LSM_CGROUP, 0);
> > + if (err == -ENOTSUPP) {
> > + test__skip();
> > + goto close_cgroup;
> > + }
>
> It seems ENOTSUPP is only used in the kernel. I wonder whether we
> should let libbpf map ENOTSUPP to ENOTSUP, which is the errno used in
> userspace and has been used in libbpf.
Yeah, this comes up occasionally, I don't think we've agreed on some
kind of general policy about what to do with these :-(
Thanks for the review!
> Maybe the right thing is having bpf syscall return EOPNOTSUPP.
>
> But, anyway, this fix looks good to me.
>
> Acked-by: Hao Luo <haoluo@google.com>
>
>
>
> > if (!ASSERT_OK(err, "attach alloc_prog_fd"))
> > goto detach_cgroup;
> > ASSERT_EQ(query_prog_cnt(cgroup_fd, "bpf_lsm_sk_alloc_security"), 1, "prog count");
> > --
> > 2.37.0.rc0.161.g10f37bed90-goog
> >
^ permalink raw reply [flat|nested] 7+ messages in thread* Re: [PATCH bpf-next] selftests/bpf: skip lsm_cgroup when don't have trampolines
2022-07-01 0:16 ` Stanislav Fomichev
@ 2022-07-01 13:21 ` Daniel Borkmann
2022-07-01 16:12 ` Stanislav Fomichev
2022-07-01 17:04 ` Hao Luo
0 siblings, 2 replies; 7+ messages in thread
From: Daniel Borkmann @ 2022-07-01 13:21 UTC (permalink / raw)
To: Stanislav Fomichev, Hao Luo
Cc: bpf, ast, andrii, martin.lau, song, yhs, john.fastabend, kpsingh,
jolsa
On 7/1/22 2:16 AM, Stanislav Fomichev wrote:
> On Thu, Jun 30, 2022 at 4:48 PM Hao Luo <haoluo@google.com> wrote:
>> On Thu, Jun 30, 2022 at 3:42 PM Stanislav Fomichev <sdf@google.com> wrote:
[...]
>>> With arch_prepare_bpf_trampoline removed on x86:
>>>
>>> #98/1 lsm_cgroup/functional:SKIP
>>> #98 lsm_cgroup:SKIP
>>> Summary: 1/0 PASSED, 1 SKIPPED, 0 FAILED
>>>
>>> Fixes: dca85aac8895 ("selftests/bpf: lsm_cgroup functional test")
>>> Signed-off-by: Stanislav Fomichev <sdf@google.com>
>>> ---
>>> tools/testing/selftests/bpf/prog_tests/lsm_cgroup.c | 8 ++++++++
>>> 1 file changed, 8 insertions(+)
>>>
>>> diff --git a/tools/testing/selftests/bpf/prog_tests/lsm_cgroup.c b/tools/testing/selftests/bpf/prog_tests/lsm_cgroup.c
>>> index d40810a742fa..c542d7e80a5b 100644
>>> --- a/tools/testing/selftests/bpf/prog_tests/lsm_cgroup.c
>>> +++ b/tools/testing/selftests/bpf/prog_tests/lsm_cgroup.c
>>> @@ -9,6 +9,10 @@
>>> #include "cgroup_helpers.h"
>>> #include "network_helpers.h"
>>>
>>> +#ifndef ENOTSUPP
>>> +#define ENOTSUPP 524
>>> +#endif
>>> +
>>> static struct btf *btf;
>>>
>>> static __u32 query_prog_cnt(int cgroup_fd, const char *attach_func)
>>> @@ -100,6 +104,10 @@ static void test_lsm_cgroup_functional(void)
>>> ASSERT_EQ(query_prog_cnt(cgroup_fd, "bpf_lsm_sk_alloc_security"), 0, "prog count");
>>> ASSERT_EQ(query_prog_cnt(cgroup_fd, NULL), 0, "total prog count");
>>> err = bpf_prog_attach(alloc_prog_fd, cgroup_fd, BPF_LSM_CGROUP, 0);
>>> + if (err == -ENOTSUPP) {
>>> + test__skip();
>>> + goto close_cgroup;
>>> + }
>>
>> It seems ENOTSUPP is only used in the kernel. I wonder whether we
>> should let libbpf map ENOTSUPP to ENOTSUP, which is the errno used in
>> userspace and has been used in libbpf.
>
> Yeah, this comes up occasionally, I don't think we've agreed on some
> kind of general policy about what to do with these :-(
> Thanks for the review!
Consensus was that for existing code, the ship has sailed to change it given
applications could one way or another depend on this error code, but it should
be avoided for new APIs (e.g. [0]).
Thanks,
Daniel
[0] https://lore.kernel.org/bpf/20211209182349.038ac2b8@kicinski-fedora-pc1c0hjn.dhcp.thefacebook.com/
^ permalink raw reply [flat|nested] 7+ messages in thread* Re: [PATCH bpf-next] selftests/bpf: skip lsm_cgroup when don't have trampolines
2022-07-01 13:21 ` Daniel Borkmann
@ 2022-07-01 16:12 ` Stanislav Fomichev
2022-07-01 17:04 ` Hao Luo
1 sibling, 0 replies; 7+ messages in thread
From: Stanislav Fomichev @ 2022-07-01 16:12 UTC (permalink / raw)
To: Daniel Borkmann
Cc: Hao Luo, bpf, ast, andrii, martin.lau, song, yhs, john.fastabend,
kpsingh, jolsa
On Fri, Jul 1, 2022 at 6:22 AM Daniel Borkmann <daniel@iogearbox.net> wrote:
>
> On 7/1/22 2:16 AM, Stanislav Fomichev wrote:
> > On Thu, Jun 30, 2022 at 4:48 PM Hao Luo <haoluo@google.com> wrote:
> >> On Thu, Jun 30, 2022 at 3:42 PM Stanislav Fomichev <sdf@google.com> wrote:
> [...]
> >>> With arch_prepare_bpf_trampoline removed on x86:
> >>>
> >>> #98/1 lsm_cgroup/functional:SKIP
> >>> #98 lsm_cgroup:SKIP
> >>> Summary: 1/0 PASSED, 1 SKIPPED, 0 FAILED
> >>>
> >>> Fixes: dca85aac8895 ("selftests/bpf: lsm_cgroup functional test")
> >>> Signed-off-by: Stanislav Fomichev <sdf@google.com>
> >>> ---
> >>> tools/testing/selftests/bpf/prog_tests/lsm_cgroup.c | 8 ++++++++
> >>> 1 file changed, 8 insertions(+)
> >>>
> >>> diff --git a/tools/testing/selftests/bpf/prog_tests/lsm_cgroup.c b/tools/testing/selftests/bpf/prog_tests/lsm_cgroup.c
> >>> index d40810a742fa..c542d7e80a5b 100644
> >>> --- a/tools/testing/selftests/bpf/prog_tests/lsm_cgroup.c
> >>> +++ b/tools/testing/selftests/bpf/prog_tests/lsm_cgroup.c
> >>> @@ -9,6 +9,10 @@
> >>> #include "cgroup_helpers.h"
> >>> #include "network_helpers.h"
> >>>
> >>> +#ifndef ENOTSUPP
> >>> +#define ENOTSUPP 524
> >>> +#endif
> >>> +
> >>> static struct btf *btf;
> >>>
> >>> static __u32 query_prog_cnt(int cgroup_fd, const char *attach_func)
> >>> @@ -100,6 +104,10 @@ static void test_lsm_cgroup_functional(void)
> >>> ASSERT_EQ(query_prog_cnt(cgroup_fd, "bpf_lsm_sk_alloc_security"), 0, "prog count");
> >>> ASSERT_EQ(query_prog_cnt(cgroup_fd, NULL), 0, "total prog count");
> >>> err = bpf_prog_attach(alloc_prog_fd, cgroup_fd, BPF_LSM_CGROUP, 0);
> >>> + if (err == -ENOTSUPP) {
> >>> + test__skip();
> >>> + goto close_cgroup;
> >>> + }
> >>
> >> It seems ENOTSUPP is only used in the kernel. I wonder whether we
> >> should let libbpf map ENOTSUPP to ENOTSUP, which is the errno used in
> >> userspace and has been used in libbpf.
> >
> > Yeah, this comes up occasionally, I don't think we've agreed on some
> > kind of general policy about what to do with these :-(
> > Thanks for the review!
>
> Consensus was that for existing code, the ship has sailed to change it given
> applications could one way or another depend on this error code, but it should
> be avoided for new APIs (e.g. [0]).
Ah, great, thanks Daniel!
> Thanks,
> Daniel
>
> [0] https://lore.kernel.org/bpf/20211209182349.038ac2b8@kicinski-fedora-pc1c0hjn.dhcp.thefacebook.com/
^ permalink raw reply [flat|nested] 7+ messages in thread* Re: [PATCH bpf-next] selftests/bpf: skip lsm_cgroup when don't have trampolines
2022-07-01 13:21 ` Daniel Borkmann
2022-07-01 16:12 ` Stanislav Fomichev
@ 2022-07-01 17:04 ` Hao Luo
1 sibling, 0 replies; 7+ messages in thread
From: Hao Luo @ 2022-07-01 17:04 UTC (permalink / raw)
To: Daniel Borkmann
Cc: Stanislav Fomichev, bpf, ast, andrii, martin.lau, song, yhs,
john.fastabend, kpsingh, jolsa
On Fri, Jul 1, 2022 at 6:22 AM Daniel Borkmann <daniel@iogearbox.net> wrote:
>
> On 7/1/22 2:16 AM, Stanislav Fomichev wrote:
> > On Thu, Jun 30, 2022 at 4:48 PM Hao Luo <haoluo@google.com> wrote:
> >> On Thu, Jun 30, 2022 at 3:42 PM Stanislav Fomichev <sdf@google.com> wrote:
[...]
> >>
> >> It seems ENOTSUPP is only used in the kernel. I wonder whether we
> >> should let libbpf map ENOTSUPP to ENOTSUP, which is the errno used in
> >> userspace and has been used in libbpf.
> >
> > Yeah, this comes up occasionally, I don't think we've agreed on some
> > kind of general policy about what to do with these :-(
> > Thanks for the review!
>
> Consensus was that for existing code, the ship has sailed to change it given
> applications could one way or another depend on this error code, but it should
> be avoided for new APIs (e.g. [0]).
>
> Thanks,
> Daniel
>
> [0] https://lore.kernel.org/bpf/20211209182349.038ac2b8@kicinski-fedora-pc1c0hjn.dhcp.thefacebook.com/
Thanks for the reference!
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH bpf-next] selftests/bpf: skip lsm_cgroup when don't have trampolines
2022-06-30 22:42 [PATCH bpf-next] selftests/bpf: skip lsm_cgroup when don't have trampolines Stanislav Fomichev
2022-06-30 23:48 ` Hao Luo
@ 2022-07-01 13:20 ` patchwork-bot+netdevbpf
1 sibling, 0 replies; 7+ messages in thread
From: patchwork-bot+netdevbpf @ 2022-07-01 13:20 UTC (permalink / raw)
To: Stanislav Fomichev
Cc: bpf, ast, daniel, andrii, martin.lau, song, yhs, john.fastabend,
kpsingh, haoluo, jolsa
Hello:
This patch was applied to bpf/bpf-next.git (master)
by Daniel Borkmann <daniel@iogearbox.net>:
On Thu, 30 Jun 2022 15:42:03 -0700 you wrote:
> With arch_prepare_bpf_trampoline removed on x86:
>
> #98/1 lsm_cgroup/functional:SKIP
> #98 lsm_cgroup:SKIP
> Summary: 1/0 PASSED, 1 SKIPPED, 0 FAILED
>
> Fixes: dca85aac8895 ("selftests/bpf: lsm_cgroup functional test")
> Signed-off-by: Stanislav Fomichev <sdf@google.com>
>
> [...]
Here is the summary with links:
- [bpf-next] selftests/bpf: skip lsm_cgroup when don't have trampolines
https://git.kernel.org/bpf/bpf-next/c/b0d93b44641a
You are awesome, thank you!
--
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2022-07-01 17:04 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-06-30 22:42 [PATCH bpf-next] selftests/bpf: skip lsm_cgroup when don't have trampolines Stanislav Fomichev
2022-06-30 23:48 ` Hao Luo
2022-07-01 0:16 ` Stanislav Fomichev
2022-07-01 13:21 ` Daniel Borkmann
2022-07-01 16:12 ` Stanislav Fomichev
2022-07-01 17:04 ` Hao Luo
2022-07-01 13:20 ` patchwork-bot+netdevbpf
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox