Commit f58f065a authored by Geliang Tang's avatar Geliang Tang Committed by David S. Miller

mptcp: add accept_subflow re-check

The re-check of pm->accept_subflow with pm->lock held was missing, this
patch fixed it.
Suggested-by: default avatarMat Martineau <mathew.j.martineau@linux.intel.com>
Reviewed-by: default avatarMat Martineau <mathew.j.martineau@linux.intel.com>
Signed-off-by: default avatarGeliang Tang <geliangtang@gmail.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent be613160
...@@ -48,7 +48,7 @@ void mptcp_pm_new_connection(struct mptcp_sock *msk, int server_side) ...@@ -48,7 +48,7 @@ void mptcp_pm_new_connection(struct mptcp_sock *msk, int server_side)
bool mptcp_pm_allow_new_subflow(struct mptcp_sock *msk) bool mptcp_pm_allow_new_subflow(struct mptcp_sock *msk)
{ {
struct mptcp_pm_data *pm = &msk->pm; struct mptcp_pm_data *pm = &msk->pm;
int ret; int ret = 0;
pr_debug("msk=%p subflows=%d max=%d allow=%d", msk, pm->subflows, pr_debug("msk=%p subflows=%d max=%d allow=%d", msk, pm->subflows,
pm->subflows_max, READ_ONCE(pm->accept_subflow)); pm->subflows_max, READ_ONCE(pm->accept_subflow));
...@@ -58,9 +58,11 @@ bool mptcp_pm_allow_new_subflow(struct mptcp_sock *msk) ...@@ -58,9 +58,11 @@ bool mptcp_pm_allow_new_subflow(struct mptcp_sock *msk)
return false; return false;
spin_lock_bh(&pm->lock); spin_lock_bh(&pm->lock);
if (READ_ONCE(pm->accept_subflow)) {
ret = pm->subflows < pm->subflows_max; ret = pm->subflows < pm->subflows_max;
if (ret && ++pm->subflows == pm->subflows_max) if (ret && ++pm->subflows == pm->subflows_max)
WRITE_ONCE(pm->accept_subflow, false); WRITE_ONCE(pm->accept_subflow, false);
}
spin_unlock_bh(&pm->lock); spin_unlock_bh(&pm->lock);
return ret; return ret;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment