Skip to content

Commit 1489b2d

Browse files
matttbegregkh
authored andcommitted
mptcp: reset when MPTCP opts are dropped after join
commit 8668860b0ad32a13fcd6c94a0995b7aa7638c9ef upstream. Before this patch, if the checksum was not used, the subflow was only reset if map_data_len was != 0. If there were no MPTCP options or an invalid mapping, map_data_len was not set to the data len, and then the subflow was not reset as it should have been, leaving the MPTCP connection in a wrong fallback mode. This map_data_len condition has been introduced to handle the reception of the infinite mapping. Instead, a new dedicated mapping error could have been returned and treated as a special case. However, the commit 31bf11d ("mptcp: introduce MAPPING_BAD_CSUM") has been introduced by Paolo Abeni soon after, and backported later on to stable. It better handle the csum case, and it means the exception for valid_csum_seen in subflow_can_fallback(), plus this one for the infinite mapping in subflow_check_data_avail(), are no longer needed. In other words, the code can be simplified there: a fallback should only be done if msk->allow_infinite_fallback is set. This boolean is set to false once MPTCP-specific operations acting on the whole MPTCP connection vs the initial path have been done, e.g. a second path has been created, or an MPTCP re-injection -- yes, possible even with a single subflow. The subflow_can_fallback() helper can then be dropped, and replaced by this single condition. This also makes the code clearer: a fallback should only be done if it is possible to do so. While at it, no need to set map_data_len to 0 in get_mapping_status() for the infinite mapping case: it will be set to skb->len just after, at the end of subflow_check_data_avail(), and not read in between. Fixes: f8d4bca ("mptcp: infinite mapping receiving") Cc: [email protected] Reported-by: Chester A. Unal <[email protected]> Closes: multipath-tcp/mptcp_net-next#544 Acked-by: Paolo Abeni <[email protected]> Signed-off-by: Matthieu Baerts (NGI0) <[email protected]> Tested-by: Chester A. Unal <[email protected]> Link: https://patch.msgid.link/[email protected] Signed-off-by: Jakub Kicinski <[email protected]> Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent 8116fb4 commit 1489b2d

File tree

1 file changed

+1
-14
lines changed

1 file changed

+1
-14
lines changed

net/mptcp/subflow.c

Lines changed: 1 addition & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1020,7 +1020,6 @@ static enum mapping_status get_mapping_status(struct sock *ssk,
10201020
if (data_len == 0) {
10211021
pr_debug("infinite mapping received\n");
10221022
MPTCP_INC_STATS(sock_net(ssk), MPTCP_MIB_INFINITEMAPRX);
1023-
subflow->map_data_len = 0;
10241023
return MAPPING_INVALID;
10251024
}
10261025

@@ -1162,18 +1161,6 @@ static void subflow_sched_work_if_closed(struct mptcp_sock *msk, struct sock *ss
11621161
mptcp_schedule_work(sk);
11631162
}
11641163

1165-
static bool subflow_can_fallback(struct mptcp_subflow_context *subflow)
1166-
{
1167-
struct mptcp_sock *msk = mptcp_sk(subflow->conn);
1168-
1169-
if (subflow->mp_join)
1170-
return false;
1171-
else if (READ_ONCE(msk->csum_enabled))
1172-
return !subflow->valid_csum_seen;
1173-
else
1174-
return READ_ONCE(msk->allow_infinite_fallback);
1175-
}
1176-
11771164
static void mptcp_subflow_fail(struct mptcp_sock *msk, struct sock *ssk)
11781165
{
11791166
struct mptcp_subflow_context *subflow = mptcp_subflow_ctx(ssk);
@@ -1277,7 +1264,7 @@ static bool subflow_check_data_avail(struct sock *ssk)
12771264
return true;
12781265
}
12791266

1280-
if (!subflow_can_fallback(subflow) && subflow->map_data_len) {
1267+
if (!READ_ONCE(msk->allow_infinite_fallback)) {
12811268
/* fatal protocol error, close the socket.
12821269
* subflow_error_report() will introduce the appropriate barriers
12831270
*/

0 commit comments

Comments
 (0)