mptcp: misc fixes
Subsystems (4)
Matthieu Baerts (NGI0)
maintainerv4 cover mptcp: misc fixes
Here are various fixes, one from Shardul Bankar:
- Patches 1-3: after a simultaneous connect, reset the MP_JOIN subflows, which could trigger a warning, or make the connection fall back to TCP, do not drop the first received byte, and move to ESTABLISHED without waiting for the next packet. Fixes for v5.7, v6.19, and for another fix introduced in v6.19 and targeting v6.2.
- Patch 4: with MSG_PEEK, do not skip data after a partly peeked skb:
the peeked data was corrupted. A fix for v6.18.
- Patch 5: send the DATA_ACK of the data moved from the backlog, to avoid spurious MPTCP retransmissions, preventing a fallback after an MP_FAIL. A fix for v6.15.
- Patches 6-9: in the selftests, avoid spurious MPTCP retransmissions preventing the infinite fallback in the 'Infinite map' subtest, wait for the data to be acked before a fastclose, read the reply in the splice mode with MPTFO and a small file, and keep the connections open until the end of the diag checks with many connections. Fixes for v5.19, only effective from v7.3, for v6.1, v7.0, and v6.8.
- Patches 10-11: order the write_seq and DATA_FIN flag updates, not to send a DATA_FIN with the sequence number of the last byte, or a FIN before this byte after a fallback, on weakly ordered CPUs. Fixes for v5.9, and for another fix, now in net, and targeting v5.19.
- Patch 12: retransmit the DATA_FIN after the RTO, not at the next tick, once all the data has been acked. A fix for v5.15.
- Patch 13: in the default scheduler, do not truncate the pacing rates above 4 GB/s, nor let their running average wrap, which could make the fastest subflow look like the slowest one. A fix for v5.10.
- Patches 14-15: Squash-to patches for the BPF packet schedulers, in the MPTCP tree only: stop pushing when they pick no subflow, or one that cannot send, instead of spinning, and set the rtx timer interval before calling them, as done with the default scheduler.
- Patch 16: for mptcp-next: push the pending data, and the FIN, right after a fallback on reception, not at the next retransmission timeout. A non-urgent fix for v6.12.
- Patch 17: for mptcp-next: report the errors as TCP does when closing:
ETIMEDOUT after the close timeout or the last subflow's RTO, and the reset errors when the last subflow is reset.
- Patch 18: for mptcp-next: name all the mapping statuses in a tracepoint.
- Patch 19: for mptcp-next: set ECONNRESET when a disconnect aborts a connection, as TCP does.
- Patch 20: RFC for mptcp-next: reset the subflow when the DSS disappears after a DATA_ACK, instead of a fallback to TCP, as suggested by RFC 8684.
The Packetdrill tests mptcp/regressions/close_mpj_timeout* will fail because of patch 17, and mptcp/fastopen/client-TCP_FASTOPEN_CONNECT-disconnect.pkt because of patch 19: the Packetdrill patches adapting them will be shared later.
---
Changes in v4:
- Patch 1: new, for an issue spotted by Sashiko.
- Patch 8: new, for a failure observed with the selftests.
- Patch 9: new, for a failure observed in the CI.
- Patch 12: new, for an issue spotted by Sashiko.
- Patch 13: new, Shardul's patch from the v5 of another series, with
fixes, one for an issue reported by Clashiko and Abdul:
https://patch.msgid.link/20261028-mptcp_penalise_send_v2-v5-1-32fb379ce117@mpiricsoftware.com
- Patch 15: commit msg: the rtx interval is no longer 0 since patch 12.
- Patch 17: process the ack of our DATA_FIN before picking the error,
and comment in mptcp_poll() (Clashiko).
- Patch 19: new, for mptcp-next, for a difference with TCP found by a
review agent.
- Patch 20: also reset on data past its mapping, but fall back after an
infinite mapping without data (Sashiko, Clashiko).
- Other comments from Clashiko and Sashiko: notes under the "---" of the patches.
- Patches 1-36 from v3: dropped, applied in the MPTCP tree, with the modifications of v4 for patches 4, 6, 10, 12, 26, 29, 33, 34 and 36.
- Link to v3: https://patch.msgid.link/[email protected]
Changes in v3:
- Patch 4: process the DATA_FIN before the disconnect of the first
subflow, which clears its FIN (Clashiko).
- Patch 5: stop passing data to the MPTCP socket before checking for
unread data (Clashiko).
- Patch 6: no second reset for the children of a closed listener, also
without fallback (Clashiko).
- Patch 11: commit msg: the flaky subtest is fixed by patch 7, and the
remaining issue (Clashiko).
- Patch 14: new, for an issue spotted by Clashiko.
- Patch 17: comment and commit msg: also after a disconnect, and what
write() does without the race (Clashiko).
- Patch 18: move the subflow to TCP_CLOSE at once (Clashiko).
- Patch 19: also skip the disconnect for a connected socket, not to
drop data to read (Clashiko).
- Patch 21: commit msg: the netns pinned by the queued children
(Clashiko).
- Patches 25-26: commit msg: why an MSS decrease before the infinite
mapping is acked is not handled (Clashiko).
- Patch 38: also check if MPTCP is blocked (Clashiko).
- Patch 43: new, for an issue spotted by Clashiko.
- Patch 44: only the acquire, the release being in patch 43.
- Patches 45-46: stop the push loop of __mptcp_push_pending() too, and
set the rtx timer interval when a subflow is already scheduled
(Clashiko).
- Patch 49: new, for an issue spotted by Clashiko.
- Patch 50: name the new mapping status in the tracepoint, and commit
msg: all invalid mappings (Clashiko).
- Other comments from Clashiko: notes under the "---" of the patches.
- Patches 1-11, 32-33, 35 and 45 from v2: dropped, applied in the MPTCP
tree, with the modifications of v3 for patches 6, 7 and 45.
- Link to v2: https://patch.msgid.link/[email protected]
Changes in v2:
- Patches 1-2: on top of commit 342e62fd34c2 ("tcp: purge Fast Open RST
queue when listen() fails"), which purges the RST queue: only the
accept queue is left. Patch 2 is now reproduced, with MPTCP sockets.
- Patch 5: no netlink event for the dropped ids (Clashiko), but still
for the next pending ones (Sashiko).
- Patch 6: send the RM_ADDR at once (Clashiko).
- Patch 7: new, for an issue spotted by Clashiko.
- Patch 12: new, for issue #647 reported on GitHub.
- Patch 13: new, to limit the orphans kept by patch 12, as TCP does,
for an issue found by a review agent.
- Patch 14: new, spotted by a review agent.
- Patch 15: new, for issue #647 reported on GitHub.
- Patch 16: new, for a similar issue found by a review agent.
- Patch 17: new, for an issue found by a review agent.
- Patch 18: new, for issue #648 reported on GitHub.
- Patch 19: new, for a similar issue found by a review agent.
- Patch 20: new, for an issue found by a review agent and Sashiko.
- Patches 21-23: new, for issues causing flaky selftests.
- Patches 24-25: new, for issues found by a review agent.
- Patch 26: new, for an issue found by a review agent.
- Patch 27: new, for an issue spotted by Sashiko.
- Patch 28: new, for an issue found by a review agent.
- Patches 29-30: new, for issues found by a review agent.
- Patch 34: commit msg: the reset after a bad checksum too (Sashiko).
- Patch 36: count the listener once listen() succeeded, and restore
TCP_CLOSE otherwise (Sashiko, Kyuwon Cho).
- Patch 37: commit msg: explain the two Fixes tags.
- Patch 38: new, for an issue causing a flaky selftest.
- Patch 39: new, for an issue spotted by Sashiko.
- Patch 40: commit msg: the peer can still fall back alone (Clashiko),
and only clamp to one MSS when sending the infinite mapping (Sashiko).
- Patch 41: drop the segment if the push resets the subflow (Sashiko,
Clashiko).
- Patch 42: new, for an issue spotted by Clashiko.
- Patch 44: skip a part if the nft rule cannot be added (Clashiko).
- Patch 49: update a comment (Clashiko).
- Patch 50: commit msg: the sender now resets in the remaining case
(Clashiko).
- Patch 51: new, for an issue spotted by Sashiko.
- Patch 52: new, for an issue found by a review agent, after a Sashiko
review.
- Patch 53: new, for an issue causing a flaky selftest.
- Patch 54: new, for an issue causing a flaky selftest.
- Patches 55-56: new, for flaky selftests.
- Patch 57: new, for an issue spotted by Clashiko in a fix pending in
net.
- Patch 58: new, for an issue found by a review agent.
- Patch 59: new, for an issue spotted by Clashiko.
- Patch 60: new, for mptcp-next, for an issue spotted by Clashiko in a
fix pending in net.
- Patch 61: new, for mptcp-next, as suggested in the GitHub issue #648.
- Patch 62: also reset on an invalid mapping (Clashiko).
- Patches 11, 23-26 and 32 from v1: dropped, applied in the MPTCP tree.
- Link to v1: https://patch.msgid.link/[email protected]
---
Matthieu Baerts (NGI0) (19):
mptcp: reset MP_JOIN subflows on simult connect
mptcp: keep the first byte after a simult connect
mptcp: move to ESTABLISHED after a simult connect
mptcp: fix MSG_PEEK after a partly peeked skb
mptcp: send the DATA_ACK after moving the backlog
selftests: mptcp: join: infinite map: no spurious rtx
selftests: mptcp: connect: trunc: wait for acks
selftests: mptcp: connect: splice: handle MPTFO
selftests: mptcp: diag: wait longer before closing
mptcp: order write_seq and DATA_FIN flag
mptcp: order write_seq and DATA_FIN flag for fallback
mptcp: reset the rtx interval to the min RTO
Squash to "bpf: Add mptcp packet scheduler struct_ops" Squash to "bpf: Export mptcp packet scheduler helpers" [mptcp-next] mptcp: push pending data after a fallback on reception [mptcp-next] mptcp: report errors as TCP does when closing [mptcp-next] mptcp: trace: name all the mapping statuses [mptcp-next] mptcp: set ECONNRESET on disconnect, as TCP does [RFC mptcp-next] mptcp: reset when the DSS disappears after a DATA_ACK
Shardul Bankar (1):
mptcp: sched: avoid truncating the pacing rate in the scheduler
include/trace/events/mptcp.h | 13 +- net/mptcp/mib.h | 4 +- net/mptcp/options.c | 23 ++- net/mptcp/protocol.c | 177 +++++++++++++++++----- net/mptcp/protocol.h | 14 +- net/mptcp/sched.c | 5 + net/mptcp/subflow.c | 55 ++++++- tools/testing/selftests/net/mptcp/diag.sh | 10 +- tools/testing/selftests/net/mptcp/mptcp_connect.c | 41 ++++- tools/testing/selftests/net/mptcp/mptcp_join.sh | 6 + 10 files changed, 284 insertions(+), 64 deletions(-)
---
base-commit: 3af60e2b875037f465ca2fb7894b86e97befe8c0
change-id: 20261110-mptcp-cmason-fixes-eec0054c880a
Best regards,
Signature · 1 line
Matthieu Baerts (NGI0) <[email protected]>
Matthieu Baerts (NGI0)
maintainerPATCH v4 1/20 mptcp: reset MP_JOIN subflows on simult connect
When the SYN of a new MP_JOIN subflow is answered with a SYN instead of a SYN-ACK, TCP handles it as a simultaneous connect, and the subflow is established without the MP_JOIN handshake: the peer's HMAC, normally checked by subflow_finish_connect() when receiving the SYN-ACK, is never received. This function is only called on the next packet, and then resets the subflow, but the packet establishing the subflow is processed
before: with data, or urgent data, a warning was triggered in subflow_data_ready(). Without MPTCP options, or with a reset, in reply to the SYN or after the crossed SYN, the whole MPTCP connection could fall back to TCP, depending on the peer's sequence number, while it could still have other subflows.
The peer, or an attacker on the path of this new subflow, could then trigger this warning, or force a fallback to TCP. Reset such subflows as soon as they reach the ESTABLISHED state, before processing the packet, as done when the SYN-ACK has no MP_JOIN option, and ignore the MPTCP options received before.
This issue has been found by an AI code review agent (Sashiko), while reviewing another fix, and confirmed with new Packetdrill tests: after an ADD_ADDR, an MPTCP client creates a new subflow, and the peer replies with a SYN, then an ACK with data, urgent data or without MPTCP options, or a reset; or directly with a reset. Without this patch, the warning was triggered:
WARNING: net/mptcp/subflow.c:1656 at subflow_data_ready+0x11d/0x1a0, CPU#3: packetdrill/183 Call Trace: <TASK> tcp_data_queue+0x768/0x10c0 tcp_rcv_state_process+0x190/0x1730 tcp_v4_do_rcv+0xd1/0x300 tcp_v4_rcv+0xbff/0x1200 (...)
And the connection fell back to TCP, e.g. after a reset:
mp_join_client_syn_rst_seq1.pkt:32: error executing `test $(nstat -azj | jq '.kernel.MPTcpExtMPCapableDataFallback') -eq 0` command: non-zero status 1
Note for the backports: MPTCP_MIB_MPJOINSYNACKNOMPJOIN has been added in v7.3: the line incrementing it can be dropped before.
---
v4: new, for an issue spotted by Sashiko
--- net/mptcp/options.c | 4 ++++ net/mptcp/subflow.c | 9 +++++++++ 2 files changed, 13 insertions(+)
net/mptcp/options.c +4 -0
@@ -1008,6 +1008,10 @@ static bool check_fully_established(struct mptcp_sock *msk, struct sock *ssk, goto check_notify; } +/* no MP_JOIN handshake, e.g. a reset in reply to the SYN */ +if (unlikely (subflow->request_join && !subflow->mp_join)) +return false; +/* we must process OoO packets before the first subflow is fully * established. OoO packets are instead a protocol violation * for MP_JOIN subflows as the peer must not send any data
net/mptcp/subflow.c +9 -0
@@ -1987,6 +1987,15 @@ static void subflow_state_change(struct sock *sk)__subflow_state_change (sk); +/* simult connect: the peer's HMAC was never checked */ +if (unlikely (subflow->request_join && !subflow->mp_join && + sk->sk_state ==TCP_ESTABLISHED )) { +MPTCP_INC_STATS (sock_net (sk),MPTCP_MIB_MPJOINSYNACKNOMPJOIN ); + subflow->reset_reason =MPTCP_RST_EMPTCP ; +mptcp_subflow_reset (sk); +return ; + } +/* Rx queue processing is unneeded, error reporting will take place at * __mptcp_close_ssk() time and subflow reset can't happen in case of * fallback: subflow_sched_work_if_closed() would be a no-op.
Signature · 1 line
2.55.0
Matthieu Baerts (NGI0)
maintainerPATCH v4 2/20 mptcp: keep the first byte after a simult connect
In reply to Matthieu Baerts (NGI0)A simultaneous connect leads to a fallback to TCP, decided when sending the SYN-ACK from the SYN_RECV state. The received data is then mapped with dummy mappings, based on ssn_offset, the peer's ISN, normally set by subflow_finish_connect() when receiving the SYN-ACK. But here, it is only called on the next packet, received in ESTABLISHED: its sequence number was then used as ssn_offset, and the first received byte was dropped.
Set ssn_offset when sending the SYN-ACK after a simultaneous connect, and only take it from a SYN in subflow_finish_connect().
This issue has been reported by Sashiko, while reviewing another fix, and confirmed with a new Packetdrill test: after a simultaneous connect, 10 bytes are received. Without this patch, only 9 were read:
simult_connect_data.pkt:24: runtime error in read call: Expected result 10 but got 9 with errno 115 (Operation now in progress)
---
v2: new, for an issue spotted by Sashiko
Note (Clashiko on v2 and v3): ssn_offset is not set if the crossed SYN-ACK cannot be built: theoretical, it needs a simultaneous connect and an allocation failure.
Note (Sashiko on v2 and v3): an MP_JOIN subflow established by a simultaneous connect is now reset by the previous commit.
--- net/mptcp/options.c | 5 +++++ net/mptcp/subflow.c | 4 +++- 2 files changed, 8 insertions(+), 1 deletion(-)
net/mptcp/options.c +5 -0
@@ -474,6 +474,11 @@ bool mptcp_syn_options(struct sock *sk, const struct sk_buff *skb,* in mptcp_established_options_mp() */ subflow->snd_isn =TCP_SKB_CB (skb)->end_seq; + +/* simult connect: the peer's SYN-ACK will not set ssn_offset */ +if (unlikely (sk->sk_state ==TCP_SYN_RECV )) + subflow->ssn_offset =tcp_sk (sk)->rcv_nxt -1 ; +if (subflow->request_mptcp) {if (unlikely (subflow_simultaneous_connect (sk))) {WARN_ON_ONCE (!mptcp_try_fallback (sk,MPTCP_MIB_SIMULTCONNFALLBACK ));
net/mptcp/subflow.c +3 -1
@@ -591,7 +591,9 @@ static void subflow_finish_connect(struct sock *sk, const struct sk_buff *skb) subflow->rel_write_seq =1 ; subflow->opt_ack_seq =tcp_sk (sk)->snd_una; subflow->conn_finished =1 ; - subflow->ssn_offset =TCP_SKB_CB (skb)->seq; +/* simult connect: not a SYN-ACK, see mptcp_syn_options() */ +if (TCP_SKB_CB (skb)->tcp_flags &TCPHDR_SYN ) + subflow->ssn_offset =TCP_SKB_CB (skb)->seq;pr_debug ("subflow=%p synack seq=%x\n" , subflow, subflow->ssn_offset);mptcp_get_options (skb, &mp_opt);
Signature · 1 line
2.55.0
Matthieu Baerts (NGI0)
maintainerPATCH v4 3/20 mptcp: move to ESTABLISHED after a simult connect
In reply to Matthieu Baerts (NGI0)After a simultaneous connect, the subflow moves from SYN_RECV to ESTABLISHED when it receives the peer's SYN-ACK. Since the commit mentioned below, the MPTCP socket only follows when subflow_finish_connect() is called, on the next received packet. Until then, it stays in SYN_SENT: POLLOUT is not reported, write() returns EAGAIN, and a blocking connect() waits, until the peer sends something.
As it was done before this commit, propagate the state from subflow_state_change() in this case. subflow_finish_connect() then returns early: also check there if MPTCP is blocked, as it does.
This issue has been found by an AI code review agent, while checking a review from Sashiko, and confirmed with a new Packetdrill test: after a simultaneous connect, poll() is called. Without this patch, POLLOUT was not reported:
simult_connect_write.pkt:18: runtime error in poll call: Expected result 1 but got 0 with errno 115 (Operation now in progress)
---
v2: new, for an issue found by a review agent, after a Sashiko review
v3: also check if MPTCP is blocked, as subflow_finish_connect() did
(Clashiko)
--- net/mptcp/subflow.c | 13 +++++++++++++ 1 file changed, 13 insertions(+)
net/mptcp/subflow.c +13 -0
@@ -1998,6 +1998,19 @@ static void subflow_state_change(struct sock *sk)return ; } +/* simult connect: not finished by subflow_finish_connect() */ +if (unlikely (!subflow->conn_finished && + sk->sk_state ==TCP_ESTABLISHED && +inet_sk_state_load (parent) ==TCP_SYN_SENT && +mptcp_check_fallback (sk))) { + subflow->rel_write_seq =1 ; + subflow->conn_finished =1 ; +/* It looks like MPTCP is blocked, while TCP is not */ +if (subflow->mpc_drop) +mptcp_active_disable (parent); +mptcp_propagate_state (parent, sk, subflow,NULL ); + } +/* Rx queue processing is unneeded, error reporting will take place at * __mptcp_close_ssk() time and subflow reset can't happen in case of * fallback: subflow_sched_work_if_closed() would be a no-op.
Signature · 1 line
2.55.0
Matthieu Baerts (NGI0)
maintainerPATCH v4 4/20 mptcp: fix MSG_PEEK after a partly peeked skb
In reply to Matthieu Baerts (NGI0)When recvmsg() with MSG_PEEK needs another pass, e.g. after having moved the data from the backlog, the data already peeked is skipped. If this data ends in the middle of an skb, e.g. the last one peeked, extended since then by coalescing, the following skbs were skipped too, entirely or partly, because the length of the data skipped in the first skb was not counted: the peeked data was then corrupted.
This issue was likely causing a subtest from mptcp_connect_sendfile.sh to fail, e.g. on NIPA, with a debug kernel. In the "saveWithPeek" mode, the client saves the data peeked before reading it: the received file had the same size, but not the same content.
# 46 ns1 MPTCP -> ns1 (10.0.1.1:10043 ) TCP (duration 264ms) [FAIL] file received by client does not match (in, out):
The root cause has been confirmed with a debug patch holding the MPTCP socket lock for 200ms after the first MSG_PEEK pass in recvmsg(): 1000 bytes are peeked, then 1000 bytes are received and coalesced with them, and 60000 more bytes in other skbs. Without this patch, only 60000 bytes were peeked instead of 62000, and they were different from the data read after:
peek repro: peeked 60000 bytes, DIFFERENT data
To fix this, count the data skipped in the first skb, so that the next ones are not skipped.
---
v2: new, for an issue causing a flaky selftest
--- net/mptcp/protocol.c | 1 + 1 file changed, 1 insertion(+)
net/mptcp/protocol.c +1 -0
@@ -2295,6 +2295,7 @@ static int __mptcp_recvmsg_mskq(struct sock *sk, struct msghdr *msg, delta = copied_total - total_data_len; offset += delta; data_len -= delta; + total_data_len += delta; } count =min_t (size_t, len - copied, data_len);
Signature · 1 line
2.55.0
Matthieu Baerts (NGI0)
maintainerPATCH v4 5/20 mptcp: send the DATA_ACK after moving the backlog
In reply to Matthieu Baerts (NGI0)The data received while the MPTCP socket is owned by the user is put in the backlog, and only moved to the MPTCP socket later. The TCP ACK sent for this data then carries the previous DATA_ACK, and after having moved the data, an updated DATA_ACK was only sent if a TCP ACK was still pending, for more than one MSS.
If the peer had nothing else to send, it then didn't get the new DATA_ACK, until another ACK was sent, e.g. when the reader frees enough space in the receive buffer. Its MPTCP retransmission timer could then fire, and the data was retransmitted for nothing at the MPTCP level. Such a retransmission also prevents a later fallback to TCP, after anMP_FAIL: this was causing the "Infinite map" subtest from mptcp_join.sh to fail from time to time, with an unexpected MP_RST.
This behaviour has been introduced by commit bc68b0efa1bf ("mptcp: move the whole rx path under msk socket lock protection"): before, this data was moved to the MPTCP socket right away, even if it was owned by the user.
To fix this, schedule a delayed ACK on the subflow of the last skb taken from the backlog, if no ACK is pending there: the new DATA_ACK is then sent with the next ACK on this subflow, or when the delayed ACK timer expires. TCP sends its ACK when processing its own backlog, possibly delayed too.
The root cause has been confirmed with a Packetdrill script and a debug patch keeping the MPTCP socket lock in recvmsg() while data is received. Without this patch, the DATA_ACK was not updated after having read the data:
error handling packet: Timed out waiting for packet
---
v2: new, for an issue causing a flaky selftest
Note (Clashiko on v2 and v3): with several subflows, no DATA_ACK is scheduled if the last subflow cannot send ACKs: only a spurious retransmission, as before.
Note (Clashiko on v3): when this delayed ACK is sent by its timer, TCP adapts its ato as for its own delayed ACKs: sending this ACK at once would send more ACKs.
--- net/mptcp/protocol.c | 17 +++++++++++++++++ 1 file changed, 17 insertions(+)
net/mptcp/protocol.c +17 -0
@@ -2411,10 +2411,21 @@ static void mptcp_rcv_space_adjust(struct mptcp_sock *msk, int copied) msk->rcvq_space.time = mstamp; } +/* The ACKs of the data put in the backlog carried the previous DATA_ACK */ +static void mptcp_subflow_schedule_ack (struct sock *ssk) +{ +bool slow =lock_sock_fast (ssk); + +if (tcp_can_send_ack (ssk) && !inet_csk_ack_scheduled (ssk)) +tcp_send_delayed_ack (ssk); +unlock_sock_fast (ssk, slow); +} +static bool __mptcp_move_skbs (struct sock *sk,struct list_head *skbs,u32 *delta) { struct sk_buff *skb = list_first_entry(skbs, struct sk_buff, list);struct mptcp_sock *msk =mptcp_sk (sk); +struct sock *ssk =NULL ;bool moved = false;while (1 ) {
@@ -2422,6 +2433,9 @@ static bool __mptcp_move_skbs(struct sock *sk, struct list_head *skbs, u32 *deltlist_del (&skb->list); *delta += skb->truesize; +/* NULL if the subflow has been closed */ +if (skb->sk) + ssk = skb->sk; moved |=__mptcp_move_skb (sk, skb);if (list_empty (skbs))break ;
@@ -2433,6 +2447,9 @@ static bool __mptcp_move_skbs(struct sock *sk, struct list_head *skbs, u32 *deltif (!moved)return false; +if (ssk && !__mptcp_check_fallback (msk)) +mptcp_subflow_schedule_ack (ssk); +/* Only the worker can close an orphan, as it must then destroy it */ if (!sock_flag (sk,SOCK_DEAD ))mptcp_check_data_fin (sk);
Signature · 1 line
2.55.0
Matthieu Baerts (NGI0)
maintainerPATCH v4 6/20 selftests: mptcp: join: infinite map: no spurious rtx
In reply to Matthieu Baerts (NGI0)The "Infinite map" subtest sometimes failed with a reset instead of a fallback to TCP, and the transfer was then stuck:
[FAIL] client exit code 2, server 2
(...)
MPTcpExtMPTCPRetrans 1
(...)
MPTcpExtDuplicateData 1
(...)
reset tx server [FAIL] got 1 MP_RST[s] TX expected 0
infi tx client [FAIL] got 0 infinite map[s] TX expected 1
Once some data has been retransmitted at the MPTCP level, a fallback with an infinite mapping is no longer allowed: a checksum failure then leads to a reset. Here, the retransmission is spurious: in the 'fast' mode used by this subtest, each side writes 100 bytes, then waits 200ms. The 100 bytes from the server can be received while the client socket is owned, e.g. when it is writing its own data: the TCP ACK is then sent with the previous DATA_ACK, and the next one is only sent with the next data, 200ms later. Meanwhile, the MPTCP retransmission timer of the server, armed with the minimum RTO of its MPTCP socket, 200ms by default, can expire.
This has been confirmed by setting tcp_rto_min_us to 20ms in both netns, with a capture showing the stale DATA_ACK, then the retransmission of the same data 20ms later, with a new subflow sequence number:
S>C [P.], seq 1:101, ack 1, [mptcp 24 dss ack 3936022471 seq 1159191301011008422 subseq 1 len 100 (...)], length 100 C>S [.], ack 101, [mptcp 12 dss ack 1159191301011008422], length 0
(...)
S>C [P.], seq 101:201, ack 101, [mptcp 28 dss ack (...) seq 1159191301011008422 subseq 101 len 100 (...)], length 100
These MPTCP retransmissions are expected here. To avoid them, increase the minimum RTO to 1 second in this subtest: the corrupted packet is the next one sent by the client, after its 200ms pause. The MPTCP socket only uses this sysctl since commit ea4eb2adb0d3 ("mptcp: honour configured min/max RTO in retransmit paths"), in v7.3: before, this change only increases the minimum RTO of the subflows. Errors are ignored on kernels without this sysctl.
---
v2: new, for a flaky selftest
--- tools/testing/selftests/net/mptcp/mptcp_join.sh | 6 ++++++ 1 file changed, 6 insertions(+)
tools/testing/selftests/net/mptcp/mptcp_join.sh +6 -0
@@ -3828,6 +3828,12 @@ fail_tests() # single subflow if reset_with_fail "Infinite map" 1; then MPTCP_LIB_SUBTEST_FLAKY=1 + # MPTCP retransmissions prevent the fallback: avoid spurious + # ones during the 200ms pause of the 'fast' mode + ip netns exec $ns1 sysctl -q net.ipv4.tcp_rto_min_us=1000000 \ + 2>/dev/null || true + ip netns exec $ns2 sysctl -q net.ipv4.tcp_rto_min_us=1000000 \ + 2>/dev/null || true test_linkfail=128 \ run_tests $ns1 $ns2 10.0.1.1 join_csum_ns1=+1 join_csum_ns2=+0 \
Signature · 1 line
2.55.0
Matthieu Baerts (NGI0)
maintainerPATCH v4 7/20 selftests: mptcp: connect: trunc: wait for acks
In reply to Matthieu Baerts (NGI0)The "fastclose server test" subtest from mptcp_join.sh was still failing from time to time, because the client output file didn't have the expected size, e.g. on NIPA:
[FAIL] file received by client output file has wrong size (866, 1024) Server ns stats (...)
(...)
TcpExtTCPOrigDataSent 3
TcpExtTCPDelivered 2
Here, the server sent 3 data segments only, the last one not acked yet, and the client received all the data from these segments. The rest of the data, already written by the server, was still queued, e.g. held by Nagle, waiting for the last segment to be acked. But the server then closed its socket, with data from the client still to read, as expected
here: an MP_FASTCLOSE is then sent, and the data still queued is discarded, as with a TCP reset.
To fix this, wait for the written data to be acked, with SIOCOUTQ, before stopping in the truncate mode, so before closing the socket. A timeout is reported: it would look like this issue otherwise.
This issue has been confirmed on a debug kernel, where this subtest failed a few times: each time, the client didn't have any data left in its queues, and the data received matched the data in the segments sent by the server. With this patch, it no longer failed.
---
v2: new, for a flaky selftest
--- tools/testing/selftests/net/mptcp/mptcp_connect.c | 24 ++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-)
tools/testing/selftests/net/mptcp/mptcp_connect.c +23 -1
@@ -643,6 +643,26 @@ static void shut_wr(int fd)shutdown (fd,SHUT_WR ); } +/* the data still queued would be dropped by a reset: wait for its ack */ +static void wait_for_ack (int fd) +{ +struct pollfd pfd = { .fd = fd }; +int i, queued; + +for (i =0 ; poll_timeout <0 || i < poll_timeout; i +=10 ) { +if (quit ||ioctl (fd,SIOCOUTQ , &queued) <0 || queued <=0 ) +return ; + +/* e.g. reset: the data will not be acked */ +if (poll (&pfd,1 ,0 ) >0 && (pfd.revents &POLLERR )) +return ; + +usleep (10000 ); + } + +fprintf (stderr,"timeout while waiting for the data to be acked\n" ); +} +static int copyfd_io_poll (int infd,int peerfd,int outfd,bool *in_closed_after_out,struct wstate *winfo) {
@@ -768,8 +788,10 @@ static int copyfd_io_poll(int infd, int peerfd, int outfd, }if (cfg_truncate >0 && total_wlen >= cfg_truncate && - total_rlen >= cfg_truncate) + total_rlen >= cfg_truncate) { +wait_for_ack (peerfd);break ; + } }/* leave some time for late join/announce */
Signature · 1 line
2.55.0
Matthieu Baerts (NGI0)
maintainerPATCH v4 8/20 selftests: mptcp: connect: splice: handle MPTFO
In reply to Matthieu Baerts (NGI0)With MPTFO, the client reads the beginning of its input file to send it with the SYN, and keeps the size of what it read in winfo->total_len. In splice mode, this size is also removed from the length passed to splice() when reading the reply: with an input file of 8 KB or less, this length is 0, and the client never reads the reply.
The size of this file is random, and rarely that small. This has been observed once, with a client file of 4252 bytes, and the test timed out:
# INFO: with MPTFO start
# 57 ns2 MPTCP -> ns1 (10.0.1.1:10054 ) MPTCP timeout
(...)
# (duration 61192ms) [FAIL] client exit code 0, server 143
It can be reproduced with small files, e.g. with '-f 4000': the file received by the client is then empty.
Only use winfo when sending, and send what is left in the buffer first, as the other modes do.
--- tools/testing/selftests/net/mptcp/mptcp_connect.c | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-)
tools/testing/selftests/net/mptcp/mptcp_connect.c +13 -4
@@ -971,13 +971,22 @@ static int copyfd_io_sendfile(int infd, int peerfd, int outfd,return err; } -static int do_splice (const int infd,const int outfd,const size_t len, +/* winfo: only when sending, with what MPTFO did not send yet */ +static int do_splice (const int infd,const int outfd,size_t len,struct wstate *winfo) {ssize_t in_bytes, out_bytes;int pipefd[2 ];int err; +if (winfo) { + err =spool_buf (outfd, winfo); +if (err) +return err; + + len -= winfo->total_len; + } + err =pipe (pipefd);if (err) {perror ("pipe" );
@@ -985,7 +994,7 @@ static int do_splice(const int infd, const int outfd, const size_t len, } again: - in_bytes =splice (infd,NULL , pipefd[1 ],NULL , len - winfo->total_len, + in_bytes =splice (infd,NULL , pipefd[1 ],NULL , len,SPLICE_F_MOVE |SPLICE_F_MORE );if (in_bytes <0 ) {perror ("splice in" );
@@ -1017,7 +1026,7 @@ static int copyfd_io_splice(int infd, int peerfd, int outfd, unsigned int size,int err;if (listen_mode) { - err =do_splice (peerfd, outfd, size, winfo); + err =do_splice (peerfd, outfd, size,NULL );if (err)return err;
@@ -1029,7 +1038,7 @@ static int copyfd_io_splice(int infd, int peerfd, int outfd, unsigned int size,shut_wr (peerfd); - err =do_splice (peerfd, outfd, size, winfo); + err =do_splice (peerfd, outfd, size,NULL ); *in_closed_after_out = true; }
Signature · 1 line
2.55.0
Matthieu Baerts (NGI0)
maintainerPATCH v4 9/20 selftests: mptcp: diag: wait longer before closing
In reply to Matthieu Baerts (NGI0)The 'many cestab' subtest can fail in slow environments, e.g. with a debug kernel config:
# 26 ....chk many cestab [FAIL] expected 200 found 190
For this part, 100 servers and 100 clients are started, each one shutting down its side of the connection 20 seconds after having sent its data. But starting them all can take longer: the first connections can then be closing when the MPTCP CurrEstab counter is checked. This counter no longer includes the connections that sent their DATA_FIN, while the previous checks, about the number of MPTCP sockets, still include them, until both sides have closed: these checks can then fail too.
The fix used here is to wait until the end of the processes before closing, instead of 20 seconds: they are stopped after the checks anyway.
This failure has been observed in the MPTCP CI, and reproduced by slowing down the start of the clients: the first connections were then already closed when the last ones were established:
# 24 many msk socket present [FAIL] timeout while expecting 200 max 168 last 0
---
v4: new, for a failure observed in the CI
--- tools/testing/selftests/net/mptcp/diag.sh | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-)
tools/testing/selftests/net/mptcp/diag.sh +6 -4
@@ -406,8 +406,9 @@ for I in $(seq 1 $NR_CLIENTS); do echo "a" | \ timeout ${timeout_test} \ ip netns exec $ns \ - ./mptcp_connect -p $((I+10001)) -l -w 20 \ - -t ${timeout_poll} 0.0.0.0 >/dev/null & + ./mptcp_connect -p $((I+10001)) -l \ + -w ${timeout_test} -t ${timeout_poll} \ + 0.0.0.0 >/dev/null & done mptcp_lib_wait_local_port_listen $ns $((NR_CLIENTS + 10001))
@@ -415,8 +416,9 @@ for I in $(seq 1 $NR_CLIENTS); do echo "b" | \ timeout ${timeout_test} \ ip netns exec $ns \ - ./mptcp_connect -p $((I+10001)) -w 20 \ - -t ${timeout_poll} 127.0.0.1 >/dev/null & + ./mptcp_connect -p $((I+10001)) \ + -w ${timeout_test} -t ${timeout_poll} \ + 127.0.0.1 >/dev/null & done wait_msk_nr $((NR_CLIENTS*2)) "many msk socket present"
Signature · 1 line
2.55.0
Matthieu Baerts (NGI0)
maintainerPATCH v4 10/20 mptcp: order write_seq and DATA_FIN flag
In reply to Matthieu Baerts (NGI0)mptcp_data_fin_enabled() can be called from the subflow TX path, e.g. when an ACK is sent from BH, without the msk socket lock. But __mptcp_wr_shutdown() sets write_seq and snd_data_fin_enable without ordering them: on a weakly ordered CPU, the TX path could see the flag with the old write_seq. After all the data had been sent, the DATA_FIN could then be sent with the sequence number of the last byte of data, before the right one.
Use a release/acquire pair, to read the new write_seq with the flag.
This issue has been found by an AI code review agent (Clashiko), while reviewing "mptcp: order write_seq and DATA_FIN flag for fallback". It is
theoretical: it has not been reproduced, and it needs a shutdown racing with a packet sent from another CPU, after all the data has been sent. Still, it is fine to fix it like that, without real impact: the release/acquire pair is cheap -- plain accesses on x86 -- with the release done once at shutdown time, and the acquire when sending a packet, as the plain accesses before.
---
v3: new, for an issue spotted by Clashiko
Note (Clashiko on v3): the other lockless reader is ordered by the next commit, with its own Fixes tag.
--- net/mptcp/protocol.c | 3 ++- net/mptcp/protocol.h | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-)
net/mptcp/protocol.c +2 -1
@@ -3688,7 +3688,8 @@ static void __mptcp_wr_shutdown(struct sock *sk)/* will be ignored by fallback sockets */ WRITE_ONCE (msk->write_seq, msk->write_seq +1 ); -WRITE_ONCE (msk->snd_data_fin_enable,1 ); +/* pairs with the acquire in mptcp_data_fin_enabled() */ +smp_store_release (&msk->snd_data_fin_enable,1 );mptcp_check_send_data_fin (sk); }
net/mptcp/protocol.h +2 -1
@@ -1028,7 +1028,8 @@ void __mptcp_error_report(struct sock *sk);bool mptcp_update_rcv_data_fin (struct mptcp_sock *msk,u64 data_fin_seq,bool use_64bit);static inline bool mptcp_data_fin_enabled (const struct mptcp_sock *msk) { -return READ_ONCE (msk->snd_data_fin_enable) && +/* pairs with the release in __mptcp_wr_shutdown() */ +return smp_load_acquire (&msk->snd_data_fin_enable) &&READ_ONCE (msk->write_seq) ==READ_ONCE (msk->snd_nxt); }
Signature · 1 line
2.55.0
Matthieu Baerts (NGI0)
maintainerPATCH v4 11/20 mptcp: order write_seq and DATA_FIN flag for fallback
In reply to Matthieu Baerts (NGI0)mptcp_try_fallback() can run in BH, without the msk socket lock. Since the commit mentioned below, it reads write_seq after snd_data_fin_enable, not to send a FIN before new data. But it reads the flag without ordering it with write_seq: on a weakly ordered CPU, mptcp_try_fallback() could see the flag with the old write_seq, and send a FIN before the last byte of data.
Read the flag with an acquire, pairing with the release used by __mptcp_wr_shutdown() since the previous commit, to read the new write_seq with the flag.
This issue has been found by Clashiko, while reviewing the commit mentioned below. It is theoretical: it has not been reproduced, and it needs a shutdown racing with a fallback, with exactly one byte not sent yet. Still, it is fine to fix it like that, without real impact: the release/acquire pair is cheap -- plain accesses on x86 -- with the release done once at shutdown time, and the acquire only when falling back.
---
v2: new, for an issue spotted by Clashiko
v3: only the acquire, the release being in the new previous commit,
fixing an older issue
--- net/mptcp/protocol.c | 4 +++- net/mptcp/protocol.h | 6 ++++-- 2 files changed, 7 insertions(+), 3 deletions(-)
net/mptcp/protocol.c +3 -1
@@ -3688,7 +3688,9 @@ static void __mptcp_wr_shutdown(struct sock *sk)/* will be ignored by fallback sockets */ WRITE_ONCE (msk->write_seq, msk->write_seq +1 ); -/* pairs with the acquire in mptcp_data_fin_enabled() */ +/* pairs with the acquires in mptcp_data_fin_enabled() and +* mptcp_try_fallback() +*/ smp_store_release (&msk->snd_data_fin_enable,1 );mptcp_check_send_data_fin (sk);
net/mptcp/protocol.h +4 -2
@@ -1365,8 +1365,10 @@ static inline bool mptcp_try_fallback(struct sock *ssk, int fb_mib)if (!__mptcp_try_fallback (msk, fb_mib))return false; -/* no FIN before new data: see mptcp_check_send_data_fin() */ -if (READ_ONCE (msk->snd_data_fin_enable) && +/* no FIN before new data: see mptcp_check_send_data_fin(), and the +* release in __mptcp_wr_shutdown() +*/ +if (smp_load_acquire (&msk->snd_data_fin_enable) && !before64 (READ_ONCE (msk->snd_nxt) +1 ,READ_ONCE (msk->write_seq)) && !(ssk->sk_shutdown &SEND_SHUTDOWN )) {gfp_t saved_allocation = ssk->sk_allocation;
Signature · 1 line
2.55.0
Matthieu Baerts (NGI0)
maintainerPATCH v4 12/20 mptcp: reset the rtx interval to the min RTO
In reply to Matthieu Baerts (NGI0)Once all the data has been acked, a DATA_FIN is retransmitted at the next tick, instead of after the RTO.
When all the data has been acked, mptcp_stop_rtx_timer() resets the interval of the MPTCP-level retransmission timer to 0. The packet scheduler sets it again before pushing data, but mptcp_subflow_shutdown() arms this timer for the DATA_FIN without setting it: commit 33d41c9cd74c ("mptcp: more accurate timeout") removed this step, and the fallback to TCP_RTO_MIN when the interval was 0. A push on a subflow that is already scheduled does not call the packet scheduler either, and can then also arm this timer with an interval of 0.
The fix used here is to reset the interval to the minimum RTO, as when creating the socket, and at disconnect time.
Sashiko spotted the issue with a push on a subflow already scheduled, when reviewing a similar fix for the BPF packet schedulers. This case has not been reproduced, but the DATA_FIN one has, with a Packetdrill
test: the DATA_FIN was retransmitted right after being sent, instead of after the minimum RTO:
dss_fin_retrans_after_data.pkt:22: error handling packet: timing error: expected outbound packet at 0.401059 sec but happened at 0.201774 sec; tolerance 0.100000 sec
Note for the backports: before commit ea4eb2adb0d3 ("mptcp: honour configured min/max RTO in retransmit paths"), in v7.3, the min RTO of the MPTCP socket is not set: TCP_RTO_MIN can be used instead.
---
v4: new, for an issue spotted by Sashiko
--- net/mptcp/protocol.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
net/mptcp/protocol.c +1 -1
@@ -502,7 +502,7 @@ static bool __mptcp_move_skb(struct sock *sk, struct sk_buff *skb)static void mptcp_stop_rtx_timer (struct sock *sk) {sk_stop_timer (sk, &sk->mptcp_retransmit_timer); -mptcp_sk (sk)->timer_ival =0 ; +mptcp_sk (sk)->timer_ival =READ_ONCE (inet_csk (sk)->icsk_rto_min); }static void mptcp_close_wake_up (struct sock *sk)
Signature · 1 line
2.55.0
Matthieu Baerts (NGI0)
maintainerPATCH v4 13/20 mptcp: sched: avoid truncating the pacing rate in the scheduler
In reply to Matthieu Baerts (NGI0)From: Shardul Bankar <[email protected]>
mptcp_subflow_get_send() computes the linger time of each subflow and a running average of its pacing rate through a u32 "pace", while sk_pacing_rate and avg_pacing_rate are unsigned long: the rates above 4 GB/s are truncated, skewing the subflow selection on fast paths.
The running average can also wrap: on 32-bit, the uncast product of sk_pacing_rate and burst wraps at ordinary rates, and on 64-bit, the one of avg_pacing_rate and wmem wraps with a high rate and a send queue near the 2 GB that sk_wmem_queued allows. The fastest subflow can then look like the slowest one.
Widen "pace" to unsigned long, and compute each product of the average with mul_u64_u64_div_u64(). Dividing each term first would avoid the wrap more cheaply, but the quotient becomes zero once the queue holds a second or more of data: exactly the bufferbloated subflow this estimate needs to describe.
Sockets also start with sk_pacing_rate set to ~0UL, until the congestion control sets it, and the scheduler can pick a subflow before that, e.g. after a passive MP_JOIN. Without the truncation, the average would be seeded with this value: this subflow would then always be picked, and look like the fastest one for long. The average is then only seeded once the congestion control sets the rate, and once the RTT is known: e.g. without timestamps after a retransmitted SYN, tcp_update_pacing_rate() does not divide the rate by the RTT until the first sample.
The running average has been added later, in v5.17, by commit 3ce0852c86b9 ("mptcp: enforce HoL-blocking estimation"): before, only the truncation of the rate is to be fixed.
[ Do not seed the average with the initial ~0UL rate, nor before the
first RTT sample. div64_ul() for the linger time, the full rate in the tracepoint, one Fixes tag, and a shorter commit message. ]
--- include/trace/events/mptcp.h | 8 +++++--- net/mptcp/protocol.c | 29 ++++++++++++++++++++++------- 2 files changed, 27 insertions(+), 10 deletions(-)
include/trace/events/mptcp.h +5 -3
@@ -31,7 +31,7 @@ TRACE_EVENT(mptcp_subflow_get_send, __field(bool, active) __field(bool, free) __field(u32, snd_wnd) - __field(u32, pace) + __field(u64, pace) __field(u8, backup)__field (u64, ratio) ),
@@ -57,12 +57,14 @@ TRACE_EVENT(mptcp_subflow_get_send, }if (ssk &&sk_fullsock (ssk) && __entry->pace) - __entry->ratio =div_u64 ((u64 )ssk->sk_wmem_queued <<32 , __entry->pace); + __entry->ratio = +div64_u64 ((u64 )ssk->sk_wmem_queued <<32 , + __entry->pace);else __entry->ratio =0 ; ), -TP_printk ("active=%d free=%d snd_wnd=%u pace=%u backup=%u ratio=%llu" , +TP_printk ("active=%d free=%d snd_wnd=%u pace=%llu backup=%u ratio=%llu" , __entry->active, __entry->free, __entry->snd_wnd, __entry->pace, __entry->backup, __entry->ratio)
net/mptcp/protocol.c +22 -7
@@ -1693,7 +1693,8 @@ struct sock *mptcp_subflow_get_send(struct mptcp_sock *msk)struct subflow_send_info send_info[SSK_MODE_MAX ];struct mptcp_subflow_context *subflow;struct sock *sk = (struct sock *)msk; -u32 pace, burst, wmem; +unsigned long pace; +u32 burst, wmem;int i, nr_active =0 ;struct sock *ssk;u64 linger_time;
@@ -1718,13 +1719,20 @@ struct sock *mptcp_subflow_get_send(struct mptcp_sock *msk) pace = subflow->avg_pacing_rate;if (unlikely (!pace)) {/* init pacing rate from socket */ - subflow->avg_pacing_rate =READ_ONCE (ssk->sk_pacing_rate); - pace = subflow->avg_pacing_rate; + pace =READ_ONCE (ssk->sk_pacing_rate);if (!pace)continue ; + +/* ~0UL until set by the CC, and not divided by the srtt +* until known: not to be averaged +*/ +if (pace == ~0UL || !READ_ONCE (tcp_sk (ssk)->srtt_us)) + pace =U32_MAX ; +else + subflow->avg_pacing_rate = pace; } - linger_time =div_u64 ((u64 )READ_ONCE (ssk->sk_wmem_queued) <<32 , pace); + linger_time =div64_ul ((u64 )READ_ONCE (ssk->sk_wmem_queued) <<32 , pace);if (linger_time < send_info[backup].linger_time) { send_info[backup].ssk = ssk; send_info[backup].linger_time = linger_time;
@@ -1757,9 +1765,16 @@ struct sock *mptcp_subflow_get_send(struct mptcp_sock *msk)return ssk; subflow =mptcp_subflow_ctx (ssk); - subflow->avg_pacing_rate =div_u64 ((u64 )subflow->avg_pacing_rate * wmem + -READ_ONCE (ssk->sk_pacing_rate) * burst, - burst + wmem); + pace =READ_ONCE (ssk->sk_pacing_rate); +if (subflow->avg_pacing_rate) { +/* 64-bit arithmetic overflows at high rate with large queues */ + subflow->avg_pacing_rate = +mul_u64_u64_div_u64 (subflow->avg_pacing_rate, wmem, + burst + wmem) + +mul_u64_u64_div_u64 (pace, burst, burst + wmem); + }else if (pace != ~0UL &&READ_ONCE (tcp_sk (ssk)->srtt_us)) { + subflow->avg_pacing_rate = pace; + } msk->snd_burst = burst;return ssk; }
Signature · 1 line
2.55.0
Matthieu Baerts (NGI0)
maintainerPATCH v4 14/20 Squash to "bpf: Add mptcp packet scheduler struct_ops"
In reply to Matthieu Baerts (NGI0)A BPF scheduler can return 0 from get_send() without picking any subflow, e.g. the bkup one from the BPF selftests, when all the subflows are backup on both sides. With data to send, a DATA_ACK received while the msk is not owned by the user then makes the push loop of __mptcp_subflow_push_pending() spin forever, in softirq:
watchdog: BUG: soft lockup - CPU#2 stuck for 49s! [python3:182] (...) RIP: 0010:bpf_iter_mptcp_subflow_next+0xf/0x40 (...) Call Trace: <IRQ> bpf_prog_bf2471f1d206d5cc_bpf_bkup_get_send+0x78/0xd7 bpf__mptcp_sched_ops_get_send+0x4c/0xb0 __mptcp_subflow_push_pending+0x148/0x390 mptcp_incoming_options+0x836/0xba0 tcp_data_queue+0x6da/0x10c0 tcp_rcv_established+0x2d5/0xce0 tcp_v4_do_rcv+0x13f/0x300 tcp_v4_rcv+0xbff/0x1200 (...)
Stop this loop when the current subflow is not picked: if another one is, the loop already stops after delegating the push to it. The default scheduler always picks a subflow when returning 0: not affected.
This issue has been found by an AI code review agent, while reviewing a patch for the BPF schedulers, and confirmed with a reproducer: the bkup scheduler on the client side, its only subflow marked as backup on both sides, data queued by the client, then data sent by the server, carrying the DATA_ACK causing the soft lockup above.
Similarly, the push loop of __mptcp_push_pending() spins forever, with the msk and subflow locks held, when a BPF scheduler keeps picking a subflow that cannot send, e.g. a new subflow in SYN_SENT picked by the bkup scheduler before its backup flag is set: mptcp_sendmsg_frag() then returns -EAGAIN, which does not decrease push_count in this state. Decrease it after any failure: -EAGAIN is only returned for a subflow that cannot send, or that has just been reset. The default scheduler does not pick such subflows: not affected.
This second issue has been found by an AI code review agent (Clashiko), while reviewing a previous version of this patch.
---
v2: new, for an issue found by a review agent
v3: also stop the push loop of __mptcp_push_pending() when the picked
subflow cannot send (Clashiko)
Note: when squashing, the commit message could explain why these loops are stopped, and why the default scheduler is not affected (Clashiko on v3).
--- net/mptcp/protocol.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
net/mptcp/protocol.c +4 -4
@@ -1910,10 +1910,7 @@ void __mptcp_push_pending(struct sock *sk, unsigned int flags) ret =__subflow_push_pending (sk, ssk, &info);if (ret <=0 ) { -if (ret != -EAGAIN || - (1 << ssk->sk_state) & - (TCPF_FIN_WAIT1 |TCPF_FIN_WAIT2 |TCPF_CLOSE )) - push_count--; + push_count--;continue ; } copied = true;
@@ -1970,6 +1967,9 @@ static void __mptcp_subflow_push_pending(struct sock *sk, struct sock *ssk, bool keep_pushing = false; else copied += ret; + }else { +/* a BPF scheduler might not pick any subflow */ + keep_pushing = false; }mptcp_for_each_subflow (msk, subflow) {
Signature · 1 line
2.55.0
Matthieu Baerts (NGI0)
maintainerPATCH v4 15/20 Squash to "bpf: Export mptcp packet scheduler helpers"
In reply to Matthieu Baerts (NGI0)With a BPF scheduler, the rtx timer interval, msk->timer_ival, is only set if the scheduler calls the mptcp_set_timeout() kfunc: only the burst one does. Otherwise, the rtx timer is armed with an interval not based on the subflows' timeouts, e.g. the minimum RTO once all the data has been acked, which can cause spurious retransmissions.
Set this interval before calling a BPF scheduler, as the default one does when picking a subflow, also when a subflow is already scheduled, as the scheduler is then not called.
This issue has been found by Clashiko, while reviewing "mptcp: arm the rtx timer if a push leaves data behind". Not reproduced.
---
v2: new, for an issue spotted by Clashiko
v3: also set the interval when a subflow is already scheduled (Clashiko)
v4: msg: the interval is no longer 0 since "mptcp: reset the rtx
interval to the min RTO"
Note: when squashing, the commit message could mention that mptcp_sched_get_send() now sets the rtx timer interval with a BPF scheduler, as the default one does.
--- net/mptcp/sched.c | 5 +++++ 1 file changed, 5 insertions(+)
net/mptcp/sched.c +5 -0
@@ -182,6 +182,10 @@ int mptcp_sched_get_send(struct mptcp_sock *msk)return -EINVAL ; } +/* as the default scheduler: the rtx timer needs an interval */ +if (msk->sched && msk->sched != &mptcp_sched_default) +mptcp_set_timeout ((struct sock *)msk); +mptcp_for_each_subflow (msk, subflow) {if (READ_ONCE (subflow->scheduled))return 0 ;
@@ -189,6 +193,7 @@ int mptcp_sched_get_send(struct mptcp_sock *msk)if (msk->sched == &mptcp_sched_default || !msk->sched)return mptcp_sched_default_get_send (msk); +return msk->sched->get_send (msk); }
Signature · 1 line
2.55.0
Matthieu Baerts (NGI0)
maintainerPATCH v4 16/20 mptcp: push pending data after a fallback on reception
In reply to Matthieu Baerts (NGI0)When received data without DSS makes the MPTCP socket fall back to TCP, the data not sent yet is not pushed: on fallback, this is done by mptcp_incoming_options(), which already processed this packet before the fallback. This data, and the FIN of an earlier shutdown, then wait for the next packet from the peer, or for the MPTCP retransmission timer armed before the fallback: up to one RTO.
Push it from mptcp_data_ready(), which follows these fallbacks, also the ones after a DSS corruption. For the next packets, this push comes after the one from mptcp_incoming_options(), which already sent what it could.
This issue has been found by Clashiko, while reviewing "mptcp: don't send a FIN before the pending data on fallback", and confirmed with a new Packetdrill test: after a shutdown, with data still in the MPTCP socket, the peer sends data without MPTCP options. Without this patch, with an RTO of one second, the data is sent about one second later:
dss_fallback_push_pending_server.pkt:27: error handling packet: timing error: expected outbound packet at 0.312538 sec but happened at 1.274089 sec; tolerance 0.100000 sec
With this patch, the data and the FIN are sent right after the fallback.
Note for the backports: the fallback after receiving data without DSS comes from commit 119d51e225fe ("mptcp: fallback when MPTCP opts are dropped after 1st data"), also in v6.12, and backported down to v5.15.
---
v2: new, for mptcp-next, for an issue spotted by Clashiko in a fix
pending in net
--- net/mptcp/protocol.c | 4 ++++ 1 file changed, 4 insertions(+)
net/mptcp/protocol.c +4 -0
@@ -1077,6 +1077,10 @@ void mptcp_data_ready(struct sock *sk, struct sock *ssk) }else {__mptcp_move_skbs_from_subflow (msk, ssk, false); } + +/* mptcp_incoming_options() can't push if this data caused a fallback */ +if (__mptcp_check_fallback (msk) &&sk_stream_memory_free (ssk)) +__mptcp_check_push (sk, ssk);mptcp_data_unlock (sk); }
Signature · 1 line
2.55.0
[email protected]
AI reviewRe: [PATCH mptcp-next mptcp-net v4 16/20] mptcp: push pending data after a fallback on reception
Thank you for your contribution! Sashiko AI review found 1 potential issue to consider: - [Medium] mptcp: missing snd_una update and rtx_queue cleanup in mptcp_data_ready() --
Thank you for your contribution! Sashiko AI review found 1 potential issue to consider:
- [Medium] mptcp: missing snd_una update and rtx_queue cleanup in mptcp_data_ready()
--
commit 7e3a760d0b9eb64d294440dba08a325c185e5bb7
Author: Matthieu Baerts (NGI0) <[email protected]>
mptcp: push pending data after a fallback on reception
This commit pushes pending send data from mptcp_data_ready() when an incoming data packet triggers a fallback to plain TCP after mptcp_incoming_options() has already run.
Quoted 5 lines
net/mptcp/protocol.c +0
-0
net/mptcp/protocol.c void mptcp_data_ready(struct sock *sk, struct sock *ssk) · line 1085
Quoted 9 lines
net/mptcp/protocol.c +4
-0@@ -1077,6 +1077,10 @@ void mptcp_data_ready(struct sock *sk, struct sock *ssk) }else {__mptcp_move_skbs_from_subflow (msk, ssk, false); } + +/* mptcp_incoming_options() can't push if this data caused a fallback */ +if (__mptcp_check_fallback (msk) &&sk_stream_memory_free (ssk)) +__mptcp_check_push (sk, ssk);mptcp_data_unlock (sk); }
[Severity: Medium]
Should this fallback path also advance msk->snd_una to msk->snd_nxt and call __mptcp_data_acked(sk), like the fallback block in mptcp_incoming_options() does?
net/mptcp/options.c:mptcp_incoming_options() {
if (__mptcp_check_fallback(msk)) {
...
if (sk_stream_memory_free(sk))
__mptcp_check_push(subflow->conn, sk);
/* on fallback we just need to ignore the msk-level snd_una, as
* this is really plain TCP
*/
__mptcp_snd_una_update(msk, READ_ONCE(msk->snd_nxt));
__mptcp_data_acked(subflow->conn);
mptcp_data_unlock(subflow->conn);
return true;
}When an incoming data packet triggers a fallback after mptcp_incoming_options() has already run, omitting those calls leaves dfrags up to msk->snd_nxt on msk->rtx_queue and charged to sk->sk_wmem_queued until the peer sends another packet. If the local sender filled sk->sk_sndbuf and the peer waits for more data before sending again, mptcp_write_space() sees sk->sk_wmem_queued still full and never wakes the blocked writer. It also leaves sk->mptcp_retransmit_timer armed, causes mptcp_ioctl_outq() to overreport SIOCOUTQ, and skips the mptcp_pending_data_fin_ack() check in __mptcp_clean_una().
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=16
Matthieu Baerts (NGI0)
maintainerPATCH v4 17/20 mptcp: report errors as TCP does when closing
In reply to Matthieu Baerts (NGI0)When the close timeout expires, or when the last subflow is closed in another state than ESTABLISHED, the MPTCP socket moves to TCP_CLOSE without error, and recv() then reports ENOTCONN instead of EOF. In these cases, TCP sets SHUTDOWN_MASK and an error depending on the
state: ETIMEDOUT after a timeout, and ECONNRESET, EPIPE or ECONNREFUSED after a reset.
Do the same, as tcp_done_with_error() does, also in the late cleanup done by accept(), when the first subflow has been closed before: with the error of the last subflow, e.g. ETIMEDOUT after its RTO. After a reset, or without error, the error depends on the MPTCP-level state, e.g. EPIPE after a DATA_FIN. When a subflow error closes the socket, SHUTDOWN_MASK is now set too, as tcp_done() does.
This changes the errors seen by the applications: after the close timeout, reading or writing now reports ETIMEDOUT once, instead of ENOTCONN or EPIPE, then EOF and EPIPE, as with TCP after a timeout. The tests checking these errors in the MPTCP Packetdrill repository have to be adapted.
With the reproducer from the GitHub issue, where the only subflow dies by RTO, send() now returns ETIMEDOUT after the subflow timeout and the close timeout, instead of EPIPE.
---
v2: new, for mptcp-next, as suggested in issue #648 on GitHub
v4: process the ack of our DATA_FIN before picking the error, and
comment in mptcp_poll() (Clashiko)
Note (Clashiko on v2): the FIN cleared by the disconnect of the first subflow is now handled by "mptcp: return EOF after a DATA_FIN, as TCP does", and a reset received before accept() after a fallback by "mptcp:
report errors received before accept()". In FIN_WAIT2, the subflow error is still reported by __mptcp_error_report(), deferred to the release of the socket.
Note (Sashiko on v3): while the worker closes the socket, lockless readers can briefly see it closed before its final error is set.
--- net/mptcp/protocol.c | 94 ++++++++++++++++++++++++++++++++++++++++------------ 1 file changed, 72 insertions(+), 22 deletions(-)
net/mptcp/protocol.c +72 -22
@@ -518,6 +518,56 @@ static void mptcp_close_wake_up(struct sock *sk)sk_wake_async (sk,SOCK_WAKE_WAITD ,POLL_IN ); } +/* Mirror the tcp_reset() error propagation */ +static int mptcp_reset_err (const struct sock *sk) +{ +int err; + +switch (sk->sk_state) { +case TCP_SYN_SENT : + err =ECONNREFUSED ; +break ; +case TCP_CLOSE_WAIT : + err =EPIPE ; +break ; +default : + err =ECONNRESET ; + } + +return err; +} + +/* No more data can be exchanged: report it, as tcp_done_with_error() does */ +static void mptcp_close_err (struct sock *sk,int err) +{ +WRITE_ONCE (sk->sk_err, err); +/* This barrier is coupled with smp_rmb() in mptcp_poll() */ +smp_wmb (); +WRITE_ONCE (sk->sk_shutdown,SHUTDOWN_MASK ); +mptcp_set_state (sk,TCP_CLOSE ); +if (sock_flag (sk,SOCK_DEAD )) +return ; + +mptcp_close_wake_up (sk); +sk_error_report (sk); +} + +/* As TCP: the error of the last subflow, e.g. ETIMEDOUT, but after a reset +* (EBADMSG: by MPTCP) or without error, it depends on the msk state +*/ +static void mptcp_close_last_err (struct sock *sk,int err) +{ +switch (err) { +case 0 : +case ECONNREFUSED : +case ECONNRESET : +case EPIPE : +case EBADMSG : + err =mptcp_reset_err (sk); + } +mptcp_close_err (sk, err); +} +static void mptcp_shutdown_subflows (struct mptcp_sock *msk) {struct mptcp_subflow_context *subflow;
@@ -977,7 +1027,7 @@ static bool __mptcp_subflow_error_report(struct sock *sk, struct sock *ssk)if (ssk_state ==TCP_CLOSE && !sock_flag (sk,SOCK_DEAD )) {/* This barrier is coupled with smp_rmb() in mptcp_poll() */ smp_wmb (); -WRITE_ONCE (sk->sk_shutdown, sk->sk_shutdown |SEND_SHUTDOWN ); +WRITE_ONCE (sk->sk_shutdown,SHUTDOWN_MASK );mptcp_set_state (sk, ssk_state); } report = true;
@@ -2818,7 +2868,7 @@ static void __mptcp_close_ssk(struct sock *sk, struct sock *ssk, {struct mptcp_sock *msk =mptcp_sk (sk);bool dispose_it, need_push = false; -int fwd_remaining; +int fwd_remaining, ssk_err;/* Do not pass RX data to the msk, even if the subflow socket is not * going to be freed (i.e. even for the first subflow on graceful
@@ -2826,6 +2876,8 @@ static void __mptcp_close_ssk(struct sock *sk, struct sock *ssk,*/ lock_sock_nested (ssk,SINGLE_DEPTH_NESTING ); subflow->closing =1 ; +/* in case it is the last subflow: before its disconnect or dispose */ + ssk_err =READ_ONCE (ssk->sk_err);if (flags &MPTCP_CF_PUSH )mptcp_cleanup_ssk_backlog (sk, ssk);
@@ -2914,13 +2966,17 @@ static void __mptcp_close_ssk(struct sock *sk, struct sock *ssk,mptcp_set_close_tout (sk, tcp_jiffies32 - (mptcp_close_timeout (sk) +1 ));mptcp_schedule_work (sk); + }else if (sk->sk_state ==TCP_CLOSE ) { +mptcp_close_wake_up (sk); }else if (sk->sk_state !=TCP_ESTABLISHED || msk->in_accept_queue) {mptcp_check_rcv_close (sk); -mptcp_set_state (sk,TCP_CLOSE ); -WRITE_ONCE (sk->sk_shutdown, - sk->sk_shutdown |SEND_SHUTDOWN ); -mptcp_close_wake_up (sk); +/* the ack of our DATA_FIN might not be processed yet */ +mptcp_check_data_fin_ack (sk); +if (sk->sk_state ==TCP_CLOSE ) +mptcp_close_wake_up (sk); +else +mptcp_close_last_err (sk, ssk_err); }else {mptcp_start_tout_timer (sk); }
@@ -3117,20 +3173,10 @@ static void mptcp_check_fastclose(struct mptcp_sock *msk)unlock_sock_fast (tcp_sk, slow); } -/* Mirror the tcp_reset() error propagation */ -switch (sk->sk_state) { -case TCP_SYN_SENT : -WRITE_ONCE (sk->sk_err,ECONNREFUSED ); -break ; -case TCP_CLOSE_WAIT : -WRITE_ONCE (sk->sk_err,EPIPE ); -break ; -case TCP_CLOSE : +if (sk->sk_state ==TCP_CLOSE )return ; -default : -WRITE_ONCE (sk->sk_err,ECONNRESET ); - } +WRITE_ONCE (sk->sk_err,mptcp_reset_err (sk));mptcp_set_state (sk,TCP_CLOSE );WRITE_ONCE (sk->sk_shutdown,SHUTDOWN_MASK );smp_mb__before_atomic ();/* SHUTDOWN must be visible first */
@@ -3450,8 +3496,7 @@ static void mptcp_worker(struct work_struct *work)mptcp_do_fastclose (sk);mptcp_for_each_subflow_safe (msk, subflow, tmp)__mptcp_close_ssk (sk, subflow->tcp_sock, subflow,0 ); -WRITE_ONCE (sk->sk_shutdown, sk->sk_shutdown |SEND_SHUTDOWN ); -mptcp_close_wake_up (sk); +mptcp_close_err (sk,ETIMEDOUT ); }if (sock_flag (sk,SOCK_DEAD ) && sk->sk_state ==TCP_CLOSE ) {
@@ -4804,10 +4849,13 @@ static int mptcp_stream_accept(struct socket *sock, struct socket *newsock,*/ if (unlikely (inet_sk_state_load (msk->first) ==TCP_CLOSE )) {if (unlikely (list_is_singular (&msk->conn_list))) { +int err =READ_ONCE (msk->first->sk_err); +mptcp_check_rcv_close (newsk);/* not reported in the accept queue */ __mptcp_error_report (newsk); -mptcp_set_state (newsk,TCP_CLOSE ); +if (newsk->sk_state !=TCP_CLOSE ) +mptcp_close_last_err (newsk, err); }mptcp_close_ssk (newsk, msk->first,mptcp_subflow_ctx (msk->first));
@@ -4887,7 +4935,9 @@ static __poll_t mptcp_poll(struct file *file, struct socket *sock, mask |=EPOLLOUT |EPOLLWRNORM ; } -/* This barrier is coupled with smp_wmb() in __mptcp_error_report() */ +/* This barrier is coupled with smp_wmb() in +* __mptcp_subflow_error_report() and mptcp_close_err() +*/ smp_rmb ();if (READ_ONCE (sk->sk_err) || !skb_queue_empty_lockless (&sk->sk_error_queue))
Signature · 1 line
2.55.0
[email protected]
AI reviewRe: [PATCH mptcp-next mptcp-net v4 17/20] mptcp: report errors as TCP does when closing
Thank you for your contribution! Sashiko AI review found 3 potential issues to consider: - [Medium] mptcp: missing mptcp_check_rcv_close() in __mptcp_close_ssk() when ESTABLISHED - [Medium] mptcp…
Thank you for your contribution! Sashiko AI review found 3 potential issues to consider:
- [Medium] mptcp: missing mptcp_check_rcv_close() in __mptcp_close_ssk() when ESTABLISHED
- [Medium] mptcp: dummy DATA_FIN on fallback reset causes EPIPE in __mptcp_close_ssk()
- [Medium] mptcp: premature TCP_CLOSE and wakeup before mptcp_close_err() on timeout
--
commit 6ce8d717af5ad3fbd6c9029fe140c704cbd41b8e
Author: Matthieu Baerts (NGI0) <[email protected]>
mptcp: report errors as TCP does when closing
This commit updates MPTCP socket closure on close timeouts and last-subflow closure outside TCP_ESTABLISHED to set SHUTDOWN_MASK and report errors based on the last subflow error and MPTCP socket state, matching TCP behavior.
Quoted 4 lines
net/mptcp/protocol.c +0
-0
[ ... ]
Quoted 10 lines
net/mptcp/protocol.c +1
-1@@ -2818,7 +2868,7 @@ static void __mptcp_close_ssk(struct sock *sk, struct sock *ssk, {struct mptcp_sock *msk =mptcp_sk (sk);bool dispose_it, need_push = false; -int fwd_remaining; +int fwd_remaining, ssk_err;/* Do not pass RX data to the msk, even if the subflow socket is not * going to be freed (i.e. even for the first subflow on graceful
net/mptcp/protocol.c static void __mptcp_close_ssk(struct sock *sk, struct sock *ssk, · line 2880
Quoted 5 lines
net/mptcp/protocol.c +2
-0@@ -2826,6 +2876,8 @@ static void __mptcp_close_ssk(struct sock *sk, struct sock *ssk,*/ lock_sock_nested (ssk,SINGLE_DEPTH_NESTING ); subflow->closing =1 ; +/* in case it is the last subflow: before its disconnect or dispose */ + ssk_err =READ_ONCE (ssk->sk_err);
[Severity: Medium]
On a fallback socket, if msk->first is closed by a TCP RST without a prior FIN while mptcp_worker() holds lock_sock(sk), can this report EPIPE instead of ECONNRESET and then report the error a second time on release_sock(sk)?
When the reset arrives in softirq while sk is owned, subflow_error_report() defers MPTCP_ERROR_REPORT to mptcp_release_cb() (leaving ssk->sk_err set to ECONNRESET), and subflow_sched_work_if_closed() emulates a dummy DATA_FIN because ssk->sk_state is TCP_CLOSE. Before __mptcp_close_ssk() runs, mptcp_check_data_fin() processes that dummy rcv_data_fin and moves sk->sk_state from TCP_ESTABLISHED to TCP_CLOSE_WAIT (or from TCP_FIN_WAIT2 to TCP_CLOSE) even when SOCK_DONE is not set on msk->first:
net/mptcp/protocol.c:mptcp_check_data_fin() {
...
/* on fallback, also emulated after a reset: check for a FIN */
if (!__mptcp_check_fallback(msk) ||
(msk->first && sock_flag(msk->first, SOCK_DONE)))
sock_set_flag(sk, SOCK_DONE);
smp_mb__before_atomic(); /* SHUTDOWN must be visible first */
switch (sk->sk_state) {
case TCP_ESTABLISHED:
mptcp_set_state(sk, TCP_CLOSE_WAIT);
break;
...
}In __mptcp_close_ssk(), dispose_it is false for msk->first, so it jumps to
out: without calling __mptcp_subflow_error_report(). In TCP_CLOSE_WAIT, mptcp_close_last_err(sk, ECONNRESET) then maps ECONNRESET through mptcp_reset_err(sk) to EPIPE (or in TCP_FIN_WAIT2 finds sk->sk_state already in TCP_CLOSE and wakes waiters with sk_err == 0). Because ssk->sk_err was only read with READ_ONCE() and not consumed, mptcp_release_cb() later runs __mptcp_error_report(sk), which consumes ssk->sk_err, overwrites sk->sk_err with ECONNRESET, and calls sk_error_report(sk) a second time.
[ ... ]
Quoted 12 lines
net/mptcp/protocol.c +2
-3@@ -2914,13 +2966,17 @@ static void __mptcp_close_ssk(struct sock *sk, struct sock *ssk,mptcp_set_close_tout (sk, tcp_jiffies32 - (mptcp_close_timeout (sk) +1 ));mptcp_schedule_work (sk); + }else if (sk->sk_state ==TCP_CLOSE ) { +mptcp_close_wake_up (sk); }else if (sk->sk_state !=TCP_ESTABLISHED || msk->in_accept_queue) {mptcp_check_rcv_close (sk); -mptcp_set_state (sk,TCP_CLOSE ); -WRITE_ONCE (sk->sk_shutdown, - sk->sk_shutdown |SEND_SHUTDOWN );
net/mptcp/protocol.c static void __mptcp_close_ssk(struct sock *sk, struct sock *ssk, · line 2982
Quoted 10 lines
net/mptcp/protocol.c +6
-1-mptcp_close_wake_up (sk); +/* the ack of our DATA_FIN might not be processed yet */ +mptcp_check_data_fin_ack (sk); +if (sk->sk_state ==TCP_CLOSE ) +mptcp_close_wake_up (sk); +else +mptcp_close_last_err (sk, ssk_err); }else {mptcp_start_tout_timer (sk); }
[Severity: Medium]
Does gating mptcp_check_rcv_close(sk) behind sk->sk_state != TCP_ESTABLISHED miss a pending DATA_FIN or MP_FASTCLOSE when the last subflow of an accepted, non-fallback socket closes?
If final data with DATA_FIN and a subflow close arrive in softirq while mptcp_worker() holds lock_sock(sk), the data sits in msk->backlog_list, so mptcp_check_data_fin() in mptcp_worker() cannot advance msk->ack_seq to msk->rcv_data_fin_seq and sk->sk_state stays TCP_ESTABLISHED (the same happens if DATA_FIN or MP_FASTCLOSE arrives after mptcp_worker() has already run mptcp_check_fastclose() and mptcp_check_data_fin()). Because mptcp_close_ssk() only spools the backlog beforehand when __mptcp_check_fallback(msk) is true, __mptcp_close_ssk() sees sk->sk_state == TCP_ESTABLISHED, skips mptcp_check_rcv_close(sk) and mptcp_close_last_err(), and starts the close timeout timer instead. When release_sock(sk) subsequently drains msk->backlog_list via mptcp_release_cb() -> __mptcp_move_skbs(), mptcp_check_data_fin() moves sk->sk_state to TCP_CLOSE_WAIT after subflow->close_event_done is already set, leaving the socket stranded in TCP_CLOSE_WAIT with no subflows until the close timeout expires and reports ETIMEDOUT instead of EPIPE.
Calling mptcp_check_rcv_close(sk) before checking sk->sk_state in the all-subflows-closed block would process the queued DATA_FIN or fastclose first.
[ ... ]
net/mptcp/protocol.c static void mptcp_worker(struct work_struct *work) · line 3500
Quoted 8 lines
net/mptcp/protocol.c +1
-2@@ -3450,8 +3496,7 @@ static void mptcp_worker(struct work_struct *work)mptcp_do_fastclose (sk);mptcp_for_each_subflow_safe (msk, subflow, tmp)__mptcp_close_ssk (sk, subflow->tcp_sock, subflow,0 ); -WRITE_ONCE (sk->sk_shutdown, sk->sk_shutdown |SEND_SHUTDOWN ); -mptcp_close_wake_up (sk); +mptcp_close_err (sk,ETIMEDOUT ); }
[Severity: Medium]
When the close timeout expires here, doesn't __mptcp_close_ssk() wake pollers after mptcp_do_fastclose() sets TCP_CLOSE but before mptcp_close_err() publishes ETIMEDOUT and SHUTDOWN_MASK?
kworker (mptcp_worker) CPU1
---------------------- ----mptcp_do_fastclose(sk)
mptcp_set_state(sk, TCP_CLOSE)__mptcp_close_ssk(...)
if (sk->sk_state == TCP_CLOSE)
mptcp_close_wake_up(sk)
mptcp_poll() / getsockopt(SO_ERROR)
state == TCP_CLOSE
sk_shutdown == 0
sk_err == 0 <-- misses ETIMEDOUTmptcp_close_err(sk, ETIMEDOUT)
WRITE_ONCE(sk->sk_err, ETIMEDOUT)
smp_wmb()
WRITE_ONCE(sk->sk_shutdown, SHUTDOWN_MASK)
Because mptcp_poll() and sk_getsockopt(SO_ERROR) run without locking sk, a waiter woken by __mptcp_close_ssk() can see EPOLLHUP without EPOLLERR, EPOLLIN or EPOLLOUT, and read SO_ERROR == 0 instead of ETIMEDOUT.
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=17
Matthieu Baerts (NGI0)
maintainerPATCH v4 18/20 mptcp: trace: name all the mapping statuses
In reply to Matthieu Baerts (NGI0)The subflow_check_data_avail tracepoint prints the status returned by get_mapping_status() with its name, except for MAPPING_BAD_CSUM and MAPPING_NODSS, added later: they were printed as numbers.
This has been found by an AI code review agent (Clashiko), while reviewing a patch adding another status.
---
v3: new, for an issue spotted by Clashiko
--- include/trace/events/mptcp.h | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
include/trace/events/mptcp.h +3 -1
@@ -19,7 +19,9 @@ { 1, "MAPPING_INVALID" }, \ { 2, "MAPPING_EMPTY" }, \ { 3, "MAPPING_DATA_FIN" }, \ - { 4, "MAPPING_DUMMY" }) + { 4, "MAPPING_DUMMY" }, \ + { 5, "MAPPING_BAD_CSUM" }, \ + { 6, "MAPPING_NODSS" }) TRACE_EVENT(mptcp_subflow_get_send,
Signature · 1 line
2.55.0
Matthieu Baerts (NGI0)
maintainerPATCH v4 19/20 mptcp: set ECONNRESET on disconnect, as TCP does
In reply to Matthieu Baerts (NGI0)When a disconnect aborts a connection, e.g. connect(AF_UNSPEC) on an established socket, or shutdown() in SYN_SENT, TCP sets ECONNRESET. It is then reported once, e.g. by SO_ERROR or the next send(), or returned by a connect() blocked in another thread, when interrupted by shutdown(). MPTCP set no error.
Set it in the same cases as tcp_disconnect(), at the MPTCP level: in SYN_SENT, ESTABLISHED, CLOSE_WAIT, FIN_WAIT1 and FIN_WAIT2, and in CLOSING or LAST_ACK only if data or the DATA_FIN is still to be sent. As with TCP, the next connect() clears it.
This changes the errors seen by the applications: e.g. after a disconnect following a deferred connect with TCP_FASTOPEN_CONNECT, the next write() now reports ECONNRESET once, then EPIPE, as with TCP. The test checking it in the MPTCP Packetdrill repository has to be adapted.
This difference with TCP has been found by an AI code review agent, while reviewing "mptcp: clear sk_err on connect(), as TCP does", and confirmed with new Packetdrill tests, also checking that no error is reported in LAST_ACK once everything has been sent, as with TCP. Without this patch, SO_ERROR reported no error, e.g. after a disconnect in ESTABLISHED:
disconnect_established.pkt:18: runtime error in getsockopt call: Bad getsockopt optval: expected: 104 actual: 0
And a connect() blocked in another thread, interrupted by shutdown(), returned ECONNABORTED, instead of ECONNRESET as with TCP.
---
v4: new, for mptcp-next, for a difference with TCP found by a review
agent
Note: it depends on "mptcp: clear sk_err on connect(), as TCP does", applied in the MPTCP tree: without it, the next connection would report this error too.
Note: only the MPTCP-level state and data are checked, not the subflows:
e.g. data given to a subflow but not sent yet, or after a fallback, a subflow still in LAST_ACK with the MPTCP socket closed. To keep it simple, these rare cases still report no error, as before.
--- net/mptcp/protocol.c | 10 ++++++++++ 1 file changed, 10 insertions(+)
net/mptcp/protocol.c +10 -0
@@ -3957,6 +3957,7 @@ static int mptcp_disconnect(struct sock *sk, int flags) {struct inet_connection_sock *icsk =inet_csk (sk);struct mptcp_sock *msk =mptcp_sk (sk); +bool aborted;/* We are on the fastopen error path. We can't call straight into the * subflows cleanup code due to lock nesting (we are already under
@@ -3965,6 +3966,13 @@ static int mptcp_disconnect(struct sock *sk, int flags)if (msk->fastopening)return -EBUSY ; +/* as tcp_disconnect() */ + aborted = ((1 << sk->sk_state) & + (TCPF_SYN_SENT |TCPF_ESTABLISHED |TCPF_CLOSE_WAIT | +TCPF_FIN_WAIT1 |TCPF_FIN_WAIT2 )) || + (((1 << sk->sk_state) & (TCPF_CLOSING |TCPF_LAST_ACK )) && + msk->snd_nxt != msk->write_seq); +mptcp_check_listen_stop (sk);mptcp_set_state (sk,TCP_CLOSE );inet_clear_bit (DEFER_CONNECT , sk);
@@ -4020,6 +4028,8 @@ static int mptcp_disconnect(struct sock *sk, int flags)WRITE_ONCE (sk->sk_shutdown,0 );sock_reset_flag (sk,SOCK_DONE ); +if (aborted) +WRITE_ONCE (sk->sk_err,ECONNRESET );sk_error_report (sk);return 0 ; }
Signature · 1 line
2.55.0
[email protected]
AI reviewRe: [PATCH mptcp-next mptcp-net v4 19/20] mptcp: set ECONNRESET on disconnect, as TCP does
Thank you for your contribution! Sashiko AI review found 1 potential issue to consider: - [Medium] mptcp: sk_err set after TCP_CLOSE and wakeup in mptcp_disconnect() --
Thank you for your contribution! Sashiko AI review found 1 potential issue to consider:
- [Medium] mptcp: sk_err set after TCP_CLOSE and wakeup in mptcp_disconnect()
--
commit b176961a8f073aaa73d94f5077f010ae3ab9c003
Author: Matthieu Baerts (NGI0) <[email protected]>
mptcp: set ECONNRESET on disconnect, as TCP does
This commit sets sk->sk_err to ECONNRESET in mptcp_disconnect() when an active or partially closed MPTCP connection is aborted, matching tcp_disconnect().
Quoted 27 lines
net/mptcp/protocol.c +8
-0@@ -3957,6 +3957,7 @@ static int mptcp_disconnect(struct sock *sk, int flags) {struct inet_connection_sock *icsk =inet_csk (sk);struct mptcp_sock *msk =mptcp_sk (sk); +bool aborted;/* We are on the fastopen error path. We can't call straight into the * subflows cleanup code due to lock nesting (we are already under @@ -3965,6 +3966,13 @@ static int mptcp_disconnect(struct sock *sk, int flags)if (msk->fastopening)return -EBUSY ; +/* as tcp_disconnect() */ + aborted = ((1 << sk->sk_state) & + (TCPF_SYN_SENT |TCPF_ESTABLISHED |TCPF_CLOSE_WAIT | +TCPF_FIN_WAIT1 |TCPF_FIN_WAIT2 )) || + (((1 << sk->sk_state) & (TCPF_CLOSING |TCPF_LAST_ACK )) && + msk->snd_nxt != msk->write_seq); +mptcp_check_listen_stop (sk);mptcp_set_state (sk,TCP_CLOSE );inet_clear_bit (DEFER_CONNECT , sk);
net/mptcp/protocol.c static int mptcp_disconnect(struct sock *sk, int flags) · line 4035
Quoted 8 lines
net/mptcp/protocol.c +2
-0@@ -4020,6 +4028,8 @@ static int mptcp_disconnect(struct sock *sk, int flags)WRITE_ONCE (sk->sk_shutdown,0 );sock_reset_flag (sk,SOCK_DONE ); +if (aborted) +WRITE_ONCE (sk->sk_err,ECONNRESET );sk_error_report (sk);return 0 ; }
[Severity: Medium]
Can setting sk->sk_err at the end of mptcp_disconnect() cause concurrent pollers to miss EPOLLERR?
mptcp_poll() runs locklessly: it loads sk->sk_state (setting EPOLLHUP on TCP_CLOSE), executes smp_rmb(), and then reads sk->sk_err to set EPOLLERR. Because mptcp_disconnect() sets TCP_CLOSE first and then calls mptcp_destroy_common() -> __mptcp_close_ssk(), closing the last subflow sees sk->sk_state == TCP_CLOSE and calls mptcp_close_wake_up(sk) before sk->sk_err is written:
CPU0 CPU1mptcp_disconnect(sk)
mptcp_set_state(sk, TCP_CLOSE)
...
mptcp_destroy_common(msk)
__mptcp_close_ssk(...)
if (sk->sk_state == TCP_CLOSE)
mptcp_close_wake_up(sk)
sk->sk_state_change(sk)
/* woken in poll() / epoll_wait() */
mptcp_poll()
state = inet_sk_state_load(sk)
/* state == TCP_CLOSE -> EPOLLHUP */
smp_rmb()
READ_ONCE(sk->sk_err) == 0
/* returns without EPOLLERR */ ...
WRITE_ONCE(sk->sk_err, ECONNRESET)
sk_error_report(sk)
A thread sleeping in poll(), select(), or epoll_wait() can wake up on mptcp_close_wake_up(), observe TCP_CLOSE with sk->sk_err == 0, and return EPOLLHUP without EPOLLERR. Should WRITE_ONCE(sk->sk_err, ECONNRESET) (with smp_wmb(), as in mptcp_close_err() and __mptcp_subflow_error_report()) happen before mptcp_set_state(sk, TCP_CLOSE)?
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=19
Matthieu Baerts (NGI0)
maintainerRFC PATCH v4 20/20 mptcp: reset when the DSS disappears after a DATA_ACK
In reply to Matthieu Baerts (NGI0)RFC 8684, section 3.7, describes a fallback to TCP for the case where the MPTCP options get through on the SYN, but not on the next packets. A sender includes a DSS option in each segment "until one of the sent segments has been acknowledged with a DSS option containing a Data ACK": it then has "the confirmation that the DSS option passes in both directions". After that, a subflow that loses its MPTCP options "SHOULD be treated as broken and closed with a RST", with the "Middlebox interference" reason. It's a *SHOULD*.
Commit 119d51e225fe ("mptcp: fallback when MPTCP opts are dropped after 1st data") did this fallback as long as allow_infinite_fallback is set, i.e. also after this confirmation, and left the check of the DATA_ACK for later [1]. Such a late fallback is fragile: the peer might still resend data that was mapped before, or a zero window probe might have mapped old data again. The previous commits "mptcp: do not fallback while old data is in flight", "mptcp: stop resending data to a peer that fell back", "mptcp: don't resend data acked without MPTCP opts" and "mptcp: continue the last mapping after a fallback" handle these cases, except one: if only the receiver falls back, it can deliver data resent at the MPTCP level as new data, if the sender does not reset the subflow before, e.g. with an older kernel. Yeah, a very specific corner case.
Now, when data without DSS is found on a subflow, the subflow is reset if a DATA_ACK received on it acknowledged data that had been sent: the MPTCP options then passed in both directions. Except after an MP_FAIL
exchange: a fallback to TCP is then in progress, so data without DSS is expected, even if the infinite mapping has not been seen. This also closes the case above, but only for a receiver whose data has been acknowledged.
Receiving a DATA_ACK is not enough: when the MPTCP options are only dropped in one direction, the peer can fall back while the DATA_ACKs it sent before acknowledged no data. A client that is not fully established falls back when a packet from the server has no MPTCP options, e.g. an ACK of its data, and the other hosts when they receive data without DSS. Except after an MP_FAIL, Linux falls back without sending an infinite mapping, then sends data without DSS: the other side can only fall back too, as before, if its data had not been acknowledged. For the same reason, the amount of received data -- e.g. more than an initial window -- is not used.
The same is done when a mapping is invalid, e.g. when it does not cover the received data after a resegmentation by a middlebox, or when the received data goes past the end of its mapping. But not after an infinite mapping, the fallback signal from the RFC: it gets a new MAPPING_INFINITE status, also named in the tracepoint, and when it comes without data, e.g. on a pure ACK, the next data without DSS can still fall back.
For data going past the end of its mapping, the reset now sends the "MPTCP-specific error" reason, as for an invalid mapping, instead of "Unspecified error", also when a fallback is not possible, e.g. on MP_JOIN subflows.
When a middlebox starts dropping the MPTCP options in the middle of a connection, after a DATA_ACK acknowledged data, the subflow is then reset, instead of falling back to TCP when it was safe. If it was the only subflow, the MPTCP connection stays without subflow until the close timeout -- 60 seconds by default, see net.mptcp.close_timeout -- unless a new one is created in between.
New Packetdrill tests check these resets, and the fallback after an infinite mapping without data.
---
v2: also reset on an invalid mapping (Clashiko), and commit message: the
remaining case is now handled by the sender
v3: name MAPPING_INFINITE in the tracepoint, and msg: all the invalid
mappings (Clashiko)
v4: also reset on data past its mapping, with the MPTCP-specific error
reason, but fall back after an infinite mapping without data; helper name, MIB comments (Sashiko, Clashiko)
Note: this commit changes the behaviour, it is for next. It fixes a very specific corner case (but it follows what the RFC 8684 recommends to do) but for that it needs an extra flag and more checks. Is it worth it? (I think so, but that's why it is flagged as RFC.)
Note: no Packetdrill test for data past its mapping: it triggers the DEBUG_NET_WARN_ON_ONCE() in __mptcp_move_skbs_from_subflow().
--- include/trace/events/mptcp.h | 3 ++- net/mptcp/mib.h | 4 ++-- net/mptcp/options.c | 14 ++++++++++---- net/mptcp/protocol.c | 7 ++++++- net/mptcp/protocol.h | 5 ++++- net/mptcp/subflow.c | 29 +++++++++++++++++++++++++---- 6 files changed, 49 insertions(+), 13 deletions(-)
include/trace/events/mptcp.h +2 -1
@@ -21,7 +21,8 @@ { 3, "MAPPING_DATA_FIN" }, \ { 4, "MAPPING_DUMMY" }, \ { 5, "MAPPING_BAD_CSUM" }, \ - { 6, "MAPPING_NODSS" }) + { 6, "MAPPING_NODSS" }, \ + { 7, "MAPPING_INFINITE" }) TRACE_EVENT(mptcp_subflow_get_send,
net/mptcp/mib.h +2 -2
@@ -35,7 +35,7 @@ enum linux_mptcp_mib_field {MPTCP_MIB_JOINSYNTXCONNECTERR ,/* Not able to connect() when sending a SYN + MP_JOIN */ MPTCP_MIB_DSSNOMATCH ,/* Received a new mapping that did not match the previous one */ MPTCP_MIB_DSSCORRUPTIONFALLBACK ,/* DSS corruption detected, fallback */ -MPTCP_MIB_DSSCORRUPTIONRESET ,/* DSS corruption detected, MPJ subflow reset */ +MPTCP_MIB_DSSCORRUPTIONRESET ,/* DSS corruption detected, subflow reset */ MPTCP_MIB_INFINITEMAPTX ,/* Sent an infinite mapping */ MPTCP_MIB_INFINITEMAPRX ,/* Received an infinite mapping */ MPTCP_MIB_DSSTCPMISMATCH, /* DSS-mapping did not map with TCP's sequence numbers */
@@ -91,7 +91,7 @@ enum linux_mptcp_mib_field {MPTCP_MIB_MD5SIGFALLBACK ,/* Conflicting TCP option enabled */ MPTCP_MIB_MD5SIGRESET ,/* MP_RST: MD5SIG enabled on listener */ MPTCP_MIB_DSSFALLBACK ,/* Bad or missing DSS */ -MPTCP_MIB_DSSRESET ,/* MP_RST: bad data mapping */ +MPTCP_MIB_DSSRESET ,/* MP_RST: bad or missing DSS */ MPTCP_MIB_SIMULTCONNFALLBACK ,/* Simultaneous connect */ MPTCP_MIB_FALLBACKFAILED ,/* Can't fallback: msk/subflow status */ MPTCP_MIB_WINPROBE, /* MPTCP-level zero window probe */
net/mptcp/options.c +10 -4
@@ -1148,7 +1148,7 @@ static void rwin_update(struct mptcp_sock *msk, struct sock *ssk, subflow->rcv_wnd_sent = mptcp_rcv_wnd; } -static void ack_update_msk (struct mptcp_sock *msk, +static bool ack_update_msk (struct mptcp_sock *msk,struct sock *ssk,const struct sk_buff *skb,struct mptcp_options_received *mp_opt)
@@ -1157,6 +1157,7 @@ static void ack_update_msk(struct mptcp_sock *msk,u32 win =ntohs (tcp_hdr (skb)->window);struct sock *sk = (struct sock *)msk;u64 snd_nxt; +bool acked;mptcp_data_lock (sk);
@@ -1189,7 +1190,8 @@ static void ack_update_msk(struct mptcp_sock *msk,if (after64 (msk->wnd_end, snd_nxt))__mptcp_check_push (sk, ssk); -if (after64 (new_snd_una, old_snd_una)) { + acked =after64 (new_snd_una, old_snd_una); +if (acked) {__mptcp_snd_una_update (msk, new_snd_una);__mptcp_data_acked (sk); }
@@ -1199,6 +1201,7 @@ static void ack_update_msk(struct mptcp_sock *msk,trace_ack_update_msk (mp_opt->data_ack, old_snd_una, new_snd_una, new_wnd_end,READ_ONCE (msk->wnd_end)); +return acked; }bool mptcp_update_rcv_data_fin (struct mptcp_sock *msk,u64 data_fin_seq,bool use_64bit)
@@ -1360,8 +1363,8 @@ bool mptcp_incoming_options(struct sock *sk, struct sk_buff *skb)/* we can't wait for recvmsg() to update the ack_seq, otherwise * monodirectional flows will stuck */ -if (mp_opt.use_ack) -ack_update_msk (msk, sk, skb, &mp_opt); +if (mp_opt.use_ack &&ack_update_msk (msk, sk, skb, &mp_opt)) + subflow->dss_confirmed =1 ;/* MPTCP opts pass both ways */ rwin_update (msk, sk, skb);/* Zero-data-length packets are dropped by the caller and not
@@ -1374,6 +1377,9 @@ bool mptcp_incoming_options(struct sock *sk, struct sk_buff *skb) mptcp_update_rcv_data_fin(msk, mp_opt.data_seq, mp_opt.dsn64))mptcp_schedule_work ((struct sock *)msk); +if (mp_opt.use_map && !mp_opt.data_len) + subflow->dss_confirmed =0 ;/* infinite map: fallback */ +return true; }
net/mptcp/protocol.c +6 -1
@@ -795,8 +795,13 @@ static void mptcp_check_data_fin(struct sock *sk)static void mptcp_dss_corruption (struct mptcp_sock *msk,struct sock *ssk) { -if (!mptcp_try_fallback (ssk,MPTCP_MIB_DSSCORRUPTIONFALLBACK )) { +struct mptcp_subflow_context *subflow =mptcp_subflow_ctx (ssk); + +if (mptcp_dss_fallback_is_fatal (msk, subflow) || + !mptcp_try_fallback (ssk,MPTCP_MIB_DSSCORRUPTIONFALLBACK )) {MPTCP_INC_STATS (sock_net (ssk),MPTCP_MIB_DSSCORRUPTIONRESET ); + subflow->reset_transient =0 ; + subflow->reset_reason =MPTCP_RST_EMPTCP ;mptcp_subflow_reset (ssk); } }
net/mptcp/protocol.h +4 -1
@@ -609,7 +609,8 @@ struct mptcp_subflow_context { resetting : 1, /* subflow is resetting */ old_data_pending : 1, /* old data not acked with MPTCP opts */ map_old : 1, /* MPC: peer's last map is below dsn_end */ - __unused : 7; + dss_confirmed : 1, /* a DATA_ACK acked our data */ + __unused : 6;bool data_avail;bool scheduled;bool pm_listener;/* a listener managed by the kernel PM? */
@@ -864,6 +865,8 @@ void mptcp_close_ssk(struct sock *sk, struct sock *ssk, struct mptcp_subflow_context *subflow);void __mptcp_subflow_send_ack (struct sock *ssk);void mptcp_subflow_reset (struct sock *ssk); +bool mptcp_dss_fallback_is_fatal (struct mptcp_sock *msk, +const struct mptcp_subflow_context *subflow);void mptcp_subflow_queue_clean (struct sock *sk,struct sock *ssk);void mptcp_sock_graft (struct sock *sk,struct socket *parent);u64 mptcp_wnd_end (const struct mptcp_sock *msk);
net/mptcp/subflow.c +25 -4
@@ -1072,7 +1072,8 @@ enum mapping_status {MAPPING_DATA_FIN ,MAPPING_DUMMY ,MAPPING_BAD_CSUM , - MAPPING_NODSS +MAPPING_NODSS , + MAPPING_INFINITE };static void dbg_bad_map (struct mptcp_subflow_context *subflow,u32 ssn)
@@ -1242,7 +1243,7 @@ static enum mapping_status get_mapping_status(struct sock *ssk,if (data_len ==0 ) {pr_debug ("infinite mapping received\n" );MPTCP_INC_STATS (sock_net (ssk),MPTCP_MIB_INFINITEMAPRX ); -return MAPPING_INVALID ; +return MAPPING_INFINITE ; }if (mpext->data_fin ==1 ) {
@@ -1454,6 +1455,22 @@ static void subflow_update_dsn_base(struct mptcp_subflow_context *subflow) subflow->dsn_end = end; } +/* RFC 8684, 3.7: no fallback once a DATA_ACK acked our data, except MP_FAIL */ +bool mptcp_dss_fallback_is_fatal (struct mptcp_sock *msk, +const struct mptcp_subflow_context *subflow) +{ +bool fatal; + +if (!subflow->dss_confirmed) +return false; + +/* before a fallback, only an MP_FAIL clears allow_subflows */ +spin_lock_bh (&msk->fallback_lock); + fatal = msk->allow_subflows; +spin_unlock_bh (&msk->fallback_lock); +return fatal; +} +static bool subflow_check_data_avail (struct sock *ssk) {struct mptcp_subflow_context *subflow =mptcp_subflow_ctx (ssk);
@@ -1474,7 +1491,9 @@ static bool subflow_check_data_avail(struct sock *ssk) status =get_mapping_status (ssk, msk);trace_subflow_check_data_avail (status,skb_peek (&ssk->sk_receive_queue));if (unlikely (status ==MAPPING_INVALID || status ==MAPPING_DUMMY || - status ==MAPPING_BAD_CSUM || status ==MAPPING_NODSS )) + status ==MAPPING_BAD_CSUM || + status ==MAPPING_NODSS || + status ==MAPPING_INFINITE )) goto fallback;if (status !=MAPPING_OK )
@@ -1524,7 +1543,9 @@ static bool subflow_check_data_avail(struct sock *ssk)return true; } -if (!mptcp_try_fallback (ssk,MPTCP_MIB_DSSFALLBACK )) { +if (((status ==MAPPING_NODSS || status ==MAPPING_INVALID ) && +mptcp_dss_fallback_is_fatal (msk, subflow)) || + !mptcp_try_fallback (ssk,MPTCP_MIB_DSSFALLBACK )) {/* fatal protocol error, reset the subflow and let the * worker close it */
Signature · 1 line
2.55.0