Skip to content

Commit

Permalink
mptcp: consistent map handling on failure
Browse files Browse the repository at this point in the history
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: 9c81be0 ("mptcp: add MP_FAIL response support")
Signed-off-by: Paolo Abeni <[email protected]>
Signed-off-by: Mat Martineau <[email protected]>
Signed-off-by: Jakub Kicinski <[email protected]>
  • Loading branch information
Paolo Abeni authored and kuba-moo committed Jun 29, 2022
1 parent d51991e commit f745a3e
Showing 1 changed file with 9 additions and 10 deletions.
19 changes: 9 additions & 10 deletions net/mptcp/subflow.c
Original file line number Diff line number Diff line change
Expand Up @@ -1252,28 +1252,27 @@ static bool subflow_check_data_avail(struct sock *ssk)
subflow->send_mp_fail = 1;

if (!READ_ONCE(msk->allow_infinite_fallback)) {
ssk->sk_err = EBADMSG;
tcp_set_state(ssk, TCP_CLOSE);
subflow->reset_transient = 0;
subflow->reset_reason = MPTCP_RST_EMIDDLEBOX;
tcp_send_active_reset(ssk, GFP_ATOMIC);
while ((skb = skb_peek(&ssk->sk_receive_queue)))
sk_eat_skb(ssk, skb);
} else {
mptcp_subflow_fail(msk, ssk);
goto reset;
}
WRITE_ONCE(subflow->data_avail, MPTCP_SUBFLOW_NODATA);
mptcp_subflow_fail(msk, ssk);
WRITE_ONCE(subflow->data_avail, MPTCP_SUBFLOW_DATA_AVAIL);
return true;
}

if (!subflow_can_fallback(subflow) && subflow->map_data_len) {
/* fatal protocol error, close the socket.
* subflow_error_report() will introduce the appropriate barriers
*/
ssk->sk_err = EBADMSG;
tcp_set_state(ssk, TCP_CLOSE);
subflow->reset_transient = 0;
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);
WRITE_ONCE(subflow->data_avail, MPTCP_SUBFLOW_NODATA);
return false;
Expand Down

0 comments on commit f745a3e

Please sign in to comment.