1 | From: Geliang Tang <tanggeliang@kylinos.cn> | 1 | From: Geliang Tang <tanggeliang@kylinos.cn> |
---|---|---|---|
2 | 2 | ||
3 | Address Martin's suggestions for v2. | 3 | v3: |
4 | - check sock_owned_by_user_nocheck(sk)/spin_is_locked(&sk->sk_lock.slock), | ||
5 | instead of lockdep_sock_is_held(sk). | ||
6 | - add "sizeof" and "alignof" checks. | ||
7 | - drop bpf_mptcp_sk() and bpf_mptcp_subflow_tcp_sock() definitions. Use | ||
8 | bpf_skc_to_mptcp_sock() and mptcp_subflow_tcp_sock() in mptcp_subflow | ||
9 | bpf_iter selftests instead. | ||
4 | 10 | ||
5 | Geliang Tang (3): | 11 | v2: |
12 | - add CONFIG_LOCKDEP check in patch 2 to fix the build error reported | ||
13 | by CI. | ||
14 | |||
15 | Address Martin's comments in v1. | ||
16 | |||
17 | Geliang Tang (5): | ||
18 | mptcp: update bpf_mptcp_sock_from_subflow | ||
19 | bpf: Allow use of skc_to_mptcp_sock in cg_sockopt | ||
20 | Squash to "bpf: Register mptcp common kfunc set" | ||
6 | Squash to "bpf: Add mptcp_subflow bpf_iter" | 21 | Squash to "bpf: Add mptcp_subflow bpf_iter" |
7 | Revert "bpf: Acquire and release mptcp socket" | ||
8 | Squash to "selftests/bpf: Add mptcp_subflow bpf_iter subtest" | 22 | Squash to "selftests/bpf: Add mptcp_subflow bpf_iter subtest" |
9 | 23 | ||
10 | net/mptcp/bpf.c | 34 +++++-------------- | 24 | include/net/mptcp.h | 4 +-- |
11 | .../testing/selftests/bpf/bpf_experimental.h | 2 +- | 25 | kernel/bpf/cgroup.c | 2 ++ |
12 | tools/testing/selftests/bpf/progs/mptcp_bpf.h | 3 -- | 26 | net/core/filter.c | 2 +- |
13 | .../selftests/bpf/progs/mptcp_bpf_iters.c | 6 +--- | 27 | net/mptcp/bpf.c | 34 +++++++++---------- |
14 | 4 files changed, 11 insertions(+), 34 deletions(-) | 28 | tools/testing/selftests/bpf/progs/mptcp_bpf.h | 1 - |
29 | .../selftests/bpf/progs/mptcp_bpf_iters.c | 11 +++--- | ||
30 | 6 files changed, 27 insertions(+), 27 deletions(-) | ||
15 | 31 | ||
16 | -- | 32 | -- |
17 | 2.43.0 | 33 | 2.45.2 | diff view generated by jsdifflib |
New patch | |||
---|---|---|---|
1 | From: Geliang Tang <tanggeliang@kylinos.cn> | ||
1 | 2 | ||
3 | The input parameter of bpf_mptcp_sock_from_subflow() is an msk subsocket | ||
4 | of type IPPROTO_TCP. This patch extends it to accept an IPPROTO_MPTCP | ||
5 | socket. With this change, the function name bpf_mptcp_sock_from_subflow | ||
6 | is no longer appropriate, and it is renamed to bpf_mptcp_sock_from_sock. | ||
7 | |||
8 | Signed-off-by: Geliang Tang <tanggeliang@kylinos.cn> | ||
9 | --- | ||
10 | include/net/mptcp.h | 4 ++-- | ||
11 | net/core/filter.c | 2 +- | ||
12 | net/mptcp/bpf.c | 4 +++- | ||
13 | 3 files changed, 6 insertions(+), 4 deletions(-) | ||
14 | |||
15 | diff --git a/include/net/mptcp.h b/include/net/mptcp.h | ||
16 | index XXXXXXX..XXXXXXX 100644 | ||
17 | --- a/include/net/mptcp.h | ||
18 | +++ b/include/net/mptcp.h | ||
19 | @@ -XXX,XX +XXX,XX @@ static inline void mptcpv6_handle_mapped(struct sock *sk, bool mapped) { } | ||
20 | #endif | ||
21 | |||
22 | #if defined(CONFIG_MPTCP) && defined(CONFIG_BPF_SYSCALL) | ||
23 | -struct mptcp_sock *bpf_mptcp_sock_from_subflow(struct sock *sk); | ||
24 | +struct mptcp_sock *bpf_mptcp_sock_from_sock(struct sock *sk); | ||
25 | #else | ||
26 | -static inline struct mptcp_sock *bpf_mptcp_sock_from_subflow(struct sock *sk) { return NULL; } | ||
27 | +static inline struct mptcp_sock *bpf_mptcp_sock_from_sock(struct sock *sk) { return NULL; } | ||
28 | #endif | ||
29 | |||
30 | #if !IS_ENABLED(CONFIG_MPTCP) | ||
31 | diff --git a/net/core/filter.c b/net/core/filter.c | ||
32 | index XXXXXXX..XXXXXXX 100644 | ||
33 | --- a/net/core/filter.c | ||
34 | +++ b/net/core/filter.c | ||
35 | @@ -XXX,XX +XXX,XX @@ const struct bpf_func_proto bpf_skc_to_unix_sock_proto = { | ||
36 | BPF_CALL_1(bpf_skc_to_mptcp_sock, struct sock *, sk) | ||
37 | { | ||
38 | BTF_TYPE_EMIT(struct mptcp_sock); | ||
39 | - return (unsigned long)bpf_mptcp_sock_from_subflow(sk); | ||
40 | + return (unsigned long)bpf_mptcp_sock_from_sock(sk); | ||
41 | } | ||
42 | |||
43 | const struct bpf_func_proto bpf_skc_to_mptcp_sock_proto = { | ||
44 | diff --git a/net/mptcp/bpf.c b/net/mptcp/bpf.c | ||
45 | index XXXXXXX..XXXXXXX 100644 | ||
46 | --- a/net/mptcp/bpf.c | ||
47 | +++ b/net/mptcp/bpf.c | ||
48 | @@ -XXX,XX +XXX,XX @@ static struct bpf_struct_ops bpf_mptcp_sched_ops = { | ||
49 | }; | ||
50 | #endif /* CONFIG_BPF_JIT */ | ||
51 | |||
52 | -struct mptcp_sock *bpf_mptcp_sock_from_subflow(struct sock *sk) | ||
53 | +struct mptcp_sock *bpf_mptcp_sock_from_sock(struct sock *sk) | ||
54 | { | ||
55 | + if (sk && sk_fullsock(sk) && sk->sk_protocol == IPPROTO_MPTCP) | ||
56 | + return mptcp_sk(sk); | ||
57 | if (sk && sk_fullsock(sk) && sk->sk_protocol == IPPROTO_TCP && sk_is_mptcp(sk)) | ||
58 | return mptcp_sk(mptcp_subflow_ctx(sk)->conn); | ||
59 | |||
60 | -- | ||
61 | 2.45.2 | diff view generated by jsdifflib |
New patch | |||
---|---|---|---|
1 | From: Geliang Tang <tanggeliang@kylinos.cn> | ||
1 | 2 | ||
3 | Currently, bpf_skc_to_mptcp_sock() helper is not allowed to be used | ||
4 | in cg_sockopt. This patch adds this permission. | ||
5 | |||
6 | Signed-off-by: Geliang Tang <tanggeliang@kylinos.cn> | ||
7 | --- | ||
8 | kernel/bpf/cgroup.c | 2 ++ | ||
9 | 1 file changed, 2 insertions(+) | ||
10 | |||
11 | diff --git a/kernel/bpf/cgroup.c b/kernel/bpf/cgroup.c | ||
12 | index XXXXXXX..XXXXXXX 100644 | ||
13 | --- a/kernel/bpf/cgroup.c | ||
14 | +++ b/kernel/bpf/cgroup.c | ||
15 | @@ -XXX,XX +XXX,XX @@ cg_sockopt_func_proto(enum bpf_func_id func_id, const struct bpf_prog *prog) | ||
16 | #ifdef CONFIG_INET | ||
17 | case BPF_FUNC_tcp_sock: | ||
18 | return &bpf_tcp_sock_proto; | ||
19 | + case BPF_FUNC_skc_to_mptcp_sock: | ||
20 | + return &bpf_skc_to_mptcp_sock_proto; | ||
21 | #endif | ||
22 | case BPF_FUNC_perf_event_output: | ||
23 | return &bpf_event_output_data_proto; | ||
24 | -- | ||
25 | 2.45.2 | diff view generated by jsdifflib |
1 | From: Geliang Tang <tanggeliang@kylinos.cn> | 1 | From: Geliang Tang <tanggeliang@kylinos.cn> |
---|---|---|---|
2 | 2 | ||
3 | Drop this patch as Martin suggested. | 3 | Drop bpf_mptcp_sk() and bpf_mptcp_subflow_tcp_sock() definitions. Use |
4 | bpf_skc_to_mptcp_sock() and mptcp_subflow_tcp_sock() in mptcp_subflow | ||
5 | bpf_iter selftests instead. | ||
6 | |||
7 | Address Martin's comments in v1: | ||
8 | |||
9 | - add null-check for bpf_mptcp_subflow_ctx. | ||
10 | - add KF_RET_NULL flags for bpf_mptcp_subflow_ctx. | ||
11 | - register this kfunc set to BPF_PROG_TYPE_CGROUP_SOCKOPT only, | ||
12 | not BPF_PROG_TYPE_UNSPEC. | ||
4 | 13 | ||
5 | Signed-off-by: Geliang Tang <tanggeliang@kylinos.cn> | 14 | Signed-off-by: Geliang Tang <tanggeliang@kylinos.cn> |
6 | --- | 15 | --- |
7 | net/mptcp/bpf.c | 19 ------------------- | 16 | net/mptcp/bpf.c | 20 +++++--------------- |
8 | 1 file changed, 19 deletions(-) | 17 | 1 file changed, 5 insertions(+), 15 deletions(-) |
9 | 18 | ||
10 | diff --git a/net/mptcp/bpf.c b/net/mptcp/bpf.c | 19 | diff --git a/net/mptcp/bpf.c b/net/mptcp/bpf.c |
11 | index XXXXXXX..XXXXXXX 100644 | 20 | index XXXXXXX..XXXXXXX 100644 |
12 | --- a/net/mptcp/bpf.c | 21 | --- a/net/mptcp/bpf.c |
13 | +++ b/net/mptcp/bpf.c | 22 | +++ b/net/mptcp/bpf.c |
14 | @@ -XXX,XX +XXX,XX @@ bpf_iter_mptcp_subflow_destroy(struct bpf_iter_mptcp_subflow *it) | 23 | @@ -XXX,XX +XXX,XX @@ struct bpf_iter_mptcp_subflow_kern { |
15 | { | 24 | |
16 | } | 25 | __bpf_kfunc_start_defs(); |
17 | 26 | ||
18 | -__bpf_kfunc static struct | 27 | -__bpf_kfunc static struct mptcp_sock *bpf_mptcp_sk(struct sock *sk) |
19 | -mptcp_sock *bpf_mptcp_sock_acquire(struct mptcp_sock *msk) | ||
20 | -{ | 28 | -{ |
21 | - struct sock *sk = (struct sock *)msk; | 29 | - return mptcp_sk(sk); |
22 | - | ||
23 | - if (sk && refcount_inc_not_zero(&sk->sk_refcnt)) | ||
24 | - return msk; | ||
25 | - return NULL; | ||
26 | -} | 30 | -} |
27 | - | 31 | - |
28 | -__bpf_kfunc static void bpf_mptcp_sock_release(struct mptcp_sock *msk) | 32 | __bpf_kfunc static struct mptcp_subflow_context * |
33 | bpf_mptcp_subflow_ctx(const struct sock *sk) | ||
34 | { | ||
35 | - return mptcp_subflow_ctx(sk); | ||
36 | -} | ||
37 | + if (!sk) | ||
38 | + return NULL; | ||
39 | |||
40 | -__bpf_kfunc static struct sock * | ||
41 | -bpf_mptcp_subflow_tcp_sock(const struct mptcp_subflow_context *subflow) | ||
29 | -{ | 42 | -{ |
30 | - struct sock *sk = (struct sock *)msk; | 43 | - return mptcp_subflow_tcp_sock(subflow); |
31 | - | 44 | + return mptcp_subflow_ctx(sk); |
32 | - WARN_ON_ONCE(!sk || !refcount_dec_not_one(&sk->sk_refcnt)); | 45 | } |
33 | -} | 46 | |
34 | - | 47 | __bpf_kfunc static int |
35 | __bpf_kfunc struct mptcp_subflow_context * | 48 | @@ -XXX,XX +XXX,XX @@ __bpf_kfunc static bool bpf_mptcp_subflow_queues_empty(struct sock *sk) |
36 | bpf_mptcp_subflow_ctx_by_pos(const struct mptcp_sched_data *data, unsigned int pos) | 49 | __bpf_kfunc_end_defs(); |
37 | { | 50 | |
38 | @@ -XXX,XX +XXX,XX @@ BTF_ID_FLAGS(func, bpf_mptcp_subflow_ctx, KF_RET_NULL) | 51 | BTF_KFUNCS_START(bpf_mptcp_common_kfunc_ids) |
52 | -BTF_ID_FLAGS(func, bpf_mptcp_sk) | ||
53 | -BTF_ID_FLAGS(func, bpf_mptcp_subflow_ctx) | ||
54 | -BTF_ID_FLAGS(func, bpf_mptcp_subflow_tcp_sock) | ||
55 | +BTF_ID_FLAGS(func, bpf_mptcp_subflow_ctx, KF_RET_NULL) | ||
39 | BTF_ID_FLAGS(func, bpf_iter_mptcp_subflow_new, KF_ITER_NEW | KF_TRUSTED_ARGS) | 56 | BTF_ID_FLAGS(func, bpf_iter_mptcp_subflow_new, KF_ITER_NEW | KF_TRUSTED_ARGS) |
40 | BTF_ID_FLAGS(func, bpf_iter_mptcp_subflow_next, KF_ITER_NEXT | KF_RET_NULL) | 57 | BTF_ID_FLAGS(func, bpf_iter_mptcp_subflow_next, KF_ITER_NEXT | KF_RET_NULL) |
41 | BTF_ID_FLAGS(func, bpf_iter_mptcp_subflow_destroy, KF_ITER_DESTROY) | 58 | BTF_ID_FLAGS(func, bpf_iter_mptcp_subflow_destroy, KF_ITER_DESTROY) |
42 | -BTF_ID_FLAGS(func, bpf_mptcp_sock_acquire, KF_ACQUIRE | KF_RET_NULL) | 59 | @@ -XXX,XX +XXX,XX @@ static int __init bpf_mptcp_kfunc_init(void) |
43 | -BTF_ID_FLAGS(func, bpf_mptcp_sock_release, KF_RELEASE) | 60 | int ret; |
44 | BTF_KFUNCS_END(bpf_mptcp_common_kfunc_ids) | 61 | |
45 | 62 | ret = register_btf_fmodret_id_set(&bpf_mptcp_fmodret_set); | |
46 | static const struct btf_kfunc_id_set bpf_mptcp_common_kfunc_set = { | 63 | - ret = ret ?: register_btf_kfunc_id_set(BPF_PROG_TYPE_UNSPEC, |
64 | + ret = ret ?: register_btf_kfunc_id_set(BPF_PROG_TYPE_CGROUP_SOCKOPT, | ||
65 | &bpf_mptcp_common_kfunc_set); | ||
66 | ret = ret ?: register_btf_kfunc_id_set(BPF_PROG_TYPE_STRUCT_OPS, | ||
67 | &bpf_mptcp_sched_kfunc_set); | ||
47 | -- | 68 | -- |
48 | 2.43.0 | 69 | 2.45.2 | diff view generated by jsdifflib |
1 | From: Geliang Tang <tanggeliang@kylinos.cn> | 1 | From: Geliang Tang <tanggeliang@kylinos.cn> |
---|---|---|---|
2 | 2 | ||
3 | Drop the NULL check as Martin suggested. | 3 | Add "sizeof" and "alignof" checks. |
4 | 4 | ||
5 | Use the "struct sock *sk" instead of "struct mptcp-sock *msk" as the | 5 | Address Martin's comments in v1: |
6 | argument in the bpf_iter_mptcp_subflow_new as Martin suggested. | ||
7 | 6 | ||
8 | Use msk_owned_by_me(). | 7 | - bpf_iter_mptcp_subflow_new returns -EINVAL when msk socket lock isn't |
8 | held. | ||
9 | 9 | ||
10 | Signed-off-by: Geliang Tang <tanggeliang@kylinos.cn> | 10 | Signed-off-by: Geliang Tang <tanggeliang@kylinos.cn> |
11 | --- | 11 | --- |
12 | net/mptcp/bpf.c | 15 +++++++++------ | 12 | net/mptcp/bpf.c | 10 +++++++++- |
13 | 1 file changed, 9 insertions(+), 6 deletions(-) | 13 | 1 file changed, 9 insertions(+), 1 deletion(-) |
14 | 14 | ||
15 | diff --git a/net/mptcp/bpf.c b/net/mptcp/bpf.c | 15 | diff --git a/net/mptcp/bpf.c b/net/mptcp/bpf.c |
16 | index XXXXXXX..XXXXXXX 100644 | 16 | index XXXXXXX..XXXXXXX 100644 |
17 | --- a/net/mptcp/bpf.c | 17 | --- a/net/mptcp/bpf.c |
18 | +++ b/net/mptcp/bpf.c | 18 | +++ b/net/mptcp/bpf.c |
19 | @@ -XXX,XX +XXX,XX @@ bpf_mptcp_subflow_ctx(const struct sock *sk) | 19 | @@ -XXX,XX +XXX,XX @@ bpf_iter_mptcp_subflow_new(struct bpf_iter_mptcp_subflow *it, |
20 | 20 | struct mptcp_sock *msk) | |
21 | __bpf_kfunc static int | ||
22 | bpf_iter_mptcp_subflow_new(struct bpf_iter_mptcp_subflow *it, | ||
23 | - struct mptcp_sock *msk) | ||
24 | + struct sock *sk) | ||
25 | { | 21 | { |
26 | struct bpf_iter_mptcp_subflow_kern *kit = (void *)it; | 22 | struct bpf_iter_mptcp_subflow_kern *kit = (void *)it; |
27 | - struct sock *sk = (struct sock *)msk; | 23 | + struct sock *sk = (struct sock *)msk; |
28 | + struct mptcp_sock *msk; | 24 | + |
29 | 25 | + BUILD_BUG_ON(sizeof(struct bpf_iter_mptcp_subflow_kern) != | |
30 | BUILD_BUG_ON(sizeof(struct bpf_iter_mptcp_subflow_kern) > | 26 | + sizeof(struct bpf_iter_mptcp_subflow)); |
31 | sizeof(struct bpf_iter_mptcp_subflow)); | 27 | + BUILD_BUG_ON(__alignof__(struct bpf_iter_mptcp_subflow_kern) != |
32 | BUILD_BUG_ON(__alignof__(struct bpf_iter_mptcp_subflow_kern) != | 28 | + __alignof__(struct bpf_iter_mptcp_subflow)); |
33 | __alignof__(struct bpf_iter_mptcp_subflow)); | 29 | |
34 | 30 | kit->msk = msk; | |
35 | - kit->msk = msk; | 31 | if (!msk) |
36 | - if (!msk) | ||
37 | + if (unlikely(!sk || !sk_fullsock(sk))) | ||
38 | return -EINVAL; | 32 | return -EINVAL; |
39 | 33 | ||
40 | - if (!sock_owned_by_user_nocheck(sk) && | 34 | - msk_owned_by_me(msk); |
41 | - !spin_is_locked(&sk->sk_lock.slock)) | 35 | + if (!sock_owned_by_user_nocheck(sk) && |
42 | + if (sk->sk_protocol != IPPROTO_MPTCP) | 36 | + !spin_is_locked(&sk->sk_lock.slock)) |
43 | return -EINVAL; | 37 | + return -EINVAL; |
44 | 38 | ||
45 | + msk = mptcp_sk(sk); | ||
46 | + kit->msk = msk; | ||
47 | + | ||
48 | + msk_owned_by_me(msk); | ||
49 | + | ||
50 | kit->pos = &msk->conn_list; | 39 | kit->pos = &msk->conn_list; |
51 | return 0; | 40 | return 0; |
52 | } | ||
53 | -- | 41 | -- |
54 | 2.43.0 | 42 | 2.45.2 | diff view generated by jsdifflib |
1 | From: Geliang Tang <tanggeliang@kylinos.cn> | 1 | From: Geliang Tang <tanggeliang@kylinos.cn> |
---|---|---|---|
2 | 2 | ||
3 | Drop bpf_mptcp_sock_acquire/release. | 3 | Use bpf_skc_to_mptcp_sock() and mptcp_subflow_tcp_sock() instead of |
4 | bpf_mptcp_sk() and bpf_mptcp_subflow_tcp_sock(). | ||
5 | |||
6 | IPPROTO_MPTCP is checked in bpf_skc_to_mptcp_sock(), no need to check | ||
7 | it in BPF program. | ||
8 | |||
9 | bpf_skc_to_mptcp_sock() and bpf_mptcp_subflow_ctx() may return NULL, | ||
10 | need to check the return values. | ||
4 | 11 | ||
5 | Signed-off-by: Geliang Tang <tanggeliang@kylinos.cn> | 12 | Signed-off-by: Geliang Tang <tanggeliang@kylinos.cn> |
6 | --- | 13 | --- |
7 | tools/testing/selftests/bpf/bpf_experimental.h | 2 +- | 14 | tools/testing/selftests/bpf/progs/mptcp_bpf.h | 1 - |
8 | tools/testing/selftests/bpf/progs/mptcp_bpf.h | 3 --- | 15 | tools/testing/selftests/bpf/progs/mptcp_bpf_iters.c | 11 +++++------ |
9 | tools/testing/selftests/bpf/progs/mptcp_bpf_iters.c | 6 +----- | 16 | 2 files changed, 5 insertions(+), 7 deletions(-) |
10 | 3 files changed, 2 insertions(+), 9 deletions(-) | ||
11 | 17 | ||
12 | diff --git a/tools/testing/selftests/bpf/bpf_experimental.h b/tools/testing/selftests/bpf/bpf_experimental.h | ||
13 | index XXXXXXX..XXXXXXX 100644 | ||
14 | --- a/tools/testing/selftests/bpf/bpf_experimental.h | ||
15 | +++ b/tools/testing/selftests/bpf/bpf_experimental.h | ||
16 | @@ -XXX,XX +XXX,XX @@ extern void bpf_iter_css_destroy(struct bpf_iter_css *it) __weak __ksym; | ||
17 | |||
18 | struct bpf_iter_mptcp_subflow; | ||
19 | extern int bpf_iter_mptcp_subflow_new(struct bpf_iter_mptcp_subflow *it, | ||
20 | - struct mptcp_sock *msk) __weak __ksym; | ||
21 | + struct sock *sk) __weak __ksym; | ||
22 | extern struct mptcp_subflow_context * | ||
23 | bpf_iter_mptcp_subflow_next(struct bpf_iter_mptcp_subflow *it) __weak __ksym; | ||
24 | extern void | ||
25 | diff --git a/tools/testing/selftests/bpf/progs/mptcp_bpf.h b/tools/testing/selftests/bpf/progs/mptcp_bpf.h | 18 | diff --git a/tools/testing/selftests/bpf/progs/mptcp_bpf.h b/tools/testing/selftests/bpf/progs/mptcp_bpf.h |
26 | index XXXXXXX..XXXXXXX 100644 | 19 | index XXXXXXX..XXXXXXX 100644 |
27 | --- a/tools/testing/selftests/bpf/progs/mptcp_bpf.h | 20 | --- a/tools/testing/selftests/bpf/progs/mptcp_bpf.h |
28 | +++ b/tools/testing/selftests/bpf/progs/mptcp_bpf.h | 21 | +++ b/tools/testing/selftests/bpf/progs/mptcp_bpf.h |
29 | @@ -XXX,XX +XXX,XX @@ mptcp_subflow_tcp_sock(const struct mptcp_subflow_context *subflow) | 22 | @@ -XXX,XX +XXX,XX @@ mptcp_subflow_tcp_sock(const struct mptcp_subflow_context *subflow) |
30 | } | 23 | extern struct mptcp_sock *bpf_mptcp_sock_acquire(struct mptcp_sock *msk) __ksym; |
31 | 24 | extern void bpf_mptcp_sock_release(struct mptcp_sock *msk) __ksym; | |
32 | /* ksym */ | 25 | |
33 | -extern struct mptcp_sock *bpf_mptcp_sock_acquire(struct mptcp_sock *msk) __ksym; | 26 | -extern struct mptcp_sock *bpf_mptcp_sk(struct sock *sk) __ksym; |
34 | -extern void bpf_mptcp_sock_release(struct mptcp_sock *msk) __ksym; | ||
35 | - | ||
36 | extern struct mptcp_subflow_context * | 27 | extern struct mptcp_subflow_context * |
37 | bpf_mptcp_subflow_ctx(const struct sock *sk) __ksym; | 28 | bpf_mptcp_subflow_ctx(const struct sock *sk) __ksym; |
38 | extern struct sock * | 29 | extern struct sock * |
39 | diff --git a/tools/testing/selftests/bpf/progs/mptcp_bpf_iters.c b/tools/testing/selftests/bpf/progs/mptcp_bpf_iters.c | 30 | diff --git a/tools/testing/selftests/bpf/progs/mptcp_bpf_iters.c b/tools/testing/selftests/bpf/progs/mptcp_bpf_iters.c |
40 | index XXXXXXX..XXXXXXX 100644 | 31 | index XXXXXXX..XXXXXXX 100644 |
41 | --- a/tools/testing/selftests/bpf/progs/mptcp_bpf_iters.c | 32 | --- a/tools/testing/selftests/bpf/progs/mptcp_bpf_iters.c |
42 | +++ b/tools/testing/selftests/bpf/progs/mptcp_bpf_iters.c | 33 | +++ b/tools/testing/selftests/bpf/progs/mptcp_bpf_iters.c |
43 | @@ -XXX,XX +XXX,XX @@ int iters_subflow(struct bpf_sockopt *ctx) | 34 | @@ -XXX,XX +XXX,XX @@ int iters_subflow(struct bpf_sockopt *ctx) |
44 | if (!msk || msk->pm.server_side || !msk->pm.subflows) | 35 | struct mptcp_sock *msk; |
36 | int local_ids = 0; | ||
37 | |||
38 | - if (!sk || sk->protocol != IPPROTO_MPTCP || | ||
39 | - ctx->level != SOL_TCP || ctx->optname != TCP_IS_MPTCP) | ||
40 | + if (ctx->level != SOL_TCP || ctx->optname != TCP_IS_MPTCP) | ||
45 | return 1; | 41 | return 1; |
46 | 42 | ||
47 | - msk = bpf_mptcp_sock_acquire(msk); | 43 | - msk = bpf_mptcp_sk((struct sock *)sk); |
48 | - if (!msk) | 44 | - if (msk->pm.server_side || !msk->pm.subflows) |
49 | - return 1; | 45 | + msk = bpf_skc_to_mptcp_sock(sk); |
50 | - bpf_for_each(mptcp_subflow, subflow, msk) { | 46 | + if (!msk || msk->pm.server_side || !msk->pm.subflows) |
51 | + bpf_for_each(mptcp_subflow, subflow, (struct sock *)sk) { | 47 | return 1; |
52 | /* Here MPTCP-specific packet scheduler kfunc can be called: | 48 | |
53 | * this test is not doing anything really useful, only to | 49 | msk = bpf_mptcp_sock_acquire(msk); |
54 | * verify the iteration works. | ||
55 | @@ -XXX,XX +XXX,XX @@ int iters_subflow(struct bpf_sockopt *ctx) | 50 | @@ -XXX,XX +XXX,XX @@ int iters_subflow(struct bpf_sockopt *ctx) |
51 | local_ids += subflow->subflow_id; | ||
52 | |||
53 | /* only to check the following kfunc works */ | ||
54 | - ssk = bpf_mptcp_subflow_tcp_sock(subflow); | ||
55 | + ssk = mptcp_subflow_tcp_sock(subflow); | ||
56 | } | ||
57 | |||
58 | if (!ssk) | ||
59 | @@ -XXX,XX +XXX,XX @@ int iters_subflow(struct bpf_sockopt *ctx) | ||
60 | |||
61 | /* only to check the following kfunc works */ | ||
62 | subflow = bpf_mptcp_subflow_ctx(ssk); | ||
63 | - if (subflow->token != msk->token) | ||
64 | + if (!subflow || subflow->token != msk->token) | ||
65 | goto out; | ||
66 | |||
56 | ids = local_ids; | 67 | ids = local_ids; |
57 | |||
58 | out: | ||
59 | - bpf_mptcp_sock_release(msk); | ||
60 | return 1; | ||
61 | } | ||
62 | -- | 68 | -- |
63 | 2.43.0 | 69 | 2.45.2 | diff view generated by jsdifflib |