:p
atchew
Login
v2: - keep sched API unchanged. - use bpf_sk_storage_lookup to get snd_burst from BPF context. - applied after "add bpf_stale scheduler v3" serise. v1: There's a bug in bpf_burst. snd_burst stored in mptcp_burst_storage in BPF context is not used. msk->snd_burst is still used in kernel space. To fix this, add two new interfaces in mptcp_sched_ops to get and set scheduler's paramters from BPF context to kernel space. Geliang Tang (2): mptcp: add set/get params wrappers mptcp: add bpf_burst set/get params include/net/bpf_sk_storage.h | 7 +++++ net/core/bpf_sk_storage.c | 2 +- net/mptcp/protocol.c | 8 ++--- net/mptcp/protocol.h | 2 ++ net/mptcp/sched.c | 57 ++++++++++++++++++++++++++++++++++++ 5 files changed, 71 insertions(+), 5 deletions(-) -- 2.35.3
Add two sched params wrappers: mptcp_sched_set_params() and mptcp_sched_set_params(). Use these wrappers instead of get and set msk->snd_burst directly. Signed-off-by: Geliang Tang <geliang.tang@suse.com> --- net/mptcp/protocol.c | 8 ++++---- net/mptcp/protocol.h | 2 ++ net/mptcp/sched.c | 18 ++++++++++++++++++ 3 files changed, 24 insertions(+), 4 deletions(-) diff --git a/net/mptcp/protocol.c b/net/mptcp/protocol.c index XXXXXXX..XXXXXXX 100644 --- a/net/mptcp/protocol.c +++ b/net/mptcp/protocol.c @@ -XXX,XX +XXX,XX @@ struct sock *mptcp_subflow_get_send(struct mptcp_sock *msk) subflow->avg_pacing_rate = div_u64((u64)subflow->avg_pacing_rate * wmem + READ_ONCE(ssk->sk_pacing_rate) * burst, burst + wmem); - msk->snd_burst = burst; + mptcp_sched_set_params(msk, burst); return ssk; } @@ -XXX,XX +XXX,XX @@ static void mptcp_update_post_push(struct mptcp_sock *msk, dfrag->already_sent += sent; - msk->snd_burst -= sent; + mptcp_sched_set_params(msk, mptcp_sched_get_params(msk) - sent); snd_nxt_new += dfrag->already_sent; @@ -XXX,XX +XXX,XX @@ static int __subflow_push_pending(struct sock *sk, struct sock *ssk, } WRITE_ONCE(msk->first_pending, mptcp_send_next(sk)); - if (msk->snd_burst <= 0 || + if (mptcp_sched_get_params(msk) <= 0 || !sk_stream_memory_free(ssk) || !mptcp_subflow_active(mptcp_subflow_ctx(ssk))) { err = copied; @@ -XXX,XX +XXX,XX @@ bool __mptcp_retransmit_pending_data(struct sock *sk) mptcp_data_unlock(sk); msk->first_pending = rtx_head; - msk->snd_burst = 0; + mptcp_sched_set_params(msk, 0); /* be sure to clear the "sent status" on all re-injected fragments */ list_for_each_entry(cur, &msk->rtx_queue, list) { diff --git a/net/mptcp/protocol.h b/net/mptcp/protocol.h index XXXXXXX..XXXXXXX 100644 --- a/net/mptcp/protocol.h +++ b/net/mptcp/protocol.h @@ -XXX,XX +XXX,XX @@ void mptcp_sched_data_set_contexts(const struct mptcp_sock *msk, struct mptcp_sched_data *data); struct mptcp_subflow_context * mptcp_subflow_ctx_by_pos(const struct mptcp_sched_data *data, unsigned int pos); +int mptcp_sched_get_params(struct mptcp_sock *msk); +int mptcp_sched_set_params(struct mptcp_sock *msk, int burst); static inline bool __tcp_can_send(const struct sock *ssk) { diff --git a/net/mptcp/sched.c b/net/mptcp/sched.c index XXXXXXX..XXXXXXX 100644 --- a/net/mptcp/sched.c +++ b/net/mptcp/sched.c @@ -XXX,XX +XXX,XX @@ mptcp_subflow_ctx_by_pos(const struct mptcp_sched_data *data, unsigned int pos) return NULL; return data->contexts[pos]; } + +int mptcp_sched_get_params(struct mptcp_sock *msk) +{ + if (msk->sched == &mptcp_sched_default) + return msk->snd_burst; + + return 0; +} + +int mptcp_sched_set_params(struct mptcp_sock *msk, int burst) +{ + if (msk->sched == &mptcp_sched_default) { + msk->snd_burst = burst; + return 0; + } + + return 0; +} -- 2.35.3
This patch implements the set/get params interfaces for bpf_burst scheduler. Export bpf_sk_storage_lookup(), use it to get bpf_local_storage_data from sk->sk_bpf_storage, then get or set its params ptr->snd_burst. Signed-off-by: Geliang Tang <geliang.tang@suse.com> --- include/net/bpf_sk_storage.h | 7 +++++++ net/core/bpf_sk_storage.c | 2 +- net/mptcp/sched.c | 39 ++++++++++++++++++++++++++++++++++++ 3 files changed, 47 insertions(+), 1 deletion(-) diff --git a/include/net/bpf_sk_storage.h b/include/net/bpf_sk_storage.h index XXXXXXX..XXXXXXX 100644 --- a/include/net/bpf_sk_storage.h +++ b/include/net/bpf_sk_storage.h @@ -XXX,XX +XXX,XX @@ int bpf_sk_storage_diag_put(struct bpf_sk_storage_diag *diag, struct sock *sk, struct sk_buff *skb, int stg_array_type, unsigned int *res_diag_size); +struct bpf_local_storage_data * +bpf_sk_storage_lookup(struct sock *sk, struct bpf_map *map, bool cacheit_lockit); #else static inline int bpf_sk_storage_clone(const struct sock *sk, struct sock *newsk) @@ -XXX,XX +XXX,XX @@ static inline int bpf_sk_storage_diag_put(struct bpf_sk_storage_diag *diag, { return 0; } +struct bpf_local_storage_data * +bpf_sk_storage_lookup(struct sock *sk, struct bpf_map *map, bool cacheit_lockit) +{ + return NULL; +} #endif #endif /* _BPF_SK_STORAGE_H */ diff --git a/net/core/bpf_sk_storage.c b/net/core/bpf_sk_storage.c index XXXXXXX..XXXXXXX 100644 --- a/net/core/bpf_sk_storage.c +++ b/net/core/bpf_sk_storage.c @@ -XXX,XX +XXX,XX @@ DEFINE_BPF_STORAGE_CACHE(sk_cache); -static struct bpf_local_storage_data * +struct bpf_local_storage_data * bpf_sk_storage_lookup(struct sock *sk, struct bpf_map *map, bool cacheit_lockit) { struct bpf_local_storage *sk_storage; diff --git a/net/mptcp/sched.c b/net/mptcp/sched.c index XXXXXXX..XXXXXXX 100644 --- a/net/mptcp/sched.c +++ b/net/mptcp/sched.c @@ -XXX,XX +XXX,XX @@ #include <linux/list.h> #include <linux/rculist.h> #include <linux/spinlock.h> +#include <net/bpf_sk_storage.h> #include "protocol.h" static DEFINE_SPINLOCK(mptcp_sched_list_lock); @@ -XXX,XX +XXX,XX @@ mptcp_subflow_ctx_by_pos(const struct mptcp_sched_data *data, unsigned int pos) int mptcp_sched_get_params(struct mptcp_sock *msk) { + struct sock *sk = (struct sock *)msk; + if (msk->sched == &mptcp_sched_default) return msk->snd_burst; + if (sk->sk_bpf_storage && sk->sk_bpf_storage->smap && + !strcmp(sk->sk_bpf_storage->smap->map.name, "mptcp_burst_map")) { + struct bpf_local_storage_data *sdata; + + sdata = bpf_sk_storage_lookup(sk, &sk->sk_bpf_storage->smap->map, true); + if (sdata) { + struct mptcp_burst_storage { + int snd_burst; + } *ptr; + + ptr = (struct mptcp_burst_storage *)sdata->data; + if (ptr) + return ptr->snd_burst; + } + } + return 0; } int mptcp_sched_set_params(struct mptcp_sock *msk, int burst) { + struct sock *sk = (struct sock *)msk; + if (msk->sched == &mptcp_sched_default) { msk->snd_burst = burst; return 0; } + if (sk->sk_bpf_storage && sk->sk_bpf_storage->smap && + !strcmp(sk->sk_bpf_storage->smap->map.name, "mptcp_burst_map")) { + struct bpf_local_storage_data *sdata; + + sdata = bpf_sk_storage_lookup(sk, &sk->sk_bpf_storage->smap->map, true); + if (sdata) { + struct mptcp_burst_storage { + int snd_burst; + } *ptr; + + ptr = (struct mptcp_burst_storage *)sdata->data; + if (ptr) { + ptr->snd_burst = burst; + return 0; + } + } + } + return 0; } -- 2.35.3
v3: - store burst in msk->snd_burst instead of in sk_storage. - make mptcp_sched_data_set_contexts static. - rename mptcp_subflow_ctx_by_pos to bpf_mptcp_subflow_ctx_by_pos, and add "__bpf_kfunc" before it. v2: - keep sched API unchanged. - use bpf_sk_storage_lookup to get snd_burst from BPF context. - applied after "add bpf_stale scheduler v3" serise. v1: There's a bug in bpf_burst. snd_burst stored in mptcp_burst_storage in BPF context is not used. msk->snd_burst is still used in kernel space. To fix this, add two new interfaces in mptcp_sched_ops to get and set scheduler's paramters from BPF context to kernel space. Geliang Tang (9): Squash to "bpf: Export more bpf_burst related functions" Squash to "mptcp: add sched_data helpers" Squash to "bpf: Add bpf_mptcp_sched_ops" Squash to "selftests/bpf: Add mptcp sched structs" Squash to "selftests/bpf: Add bpf_first scheduler" Squash to "selftests/bpf: Add bpf_bkup scheduler" Squash to "selftests/bpf: Add bpf_rr scheduler" Squash to "selftests/bpf: Add bpf_red scheduler" Squash to "selftests/bpf: Add bpf_burst scheduler" net/mptcp/bpf.c | 41 +++++++++++---- net/mptcp/protocol.h | 6 +-- net/mptcp/sched.c | 50 ++++++++----------- tools/testing/selftests/bpf/bpf_tcp_helpers.h | 5 +- .../selftests/bpf/progs/mptcp_bpf_bkup.c | 6 +-- .../selftests/bpf/progs/mptcp_bpf_burst.c | 30 ++--------- .../selftests/bpf/progs/mptcp_bpf_first.c | 3 +- .../selftests/bpf/progs/mptcp_bpf_red.c | 6 +-- .../selftests/bpf/progs/mptcp_bpf_rr.c | 9 ++-- 9 files changed, 70 insertions(+), 86 deletions(-) -- 2.35.3
Add __bpf_kfunc before bpf_mptcp_subflow_queues_empty(), drop __diag_*, it will be added in the next patch. Signed-off-by: Geliang Tang <geliang.tang@suse.com> --- net/mptcp/bpf.c | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/net/mptcp/bpf.c b/net/mptcp/bpf.c index XXXXXXX..XXXXXXX 100644 --- a/net/mptcp/bpf.c +++ b/net/mptcp/bpf.c @@ -XXX,XX +XXX,XX @@ static const struct btf_kfunc_id_set bpf_mptcp_fmodret_set = { .set = &bpf_mptcp_fmodret_ids, }; -__diag_push(); -__diag_ignore_all("-Wmissing-prototypes", - "kfuncs which will be used in BPF programs"); - -bool bpf_mptcp_subflow_queues_empty(struct sock *sk) +__bpf_kfunc bool bpf_mptcp_subflow_queues_empty(struct sock *sk) { return tcp_rtx_queue_empty(sk); } -__diag_pop(); - BTF_SET8_START(bpf_mptcp_sched_kfunc_ids) BTF_ID_FLAGS(func, mptcp_subflow_set_scheduled) BTF_ID_FLAGS(func, mptcp_sched_data_set_contexts) -- 2.35.3
Change mptcp_sched_data_set_contexts as static function. Rename mptcp_subflow_ctx_by_pos with bpf_ prefix, move it into bpf.c in __diag_* section. Signed-off-by: Geliang Tang <geliang.tang@suse.com> --- net/mptcp/bpf.c | 17 +++++++++++++-- net/mptcp/protocol.h | 6 ++---- net/mptcp/sched.c | 50 +++++++++++++++++++------------------------- 3 files changed, 39 insertions(+), 34 deletions(-) diff --git a/net/mptcp/bpf.c b/net/mptcp/bpf.c index XXXXXXX..XXXXXXX 100644 --- a/net/mptcp/bpf.c +++ b/net/mptcp/bpf.c @@ -XXX,XX +XXX,XX @@ static const struct btf_kfunc_id_set bpf_mptcp_fmodret_set = { .set = &bpf_mptcp_fmodret_ids, }; +__diag_push(); +__diag_ignore_all("-Wmissing-prototypes", + "kfuncs which will be used in BPF programs"); + +__bpf_kfunc struct mptcp_subflow_context * +bpf_mptcp_subflow_ctx_by_pos(const struct mptcp_sched_data *data, unsigned int pos) +{ + if (pos >= MPTCP_SUBFLOWS_MAX) + return NULL; + return data->contexts[pos]; +} + __bpf_kfunc bool bpf_mptcp_subflow_queues_empty(struct sock *sk) { return tcp_rtx_queue_empty(sk); } +__diag_pop(); + BTF_SET8_START(bpf_mptcp_sched_kfunc_ids) BTF_ID_FLAGS(func, mptcp_subflow_set_scheduled) -BTF_ID_FLAGS(func, mptcp_sched_data_set_contexts) -BTF_ID_FLAGS(func, mptcp_subflow_ctx_by_pos) +BTF_ID_FLAGS(func, bpf_mptcp_subflow_ctx_by_pos) BTF_ID_FLAGS(func, mptcp_subflow_active) BTF_ID_FLAGS(func, mptcp_set_timeout) BTF_ID_FLAGS(func, mptcp_wnd_end) diff --git a/net/mptcp/protocol.h b/net/mptcp/protocol.h index XXXXXXX..XXXXXXX 100644 --- a/net/mptcp/protocol.h +++ b/net/mptcp/protocol.h @@ -XXX,XX +XXX,XX @@ void mptcp_sock_graft(struct sock *sk, struct socket *parent); u64 mptcp_wnd_end(const struct mptcp_sock *msk); void mptcp_set_timeout(struct sock *sk); bool bpf_mptcp_subflow_queues_empty(struct sock *sk); +struct mptcp_subflow_context * +bpf_mptcp_subflow_ctx_by_pos(const struct mptcp_sched_data *data, unsigned int pos); struct sock *__mptcp_nmpc_sk(struct mptcp_sock *msk); bool __mptcp_close(struct sock *sk, long timeout); void mptcp_cancel_work(struct sock *sk); @@ -XXX,XX +XXX,XX @@ struct sock *mptcp_subflow_get_send(struct mptcp_sock *msk); struct sock *mptcp_subflow_get_retrans(struct mptcp_sock *msk); int mptcp_sched_get_send(struct mptcp_sock *msk); int mptcp_sched_get_retrans(struct mptcp_sock *msk); -void mptcp_sched_data_set_contexts(const struct mptcp_sock *msk, - struct mptcp_sched_data *data); -struct mptcp_subflow_context * -mptcp_subflow_ctx_by_pos(const struct mptcp_sched_data *data, unsigned int pos); static inline bool __tcp_can_send(const struct sock *ssk) { diff --git a/net/mptcp/sched.c b/net/mptcp/sched.c index XXXXXXX..XXXXXXX 100644 --- a/net/mptcp/sched.c +++ b/net/mptcp/sched.c @@ -XXX,XX +XXX,XX @@ void mptcp_subflow_set_scheduled(struct mptcp_subflow_context *subflow, WRITE_ONCE(subflow->scheduled, scheduled); } +static void mptcp_sched_data_set_contexts(const struct mptcp_sock *msk, + struct mptcp_sched_data *data) +{ + struct mptcp_subflow_context *subflow; + int i = 0; + + mptcp_for_each_subflow(msk, subflow) { + if (i == MPTCP_SUBFLOWS_MAX) { + pr_warn_once("too many subflows"); + break; + } + mptcp_subflow_set_scheduled(subflow, false); + data->contexts[i++] = subflow; + } + data->subflows = i; + + for (; i < MPTCP_SUBFLOWS_MAX; i++) + data->contexts[i] = NULL; +} + int mptcp_sched_get_send(struct mptcp_sock *msk) { struct mptcp_subflow_context *subflow; @@ -XXX,XX +XXX,XX @@ int mptcp_sched_get_send(struct mptcp_sock *msk) data.reinject = false; if (msk->sched == &mptcp_sched_default || !msk->sched) return mptcp_sched_default_get_subflow(msk, &data); + mptcp_sched_data_set_contexts(msk, &data); return msk->sched->get_subflow(msk, &data); } @@ -XXX,XX +XXX,XX @@ int mptcp_sched_get_retrans(struct mptcp_sock *msk) data.reinject = true; if (msk->sched == &mptcp_sched_default || !msk->sched) return mptcp_sched_default_get_subflow(msk, &data); + mptcp_sched_data_set_contexts(msk, &data); return msk->sched->get_subflow(msk, &data); } - -void mptcp_sched_data_set_contexts(const struct mptcp_sock *msk, - struct mptcp_sched_data *data) -{ - struct mptcp_subflow_context *subflow; - int i = 0; - - mptcp_for_each_subflow(msk, subflow) { - if (i == MPTCP_SUBFLOWS_MAX) { - pr_warn_once("too many subflows"); - break; - } - mptcp_subflow_set_scheduled(subflow, false); - data->contexts[i++] = subflow; - } - data->subflows = i; - - for (; i < MPTCP_SUBFLOWS_MAX; i++) - data->contexts[i] = NULL; -} - -struct mptcp_subflow_context * -mptcp_subflow_ctx_by_pos(const struct mptcp_sched_data *data, unsigned int pos) -{ - if (pos >= MPTCP_SUBFLOWS_MAX) - return NULL; - return data->contexts[pos]; -} -- 2.35.3
Add write acess to msk->snd_burst. Signed-off-by: Geliang Tang <geliang.tang@suse.com> --- net/mptcp/bpf.c | 28 ++++++++++++++++++++-------- 1 file changed, 20 insertions(+), 8 deletions(-) diff --git a/net/mptcp/bpf.c b/net/mptcp/bpf.c index XXXXXXX..XXXXXXX 100644 --- a/net/mptcp/bpf.c +++ b/net/mptcp/bpf.c @@ -XXX,XX +XXX,XX @@ #ifdef CONFIG_BPF_JIT extern struct bpf_struct_ops bpf_mptcp_sched_ops; -static const struct btf_type *mptcp_sched_type __read_mostly; -static u32 mptcp_sched_id; +static const struct btf_type *mptcp_sock_type, *mptcp_subflow_type __read_mostly; +static u32 mptcp_sock_id, mptcp_subflow_id; static const struct bpf_func_proto * bpf_mptcp_sched_get_func_proto(enum bpf_func_id func_id, @@ -XXX,XX +XXX,XX @@ static int bpf_mptcp_sched_btf_struct_access(struct bpf_verifier_log *log, size_t end; t = btf_type_by_id(reg->btf, reg->btf_id); - if (t != mptcp_sched_type) { - bpf_log(log, "only access to mptcp_subflow_context is supported\n"); + if (t != mptcp_sock_type && t != mptcp_subflow_type) { + bpf_log(log, "only access to mptcp sock or subflow is supported\n"); return -EACCES; } switch (off) { + case offsetof(struct mptcp_sock, snd_burst): + end = offsetofend(struct mptcp_sock, snd_burst); + break; case offsetof(struct mptcp_subflow_context, scheduled): end = offsetofend(struct mptcp_subflow_context, scheduled); break; @@ -XXX,XX +XXX,XX @@ static int bpf_mptcp_sched_btf_struct_access(struct bpf_verifier_log *log, end = offsetofend(struct mptcp_subflow_context, avg_pacing_rate); break; default: - bpf_log(log, "no write support to mptcp_subflow_context at off %d\n", off); + bpf_log(log, "no write support to %s at off %d\n", + t == mptcp_sock_type ? "mptcp_sock" : "mptcp_subflow_context", off); return -EACCES; } if (off + size > end) { - bpf_log(log, "access beyond mptcp_subflow_context at off %u size %u ended at %zu", + bpf_log(log, "access beyond %s at off %u size %u ended at %zu", + t == mptcp_sock_type ? "mptcp_sock" : "mptcp_subflow_context", off, size, end); return -EACCES; } @@ -XXX,XX +XXX,XX @@ static int bpf_mptcp_sched_init(struct btf *btf) { s32 type_id; + type_id = btf_find_by_name_kind(btf, "mptcp_sock", + BTF_KIND_STRUCT); + if (type_id < 0) + return -EINVAL; + mptcp_sock_id = type_id; + mptcp_sock_type = btf_type_by_id(btf, mptcp_sock_id); + type_id = btf_find_by_name_kind(btf, "mptcp_subflow_context", BTF_KIND_STRUCT); if (type_id < 0) return -EINVAL; - mptcp_sched_id = type_id; - mptcp_sched_type = btf_type_by_id(btf, mptcp_sched_id); + mptcp_subflow_id = type_id; + mptcp_subflow_type = btf_type_by_id(btf, mptcp_subflow_id); return 0; } -- 2.35.3
Update mptcp_sched_data_set_contexts and mptcp_subflow_ctx_by_pos. Signed-off-by: Geliang Tang <geliang.tang@suse.com> --- tools/testing/selftests/bpf/bpf_tcp_helpers.h | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/tools/testing/selftests/bpf/bpf_tcp_helpers.h b/tools/testing/selftests/bpf/bpf_tcp_helpers.h index XXXXXXX..XXXXXXX 100644 --- a/tools/testing/selftests/bpf/bpf_tcp_helpers.h +++ b/tools/testing/selftests/bpf/bpf_tcp_helpers.h @@ -XXX,XX +XXX,XX @@ struct mptcp_sock { extern void mptcp_subflow_set_scheduled(struct mptcp_subflow_context *subflow, bool scheduled) __ksym; -extern void mptcp_sched_data_set_contexts(const struct mptcp_sock *msk, - struct mptcp_sched_data *data) __ksym; extern struct mptcp_subflow_context * -mptcp_subflow_ctx_by_pos(const struct mptcp_sched_data *data, unsigned int pos) __ksym; +bpf_mptcp_subflow_ctx_by_pos(const struct mptcp_sched_data *data, unsigned int pos) __ksym; static __always_inline struct sock * mptcp_subflow_tcp_sock(const struct mptcp_subflow_context *subflow) { -- 2.35.3
Update mptcp_sched_data_set_contexts and mptcp_subflow_ctx_by_pos. Signed-off-by: Geliang Tang <geliang.tang@suse.com> --- tools/testing/selftests/bpf/progs/mptcp_bpf_first.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/tools/testing/selftests/bpf/progs/mptcp_bpf_first.c b/tools/testing/selftests/bpf/progs/mptcp_bpf_first.c index XXXXXXX..XXXXXXX 100644 --- a/tools/testing/selftests/bpf/progs/mptcp_bpf_first.c +++ b/tools/testing/selftests/bpf/progs/mptcp_bpf_first.c @@ -XXX,XX +XXX,XX @@ void BPF_PROG(mptcp_sched_first_release, struct mptcp_sock *msk) int BPF_STRUCT_OPS(bpf_first_get_subflow, struct mptcp_sock *msk, struct mptcp_sched_data *data) { - mptcp_sched_data_set_contexts(msk, data); - mptcp_subflow_set_scheduled(mptcp_subflow_ctx_by_pos(data, 0), true); + mptcp_subflow_set_scheduled(bpf_mptcp_subflow_ctx_by_pos(data, 0), true); return 0; } -- 2.35.3
Update mptcp_sched_data_set_contexts and mptcp_subflow_ctx_by_pos. Signed-off-by: Geliang Tang <geliang.tang@suse.com> --- tools/testing/selftests/bpf/progs/mptcp_bpf_bkup.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/tools/testing/selftests/bpf/progs/mptcp_bpf_bkup.c b/tools/testing/selftests/bpf/progs/mptcp_bpf_bkup.c index XXXXXXX..XXXXXXX 100644 --- a/tools/testing/selftests/bpf/progs/mptcp_bpf_bkup.c +++ b/tools/testing/selftests/bpf/progs/mptcp_bpf_bkup.c @@ -XXX,XX +XXX,XX @@ int BPF_STRUCT_OPS(bpf_bkup_get_subflow, struct mptcp_sock *msk, { int nr = -1; - mptcp_sched_data_set_contexts(msk, data); - for (int i = 0; i < data->subflows && i < MPTCP_SUBFLOWS_MAX; i++) { struct mptcp_subflow_context *subflow; - subflow = mptcp_subflow_ctx_by_pos(data, i); + subflow = bpf_mptcp_subflow_ctx_by_pos(data, i); if (!subflow) break; @@ -XXX,XX +XXX,XX @@ int BPF_STRUCT_OPS(bpf_bkup_get_subflow, struct mptcp_sock *msk, } if (nr != -1) { - mptcp_subflow_set_scheduled(mptcp_subflow_ctx_by_pos(data, nr), true); + mptcp_subflow_set_scheduled(bpf_mptcp_subflow_ctx_by_pos(data, nr), true); return -1; } return 0; -- 2.35.3
Update mptcp_sched_data_set_contexts and mptcp_subflow_ctx_by_pos. Signed-off-by: Geliang Tang <geliang.tang@suse.com> --- tools/testing/selftests/bpf/progs/mptcp_bpf_rr.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/tools/testing/selftests/bpf/progs/mptcp_bpf_rr.c b/tools/testing/selftests/bpf/progs/mptcp_bpf_rr.c index XXXXXXX..XXXXXXX 100644 --- a/tools/testing/selftests/bpf/progs/mptcp_bpf_rr.c +++ b/tools/testing/selftests/bpf/progs/mptcp_bpf_rr.c @@ -XXX,XX +XXX,XX @@ int BPF_STRUCT_OPS(bpf_rr_get_subflow, struct mptcp_sock *msk, last_snd = ptr->last_snd; - mptcp_sched_data_set_contexts(msk, data); - for (int i = 0; i < data->subflows && i < MPTCP_SUBFLOWS_MAX; i++) { - subflow = mptcp_subflow_ctx_by_pos(data, i); + subflow = bpf_mptcp_subflow_ctx_by_pos(data, i); if (!last_snd || !subflow) break; if (mptcp_subflow_tcp_sock(subflow) == last_snd) { - if (i + 1 == MPTCP_SUBFLOWS_MAX || !mptcp_subflow_ctx_by_pos(data, i + 1)) + if (i + 1 == MPTCP_SUBFLOWS_MAX || + !bpf_mptcp_subflow_ctx_by_pos(data, i + 1)) break; nr = i + 1; @@ -XXX,XX +XXX,XX @@ int BPF_STRUCT_OPS(bpf_rr_get_subflow, struct mptcp_sock *msk, } } - subflow = mptcp_subflow_ctx_by_pos(data, nr); + subflow = bpf_mptcp_subflow_ctx_by_pos(data, nr); if (!subflow) return -1; mptcp_subflow_set_scheduled(subflow, true); -- 2.35.3
Update mptcp_sched_data_set_contexts and mptcp_subflow_ctx_by_pos. Signed-off-by: Geliang Tang <geliang.tang@suse.com> --- tools/testing/selftests/bpf/progs/mptcp_bpf_red.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/tools/testing/selftests/bpf/progs/mptcp_bpf_red.c b/tools/testing/selftests/bpf/progs/mptcp_bpf_red.c index XXXXXXX..XXXXXXX 100644 --- a/tools/testing/selftests/bpf/progs/mptcp_bpf_red.c +++ b/tools/testing/selftests/bpf/progs/mptcp_bpf_red.c @@ -XXX,XX +XXX,XX @@ void BPF_PROG(mptcp_sched_red_release, struct mptcp_sock *msk) int BPF_STRUCT_OPS(bpf_red_get_subflow, struct mptcp_sock *msk, struct mptcp_sched_data *data) { - mptcp_sched_data_set_contexts(msk, data); - for (int i = 0; i < data->subflows && i < MPTCP_SUBFLOWS_MAX; i++) { - if (!mptcp_subflow_ctx_by_pos(data, i)) + if (!bpf_mptcp_subflow_ctx_by_pos(data, i)) break; - mptcp_subflow_set_scheduled(mptcp_subflow_ctx_by_pos(data, i), true); + mptcp_subflow_set_scheduled(bpf_mptcp_subflow_ctx_by_pos(data, i), true); } return 0; -- 2.35.3
Update mptcp_sched_data_set_contexts and mptcp_subflow_ctx_by_pos. Store burst in msk->snd_burst instead of in sk_storage. Signed-off-by: Geliang Tang <geliang.tang@suse.com> --- tools/testing/selftests/bpf/bpf_tcp_helpers.h | 1 + .../selftests/bpf/progs/mptcp_bpf_burst.c | 30 ++++--------------- 2 files changed, 6 insertions(+), 25 deletions(-) diff --git a/tools/testing/selftests/bpf/bpf_tcp_helpers.h b/tools/testing/selftests/bpf/bpf_tcp_helpers.h index XXXXXXX..XXXXXXX 100644 --- a/tools/testing/selftests/bpf/bpf_tcp_helpers.h +++ b/tools/testing/selftests/bpf/bpf_tcp_helpers.h @@ -XXX,XX +XXX,XX @@ struct mptcp_sock { struct inet_connection_sock sk; __u64 snd_nxt; + int snd_burst; __u32 token; struct sock *first; char ca_name[TCP_CA_NAME_MAX]; diff --git a/tools/testing/selftests/bpf/progs/mptcp_bpf_burst.c b/tools/testing/selftests/bpf/progs/mptcp_bpf_burst.c index XXXXXXX..XXXXXXX 100644 --- a/tools/testing/selftests/bpf/progs/mptcp_bpf_burst.c +++ b/tools/testing/selftests/bpf/progs/mptcp_bpf_burst.c @@ -XXX,XX +XXX,XX @@ char _license[] SEC("license") = "GPL"; -struct mptcp_burst_storage { - int snd_burst; -}; - -struct { - __uint(type, BPF_MAP_TYPE_SK_STORAGE); - __uint(map_flags, BPF_F_NO_PREALLOC); - __type(key, int); - __type(value, struct mptcp_burst_storage); -} mptcp_burst_map SEC(".maps"); - #define MPTCP_SEND_BURST_SIZE 65428 struct subflow_send_info { @@ -XXX,XX +XXX,XX @@ static __always_inline bool sk_stream_memory_free(const struct sock *sk) SEC("struct_ops/mptcp_sched_burst_init") void BPF_PROG(mptcp_sched_burst_init, struct mptcp_sock *msk) { - bpf_sk_storage_get(&mptcp_burst_map, msk, 0, - BPF_LOCAL_STORAGE_GET_F_CREATE); } SEC("struct_ops/mptcp_sched_burst_release") void BPF_PROG(mptcp_sched_burst_release, struct mptcp_sock *msk) { - bpf_sk_storage_delete(&mptcp_burst_map, msk); } static int bpf_burst_get_send(struct mptcp_sock *msk, @@ -XXX,XX +XXX,XX @@ static int bpf_burst_get_send(struct mptcp_sock *msk, struct subflow_send_info send_info[SSK_MODE_MAX]; struct mptcp_subflow_context *subflow; struct sock *sk = (struct sock *)msk; - struct mptcp_burst_storage *ptr; __u32 pace, burst, wmem; __u64 linger_time; struct sock *ssk; @@ -XXX,XX +XXX,XX @@ static int bpf_burst_get_send(struct mptcp_sock *msk, } for (i = 0; i < data->subflows && i < MPTCP_SUBFLOWS_MAX; i++) { - subflow = mptcp_subflow_ctx_by_pos(data, i); + subflow = bpf_mptcp_subflow_ctx_by_pos(data, i); if (!subflow) break; @@ -XXX,XX +XXX,XX @@ static int bpf_burst_get_send(struct mptcp_sock *msk, if (send_info[SSK_MODE_ACTIVE].subflow_id == MPTCP_SUBFLOWS_MAX) send_info[SSK_MODE_ACTIVE].subflow_id = send_info[SSK_MODE_BACKUP].subflow_id; - subflow = mptcp_subflow_ctx_by_pos(data, send_info[SSK_MODE_ACTIVE].subflow_id); + subflow = bpf_mptcp_subflow_ctx_by_pos(data, send_info[SSK_MODE_ACTIVE].subflow_id); if (!subflow) return -1; ssk = mptcp_subflow_tcp_sock(subflow); @@ -XXX,XX +XXX,XX @@ static int bpf_burst_get_send(struct mptcp_sock *msk, subflow->avg_pacing_rate = div_u64((__u64)subflow->avg_pacing_rate * wmem + ssk->sk_pacing_rate * burst, burst + wmem); - ptr = bpf_sk_storage_get(&mptcp_burst_map, msk, 0, - BPF_LOCAL_STORAGE_GET_F_CREATE); - if (ptr) - ptr->snd_burst = burst; + msk->snd_burst = burst; out: mptcp_subflow_set_scheduled(subflow, true); @@ -XXX,XX +XXX,XX @@ static int bpf_burst_get_retrans(struct mptcp_sock *msk, struct sock *ssk; for (int i = 0; i < data->subflows && i < MPTCP_SUBFLOWS_MAX; i++) { - subflow = mptcp_subflow_ctx_by_pos(data, i); + subflow = bpf_mptcp_subflow_ctx_by_pos(data, i); if (!subflow) break; @@ -XXX,XX +XXX,XX @@ static int bpf_burst_get_retrans(struct mptcp_sock *msk, subflow_id = min_stale_count > 1 ? backup : MPTCP_SUBFLOWS_MAX; out: - subflow = mptcp_subflow_ctx_by_pos(data, subflow_id); + subflow = bpf_mptcp_subflow_ctx_by_pos(data, subflow_id); if (!subflow) return -1; mptcp_subflow_set_scheduled(subflow, true); @@ -XXX,XX +XXX,XX @@ static int bpf_burst_get_retrans(struct mptcp_sock *msk, int BPF_STRUCT_OPS(bpf_burst_get_subflow, struct mptcp_sock *msk, struct mptcp_sched_data *data) { - mptcp_sched_data_set_contexts(msk, data); - if (data->reinject) return bpf_burst_get_retrans(msk, data); return bpf_burst_get_send(msk, data); -- 2.35.3