selftests/bpf: Fix compile error when MPTCP not support
Subsystems (4)
PATCH 1/1 selftests/bpf: Fix compile error when MPTCP not support
Fix compile error when MPTCP feature not support, though eBPF core check already done which seems invalid in this situation, the error info like:progs/mptcp_sock.c:49:40: error: no member named 'is_mptcp' in 'struct tcp_sock'
49 | is_mptcp = bpf_core_field_exists(tsk->is_mptcp) ?
The filed created in new definitions with eBPF core feature to solve this build problem, and test case result still ok in MPTCP kernel.
176/1 mptcp/base:OK 176/2 mptcp/mptcpify:OK 176 mptcp:OK
Summary: 1/2 PASSED, 0 SKIPPED, 0 FAILED
--- .../testing/selftests/bpf/progs/mptcp_sock.c | 42 ++++++++++++++----- 1 file changed, 32 insertions(+), 10 deletions(-)
tools/testing/selftests/bpf/progs/mptcp_sock.c +32 -10
@@ -25,13 +25,23 @@ struct { __type(value, struct mptcp_storage); } socket_storage_map SEC(".maps"); +struct tcp_sock___new { +bool is_mptcp; +} __attribute__((preserve_access_index)); + +struct mptcp_sock___new { +__u32 token; +struct sock *first; +char ca_name[TCP_CA_NAME_MAX ]; +} __attribute__((preserve_access_index)); + SEC("sockops")int _sockops (struct bpf_sock_ops *ctx) {struct mptcp_storage *storage; -struct mptcp_sock *msk; +struct mptcp_sock___new *msk;int op = (int )ctx->op; -struct tcp_sock *tsk; +struct tcp_sock___new *tsk;struct bpf_sock *sk;bool is_mptcp;
@@ -42,11 +52,16 @@ int _sockops(struct bpf_sock_ops *ctx)if (!sk)return 1 ; - tsk =bpf_skc_to_tcp_sock (sk); +/* recast pointer to capture new type for compiler */ + tsk = (void *)bpf_skc_to_tcp_sock (sk);if (!tsk)return 1 ; - is_mptcp =bpf_core_field_exists (tsk->is_mptcp) ? tsk->is_mptcp :0 ; +if (bpf_core_field_exists (tsk->is_mptcp)) + is_mptcp =BPF_CORE_READ (tsk, is_mptcp); +else + is_mptcp =0 ; +if (!is_mptcp) { storage =bpf_sk_storage_get (&socket_storage_map, sk,0 ,BPF_SK_STORAGE_GET_F_CREATE );
@@ -57,7 +72,7 @@ int _sockops(struct bpf_sock_ops *ctx)__builtin_memset (storage->ca_name,0 ,TCP_CA_NAME_MAX ); storage->first =NULL ; }else { - msk =bpf_skc_to_mptcp_sock (sk); + msk = (void *)bpf_skc_to_mptcp_sock (sk);if (!msk)return 1 ;
@@ -66,9 +81,9 @@ int _sockops(struct bpf_sock_ops *ctx)if (!storage)return 1 ; - storage->token = msk->token; -__builtin_memcpy (storage->ca_name, msk->ca_name,TCP_CA_NAME_MAX ); - storage->first = msk->first; + storage->token =BPF_CORE_READ (msk, token); +BPF_CORE_READ_STR_INTO (&storage->ca_name, msk, ca_name); + storage->first =BPF_CORE_READ (msk, first); } storage->invoked++; storage->is_mptcp = is_mptcp;
@@ -81,8 +96,15 @@ SEC("fentry/mptcp_pm_new_connection")int BPF_PROG (trace_mptcp_pm_new_connection ,struct mptcp_sock *msk,const struct sock *ssk,int server_side) { -if (!server_side) - token = msk->token; +struct mptcp_sock___new *mskw; + +if (!server_side) { + mskw = (void *)msk; +if (bpf_core_field_exists (mskw->token)) + token =BPF_CORE_READ (mskw, token); +else + token =0 ; + }return 0 ; }
Signature · 1 line
2.43.0
Matthieu Baerts
maintainerHi Tao Chen,
Thank you for having shared this patch.
Quoted 9 lines · Tao Chen
Fix compile error when MPTCP feature not support, though eBPF core check already done which seems invalid in this situation, the error info like:
progs/mptcp_sock.c:49:40: error: no member named 'is_mptcp' in 'structtcp_sock'
49 |is_mptcp=bpf_core_field_exists(tsk->is_mptcp)?The filed created in new definitions with eBPF core feature to solve this build problem, and test case result still ok in MPTCP kernel.
Quoted 6 lines
176/1 mptcp/base:OK 176/2 mptcp/mptcpify:OK 176 mptcp:OKSummary: 1/2 PASSED, 0 SKIPPED, 0 FAILED
Fixes 8039d353217c ("selftests/bpf: Add MPTCP test base")
The commit you mentioned here is more than 2 years old, and as far as I can see, nobody else reported this compilation issue. I guess that's because people used tools/testing/selftests/bpf/config file as expected to populate the kernel config, and I suppose you didn't, right?
I don't think other BPF selftests check for missing kernel config if they are specified in the 'config' file, but even if it is the case, I think it would be better to skip all the MPTCP tests, and not try to have them checking something that doesn't exist: no need to validate these tests if the expected kernel config has not been enabled.
But again, please correct me if I'm wrong, but I don't think there is anything to change here to fix your compilation issue: simply make sure to use this tools/testing/selftests/bpf/config file to generate your kernel config, no?
Cheers,
Matt
Signature · 1 line
Sponsored by the NGI0 Core fund.
Quoted 19 lines · Matthieu Baerts
Hi Tao Chen,
Thank you for having shared this patch.
Quoted 14 lines · Tao Chen
Fix compile error when MPTCP feature not support, though eBPF core check already done which seems invalid in this situation, the error info like:
progs/mptcp_sock.c:49:40: error: no member named 'is_mptcp' in 'structtcp_sock'49 | is_mptcp = bpf_core_field_exists(tsk->is_mptcp) ?The filed created in new definitions with eBPF core feature to solve this build problem, and test case result still ok in MPTCP kernel.
176/1 mptcp/base:OK 176/2 mptcp/mptcpify:OK 176 mptcp:OKSummary: 1/2 PASSED, 0 SKIPPED, 0 FAILED
Quoted 7 lines
Quoted 1 line
Fixes 8039d353217c ("selftests/bpf: Add MPTCP test base")The commit you mentioned here is more than 2 years old, and as far as I can see, nobody else reported this compilation issue. I guess that's because people used
tools/testing/selftests/bpf/configfile as expected to populate the kernel config, and I suppose you didn't, right?
Hi Matt, thank you for your reply, as you said, i did not use tools/testing/selftests/bpf/config to compile kernel, i will use this helpful feature.
Quoted 6 lines
I don't think other BPF selftests check for missing kernel config if they are specified in the 'config' file, but even if it is the case, I think it would be better to skip all the MPTCP tests, and not try to have them checking something that doesn't exist: no need to validate these tests if the expected kernel config has not been enabled.
If i use the kernel not support MPTCP, the compile error still exists, and i can not build the bpf test successfully. Maybe skill the test case seems better when kernel not support. Now that bpf_core_field_exists check already used in the code, i think it is better to use new definition mode.
Quoted 7 lines
But again, please correct me if I'm wrong, but I don't think there is anything to change here to fix your compilation issue: simply make sure to use this
tools/testing/selftests/bpf/configfile to generate your kernel config, no?Cheers,
Matt
Signature · 2 lines
Best Regards Dylane Chen
Matthieu Baerts
maintainerHi Tao, BPF maintainers,
Quoted 39 lines · Tao Chen
Quoted 19 lines · Matthieu Baerts
Hi Tao Chen,
Thank you for having shared this patch.
Quoted 14 lines · Tao Chen
Fix compile error when MPTCP feature not support, though eBPF core check already done which seems invalid in this situation, the error info like:
progs/mptcp_sock.c:49:40: error: no member named 'is_mptcp' in 'structtcp_sock'
49 |is_mptcp=bpf_core_field_exists(tsk->is_mptcp)?The filed created in new definitions with eBPF core feature to solve this build problem, and test case result still ok in MPTCP kernel.
176/1 mptcp/base:OK
176/2 mptcp/mptcpify:OK
176 mptcp:OK
Summary: 1/2 PASSED, 0 SKIPPED, 0 FAILEDQuoted 7 lines
Quoted 1 line
Fixes 8039d353217c ("selftests/bpf: Add MPTCP test base")The commit you mentioned here is more than 2 years old, and as far as I can see, nobody else reported this compilation issue. I guess that's because people used
tools/testing/selftests/bpf/configfile as expected to populate the kernel config, and I suppose you didn't, right?Hi Matt, thank you for your reply, as you said, i did not use
tools/testing/selftests/bpf/config to compile kernel, i will use this helpful feature.Quoted 6 lines
I don't think other BPF selftests check for missing kernel config if they are specified in the 'config' file, but even if it is the case, I think it would be better to skip all the MPTCP tests, and not try to have them checking something that doesn't exist: no need to validate these tests if the expected kernel config has not been enabled.
Quoted 5 lines
If i use the kernel not support MPTCP, the compile error still exists, and i can not build the bpf test successfully. Maybe skill the test case seems better when kernel not support. Now that
bpf_core_field_existscheck already used in the code, i think it is better to use new definition mode.
I understand it would be better, but it means more code to maintain to handle that (and remembering that in future test cases). If that's not necessary, then no need to do the effort.
@BPF maintainers: do we need to support kernels not respecting the tools/testing/selftests/bpf/config file? Should we detect when a required kernel config is not set and skip some tests?
Quoted 4 lines
Quoted 4 lines
But again, please correct me if I'm wrong, but I don't think there is anything to change here to fix your compilation issue: simply make sure to use this
tools/testing/selftests/bpf/configfile to generate your kernel config, no?
Cheers,
Matt
Signature · 1 line
Sponsored by the NGI0 Core fund.
Martin KaFai Lau
reviewerQuoted 48 lines · Matthieu Baerts
Hi Tao, BPF maintainers,
Quoted 39 lines · Tao Chen
Quoted 19 lines · Matthieu Baerts
Hi Tao Chen,
Thank you for having shared this patch.
Quoted 14 lines · Tao Chen
Fix compile error when MPTCP feature not support, though eBPF core check already done which seems invalid in this situation, the error info like:
progs/mptcp_sock.c:49:40: error: no member named 'is_mptcp' in 'structtcp_sock'
49 |is_mptcp=bpf_core_field_exists(tsk->is_mptcp)?The filed created in new definitions with eBPF core feature to solve this build problem, and test case result still ok in MPTCP kernel.
176/1 mptcp/base:OK
176/2 mptcp/mptcpify:OK
176 mptcp:OK
Summary: 1/2 PASSED, 0 SKIPPED, 0 FAILEDQuoted 7 lines
Quoted 1 line
Fixes 8039d353217c ("selftests/bpf: Add MPTCP test base")The commit you mentioned here is more than 2 years old, and as far as I can see, nobody else reported this compilation issue. I guess that's because people used
tools/testing/selftests/bpf/configfile as expected to populate the kernel config, and I suppose you didn't, right?Hi Matt, thank you for your reply, as you said, i did not use
tools/testing/selftests/bpf/config to compile kernel, i will use this helpful feature.Quoted 6 lines
I don't think other BPF selftests check for missing kernel config if they are specified in the 'config' file, but even if it is the case, I think it would be better to skip all the MPTCP tests, and not try to have them checking something that doesn't exist: no need to validate these tests if the expected kernel config has not been enabled.
Quoted 5 lines
If i use the kernel not support MPTCP, the compile error still exists, and i can not build the bpf test successfully. Maybe skill the test case seems better when kernel not support. Now that
bpf_core_field_existscheck already used in the code, i think it is better to use new definition mode.
Quoted 7 lines
I understand it would be better, but it means more code to maintain to handle that (and remembering that in future test cases). If that's not necessary, then no need to do the effort.
@BPF maintainers: do we need to support kernels not respecting the
tools/testing/selftests/bpf/configfile? Should we detect when a required kernel config is not set and skip some tests?
I guess it depends on the CONFIG_. Otherwise, it takes out the goodies of using <vmlinux.h> when writing bpf selftests.
If fixing the config is an option and sounds like it is for Tao, then it is always good to run everything in test_progs.
There are some "___local" definitions in the selftests. If mptcp test wants to go this path, then Matt's request to at least test__skip() makes sense to me.
pw-bot: cr
Quoted 8 lines
Quoted 5 lines
Quoted 5 lines
But again, please correct me if I'm wrong, but I don't think there is anything to change here to fix your compilation issue: simply make sure to use this
tools/testing/selftests/bpf/configfile to generate your kernel config, no?Cheers,
Matt
Hi Tao,
Thank you for your modifications, that's great!
Our CI did some validations and here is its report:
- KVM Validation: normal: Success! ✅
- KVM Validation: debug: Critical: 2 Call Trace(s) - Critical: Global Timeout ❌
- KVM Validation: btf-normal (only bpftest_all): Success! ✅
- KVM Validation: btf-debug (only bpftest_all): Success! ✅
- Task: https://github.com/multipath-tcp/mptcp_net-next/actions/runs/11591171451
Initiator: Patchew Applier
Commits: https://github.com/multipath-tcp/mptcp_net-next/commits/3ec75e78edda
Patchwork: https://patchwork.kernel.org/project/mptcp/list/?series=904592
If there are some issues, you can reproduce them using the same environment as the one used by the CI thanks to a docker image, e.g.:
$ cd [kernel source code]
$ docker run -v "${PWD}:${PWD}:rw" -w "${PWD}" --privileged --rm -it \
--pull always mptcp/mptcp-upstream-virtme-docker:latest \
auto-normalFor more details:
https://github.com/multipath-tcp/mptcp-upstream-virtme-docker
Please note that despite all the efforts that have been already done to have a stable tests suite when executed on a public CI like here, it is possible some reported issues are not due to your modifications. Still, do not hesitate to help us improve that ;-)
Cheers,
MPTCP GH Action bot
Bot operated by Matthieu Baerts (NGI0 Core)