Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

mptcp: sched: split validation part

A new interface .validate has been added in struct bpf_struct_ops
recently. This patch prepares a future struct_ops support by
implementing 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 <tanggeliang@kylinos.cn>
Reviewed-by: Mat Martineau <martineau@kernel.org>
Signed-off-by: Matthieu Baerts (NGI0) <matttbe@kernel.org>
Link: https://patch.msgid.link/20250413-net-next-mptcp-sched-mib-sft-misc-v2-2-0f83a4350150@kernel.org
Signed-off-by: Jakub Kicinski <kuba@kernel.org>

authored by

Geliang Tang and committed by
Jakub Kicinski
760ff076 6e83166d

+16 -2
+1
net/mptcp/protocol.h
··· 744 744 struct sockaddr_storage *addr, 745 745 unsigned short family); 746 746 struct mptcp_sched_ops *mptcp_sched_find(const char *name); 747 + int mptcp_validate_scheduler(struct mptcp_sched_ops *sched); 747 748 int mptcp_register_scheduler(struct mptcp_sched_ops *sched); 748 749 void mptcp_unregister_scheduler(struct mptcp_sched_ops *sched); 749 750 void mptcp_sched_init(void);
+15 -2
net/mptcp/sched.c
··· 82 82 rcu_read_unlock(); 83 83 } 84 84 85 + int mptcp_validate_scheduler(struct mptcp_sched_ops *sched) 86 + { 87 + if (!sched->get_send) { 88 + pr_err("%s does not implement required ops\n", sched->name); 89 + return -EINVAL; 90 + } 91 + 92 + return 0; 93 + } 94 + 85 95 int mptcp_register_scheduler(struct mptcp_sched_ops *sched) 86 96 { 87 - if (!sched->get_send) 88 - return -EINVAL; 97 + int ret; 98 + 99 + ret = mptcp_validate_scheduler(sched); 100 + if (ret) 101 + return ret; 89 102 90 103 spin_lock(&mptcp_sched_list_lock); 91 104 if (mptcp_sched_find(sched->name)) {