From: Mat Martineau <martineau@kernel.org>
To: Geliang Tang <geliang.tang@suse.com>
Cc: mptcp@lists.linux.dev
Subject: Re: [RFC mptcp-next v2 2/2] mptcp: add bpf_burst set/get params
Date: Fri, 1 Sep 2023 16:53:56 -0700 (PDT) [thread overview]
Message-ID: <ee098f0f-89ef-ba84-c09b-e93a770ab264@kernel.org> (raw)
In-Reply-To: <486891cb494ba4e9eeb02b6e220ca670dbc80866.1692788531.git.geliang.tang@suse.com>
On Wed, 23 Aug 2023, Geliang Tang wrote:
> 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 2926f1f00d65..805142d59d02 100644
> --- a/include/net/bpf_sk_storage.h
> +++ b/include/net/bpf_sk_storage.h
> @@ -37,6 +37,8 @@ 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)
> @@ -58,6 +60,11 @@ 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 cca7594be92e..1c023f65017f 100644
> --- a/net/core/bpf_sk_storage.c
> +++ b/net/core/bpf_sk_storage.c
> @@ -17,7 +17,7 @@
>
> 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 c78ed61290d2..067df28899a6 100644
> --- a/net/mptcp/sched.c
> +++ b/net/mptcp/sched.c
> @@ -11,6 +11,7 @@
> #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);
> @@ -202,18 +203,56 @@ 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;
> }
This seems very complex. Why implement it this way versus adding snd_burst
to 'struct mptcp_sock' in bpf_tcp_helpers.h?
- Mat
>
> 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
>
>
>
prev parent reply other threads:[~2023-09-01 23:53 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-08-23 11:04 [RFC mptcp-next v2 0/2] BPF packet scheduler updates part 4 Geliang Tang
2023-08-23 11:04 ` [RFC mptcp-next v2 1/2] mptcp: add set/get params wrappers Geliang Tang
2023-08-23 11:04 ` [RFC mptcp-next v2 2/2] mptcp: add bpf_burst set/get params Geliang Tang
2023-08-23 11:28 ` mptcp: add bpf_burst set/get params: Build Failure MPTCP CI
2023-08-23 12:11 ` mptcp: add bpf_burst set/get params: Tests Results MPTCP CI
2023-08-23 17:21 ` [RFC mptcp-next v2 2/2] mptcp: add bpf_burst set/get params kernel test robot
2023-08-23 17:21 ` kernel test robot
2023-08-23 20:09 ` kernel test robot
2023-08-23 21:12 ` kernel test robot
2023-08-26 1:21 ` kernel test robot
2023-08-26 1:44 ` kernel test robot
2023-09-01 23:53 ` Mat Martineau [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=ee098f0f-89ef-ba84-c09b-e93a770ab264@kernel.org \
--to=martineau@kernel.org \
--cc=geliang.tang@suse.com \
--cc=mptcp@lists.linux.dev \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.