Skip to content

Commit

Permalink
mptcp: add bpf_burst set/get params
Browse files Browse the repository at this point in the history
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 <[email protected]>
  • Loading branch information
geliangtang authored and intel-lab-lkp committed Aug 23, 2023
1 parent 891d831 commit 81fd11a
Show file tree
Hide file tree
Showing 3 changed files with 47 additions and 1 deletion.
7 changes: 7 additions & 0 deletions include/net/bpf_sk_storage.h
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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 */
2 changes: 1 addition & 1 deletion net/core/bpf_sk_storage.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
39 changes: 39 additions & 0 deletions net/mptcp/sched.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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;
}

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;
}

0 comments on commit 81fd11a

Please sign in to comment.