* [PATCH mptcp-next 1/3] Squash to "bpf: Register mptcp common kfunc set"
2024-11-21 7:10 [PATCH mptcp-next 0/3] Squash to "Add mptcp_subflow bpf_iter support" Geliang Tang
@ 2024-11-21 7:10 ` Geliang Tang
2024-11-21 7:10 ` [PATCH mptcp-next 2/3] Squash to "bpf: Add mptcp_subflow bpf_iter" Geliang Tang
` (3 subsequent siblings)
4 siblings, 0 replies; 7+ messages in thread
From: Geliang Tang @ 2024-11-21 7:10 UTC (permalink / raw)
To: mptcp; +Cc: Geliang Tang
From: Geliang Tang <tanggeliang@kylinos.cn>
Address Martin's comments in v1:
- check IPPROTO_MPTCP in bpf_mptcp_sk.
- add null-checks for the wrappers.
- add more BPF flags for the wrappers.
- register this kfunc set to BPF_PROG_TYPE_CGROUP_SOCKOPT only,
not BPF_PROG_TYPE_UNSPEC.
Signed-off-by: Geliang Tang <tanggeliang@kylinos.cn>
---
net/mptcp/bpf.c | 17 +++++++++++++----
1 file changed, 13 insertions(+), 4 deletions(-)
diff --git a/net/mptcp/bpf.c b/net/mptcp/bpf.c
index e9db856972cb..02038db59956 100644
--- a/net/mptcp/bpf.c
+++ b/net/mptcp/bpf.c
@@ -218,18 +218,27 @@ __bpf_kfunc_start_defs();
__bpf_kfunc static struct mptcp_sock *bpf_mptcp_sk(struct sock *sk)
{
+ if (!sk || sk->sk_protocol != IPPROTO_MPTCP)
+ return NULL;
+
return mptcp_sk(sk);
}
__bpf_kfunc static struct mptcp_subflow_context *
bpf_mptcp_subflow_ctx(const struct sock *sk)
{
+ if (!sk)
+ return NULL;
+
return mptcp_subflow_ctx(sk);
}
__bpf_kfunc static struct sock *
bpf_mptcp_subflow_tcp_sock(const struct mptcp_subflow_context *subflow)
{
+ if (!subflow)
+ return NULL;
+
return mptcp_subflow_tcp_sock(subflow);
}
@@ -299,9 +308,9 @@ __bpf_kfunc static bool bpf_mptcp_subflow_queues_empty(struct sock *sk)
__bpf_kfunc_end_defs();
BTF_KFUNCS_START(bpf_mptcp_common_kfunc_ids)
-BTF_ID_FLAGS(func, bpf_mptcp_sk)
-BTF_ID_FLAGS(func, bpf_mptcp_subflow_ctx)
-BTF_ID_FLAGS(func, bpf_mptcp_subflow_tcp_sock)
+BTF_ID_FLAGS(func, bpf_mptcp_sk, KF_TRUSTED_ARGS | KF_RET_NULL)
+BTF_ID_FLAGS(func, bpf_mptcp_subflow_ctx, KF_RET_NULL)
+BTF_ID_FLAGS(func, bpf_mptcp_subflow_tcp_sock, KF_RET_NULL)
BTF_ID_FLAGS(func, bpf_iter_mptcp_subflow_new, KF_ITER_NEW | KF_TRUSTED_ARGS)
BTF_ID_FLAGS(func, bpf_iter_mptcp_subflow_next, KF_ITER_NEXT | KF_RET_NULL)
BTF_ID_FLAGS(func, bpf_iter_mptcp_subflow_destroy, KF_ITER_DESTROY)
@@ -335,7 +344,7 @@ static int __init bpf_mptcp_kfunc_init(void)
int ret;
ret = register_btf_fmodret_id_set(&bpf_mptcp_fmodret_set);
- ret = ret ?: register_btf_kfunc_id_set(BPF_PROG_TYPE_UNSPEC,
+ ret = ret ?: register_btf_kfunc_id_set(BPF_PROG_TYPE_CGROUP_SOCKOPT,
&bpf_mptcp_common_kfunc_set);
ret = ret ?: register_btf_kfunc_id_set(BPF_PROG_TYPE_STRUCT_OPS,
&bpf_mptcp_sched_kfunc_set);
--
2.45.2
^ permalink raw reply related [flat|nested] 7+ messages in thread* [PATCH mptcp-next 2/3] Squash to "bpf: Add mptcp_subflow bpf_iter"
2024-11-21 7:10 [PATCH mptcp-next 0/3] Squash to "Add mptcp_subflow bpf_iter support" Geliang Tang
2024-11-21 7:10 ` [PATCH mptcp-next 1/3] Squash to "bpf: Register mptcp common kfunc set" Geliang Tang
@ 2024-11-21 7:10 ` Geliang Tang
2024-11-22 2:28 ` kernel test robot
2024-11-21 7:10 ` [PATCH mptcp-next 3/3] Squash to "selftests/bpf: Add mptcp_subflow bpf_iter subtest" Geliang Tang
` (2 subsequent siblings)
4 siblings, 1 reply; 7+ messages in thread
From: Geliang Tang @ 2024-11-21 7:10 UTC (permalink / raw)
To: mptcp; +Cc: Geliang Tang
From: Geliang Tang <tanggeliang@kylinos.cn>
Address Martin's comments in v1:
- bpf_iter_mptcp_subflow_new returns -EINVAL when msk socket lock isn't
held.
Signed-off-by: Geliang Tang <tanggeliang@kylinos.cn>
---
net/mptcp/bpf.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/net/mptcp/bpf.c b/net/mptcp/bpf.c
index 02038db59956..5aaeaf641f7f 100644
--- a/net/mptcp/bpf.c
+++ b/net/mptcp/bpf.c
@@ -252,7 +252,8 @@ bpf_iter_mptcp_subflow_new(struct bpf_iter_mptcp_subflow *it,
if (!msk)
return -EINVAL;
- msk_owned_by_me(msk);
+ if (!lockdep_sock_is_held((const struct sock *)msk))
+ return -EINVAL;
kit->pos = &msk->conn_list;
return 0;
--
2.45.2
^ permalink raw reply related [flat|nested] 7+ messages in thread* [PATCH mptcp-next 3/3] Squash to "selftests/bpf: Add mptcp_subflow bpf_iter subtest"
2024-11-21 7:10 [PATCH mptcp-next 0/3] Squash to "Add mptcp_subflow bpf_iter support" Geliang Tang
2024-11-21 7:10 ` [PATCH mptcp-next 1/3] Squash to "bpf: Register mptcp common kfunc set" Geliang Tang
2024-11-21 7:10 ` [PATCH mptcp-next 2/3] Squash to "bpf: Add mptcp_subflow bpf_iter" Geliang Tang
@ 2024-11-21 7:10 ` Geliang Tang
2024-11-21 7:31 ` [PATCH mptcp-next 0/3] Squash to "Add mptcp_subflow bpf_iter support" MPTCP CI
2024-11-21 8:20 ` MPTCP CI
4 siblings, 0 replies; 7+ messages in thread
From: Geliang Tang @ 2024-11-21 7:10 UTC (permalink / raw)
To: mptcp; +Cc: Geliang Tang
From: Geliang Tang <tanggeliang@kylinos.cn>
IPPROTO_MPTCP is checked in bpf_mptcp_sk(), no need to check it in BPF
program.
bpf_mptcp_sk() and bpf_mptcp_subflow_ctx() may return NULL, need to
check the return values.
Signed-off-by: Geliang Tang <tanggeliang@kylinos.cn>
---
tools/testing/selftests/bpf/progs/mptcp_bpf_iters.c | 7 +++----
1 file changed, 3 insertions(+), 4 deletions(-)
diff --git a/tools/testing/selftests/bpf/progs/mptcp_bpf_iters.c b/tools/testing/selftests/bpf/progs/mptcp_bpf_iters.c
index 1bede22a7e3d..5e475edf37b3 100644
--- a/tools/testing/selftests/bpf/progs/mptcp_bpf_iters.c
+++ b/tools/testing/selftests/bpf/progs/mptcp_bpf_iters.c
@@ -21,12 +21,11 @@ int iters_subflow(struct bpf_sockopt *ctx)
struct mptcp_sock *msk;
int local_ids = 0;
- if (!sk || sk->protocol != IPPROTO_MPTCP ||
- ctx->level != SOL_TCP || ctx->optname != TCP_IS_MPTCP)
+ if (ctx->level != SOL_TCP || ctx->optname != TCP_IS_MPTCP)
return 1;
msk = bpf_mptcp_sk((struct sock *)sk);
- if (msk->pm.server_side || !msk->pm.subflows)
+ if (!msk || msk->pm.server_side || !msk->pm.subflows)
return 1;
msk = bpf_mptcp_sock_acquire(msk);
@@ -53,7 +52,7 @@ int iters_subflow(struct bpf_sockopt *ctx)
/* only to check the following kfunc works */
subflow = bpf_mptcp_subflow_ctx(ssk);
- if (subflow->token != msk->token)
+ if (!subflow || subflow->token != msk->token)
goto out;
ids = local_ids;
--
2.45.2
^ permalink raw reply related [flat|nested] 7+ messages in thread
* Re: [PATCH mptcp-next 0/3] Squash to "Add mptcp_subflow bpf_iter support"
2024-11-21 7:10 [PATCH mptcp-next 0/3] Squash to "Add mptcp_subflow bpf_iter support" Geliang Tang
` (2 preceding siblings ...)
2024-11-21 7:10 ` [PATCH mptcp-next 3/3] Squash to "selftests/bpf: Add mptcp_subflow bpf_iter subtest" Geliang Tang
@ 2024-11-21 7:31 ` MPTCP CI
2024-11-21 8:20 ` MPTCP CI
4 siblings, 0 replies; 7+ messages in thread
From: MPTCP CI @ 2024-11-21 7:31 UTC (permalink / raw)
To: Geliang Tang; +Cc: mptcp
Hi Geliang,
Thank you for your modifications, that's great!
But sadly, our CI spotted some issues with it when trying to build it.
You can find more details there:
https://github.com/multipath-tcp/mptcp_net-next/actions/runs/11948563035
Status: failure
Initiator: Patchew Applier
Commits: https://github.com/multipath-tcp/mptcp_net-next/commits/b85b1ada972f
Patchwork: https://patchwork.kernel.org/project/mptcp/list/?series=911431
Feel free to reply to this email if you cannot access logs, if you need
some support to fix the error, if this doesn't seem to be caused by your
modifications or if the error is a false positive one.
Cheers,
MPTCP GH Action bot
Bot operated by Matthieu Baerts (NGI0 Core)
^ permalink raw reply [flat|nested] 7+ messages in thread* Re: [PATCH mptcp-next 0/3] Squash to "Add mptcp_subflow bpf_iter support"
2024-11-21 7:10 [PATCH mptcp-next 0/3] Squash to "Add mptcp_subflow bpf_iter support" Geliang Tang
` (3 preceding siblings ...)
2024-11-21 7:31 ` [PATCH mptcp-next 0/3] Squash to "Add mptcp_subflow bpf_iter support" MPTCP CI
@ 2024-11-21 8:20 ` MPTCP CI
4 siblings, 0 replies; 7+ messages in thread
From: MPTCP CI @ 2024-11-21 8:20 UTC (permalink / raw)
To: Geliang Tang; +Cc: mptcp
Hi Geliang,
Thank you for your modifications, that's great!
Our CI did some validations and here is its report:
- KVM Validation: normal: Script error! ❓
- KVM Validation: debug: Success! ✅
- KVM Validation: btf-normal (only bpftest_all): Script error! ❓
- KVM Validation: btf-debug (only bpftest_all): Success! ✅
- Task: https://github.com/multipath-tcp/mptcp_net-next/actions/runs/11948563025
Initiator: Patchew Applier
Commits: https://github.com/multipath-tcp/mptcp_net-next/commits/b85b1ada972f
Patchwork: https://patchwork.kernel.org/project/mptcp/list/?series=911431
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-normal
For 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)
^ permalink raw reply [flat|nested] 7+ messages in thread