diff options
author | Geliang Tang <geliang.tang@suse.com> | 2023-08-22 01:25:16 +0300 |
---|---|---|
committer | Jakub Kicinski <kuba@kernel.org> | 2023-08-23 03:31:19 +0300 |
commit | 1730b2b2c5a5a886007b247366aebe0976dc8881 (patch) | |
tree | 6bdfe2645f4be4f94423f41e011cb733e32cb7cb /net/mptcp/sched.c | |
parent | e3b2870b6d220d1cbd2d52d7acc9f0de9fdfeccf (diff) | |
download | linux-1730b2b2c5a5a886007b247366aebe0976dc8881.tar.xz |
mptcp: add sched in mptcp_sock
This patch adds a new struct member sched in struct mptcp_sock.
And two helpers mptcp_init_sched() and mptcp_release_sched() to
init and release it.
Init it with the sysctl scheduler in mptcp_init_sock(), copy the
scheduler from the parent in mptcp_sk_clone(), and release it in
__mptcp_destroy_sock().
Acked-by: Paolo Abeni <pabeni@redhat.com>
Reviewed-by: Mat Martineau <martineau@kernel.org>
Signed-off-by: Geliang Tang <geliang.tang@suse.com>
Signed-off-by: Mat Martineau <martineau@kernel.org>
Link: https://lore.kernel.org/r/20230821-upstream-net-next-20230818-v1-5-0c860fb256a8@kernel.org
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
Diffstat (limited to 'net/mptcp/sched.c')
-rw-r--r-- | net/mptcp/sched.c | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/net/mptcp/sched.c b/net/mptcp/sched.c index c5d3bbafba71..53773668b5ee 100644 --- a/net/mptcp/sched.c +++ b/net/mptcp/sched.c @@ -54,3 +54,36 @@ void mptcp_unregister_scheduler(struct mptcp_sched_ops *sched) list_del_rcu(&sched->list); spin_unlock(&mptcp_sched_list_lock); } + +int mptcp_init_sched(struct mptcp_sock *msk, + struct mptcp_sched_ops *sched) +{ + if (!sched) + goto out; + + if (!bpf_try_module_get(sched, sched->owner)) + return -EBUSY; + + msk->sched = sched; + if (msk->sched->init) + msk->sched->init(msk); + + pr_debug("sched=%s", msk->sched->name); + +out: + return 0; +} + +void mptcp_release_sched(struct mptcp_sock *msk) +{ + struct mptcp_sched_ops *sched = msk->sched; + + if (!sched) + return; + + msk->sched = NULL; + if (sched->release) + sched->release(msk); + + bpf_module_put(sched, sched->owner); +} |