mirror of
https://mirrors.bfsu.edu.cn/git/linux.git
synced 2024-11-27 14:14:24 +08:00
mptcp: fix subflow accounting on close
If the PM closes a fully established MPJ subflow or the subflow
creation errors out in it's early stage the subflows counter is
not bumped accordingly.
This change adds the missing accounting, additionally taking care
of updating accordingly the 'accept_subflow' flag.
Fixes: a88c9e4969
("mptcp: do not block subflows creation on errors")
Signed-off-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>
This commit is contained in:
parent
04c494e68a
commit
95d6865178
@ -178,14 +178,13 @@ void mptcp_pm_subflow_check_next(struct mptcp_sock *msk, const struct sock *ssk,
|
||||
struct mptcp_pm_data *pm = &msk->pm;
|
||||
bool update_subflows;
|
||||
|
||||
update_subflows = (ssk->sk_state == TCP_CLOSE) &&
|
||||
(subflow->request_join || subflow->mp_join);
|
||||
update_subflows = subflow->request_join || subflow->mp_join;
|
||||
if (!READ_ONCE(pm->work_pending) && !update_subflows)
|
||||
return;
|
||||
|
||||
spin_lock_bh(&pm->lock);
|
||||
if (update_subflows)
|
||||
pm->subflows--;
|
||||
__mptcp_pm_close_subflow(msk);
|
||||
|
||||
/* Even if this subflow is not really established, tell the PM to try
|
||||
* to pick the next ones, if possible.
|
||||
|
@ -833,6 +833,20 @@ unsigned int mptcp_pm_get_add_addr_accept_max(const struct mptcp_sock *msk);
|
||||
unsigned int mptcp_pm_get_subflows_max(const struct mptcp_sock *msk);
|
||||
unsigned int mptcp_pm_get_local_addr_max(const struct mptcp_sock *msk);
|
||||
|
||||
/* called under PM lock */
|
||||
static inline void __mptcp_pm_close_subflow(struct mptcp_sock *msk)
|
||||
{
|
||||
if (--msk->pm.subflows < mptcp_pm_get_subflows_max(msk))
|
||||
WRITE_ONCE(msk->pm.accept_subflow, true);
|
||||
}
|
||||
|
||||
static inline void mptcp_pm_close_subflow(struct mptcp_sock *msk)
|
||||
{
|
||||
spin_lock_bh(&msk->pm.lock);
|
||||
__mptcp_pm_close_subflow(msk);
|
||||
spin_unlock_bh(&msk->pm.lock);
|
||||
}
|
||||
|
||||
void mptcp_sockopt_sync(struct mptcp_sock *msk, struct sock *ssk);
|
||||
void mptcp_sockopt_sync_locked(struct mptcp_sock *msk, struct sock *ssk);
|
||||
|
||||
|
@ -1422,20 +1422,20 @@ int __mptcp_subflow_connect(struct sock *sk, const struct mptcp_addr_info *loc,
|
||||
struct sockaddr_storage addr;
|
||||
int remote_id = remote->id;
|
||||
int local_id = loc->id;
|
||||
int err = -ENOTCONN;
|
||||
struct socket *sf;
|
||||
struct sock *ssk;
|
||||
u32 remote_token;
|
||||
int addrlen;
|
||||
int ifindex;
|
||||
u8 flags;
|
||||
int err;
|
||||
|
||||
if (!mptcp_is_fully_established(sk))
|
||||
return -ENOTCONN;
|
||||
goto err_out;
|
||||
|
||||
err = mptcp_subflow_create_socket(sk, &sf);
|
||||
if (err)
|
||||
return err;
|
||||
goto err_out;
|
||||
|
||||
ssk = sf->sk;
|
||||
subflow = mptcp_subflow_ctx(ssk);
|
||||
@ -1492,6 +1492,12 @@ failed_unlink:
|
||||
failed:
|
||||
subflow->disposable = 1;
|
||||
sock_release(sf);
|
||||
|
||||
err_out:
|
||||
/* we account subflows before the creation, and this failures will not
|
||||
* be caught by sk_state_change()
|
||||
*/
|
||||
mptcp_pm_close_subflow(msk);
|
||||
return err;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user