Skip to content

Commit 478d770

Browse files
Geliang Tangdavem330
authored andcommitted
mptcp: send out MP_FAIL when data checksum fails
When a bad checksum is detected, set the send_mp_fail flag to send out the MP_FAIL option. Add a new function mptcp_has_another_subflow() to check whether there's only a single subflow. When multiple subflows are in use, close the affected subflow with a RST that includes an MP_FAIL option and discard the data with the bad checksum. Set the sk_state of the subsocket to TCP_CLOSE, then the flag MPTCP_WORK_CLOSE_SUBFLOW will be set in subflow_sched_work_if_closed, and the subflow will be closed. When a single subfow is in use, temporarily handled by sending MP_FAIL with a RST too. Signed-off-by: Geliang Tang <geliangtang@xiaomi.com> Signed-off-by: Mat Martineau <mathew.j.martineau@linux.intel.com> Signed-off-by: David S. Miller <davem@davemloft.net>
1 parent 5580d41 commit 478d770

File tree

2 files changed

+28
-0
lines changed

2 files changed

+28
-0
lines changed

net/mptcp/protocol.h

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -614,6 +614,19 @@ static inline void mptcp_subflow_tcp_fallback(struct sock *sk,
614614
inet_csk(sk)->icsk_af_ops = ctx->icsk_af_ops;
615615
}
616616

617+
static inline bool mptcp_has_another_subflow(struct sock *ssk)
618+
{
619+
struct mptcp_subflow_context *subflow = mptcp_subflow_ctx(ssk), *tmp;
620+
struct mptcp_sock *msk = mptcp_sk(subflow->conn);
621+
622+
mptcp_for_each_subflow(msk, tmp) {
623+
if (tmp != subflow)
624+
return true;
625+
}
626+
627+
return false;
628+
}
629+
617630
void __init mptcp_proto_init(void);
618631
#if IS_ENABLED(CONFIG_MPTCP_IPV6)
619632
int __init mptcp_proto_v6_init(void);

net/mptcp/subflow.c

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -910,6 +910,7 @@ static enum mapping_status validate_data_csum(struct sock *ssk, struct sk_buff *
910910
csum = csum_partial(&header, sizeof(header), subflow->map_data_csum);
911911
if (unlikely(csum_fold(csum))) {
912912
MPTCP_INC_STATS(sock_net(ssk), MPTCP_MIB_DATACSUMERR);
913+
subflow->send_mp_fail = 1;
913914
return subflow->mp_join ? MAPPING_INVALID : MAPPING_DUMMY;
914915
}
915916

@@ -1157,6 +1158,20 @@ static bool subflow_check_data_avail(struct sock *ssk)
11571158

11581159
fallback:
11591160
/* RFC 8684 section 3.7. */
1161+
if (subflow->send_mp_fail) {
1162+
if (mptcp_has_another_subflow(ssk)) {
1163+
while ((skb = skb_peek(&ssk->sk_receive_queue)))
1164+
sk_eat_skb(ssk, skb);
1165+
}
1166+
ssk->sk_err = EBADMSG;
1167+
tcp_set_state(ssk, TCP_CLOSE);
1168+
subflow->reset_transient = 0;
1169+
subflow->reset_reason = MPTCP_RST_EMIDDLEBOX;
1170+
tcp_send_active_reset(ssk, GFP_ATOMIC);
1171+
WRITE_ONCE(subflow->data_avail, 0);
1172+
return true;
1173+
}
1174+
11601175
if (subflow->mp_join || subflow->fully_established) {
11611176
/* fatal protocol error, close the socket.
11621177
* subflow_error_report() will introduce the appropriate barriers

0 commit comments

Comments
 (0)