Skip to contentSkip to conversation

"add mptcp_subflow bpf_iter v3" fixes

PATCH In review Geliang Tang 2 participants 10 messages Sep 10, 2024 – Sep 11, 2024

Subsystems (3)
lore
Share & tools
lore

Geliang Tang

author reviewer
#0 lore raw

cover "add mptcp_subflow bpf_iter v3" fixes

From: Geliang Tang <[email protected]>

It's better to register mptcp_subflow bpf_iter helpers in common_btf_ids in kernel/bpf/helpers.c, not in bpf_mptcp_sched_kfunc_ids in net/mptcp/bpf.c.

Geliang Tang (2):
Squash to "bpf: Add mptcp_subflow bpf_iter" Squash to "bpf: Register mptcp tracing kfunc set"

 kernel/bpf/helpers.c | 5 +++++
 net/mptcp/bpf.c      | 3 ---
 2 files changed, 5 insertions(+), 3 deletions(-)
Signature · 1 line
2.43.0
author reviewer
#1 lore raw

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

From: Geliang Tang <[email protected]>

Register mptcp_subflow bpf_iter helpers in common_btf_ids in kernel/bpf/helpers.c, then they can be used on a larger scale, not only in types BPF_PROG_TYPE_TRACING and BPF_PROG_TYPE_STRUCT_OPS.

---
 kernel/bpf/helpers.c | 5 +++++
 1 file changed, 5 insertions(+)
kernel/bpf/helpers.c +5 -0
index b5f0adae8293..649ec8305b3f 100644
@@ -3023,6 +3023,11 @@ BTF_ID_FLAGS(func, bpf_preempt_enable)
 BTF_ID_FLAGS(func, bpf_iter_bits_new, KF_ITER_NEW)
 BTF_ID_FLAGS(func, bpf_iter_bits_next, KF_ITER_NEXT | KF_RET_NULL)
 BTF_ID_FLAGS(func, bpf_iter_bits_destroy, KF_ITER_DESTROY)
+#ifdef CONFIG_MPTCP
+BTF_ID_FLAGS(func, bpf_iter_mptcp_subflow_new)
+BTF_ID_FLAGS(func, bpf_iter_mptcp_subflow_next)
+BTF_ID_FLAGS(func, bpf_iter_mptcp_subflow_destroy)
+#endif
 BTF_KFUNCS_END(common_btf_ids)
 
 static const struct btf_kfunc_id_set common_kfunc_set = {
Signature · 1 line
2.43.0
author reviewer
#9 lore raw

PATCH 2/2 Squash to "bpf: Register mptcp tracing kfunc set"

In reply to Geliang Tang

From: Geliang Tang <[email protected]>

'''
Since the kfuncs mptcp_subflow_active() and mptcp_subflow_set_scheduled() are invoked in the mptcp_subflow bpf_iter test in a ftrace hook for mptcp_sched_get_send(), it's necessary to register them into a BPF_PROG_TYPE_TRACING type kfunc set to allow them to be invoked in the hook.
'''

---
 net/mptcp/bpf.c | 3 ---
 1 file changed, 3 deletions(-)
net/mptcp/bpf.c +0 -3
index 0b7a0c2634c4..31a3c9c1d681 100644
@@ -260,9 +260,6 @@ __bpf_kfunc bool bpf_mptcp_subflow_queues_empty(struct sock *sk)
 __bpf_kfunc_end_defs();
 
 BTF_KFUNCS_START(bpf_mptcp_sched_kfunc_ids)
-BTF_ID_FLAGS(func, bpf_iter_mptcp_subflow_new)
-BTF_ID_FLAGS(func, bpf_iter_mptcp_subflow_next)
-BTF_ID_FLAGS(func, bpf_iter_mptcp_subflow_destroy)
 BTF_ID_FLAGS(func, mptcp_subflow_active)
 BTF_ID_FLAGS(func, mptcp_subflow_set_scheduled)
 BTF_ID_FLAGS(func, bpf_mptcp_subflow_ctx_by_pos)
Signature · 1 line
2.43.0
maintainer
#2 lore raw

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

In reply to Geliang Tang

Hi Geliang,

Quoted 5 lines · Geliang Tang

From: Geliang Tang <[email protected]>

Register mptcp_subflow bpf_iter helpers in common_btf_ids in kernel/bpf/helpers.c, then they can be used on a larger scale, not only in types BPF_PROG_TYPE_TRACING and BPF_PROG_TYPE_STRUCT_OPS.

Why could they not be used in these types? I find it good to have them defined in net/mptcp, from a maintenance point of view.

Also, the different bpf_iter_xxx helpers defined there look generic. While here, it is specific to MPTCP, I'm not even sure that would be OK to add them there. Is it not OK to define them only in net/mptcp/bpf.c? (or at least for the moment)

Cheers,
Matt

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

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

Hi Matt,

Quoted 14 lines · Matthieu Baerts

Hi Geliang,

Quoted 6 lines · Geliang Tang

From: Geliang Tang <[email protected]>

Register mptcp_subflow bpf_iter helpers in common_btf_ids in kernel/bpf/helpers.c, then they can be used on a larger scale, not only in types BPF_PROG_TYPE_TRACING and BPF_PROG_TYPE_STRUCT_OPS.

Why could they not be used in these types? I find it good to have them
defined in net/mptcp, from a maintenance point of view.

Quoted 5 lines

Also, the different bpf_iter_xxx helpers defined there look generic. While here, it is specific to MPTCP, I'm not even sure that would be OK
to add them there. Is it not OK to define them only in net/mptcp/bpf.c?

Yes, a new test for #484 (BPF: setsockopt on an MPTCP socket: check support) will use these helpers in "cgroup/setsockopt", that is the BPF_PROG_TYPE_CGROUP_SOCKOPT type.

register_btf_kfunc_id_set(BPF_PROG_TYPE_CGROUP_SOCKOPT,

		&bpf_mptcp_sched_kfunc_set);

will fail, since BPF_PROG_TYPE_CGROUP_SOCKOPT is not allow to register more kfuncs (see bpf_prog_type_to_kfunc_hook() in kernel/bpf/btf.c).

So I have to move them into common_btf_ids in kernel/bpf/helpers.c to allow them can be used in almost every BPF program type.

Thanks,
-Geliang

Quoted 4 lines

(or at least for the moment)

Cheers,
Matt

maintainer
#4 lore raw

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

Hi Geliang,

Quoted 27 lines · Geliang Tang

Hi Matt,

Quoted 14 lines · Matthieu Baerts

Hi Geliang,

Quoted 6 lines · Geliang Tang

From: Geliang Tang <[email protected]>

Register mptcp_subflow bpf_iter helpers in common_btf_ids in kernel/bpf/helpers.c, then they can be used on a larger scale, not only in types BPF_PROG_TYPE_TRACING and BPF_PROG_TYPE_STRUCT_OPS.

Why could they not be used in these types? I find it good to have them
defined in net/mptcp, from a maintenance point of view.

Quoted 5 lines

Also, the different bpf_iter_xxx helpers defined there look generic. While here, it is specific to MPTCP, I'm not even sure that would be OK
to add them there. Is it not OK to define them only in net/mptcp/bpf.c?

Yes, a new test for #484 (BPF: setsockopt on an MPTCP socket: check support) will use these helpers in "cgroup/setsockopt", that is the BPF_PROG_TYPE_CGROUP_SOCKOPT type.

Quoted 8 lines

register_btf_kfunc_id_set(BPF_PROG_TYPE_CGROUP_SOCKOPT,

		&bpf_mptcp_sched_kfunc_set);

will fail, since BPF_PROG_TYPE_CGROUP_SOCKOPT is not allow to register more kfuncs (see bpf_prog_type_to_kfunc_hook() in kernel/bpf/btf.c).

So I have to move them into common_btf_ids in kernel/bpf/helpers.c to allow them can be used in almost every BPF program type.

OK, but then I guess these helpers can be upstreamed before the packet schedulers, right?

Cheers,
Matt

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

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

Quoted 40 lines · Matthieu Baerts

Hi Geliang,

Quoted 37 lines · Geliang Tang

Hi Matt,

Quoted 14 lines · Matthieu Baerts

Hi Geliang,

Quoted 6 lines · Geliang Tang

From: Geliang Tang <[email protected]>

Register mptcp_subflow bpf_iter helpers in common_btf_ids in kernel/bpf/helpers.c, then they can be used on a larger scale, not only in types BPF_PROG_TYPE_TRACING and BPF_PROG_TYPE_STRUCT_OPS.

Why could they not be used in these types? I find it good to have them
defined in net/mptcp, from a maintenance point of view.

Quoted 7 lines

Also, the different bpf_iter_xxx helpers defined there look generic.
While here, it is specific to MPTCP, I'm not even sure that would be
OK
to add them there. Is it not OK to define them only in net/mptcp/bpf.c?

Yes, a new test for #484 (BPF: setsockopt on an MPTCP socket: check support) will use these helpers in "cgroup/setsockopt", that is the BPF_PROG_TYPE_CGROUP_SOCKOPT type.

register_btf_kfunc_id_set(BPF_PROG_TYPE_CGROUP_SOCKOPT,

		&bpf_mptcp_sched_kfunc_set);

will fail, since BPF_PROG_TYPE_CGROUP_SOCKOPT is not allow to register
more kfuncs (see bpf_prog_type_to_kfunc_hook() in kernel/bpf/btf.c).

Quoted 7 lines
Quoted 3 lines

So I have to move them into common_btf_ids in kernel/bpf/helpers.c to
allow them can be used in almost every BPF program type.

OK, but then I guess these helpers can be upstreamed before the packet
schedulers, right?

Yes, indeed. I hope them can be upstreamed after the "new MPTCP subflow subtest" set under reviewing on BPF list.

So this set should be applied in this order:

selftests/bpf: Add mptcp subflow example selftests/bpf: Add getsockopt to inspect mptcp subflow selftests/bpf: Add mptcp subflow subtest
bpf: Add mptcp_subflow bpf_iter
bpf: Register mptcp tracing kfunc set selftests/bpf: Add mptcp_subflow bpf_iter test prog selftests/bpf: Add mptcp_subflow bpf_iter subtest selftests/bpf: Add bpf scheduler test selftests/bpf: Add bpf_first scheduler & test

Thanks,
-Geliang

Quoted 3 lines

Cheers,
Matt

maintainer
#6 lore raw

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

Quoted 45 lines · Geliang Tang
Quoted 44 lines · Matthieu Baerts

Hi Geliang,

Quoted 40 lines · Geliang Tang

Hi Matt,

Quoted 14 lines · Matthieu Baerts

Hi Geliang,

Quoted 6 lines · Geliang Tang

From: Geliang Tang <[email protected]>

Register mptcp_subflow bpf_iter helpers in common_btf_ids in kernel/bpf/helpers.c, then they can be used on a larger scale, not only in types BPF_PROG_TYPE_TRACING and BPF_PROG_TYPE_STRUCT_OPS.

Why could they not be used in these types? I find it good to have them
defined in net/mptcp, from a maintenance point of view.

Quoted 7 lines

Also, the different bpf_iter_xxx helpers defined there look generic.
While here, it is specific to MPTCP, I'm not even sure that would be
OK
to add them there. Is it not OK to define them only in net/mptcp/bpf.c?

Yes, a new test for #484 (BPF: setsockopt on an MPTCP socket: check support) will use these helpers in "cgroup/setsockopt", that is the BPF_PROG_TYPE_CGROUP_SOCKOPT type.

register_btf_kfunc_id_set(BPF_PROG_TYPE_CGROUP_SOCKOPT,

		&bpf_mptcp_sched_kfunc_set);

will fail, since BPF_PROG_TYPE_CGROUP_SOCKOPT is not allow to register
more kfuncs (see bpf_prog_type_to_kfunc_hook() in kernel/bpf/btf.c).

So I have to move them into common_btf_ids in kernel/bpf/helpers.c to
allow them can be used in almost every BPF program type.

Quoted 6 lines
Quoted 3 lines

OK, but then I guess these helpers can be upstreamed before the packet
schedulers, right?

Yes, indeed. I hope them can be upstreamed after the "new MPTCP subflow subtest" set under reviewing on BPF list.

OK good!

Quoted 5 lines

So this set should be applied in this order:

selftests/bpf: Add mptcp subflow example selftests/bpf: Add getsockopt to inspect mptcp subflow selftests/bpf: Add mptcp subflow subtest

I will first send these 3, before focusing on the other ones if that's OK.

Quoted 6 lines

bpf: Add mptcp_subflow bpf_iter
bpf: Register mptcp tracing kfunc set selftests/bpf: Add mptcp_subflow bpf_iter test prog selftests/bpf: Add mptcp_subflow bpf_iter subtest selftests/bpf: Add bpf scheduler test selftests/bpf: Add bpf_first scheduler & test

Cheers,
Matt

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

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

Quoted 63 lines · Matthieu Baerts
Quoted 52 lines · Geliang Tang
Quoted 51 lines · Matthieu Baerts

Hi Geliang,

Quoted 47 lines · Geliang Tang

Hi Matt,

Quoted 17 lines · Matthieu Baerts

Hi Geliang,

Quoted 8 lines · Geliang Tang

From: Geliang Tang <[email protected]>

Register mptcp_subflow bpf_iter helpers in common_btf_ids in
kernel/bpf/helpers.c, then they can be used on a larger scale,
not only in types BPF_PROG_TYPE_TRACING and BPF_PROG_TYPE_STRUCT_OPS.

Why could they not be used in these types? I find it good to have
them
defined in net/mptcp, from a maintenance point of view.

Quoted 8 lines

Also, the different bpf_iter_xxx helpers defined there look generic.
While here, it is specific to MPTCP, I'm not even sure that would
be
OK
to add them there. Is it not OK to define them only in net/mptcp/bpf.c?

Yes, a new test for #484 (BPF: setsockopt on an MPTCP socket:
check
support) will use these helpers in "cgroup/setsockopt", that is the
BPF_PROG_TYPE_CGROUP_SOCKOPT type.

register_btf_kfunc_id_set(BPF_PROG_TYPE_CGROUP_SOCKOPT,

		&bpf_mptcp_sched_kfunc_set);

will fail, since BPF_PROG_TYPE_CGROUP_SOCKOPT is not allow to register
more kfuncs (see bpf_prog_type_to_kfunc_hook() in kernel/bpf/btf.c).

So I have to move them into common_btf_ids in kernel/bpf/helpers.c
to
allow them can be used in almost every BPF program type.

Quoted 7 lines
Quoted 3 lines

OK, but then I guess these helpers can be upstreamed before the packet
schedulers, right?

Yes, indeed. I hope them can be upstreamed after the "new MPTCP subflow
subtest" set under reviewing on BPF list.

OK good!

Quoted 8 lines
Quoted 5 lines

So this set should be applied in this order:

selftests/bpf: Add mptcp subflow example selftests/bpf: Add getsockopt to inspect mptcp subflow selftests/bpf: Add mptcp subflow subtest

I will first send these 3, before focusing on the other ones if that's OK.

Thanks.

Quoted 5 lines
Quoted 5 lines

bpf: Add mptcp_subflow bpf_iter
bpf: Register mptcp tracing kfunc set selftests/bpf: Add mptcp_subflow bpf_iter test prog selftests/bpf: Add mptcp_subflow bpf_iter subtest

The next set is to use this mptcp_subflow bpf_iter to update all the BPF scheduler examples, which is almost ready. I will post them in the next few days.

Regards,
-Geliang

Quoted 4 lines
Quoted 2 lines

selftests/bpf: Add bpf scheduler test
selftests/bpf: Add bpf_first scheduler & test

Cheers,
Matt

author reviewer
#8 lore raw

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

In reply to Matthieu Baerts

Hi Matt,

Quoted 39 lines · Matthieu Baerts

Hi Geliang,

Quoted 36 lines · Geliang Tang

Hi Matt,

Quoted 14 lines · Matthieu Baerts

Hi Geliang,

Quoted 6 lines · Geliang Tang

From: Geliang Tang <[email protected]>

Register mptcp_subflow bpf_iter helpers in common_btf_ids in kernel/bpf/helpers.c, then they can be used on a larger scale, not only in types BPF_PROG_TYPE_TRACING and BPF_PROG_TYPE_STRUCT_OPS.

Why could they not be used in these types? I find it good to have them
defined in net/mptcp, from a maintenance point of view.

Quoted 7 lines

Also, the different bpf_iter_xxx helpers defined there look generic.
While here, it is specific to MPTCP, I'm not even sure that would be
OK
to add them there. Is it not OK to define them only in net/mptcp/bpf.c?

Yes, a new test for #484 (BPF: setsockopt on an MPTCP socket: check support) will use these helpers in "cgroup/setsockopt", that is the BPF_PROG_TYPE_CGROUP_SOCKOPT type.

register_btf_kfunc_id_set(BPF_PROG_TYPE_CGROUP_SOCKOPT,

		&bpf_mptcp_sched_kfunc_set);

will fail, since BPF_PROG_TYPE_CGROUP_SOCKOPT is not allow to register
more kfuncs (see bpf_prog_type_to_kfunc_hook() in kernel/bpf/btf.c).

I rethought it again, we can easily extend bpf_prog_type_to_kfunc_hook:

+++ b/kernel/bpf/btf.c
@@ -8310,6 +8310,7 @@ static int bpf_prog_type_to_kfunc_hook(enum bpf_prog_type prog_type)

                return BTF_KFUNC_HOOK_SYSCALL;
        case BPF_PROG_TYPE_CGROUP_SKB:
        case BPF_PROG_TYPE_CGROUP_SOCK_ADDR:
+       case BPF_PROG_TYPE_CGROUP_SOCKOPT:
                return BTF_KFUNC_HOOK_CGROUP_SKB;
        case BPF_PROG_TYPE_SCHED_ACT:
                return BTF_KFUNC_HOOK_SCHED_ACT;

So we can still define and register mptcp_subflow bpf_iter helpers only in net/mptcp/bpf.c. v4 is sent, this patch is superseded.

Thanks,
-Geliang

Quoted 11 lines
Quoted 4 lines

So I have to move them into common_btf_ids in kernel/bpf/helpers.c to
allow them can be used in almost every BPF program type.

OK, but then I guess these helpers can be upstreamed before the packet
schedulers, right?

Cheers,
Matt