[PATCH mptcp-next] Squash to "selftests: bpf: test bpf_skc_to_mptcp_sock"

Geliang Tang posted 1 patch 3 years, 4 months ago
Patches applied successfully (tree, apply log)
git fetch https://github.com/multipath-tcp/mptcp_net-next tags/patchew/50d4d7a13beec75c5172d81c2c6d037fb74efd79.1650947056.git.geliang.tang@suse.com
Maintainers: Shuah Khan <shuah@kernel.org>, John Fastabend <john.fastabend@gmail.com>, Alexei Starovoitov <ast@kernel.org>, Yonghong Song <yhs@fb.com>, Matthieu Baerts <matthieu.baerts@tessares.net>, Song Liu <songliubraving@fb.com>, Mat Martineau <mathew.j.martineau@linux.intel.com>, KP Singh <kpsingh@kernel.org>, Andrii Nakryiko <andrii@kernel.org>, Martin KaFai Lau <kafai@fb.com>, Daniel Borkmann <daniel@iogearbox.net>
There is a newer version of this series
tools/testing/selftests/bpf/progs/mptcp_sock.c | 4 ++++
1 file changed, 4 insertions(+)
[PATCH mptcp-next] Squash to "selftests: bpf: test bpf_skc_to_mptcp_sock"
Posted by Geliang Tang 3 years, 4 months ago
Add CONFIG_MPTCP check.

When CONFIG_MPTCP is not enabled, we'll get a clearer error message:

libbpf: extern CONFIG_MPTCP (strong) not resolved
libbpf: failed to load object './mptcp_sock.o'

The message before is like this:

libbpf: prog '_sockops': BPF program load failed: Invalid argument
libbpf: prog '_sockops': -- BEGIN PROG LOAD LOG --

Signed-off-by: Geliang Tang <geliang.tang@suse.com>
---
 tools/testing/selftests/bpf/progs/mptcp_sock.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/tools/testing/selftests/bpf/progs/mptcp_sock.c b/tools/testing/selftests/bpf/progs/mptcp_sock.c
index 5cfaec4e7245..7b6a25e37de8 100644
--- a/tools/testing/selftests/bpf/progs/mptcp_sock.c
+++ b/tools/testing/selftests/bpf/progs/mptcp_sock.c
@@ -7,6 +7,7 @@
 
 char _license[] SEC("license") = "GPL";
 __u32 _version SEC("version") = 1;
+extern bool CONFIG_MPTCP __kconfig;
 
 struct mptcp_storage {
 	__u32 invoked;
@@ -46,6 +47,9 @@ int _sockops(struct bpf_sock_ops *ctx)
 		if (!storage)
 			return 1;
 	} else {
+		if (!CONFIG_MPTCP)
+			return 1;
+
 		msk = bpf_skc_to_mptcp_sock(sk);
 		if (!msk)
 			return 1;
-- 
2.34.1


Re: [PATCH mptcp-next] Squash to "selftests: bpf: test bpf_skc_to_mptcp_sock"
Posted by Matthieu Baerts 3 years, 4 months ago
Hi Geliang, Mat,

On 26/04/2022 06:26, Geliang Tang wrote:
> Add CONFIG_MPTCP check.
> 
> When CONFIG_MPTCP is not enabled, we'll get a clearer error message:
> 
> libbpf: extern CONFIG_MPTCP (strong) not resolved
> libbpf: failed to load object './mptcp_sock.o'
> 
> The message before is like this:
> 
> libbpf: prog '_sockops': BPF program load failed: Invalid argument
> libbpf: prog '_sockops': -- BEGIN PROG LOAD LOG --

Thank you for the two patches and reviews!

Now in our tree:

- f456d87ca214: "squashed" in "bpf: add bpf_skc_to_mptcp_sock_proto"
- 8aa57e042f44: "squashed" in "selftests: bpf: test bpf_skc_to_mptcp_sock"
- Results: c2a1191f33d3..440ea2eff5af (export)

Builds and tests are now in progress:

https://cirrus-ci.com/github/multipath-tcp/mptcp_net-next/export/20220427T162930
https://github.com/multipath-tcp/mptcp_net-next/actions/workflows/build-validation.yml?query=branch:export

Cheers,
Matt
-- 
Tessares | Belgium | Hybrid Access Solutions
www.tessares.net

Re: [PATCH mptcp-next] Squash to "selftests: bpf: test bpf_skc_to_mptcp_sock"
Posted by Mat Martineau 3 years, 4 months ago
On Tue, 26 Apr 2022, Geliang Tang wrote:

> Add CONFIG_MPTCP check.
>
> When CONFIG_MPTCP is not enabled, we'll get a clearer error message:
>
> libbpf: extern CONFIG_MPTCP (strong) not resolved
> libbpf: failed to load object './mptcp_sock.o'
>
> The message before is like this:
>
> libbpf: prog '_sockops': BPF program load failed: Invalid argument
> libbpf: prog '_sockops': -- BEGIN PROG LOAD LOG --
>
> Signed-off-by: Geliang Tang <geliang.tang@suse.com>
> ---
> tools/testing/selftests/bpf/progs/mptcp_sock.c | 4 ++++
> 1 file changed, 4 insertions(+)
>

Looks like this also requires CONFIG_IKCONFIG and CONFIG_IKCONFIG_PROC, 
can you also add those to tools/testing/selftests/bpf/config? Maybe that 
should be a separate commit, since other bpf test progs appear to rely on 
this undocumented config requirement.

- Mat

> diff --git a/tools/testing/selftests/bpf/progs/mptcp_sock.c b/tools/testing/selftests/bpf/progs/mptcp_sock.c
> index 5cfaec4e7245..7b6a25e37de8 100644
> --- a/tools/testing/selftests/bpf/progs/mptcp_sock.c
> +++ b/tools/testing/selftests/bpf/progs/mptcp_sock.c
> @@ -7,6 +7,7 @@
>
> char _license[] SEC("license") = "GPL";
> __u32 _version SEC("version") = 1;
> +extern bool CONFIG_MPTCP __kconfig;
>
> struct mptcp_storage {
> 	__u32 invoked;
> @@ -46,6 +47,9 @@ int _sockops(struct bpf_sock_ops *ctx)
> 		if (!storage)
> 			return 1;
> 	} else {
> +		if (!CONFIG_MPTCP)
> +			return 1;
> +
> 		msk = bpf_skc_to_mptcp_sock(sk);
> 		if (!msk)
> 			return 1;
> -- 
> 2.34.1
>
>
>

--
Mat Martineau
Intel

Re: [PATCH mptcp-next] Squash to "selftests: bpf: test bpf_skc_to_mptcp_sock"
Posted by Geliang Tang 3 years, 4 months ago
Hi Mat,

Mat Martineau <mathew.j.martineau@linux.intel.com> 于2022年4月27日周三 08:20写道:
>
> On Tue, 26 Apr 2022, Geliang Tang wrote:
>
> > Add CONFIG_MPTCP check.
> >
> > When CONFIG_MPTCP is not enabled, we'll get a clearer error message:
> >
> > libbpf: extern CONFIG_MPTCP (strong) not resolved
> > libbpf: failed to load object './mptcp_sock.o'
> >
> > The message before is like this:
> >
> > libbpf: prog '_sockops': BPF program load failed: Invalid argument
> > libbpf: prog '_sockops': -- BEGIN PROG LOAD LOG --
> >
> > Signed-off-by: Geliang Tang <geliang.tang@suse.com>
> > ---
> > tools/testing/selftests/bpf/progs/mptcp_sock.c | 4 ++++
> > 1 file changed, 4 insertions(+)
> >
>
> Looks like this also requires CONFIG_IKCONFIG and CONFIG_IKCONFIG_PROC,
> can you also add those to tools/testing/selftests/bpf/config? Maybe that
> should be a separate commit, since other bpf test progs appear to rely on
> this undocumented config requirement.

In my test, this bpf base test still works without CONFIG_IKCONFIG and
CONFIG_IKCONFIG_PROC:

> ls /proc/config.gz
ls: cannot access '/proc/config.gz': No such file or directory
> sudo ./test_progs -n 103
#103 mptcp:OK
Summary: 1/3 PASSED, 0 SKIPPED, 0 FAILED

Thanks,
-Geliang




>
> - Mat
>
> > diff --git a/tools/testing/selftests/bpf/progs/mptcp_sock.c b/tools/testing/selftests/bpf/progs/mptcp_sock.c
> > index 5cfaec4e7245..7b6a25e37de8 100644
> > --- a/tools/testing/selftests/bpf/progs/mptcp_sock.c
> > +++ b/tools/testing/selftests/bpf/progs/mptcp_sock.c
> > @@ -7,6 +7,7 @@
> >
> > char _license[] SEC("license") = "GPL";
> > __u32 _version SEC("version") = 1;
> > +extern bool CONFIG_MPTCP __kconfig;
> >
> > struct mptcp_storage {
> >       __u32 invoked;
> > @@ -46,6 +47,9 @@ int _sockops(struct bpf_sock_ops *ctx)
> >               if (!storage)
> >                       return 1;
> >       } else {
> > +             if (!CONFIG_MPTCP)
> > +                     return 1;
> > +
> >               msk = bpf_skc_to_mptcp_sock(sk);
> >               if (!msk)
> >                       return 1;
> > --
> > 2.34.1
> >
> >
> >
>
> --
> Mat Martineau
> Intel
>

Re: [PATCH mptcp-next] Squash to "selftests: bpf: test bpf_skc_to_mptcp_sock"
Posted by Mat Martineau 3 years, 4 months ago
On Wed, 27 Apr 2022, Geliang Tang wrote:

> Hi Mat,
>
> Mat Martineau <mathew.j.martineau@linux.intel.com> 于2022年4月27日周三 08:20写道:
>>
>> On Tue, 26 Apr 2022, Geliang Tang wrote:
>>
>>> Add CONFIG_MPTCP check.
>>>
>>> When CONFIG_MPTCP is not enabled, we'll get a clearer error message:
>>>
>>> libbpf: extern CONFIG_MPTCP (strong) not resolved
>>> libbpf: failed to load object './mptcp_sock.o'
>>>
>>> The message before is like this:
>>>
>>> libbpf: prog '_sockops': BPF program load failed: Invalid argument
>>> libbpf: prog '_sockops': -- BEGIN PROG LOAD LOG --
>>>
>>> Signed-off-by: Geliang Tang <geliang.tang@suse.com>
>>> ---
>>> tools/testing/selftests/bpf/progs/mptcp_sock.c | 4 ++++
>>> 1 file changed, 4 insertions(+)
>>>
>>
>> Looks like this also requires CONFIG_IKCONFIG and CONFIG_IKCONFIG_PROC,
>> can you also add those to tools/testing/selftests/bpf/config? Maybe that
>> should be a separate commit, since other bpf test progs appear to rely on
>> this undocumented config requirement.
>
> In my test, this bpf base test still works without CONFIG_IKCONFIG and
> CONFIG_IKCONFIG_PROC:
>
>> ls /proc/config.gz
> ls: cannot access '/proc/config.gz': No such file or directory
>> sudo ./test_progs -n 103
> #103 mptcp:OK
> Summary: 1/3 PASSED, 0 SKIPPED, 0 FAILED
>

Huh, I wonder what's going on? It fails for me:

$ sudo ./test_progs -v -a mptcp
bpf_testmod.ko is already unloaded.
Loading bpf_testmod.ko...
Successfully loaded bpf_testmod.ko.
libbpf: failed to open system Kconfig
libbpf: failed to load object './mptcp_sock.o'
run_test:FAIL:165
test_base:FAIL:227
libbpf: failed to open system Kconfig
libbpf: failed to load object './mptcp_sock.o'
run_test:FAIL:165
test_base:FAIL:244
#103/1 mptcp/base:FAIL
(cgroup_helpers.c:146: errno: Device or resource busy) Removing cgroup: /mnt/cgroup-test-work-dir831/mptcp
(cgroup_helpers.c:146: errno: Device or resource busy) Removing cgroup: /mnt/cgroup-test-work-dir831
#103 mptcp:FAIL

All error logs:
#103 mptcp:FAIL

Summary: 0/0 PASSED, 0 SKIPPED, 1 FAILED

This is with Fedora 35. I'll check the BPF CI to see if there's any 
information about their configuration that might explain the difference.


- Mat

>
>
>>
>> - Mat
>>
>>> diff --git a/tools/testing/selftests/bpf/progs/mptcp_sock.c b/tools/testing/selftests/bpf/progs/mptcp_sock.c
>>> index 5cfaec4e7245..7b6a25e37de8 100644
>>> --- a/tools/testing/selftests/bpf/progs/mptcp_sock.c
>>> +++ b/tools/testing/selftests/bpf/progs/mptcp_sock.c
>>> @@ -7,6 +7,7 @@
>>>
>>> char _license[] SEC("license") = "GPL";
>>> __u32 _version SEC("version") = 1;
>>> +extern bool CONFIG_MPTCP __kconfig;
>>>
>>> struct mptcp_storage {
>>>       __u32 invoked;
>>> @@ -46,6 +47,9 @@ int _sockops(struct bpf_sock_ops *ctx)
>>>               if (!storage)
>>>                       return 1;
>>>       } else {
>>> +             if (!CONFIG_MPTCP)
>>> +                     return 1;
>>> +
>>>               msk = bpf_skc_to_mptcp_sock(sk);
>>>               if (!msk)
>>>                       return 1;
>>> --
>>> 2.34.1
>>>
>>>
>>>
>>
>> --
>> Mat Martineau
>> Intel
>>
>

--
Mat Martineau
Intel
Re: [PATCH mptcp-next] Squash to "selftests: bpf: test bpf_skc_to_mptcp_sock"
Posted by Geliang Tang 3 years, 4 months ago
Hi Mat,


Mat Martineau <mathew.j.martineau@linux.intel.com> 于2022年4月28日周四 05:47写道:
>
> On Wed, 27 Apr 2022, Geliang Tang wrote:
>
> > Hi Mat,
> >
> > Mat Martineau <mathew.j.martineau@linux.intel.com> 于2022年4月27日周三 08:20写道:
> >>
> >> On Tue, 26 Apr 2022, Geliang Tang wrote:
> >>
> >>> Add CONFIG_MPTCP check.
> >>>
> >>> When CONFIG_MPTCP is not enabled, we'll get a clearer error message:
> >>>
> >>> libbpf: extern CONFIG_MPTCP (strong) not resolved
> >>> libbpf: failed to load object './mptcp_sock.o'
> >>>
> >>> The message before is like this:
> >>>
> >>> libbpf: prog '_sockops': BPF program load failed: Invalid argument
> >>> libbpf: prog '_sockops': -- BEGIN PROG LOAD LOG --
> >>>
> >>> Signed-off-by: Geliang Tang <geliang.tang@suse.com>
> >>> ---
> >>> tools/testing/selftests/bpf/progs/mptcp_sock.c | 4 ++++
> >>> 1 file changed, 4 insertions(+)
> >>>
> >>
> >> Looks like this also requires CONFIG_IKCONFIG and CONFIG_IKCONFIG_PROC,
> >> can you also add those to tools/testing/selftests/bpf/config? Maybe that
> >> should be a separate commit, since other bpf test progs appear to rely on
> >> this undocumented config requirement.
> >
> > In my test, this bpf base test still works without CONFIG_IKCONFIG and
> > CONFIG_IKCONFIG_PROC:
> >
> >> ls /proc/config.gz
> > ls: cannot access '/proc/config.gz': No such file or directory
> >> sudo ./test_progs -n 103
> > #103 mptcp:OK
> > Summary: 1/3 PASSED, 0 SKIPPED, 0 FAILED
> >
>
> Huh, I wonder what's going on? It fails for me:
>
> $ sudo ./test_progs -v -a mptcp
> bpf_testmod.ko is already unloaded.
> Loading bpf_testmod.ko...
> Successfully loaded bpf_testmod.ko.
> libbpf: failed to open system Kconfig
> libbpf: failed to load object './mptcp_sock.o'
> run_test:FAIL:165
> test_base:FAIL:227
> libbpf: failed to open system Kconfig
> libbpf: failed to load object './mptcp_sock.o'
> run_test:FAIL:165
> test_base:FAIL:244
> #103/1 mptcp/base:FAIL
> (cgroup_helpers.c:146: errno: Device or resource busy) Removing cgroup: /mnt/cgroup-test-work-dir831/mptcp
> (cgroup_helpers.c:146: errno: Device or resource busy) Removing cgroup: /mnt/cgroup-test-work-dir831
> #103 mptcp:FAIL
>
> All error logs:
> #103 mptcp:FAIL
>
> Summary: 0/0 PASSED, 0 SKIPPED, 1 FAILED
>
> This is with Fedora 35. I'll check the BPF CI to see if there's any
> information about their configuration that might explain the difference.

I figure it out. libbpf reads /boot/config-* first, then /proc/config.gz:

 1840 static int bpf_object__read_kconfig_file(struct bpf_object *obj,
void *data)
 1841 {
 1842         char buf[PATH_MAX];
 1843         struct utsname uts;
 1844         int len, err = 0;
 1845         gzFile file;
 1846
 1847         uname(&uts);
 1848         len = snprintf(buf, PATH_MAX, "/boot/config-%s", uts.release);
 1849         if (len < 0)
 1850                 return -EINVAL;
 1851         else if (len >= PATH_MAX)
 1852                 return -ENAMETOOLONG;
 1853
 1854         /* gzopen also accepts uncompressed files. */
 1855         file = gzopen(buf, "r");
 1856         if (!file)
 1857                 file = gzopen("/proc/config.gz", "r");

So we do need to add CONFIG_IKCONFIG and CONFIG_IKCONFIG_PROC in
config. I'll send a v2 as a dedicated patch.

Thanks,
-Geliang


>
>
> - Mat
>
> >
> >
> >>
> >> - Mat
> >>
> >>> diff --git a/tools/testing/selftests/bpf/progs/mptcp_sock.c b/tools/testing/selftests/bpf/progs/mptcp_sock.c
> >>> index 5cfaec4e7245..7b6a25e37de8 100644
> >>> --- a/tools/testing/selftests/bpf/progs/mptcp_sock.c
> >>> +++ b/tools/testing/selftests/bpf/progs/mptcp_sock.c
> >>> @@ -7,6 +7,7 @@
> >>>
> >>> char _license[] SEC("license") = "GPL";
> >>> __u32 _version SEC("version") = 1;
> >>> +extern bool CONFIG_MPTCP __kconfig;
> >>>
> >>> struct mptcp_storage {
> >>>       __u32 invoked;
> >>> @@ -46,6 +47,9 @@ int _sockops(struct bpf_sock_ops *ctx)
> >>>               if (!storage)
> >>>                       return 1;
> >>>       } else {
> >>> +             if (!CONFIG_MPTCP)
> >>> +                     return 1;
> >>> +
> >>>               msk = bpf_skc_to_mptcp_sock(sk);
> >>>               if (!msk)
> >>>                       return 1;
> >>> --
> >>> 2.34.1
> >>>
> >>>
> >>>
> >>
> >> --
> >> Mat Martineau
> >> Intel
> >>
> >
>
> --
> Mat Martineau
> Intel

Re: [PATCH mptcp-next] Squash to "selftests: bpf: test bpf_skc_to_mptcp_sock"
Posted by Mat Martineau 3 years, 4 months ago
On Tue, 26 Apr 2022, Mat Martineau wrote:

> On Tue, 26 Apr 2022, Geliang Tang wrote:
>
>> Add CONFIG_MPTCP check.
>> 
>> When CONFIG_MPTCP is not enabled, we'll get a clearer error message:
>> 
>> libbpf: extern CONFIG_MPTCP (strong) not resolved
>> libbpf: failed to load object './mptcp_sock.o'
>> 
>> The message before is like this:
>> 
>> libbpf: prog '_sockops': BPF program load failed: Invalid argument
>> libbpf: prog '_sockops': -- BEGIN PROG LOAD LOG --
>> 
>> Signed-off-by: Geliang Tang <geliang.tang@suse.com>
>> ---
>> tools/testing/selftests/bpf/progs/mptcp_sock.c | 4 ++++
>> 1 file changed, 4 insertions(+)
>> 
>
> Looks like this also requires CONFIG_IKCONFIG and CONFIG_IKCONFIG_PROC, can 
> you also add those to tools/testing/selftests/bpf/config? Maybe that should 
> be a separate commit, since other bpf test progs appear to rely on this 
> undocumented config requirement.
>

I hit 'send' too soon... We should still squash this, and add that second 
commit for the config information.

- Mat

>
>> diff --git a/tools/testing/selftests/bpf/progs/mptcp_sock.c 
>> b/tools/testing/selftests/bpf/progs/mptcp_sock.c
>> index 5cfaec4e7245..7b6a25e37de8 100644
>> --- a/tools/testing/selftests/bpf/progs/mptcp_sock.c
>> +++ b/tools/testing/selftests/bpf/progs/mptcp_sock.c
>> @@ -7,6 +7,7 @@
>> 
>> char _license[] SEC("license") = "GPL";
>> __u32 _version SEC("version") = 1;
>> +extern bool CONFIG_MPTCP __kconfig;
>> 
>> struct mptcp_storage {
>> 	__u32 invoked;
>> @@ -46,6 +47,9 @@ int _sockops(struct bpf_sock_ops *ctx)
>> 		if (!storage)
>> 			return 1;
>> 	} else {
>> +		if (!CONFIG_MPTCP)
>> +			return 1;
>> +
>> 		msk = bpf_skc_to_mptcp_sock(sk);
>> 		if (!msk)
>> 			return 1;
>> -- 
>> 2.34.1
>> 
>> 
>> 
>
> --
> Mat Martineau
> Intel
>
>

--
Mat Martineau
Intel