Skip to content

Commit f3c5152

Browse files
Geliang Tangintel-lab-lkp
authored andcommitted
mptcp: add mptcp_validate_scheduler helper
New interface .validate is added in struct bpf_struct_ops recently, this patch implements it as a new helper mptcp_validate_scheduler() for struct mptcp_sched_ops. In this helper, check whether the required ops "get_subflow" of struct mptcp_sched_ops has been implemented. Signed-off-by: Geliang Tang <[email protected]>
1 parent a5cceef commit f3c5152

File tree

2 files changed

+16
-2
lines changed

2 files changed

+16
-2
lines changed

net/mptcp/protocol.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -740,6 +740,7 @@ void mptcp_info2sockaddr(const struct mptcp_addr_info *info,
740740
struct sockaddr_storage *addr,
741741
unsigned short family);
742742
struct mptcp_sched_ops *mptcp_sched_find(const char *name);
743+
int mptcp_validate_scheduler(struct mptcp_sched_ops *sched);
743744
int mptcp_register_scheduler(struct mptcp_sched_ops *sched);
744745
void mptcp_unregister_scheduler(struct mptcp_sched_ops *sched);
745746
void mptcp_sched_init(void);

net/mptcp/sched.c

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -82,10 +82,23 @@ void mptcp_get_available_schedulers(char *buf, size_t maxlen)
8282
rcu_read_unlock();
8383
}
8484

85-
int mptcp_register_scheduler(struct mptcp_sched_ops *sched)
85+
int mptcp_validate_scheduler(struct mptcp_sched_ops *sched)
8686
{
87-
if (!sched->get_send)
87+
if (!sched->get_send) {
88+
pr_err("%s does not implement required ops\n", sched->name);
8889
return -EINVAL;
90+
}
91+
92+
return 0;
93+
}
94+
95+
int mptcp_register_scheduler(struct mptcp_sched_ops *sched)
96+
{
97+
int ret;
98+
99+
ret = mptcp_validate_scheduler(sched);
100+
if (ret)
101+
return ret;
89102

90103
spin_lock(&mptcp_sched_list_lock);
91104
if (mptcp_sched_find(sched->name)) {

0 commit comments

Comments
 (0)