Skip to contentSkip to conversation

Squash to "BPF packet scheduler"

PATCH Superseded Geliang Tang 4 participants 8 messages May 20, 2025 – May 21, 2025

Subsystems (5)

v1 of 3 Superseded Latest is v3 →

lore
Share & tools
lore

Geliang Tang

author reviewer
#0 lore raw

cover Squash to "BPF packet scheduler"

From: Geliang Tang <[email protected]>

Two squash-to patches based on Martin's feedback for "bpf: Add mptcp_subflow bpf_iter support" v3.

Geliang Tang (2):
Squash to "selftests/bpf: Add mptcp_subflow bpf_iter subtest" Squash to "bpf: Export mptcp packet scheduler helpers"

 net/mptcp/bpf.c                                     | 13 +++++++++++++
 tools/testing/selftests/bpf/progs/mptcp_bpf.h       | 10 ++++++++++
 tools/testing/selftests/bpf/progs/mptcp_bpf_iters.c |  2 +-
 3 files changed, 24 insertions(+), 1 deletion(-)
Signature · 1 line
2.43.0
author reviewer
#1 lore raw

PATCH 1/2 Squash to "selftests/bpf: Add mptcp_subflow bpf_iter subtest"

From: Geliang Tang <[email protected]>

Define mptcp_subflow_ctx() using bpf_core_cast as Martin suggested.

---
 tools/testing/selftests/bpf/progs/mptcp_bpf.h       | 10 ++++++++++
 tools/testing/selftests/bpf/progs/mptcp_bpf_iters.c |  2 +-
 2 files changed, 11 insertions(+), 1 deletion(-)
tools/testing/selftests/bpf/progs/mptcp_bpf.h +10 -0
index 4e901941d5dd..815bbf865ee4 100644
@@ -39,6 +39,16 @@ mptcp_subflow_tcp_sock(const struct mptcp_subflow_context *subflow)
 	return subflow->tcp_sock;
 }
 
+static __always_inline struct mptcp_subflow_context *
+mptcp_subflow_ctx(const struct sock *sk)
+{
+	const struct inet_connection_sock *
+		icsk = bpf_core_cast(sk, struct inet_connection_sock);
+
+	/* Use RCU on icsk_ulp_data only for sock diag code */
+	return bpf_core_cast(icsk->icsk_ulp_data, struct mptcp_subflow_context);
+}
+
 /* ksym */
 extern struct mptcp_subflow_context *
 bpf_mptcp_subflow_ctx(const struct sock *sk) __ksym;
tools/testing/selftests/bpf/progs/mptcp_bpf_iters.c +1 -1
index a1d8f9b20259..88a3100dfdc2 100644
@@ -48,7 +48,7 @@ int iters_subflow(struct bpf_sockopt *ctx)
 		goto out;
 
 	/* only to check the following kfunc works */
-	subflow = bpf_mptcp_subflow_ctx(ssk);
+	subflow = mptcp_subflow_ctx(ssk);
 	if (!subflow || subflow->token != msk->token)
 		goto out;
 
Signature · 1 line
2.43.0
maintainer
#2 lore raw

Re: [PATCH mptcp-next 1/2] Squash to "selftests/bpf: Add mptcp_subflow bpf_iter subtest"

Hi Geliang,

Thank you for this follow-up!

Quoted 36 lines · Geliang Tang

From: Geliang Tang <[email protected]>

Define mptcp_subflow_ctx() using bpf_core_cast as Martin suggested.

---
 tools/testing/selftests/bpf/progs/mptcp_bpf.h       | 10 ++++++++++
 tools/testing/selftests/bpf/progs/mptcp_bpf_iters.c |  2 +-
 2 files changed, 11 insertions(+), 1 deletion(-)
tools/testing/selftests/bpf/progs/mptcp_bpf.h +10 -0
index 4e901941d5dd..815bbf865ee4 100644
@@ -39,6 +39,16 @@ mptcp_subflow_tcp_sock(const struct mptcp_subflow_context *subflow)
 	return subflow->tcp_sock;
 }
 
+static __always_inline struct mptcp_subflow_context *
+mptcp_subflow_ctx(const struct sock *sk)
+{
+	const struct inet_connection_sock *
+		icsk = bpf_core_cast(sk, struct inet_connection_sock);
+
+	/* Use RCU on icsk_ulp_data only for sock diag code */
+	return bpf_core_cast(icsk->icsk_ulp_data, struct mptcp_subflow_context);
+}
+
 /* ksym */
 extern struct mptcp_subflow_context *
 bpf_mptcp_subflow_ctx(const struct sock *sk) __ksym;
tools/testing/selftests/bpf/progs/mptcp_bpf_iters.c +0 -0
index a1d8f9b20259..88a3100dfdc2 100644

tools/testing/selftests/bpf/progs/mptcp_bpf_iters.c int iters_subflow(struct bpf_sockopt *ctx) · line 50

Quoted 3 lines
tools/testing/selftests/bpf/progs/mptcp_bpf_iters.c +0 -0
@@ -48,7 +48,7 @@ int iters_subflow(struct bpf_sockopt *ctx)
 		goto out;
 
 	/* only to check the following kfunc works */

Then we can remove this comment.

tools/testing/selftests/bpf/progs/mptcp_bpf_iters.c int iters_subflow(struct bpf_sockopt *ctx) · line 54

Quoted 5 lines
tools/testing/selftests/bpf/progs/mptcp_bpf_iters.c +1 -1
-	subflow = bpf_mptcp_subflow_ctx(ssk);
+	subflow = mptcp_subflow_ctx(ssk);
 	if (!subflow || subflow->token != msk->token)
 		goto out;
 

Note that when reading Martin's review again, it looks like this selftest is not really useful. Maybe we should drop it? WDYT?

If we do, the "common" kfunc should no longer be registered for BPF_PROG_TYPE_CGROUP_SOCKOPT, right? I think it makes sense anyway. I don't think we need that, at least not for the moment. Then, better to restrict to struct_ops to help with the maintenance ; except if you see useful use-cases for this CGroup SockOpt program type?

What we did in the selftest could be done without the kfunc, and we didn't find anything really useful to do with the kfunc, right?

Cheers,
Matt

Signature · 1 line
Sponsored by the NGI0 Core fund.
author reviewer
#3 lore raw

PATCH 2/2 Squash to "bpf: Export mptcp packet scheduler helpers"

In reply to Geliang Tang

From: Geliang Tang <[email protected]>

Define .filter as Martin suggested.

---
 net/mptcp/bpf.c | 13 +++++++++++++
 1 file changed, 13 insertions(+)
net/mptcp/bpf.c +13 -0
index 2b0cfb57df8c..4044a8f2c477 100644
@@ -317,9 +317,22 @@ BTF_ID_FLAGS(func, bpf_mptcp_subflow_queues_empty)
 BTF_ID_FLAGS(func, mptcp_pm_subflow_chk_stale, KF_SLEEPABLE)
 BTF_KFUNCS_END(bpf_mptcp_common_kfunc_ids)
 
+static int bpf_mptcp_common_kfunc_filter(const struct bpf_prog *prog, u32 kfunc_id)
+{
+	if (!btf_id_set8_contains(&bpf_mptcp_common_kfunc_ids, kfunc_id))
+		return 0;
+
+	if (prog->aux->st_ops &&
+	    prog->aux->st_ops != &bpf_mptcp_sched_ops)
+		return -EACCES;
+
+	return 0;
+}
+
 static const struct btf_kfunc_id_set bpf_mptcp_common_kfunc_set = {
 	.owner	= THIS_MODULE,
 	.set	= &bpf_mptcp_common_kfunc_ids,
+	.filter	= bpf_mptcp_common_kfunc_filter,
 };
 
 static int __init bpf_mptcp_kfunc_init(void)
Signature · 1 line
2.43.0
maintainer
#4 lore raw

Re: [PATCH mptcp-next 2/2] Squash to "bpf: Export mptcp packet scheduler helpers"

Hi Geliang,

Quoted 14 lines · Geliang Tang

From: Geliang Tang <[email protected]>

Define .filter as Martin suggested.

---
 net/mptcp/bpf.c | 13 +++++++++++++
 1 file changed, 13 insertions(+)
net/mptcp/bpf.c +0 -0
index 2b0cfb57df8c..4044a8f2c477 100644

net/mptcp/bpf.c BTF_ID_FLAGS(func, bpf_mptcp_subflow_queues_empty) · line 325

Quoted 9 lines
net/mptcp/bpf.c +6 -0
@@ -317,9 +317,22 @@ BTF_ID_FLAGS(func, bpf_mptcp_subflow_queues_empty)
 BTF_ID_FLAGS(func, mptcp_pm_subflow_chk_stale, KF_SLEEPABLE)
 BTF_KFUNCS_END(bpf_mptcp_common_kfunc_ids)
 
+static int bpf_mptcp_common_kfunc_filter(const struct bpf_prog *prog, u32 kfunc_id)
+{
+	if (!btf_id_set8_contains(&bpf_mptcp_common_kfunc_ids, kfunc_id))
+		return 0;
+
+	if (prog->aux->st_ops &&

See my message on the previous patch: maybe we don't need this condition then.

net/mptcp/bpf.c BTF_ID_FLAGS(func, bpf_mptcp_subflow_queues_empty) · line 338

Quoted 13 lines
net/mptcp/bpf.c +7 -0
+	    prog->aux->st_ops != &bpf_mptcp_sched_ops)
+		return -EACCES;
+
+	return 0;
+}
+
 static const struct btf_kfunc_id_set bpf_mptcp_common_kfunc_set = {
 	.owner	= THIS_MODULE,
 	.set	= &bpf_mptcp_common_kfunc_ids,
+	.filter	= bpf_mptcp_common_kfunc_filter,
 };
 
 static int __init bpf_mptcp_kfunc_init(void)

Cheers,
Matt

Signature · 1 line
Sponsored by the NGI0 Core fund.
#5 lore raw

Re: [PATCH mptcp-next 2/2] Squash to "bpf: Export mptcp packet scheduler helpers"

In reply to Geliang Tang
kernel test robot noticed the following build errors:

Hi Geliang,

kernel test robot noticed the following build errors:

[auto build test ERROR on mptcp/export]
[cannot apply to mptcp/export-net linus/master v6.15-rc7 next-20250516] [If your patch is applied to the wrong git tree, kindly drop us a note. And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]

url:    https://github.com/intel-lab-lkp/linux/commits/Geliang-Tang/Squash-to-selftests-bpf-Add-mptcp_subflow-bpf_iter-subtest/20250520-165020
base:   https://github.com/multipath-tcp/mptcp_net-next.git export
patch link:    https://lore.kernel.org/r/9c089a245833c43d55ec240be1b880909af849ce.1747730598.git.tanggeliang%40kylinos.cn
patch subject: [PATCH mptcp-next 2/2] Squash to "bpf: Export mptcp packet scheduler helpers"
config: i386-buildonly-randconfig-005-20250521 (https://download.01.org/0day-ci/archive/20250521/[email protected]/config)
compiler: gcc-12 (Debian 12.2.0-14) 12.2.0
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20250521/[email protected]/reproduce)

If you fix the issue in a separate patch/commit (i.e. not just a new version of the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <[email protected]>
| Closes: https://lore.kernel.org/oe-kbuild-all/[email protected]/

All errors (new ones prefixed by >>):

net/mptcp/bpf.c: In function 'bpf_mptcp_common_kfunc_filter':

>> net/mptcp/bpf.c:326:35: error: 'bpf_mptcp_sched_ops' undeclared (first use in this function); did you mean 'mptcp_sched_ops'?
     326 |             prog->aux->st_ops != &bpf_mptcp_sched_ops)
         |                                   ^~~~~~~~~~~~~~~~~~~
         |                                   mptcp_sched_ops

net/mptcp/bpf.c:326:35: note: each undeclared identifier is reported only once for each function it appears in

vim +326 net/mptcp/bpf.c

319
320 static int bpf_mptcp_common_kfunc_filter(const struct bpf_prog *prog, u32 kfunc_id)
321 {
322 if (!btf_id_set8_contains(&bpf_mptcp_common_kfunc_ids, kfunc_id))
323 return 0;
324
325 if (prog->aux->st_ops &&

 > 326		    prog->aux->st_ops != &bpf_mptcp_sched_ops)

327 return -EACCES;
328
329 return 0;
330 }
331

Signature · 2 lines
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki
#6 lore raw
In reply to Geliang Tang

Hi Geliang,

Thank you for your modifications, that's great!

Our CI did some validations and here is its report:

- KVM Validation: normal: Critical: 82 Call Trace(s) - Critical: Global Timeout ❌
- KVM Validation: debug: Success! ✅
- 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/15133544129

Initiator: Patchew Applier
Commits: https://github.com/multipath-tcp/mptcp_net-next/commits/26fbacaac134
Patchwork: https://patchwork.kernel.org/project/mptcp/list/?series=964483

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)

#7 lore raw
In reply to Geliang Tang

Hi Geliang,

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: Success! ✅
- 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/15133544129

Initiator: Patchew Applier
Commits: https://github.com/multipath-tcp/mptcp_net-next/commits/26fbacaac134
Patchwork: https://patchwork.kernel.org/project/mptcp/list/?series=964483

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)