diff options
author | Mat Martineau <mathew.j.martineau@linux.intel.com> | 2022-04-28 00:50:01 +0200 |
---|---|---|
committer | Jakub Kicinski <kuba@kernel.org> | 2022-04-30 02:25:14 +0200 |
commit | 6bb63ccc25d4a8cb8fe48efeda680cb13f84d1b0 (patch) | |
tree | 27a07b92bb40e431961f8ea6cb58b35e984fc353 /net/mptcp/pm.c | |
parent | mptcp: Make kernel path manager check for userspace-managed sockets (diff) | |
download | linux-6bb63ccc25d4a8cb8fe48efeda680cb13f84d1b0.tar.xz linux-6bb63ccc25d4a8cb8fe48efeda680cb13f84d1b0.zip |
mptcp: Add a per-namespace sysctl to set the default path manager type
The new net.mptcp.pm_type sysctl determines which path manager will be
used by each newly-created MPTCP socket.
v2: Handle builds without CONFIG_SYSCTL
v3: Clarify logic for type-specific PM init (Geliang Tang and Paolo Abeni)
Acked-by: Paolo Abeni <pabeni@redhat.com>
Signed-off-by: Mat Martineau <mathew.j.martineau@linux.intel.com>
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
Diffstat (limited to 'net/mptcp/pm.c')
-rw-r--r-- | net/mptcp/pm.c | 34 |
1 files changed, 23 insertions, 11 deletions
diff --git a/net/mptcp/pm.c b/net/mptcp/pm.c index 5320270b3926..57f67578a47f 100644 --- a/net/mptcp/pm.c +++ b/net/mptcp/pm.c @@ -415,7 +415,7 @@ void mptcp_pm_subflow_chk_stale(const struct mptcp_sock *msk, struct sock *ssk) void mptcp_pm_data_reset(struct mptcp_sock *msk) { - bool subflows_allowed = !!mptcp_pm_get_subflows_max(msk); + u8 pm_type = mptcp_get_pm_type(sock_net((struct sock *)msk)); struct mptcp_pm_data *pm = &msk->pm; pm->add_addr_signaled = 0; @@ -424,17 +424,29 @@ void mptcp_pm_data_reset(struct mptcp_sock *msk) pm->subflows = 0; pm->rm_list_tx.nr = 0; pm->rm_list_rx.nr = 0; - WRITE_ONCE(pm->pm_type, MPTCP_PM_TYPE_KERNEL); - /* pm->work_pending must be only be set to 'true' when - * pm->pm_type is set to MPTCP_PM_TYPE_KERNEL - */ - WRITE_ONCE(pm->work_pending, - (!!mptcp_pm_get_local_addr_max(msk) && subflows_allowed) || - !!mptcp_pm_get_add_addr_signal_max(msk)); + WRITE_ONCE(pm->pm_type, pm_type); + + if (pm_type == MPTCP_PM_TYPE_KERNEL) { + bool subflows_allowed = !!mptcp_pm_get_subflows_max(msk); + + /* pm->work_pending must be only be set to 'true' when + * pm->pm_type is set to MPTCP_PM_TYPE_KERNEL + */ + WRITE_ONCE(pm->work_pending, + (!!mptcp_pm_get_local_addr_max(msk) && + subflows_allowed) || + !!mptcp_pm_get_add_addr_signal_max(msk)); + WRITE_ONCE(pm->accept_addr, + !!mptcp_pm_get_add_addr_accept_max(msk) && + subflows_allowed); + WRITE_ONCE(pm->accept_subflow, subflows_allowed); + } else { + WRITE_ONCE(pm->work_pending, 0); + WRITE_ONCE(pm->accept_addr, 0); + WRITE_ONCE(pm->accept_subflow, 0); + } + WRITE_ONCE(pm->addr_signal, 0); - WRITE_ONCE(pm->accept_addr, - !!mptcp_pm_get_add_addr_accept_max(msk) && subflows_allowed); - WRITE_ONCE(pm->accept_subflow, subflows_allowed); WRITE_ONCE(pm->remote_deny_join_id0, false); pm->status = 0; bitmap_fill(msk->pm.id_avail_bitmap, MPTCP_PM_MAX_ADDR_ID + 1); |