mptcp: sched: split validation part
authorGeliang Tang <tanggeliang@kylinos.cn>
Sun, 13 Apr 2025 09:34:33 +0000 (11:34 +0200)
committerJakub Kicinski <kuba@kernel.org>
Tue, 15 Apr 2025 15:21:46 +0000 (08:21 -0700)
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>
net/mptcp/protocol.h
net/mptcp/sched.c

index d409586..7aa38d7 100644 (file)
@@ -744,6 +744,7 @@ void mptcp_info2sockaddr(const struct mptcp_addr_info *info,
                         struct sockaddr_storage *addr,
                         unsigned short family);
 struct mptcp_sched_ops *mptcp_sched_find(const char *name);
+int mptcp_validate_scheduler(struct mptcp_sched_ops *sched);
 int mptcp_register_scheduler(struct mptcp_sched_ops *sched);
 void mptcp_unregister_scheduler(struct mptcp_sched_ops *sched);
 void mptcp_sched_init(void);
index f09f7eb..1e59072 100644 (file)
@@ -82,10 +82,23 @@ void mptcp_get_available_schedulers(char *buf, size_t maxlen)
        rcu_read_unlock();
 }
 
-int mptcp_register_scheduler(struct mptcp_sched_ops *sched)
+int mptcp_validate_scheduler(struct mptcp_sched_ops *sched)
 {
-       if (!sched->get_send)
+       if (!sched->get_send) {
+               pr_err("%s does not implement required ops\n", sched->name);
                return -EINVAL;
+       }
+
+       return 0;
+}
+
+int mptcp_register_scheduler(struct mptcp_sched_ops *sched)
+{
+       int ret;
+
+       ret = mptcp_validate_scheduler(sched);
+       if (ret)
+               return ret;
 
        spin_lock(&mptcp_sched_list_lock);
        if (mptcp_sched_find(sched->name)) {