Skip to content

Commit

Permalink
mptcp: add bpf set scheduled helper
Browse files Browse the repository at this point in the history
This patch adds a new helper bpf_mptcp_subflow_set_scheduled() to set the
scheduled flag of struct mptcp_subflow_context using WRITE_ONCE().
Register this helper in bpf_mptcp_sched_kfunc_init() to make sure it can
be accessed from the BPF context.

Signed-off-by: Geliang Tang <geliang.tang@suse.com>
  • Loading branch information
geliangtang authored and intel-lab-lkp committed Jun 1, 2022
1 parent 573964e commit 4bfb6a3
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 0 deletions.
22 changes: 22 additions & 0 deletions net/mptcp/bpf.c
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,28 @@ struct bpf_struct_ops bpf_mptcp_sched_ops = {
.init = bpf_mptcp_sched_init,
.name = "mptcp_sched_ops",
};

void bpf_mptcp_subflow_set_scheduled(struct mptcp_subflow_context *subflow)
{
WRITE_ONCE(subflow->scheduled, true);
}
EXPORT_SYMBOL(bpf_mptcp_subflow_set_scheduled);

BTF_SET_START(bpf_mptcp_sched_kfunc_ids)
BTF_ID(func, bpf_mptcp_subflow_set_scheduled)
BTF_SET_END(bpf_mptcp_sched_kfunc_ids)

static const struct btf_kfunc_id_set bpf_mptcp_sched_kfunc_set = {
.owner = THIS_MODULE,
.check_set = &bpf_mptcp_sched_kfunc_ids,
};

static int __init bpf_mptcp_sched_kfunc_init(void)
{
return register_btf_kfunc_id_set(BPF_PROG_TYPE_STRUCT_OPS,
&bpf_mptcp_sched_kfunc_set);
}
late_initcall(bpf_mptcp_sched_kfunc_init);
#endif /* CONFIG_BPF_JIT */

struct mptcp_sock *bpf_mptcp_sock_from_subflow(struct sock *sk)
Expand Down
2 changes: 2 additions & 0 deletions tools/testing/selftests/bpf/bpf_tcp_helpers.h
Original file line number Diff line number Diff line change
Expand Up @@ -261,4 +261,6 @@ struct mptcp_sock {
char ca_name[TCP_CA_NAME_MAX];
} __attribute__((preserve_access_index));

extern void bpf_mptcp_subflow_set_scheduled(struct mptcp_subflow_context *subflow) __ksym;

#endif

0 comments on commit 4bfb6a3

Please sign in to comment.