Skip to content

Commit

Permalink
mptcp: bpf: allow to write to mptcp_sched_chunk
Browse files Browse the repository at this point in the history
This patch allows to write to either limit or flags, allowing a bpf
program to change the packet scheduling behavior.

The fields will be used in next commit.

Signed-off-by: Gregory Detal <[email protected]>
  • Loading branch information
gdetal authored and intel-lab-lkp committed May 27, 2024
1 parent 7d4b5ab commit 8bb7680
Showing 1 changed file with 23 additions and 2 deletions.
25 changes: 23 additions & 2 deletions net/mptcp/bpf.c
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,9 @@

#ifdef CONFIG_BPF_JIT
static struct bpf_struct_ops bpf_mptcp_sched_ops;
static const struct btf_type *mptcp_sock_type, *mptcp_subflow_type __read_mostly;
static u32 mptcp_sock_id, mptcp_subflow_id;
static const struct btf_type *mptcp_sock_type, *mptcp_subflow_type __read_mostly,
*mptcp_sched_chunk_type;
static u32 mptcp_sock_id, mptcp_subflow_id, mptcp_sched_chunk_id;

static const struct bpf_func_proto *
bpf_mptcp_sched_get_func_proto(enum bpf_func_id func_id,
Expand Down Expand Up @@ -71,6 +72,19 @@ static int bpf_mptcp_sched_btf_struct_access(struct bpf_verifier_log *log,
off);
return -EACCES;
}
} else if (t == mptcp_sched_chunk_type) {
switch (off) {
case offsetof(struct mptcp_sched_chunk, limit):
end = offsetofend(struct mptcp_sched_chunk, limit);
break;
case offsetof(struct mptcp_sched_chunk, flags):
end = offsetofend(struct mptcp_sched_chunk, flags);
break;
default:
bpf_log(log, "no write support to mptcp_sched_chunk at off %d\n",
off);
return -EACCES;
}
} else {
bpf_log(log, "only access to mptcp sock or subflow is supported\n");
return -EACCES;
Expand Down Expand Up @@ -152,6 +166,13 @@ static int bpf_mptcp_sched_init(struct btf *btf)
mptcp_subflow_id = type_id;
mptcp_subflow_type = btf_type_by_id(btf, mptcp_subflow_id);

type_id = btf_find_by_name_kind(btf, "mptcp_sched_chunk",
BTF_KIND_STRUCT);
if (type_id < 0)
return -EINVAL;
mptcp_sched_chunk_id = type_id;
mptcp_sched_chunk_type = btf_type_by_id(btf, mptcp_sched_chunk_id);

return 0;
}

Expand Down

0 comments on commit 8bb7680

Please sign in to comment.