Commit f745a3eb authored by Paolo Abeni's avatar Paolo Abeni Committed by Jakub Kicinski

mptcp: consistent map handling on failure

When the MPTCP receive path reach a non fatal fall-back condition, e.g.
when the MPC sockets must fall-back to TCP, the existing code is a little
self-inconsistent: it reports that new data is available - return true -
but sets the MPC flag to the opposite value.

As the consequence read operations in some exceptional scenario may block
unexpectedly.

Address the issue setting the correct MPC read status. Additionally avoid
some code duplication in the fatal fall-back scenario.

Fixes: 9c81be0d ("mptcp: add MP_FAIL response support")
Signed-off-by: default avatarPaolo Abeni <pabeni@redhat.com>
Signed-off-by: default avatarMat Martineau <mathew.j.martineau@linux.intel.com>
Signed-off-by: default avatarJakub Kicinski <kuba@kernel.org>
parent d51991e2
...@@ -1252,17 +1252,12 @@ static bool subflow_check_data_avail(struct sock *ssk) ...@@ -1252,17 +1252,12 @@ static bool subflow_check_data_avail(struct sock *ssk)
subflow->send_mp_fail = 1; subflow->send_mp_fail = 1;
if (!READ_ONCE(msk->allow_infinite_fallback)) { if (!READ_ONCE(msk->allow_infinite_fallback)) {
ssk->sk_err = EBADMSG;
tcp_set_state(ssk, TCP_CLOSE);
subflow->reset_transient = 0; subflow->reset_transient = 0;
subflow->reset_reason = MPTCP_RST_EMIDDLEBOX; subflow->reset_reason = MPTCP_RST_EMIDDLEBOX;
tcp_send_active_reset(ssk, GFP_ATOMIC); goto reset;
while ((skb = skb_peek(&ssk->sk_receive_queue)))
sk_eat_skb(ssk, skb);
} else {
mptcp_subflow_fail(msk, ssk);
} }
WRITE_ONCE(subflow->data_avail, MPTCP_SUBFLOW_NODATA); mptcp_subflow_fail(msk, ssk);
WRITE_ONCE(subflow->data_avail, MPTCP_SUBFLOW_DATA_AVAIL);
return true; return true;
} }
...@@ -1270,10 +1265,14 @@ static bool subflow_check_data_avail(struct sock *ssk) ...@@ -1270,10 +1265,14 @@ static bool subflow_check_data_avail(struct sock *ssk)
/* fatal protocol error, close the socket. /* fatal protocol error, close the socket.
* subflow_error_report() will introduce the appropriate barriers * subflow_error_report() will introduce the appropriate barriers
*/ */
ssk->sk_err = EBADMSG;
tcp_set_state(ssk, TCP_CLOSE);
subflow->reset_transient = 0; subflow->reset_transient = 0;
subflow->reset_reason = MPTCP_RST_EMPTCP; subflow->reset_reason = MPTCP_RST_EMPTCP;
reset:
ssk->sk_err = EBADMSG;
tcp_set_state(ssk, TCP_CLOSE);
while ((skb = skb_peek(&ssk->sk_receive_queue)))
sk_eat_skb(ssk, skb);
tcp_send_active_reset(ssk, GFP_ATOMIC); tcp_send_active_reset(ssk, GFP_ATOMIC);
WRITE_ONCE(subflow->data_avail, MPTCP_SUBFLOW_NODATA); WRITE_ONCE(subflow->data_avail, MPTCP_SUBFLOW_NODATA);
return false; return false;
......
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