On Thu, 6 Mar 2025, Geliang Tang wrote:
> From: Geliang Tang <tanggeliang@kylinos.cn>
>
> 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 <tanggeliang@kylinos.cn>
This patch LGTM:
Reviewed-by: Mat Martineau <martineau@kernel.org>
The rest of the series looks ok to squash, with one note on patch 3.
- Mat
> ---
> net/mptcp/protocol.h | 1 +
> net/mptcp/sched.c | 17 +++++++++++++++--
> 2 files changed, 16 insertions(+), 2 deletions(-)
>
> diff --git a/net/mptcp/protocol.h b/net/mptcp/protocol.h
> index 3492b256ecba..77b4ec0b0dd8 100644
> --- a/net/mptcp/protocol.h
> +++ b/net/mptcp/protocol.h
> @@ -740,6 +740,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);
> diff --git a/net/mptcp/sched.c b/net/mptcp/sched.c
> index f09f7eb1d63f..1e59072d478c 100644
> --- a/net/mptcp/sched.c
> +++ b/net/mptcp/sched.c
> @@ -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)) {
> --
> 2.43.0
>
>
>