@@ -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,
@@ -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;
@@ -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;
}
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 <gregory.detal@gmail.com> --- net/mptcp/bpf.c | 25 +++++++++++++++++++++++-- 1 file changed, 23 insertions(+), 2 deletions(-)