]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
mptcp: do not drop partial packets
authorShardul Bankar <shardul.b@mpiricsoftware.com>
Fri, 15 May 2026 04:27:32 +0000 (06:27 +0200)
committerPaolo Abeni <pabeni@redhat.com>
Tue, 19 May 2026 13:36:35 +0000 (15:36 +0200)
When a packet arrives with map_seq < ack_seq < end_seq, the beginning
of the packet has already been acknowledged but the end contains new
data. Currently the entire packet is dropped as "old data," forcing
the sender to retransmit.

Instead, skip the already-acked bytes by adjusting the skb offset and
enqueue only the new portion. Update bytes_received and ack_seq to
reflect the new data consumed.

A previous attempt at this fix has been sent by Paolo Abeni [1], but had
issues [2]: it also added a zero-window check and changed rcv_wnd_sent
initialization, which caused test regressions. This version addresses
only the partial packet handling without modifying receive window
accounting.

Fixes: ab174ad8ef76 ("mptcp: move ooo skbs into msk out of order queue.")
Cc: stable@vger.kernel.org
Link: https://lore.kernel.org/c9b426a4e163aa3c4fe8b80c79f1a610f47ae7d8.1763075056.git.pabeni@redhat.com
Closes: https://github.com/multipath-tcp/mptcp_net-next/issues/600 [2]
Signed-off-by: Shardul Bankar <shardul.b@mpiricsoftware.com>
[pabeni@redhat.com: update map]
Signed-off-by: Paolo Abeni <pabeni@redhat.com>
Reviewed-by: Matthieu Baerts (NGI0) <matttbe@kernel.org>
Signed-off-by: Matthieu Baerts (NGI0) <matttbe@kernel.org>
Link: https://patch.msgid.link/20260515-net-mptcp-misc-fixes-7-1-rc4-v2-1-701e96419f2f@kernel.org
Signed-off-by: Paolo Abeni <pabeni@redhat.com>
net/mptcp/protocol.c

index 4546a8b09884a36f34d2ca1f0b1c8b8a38a5eaad..859df49e16dc21c7b31fd56b5b574b4164fcbb29 100644 (file)
@@ -397,12 +397,26 @@ static bool __mptcp_move_skb(struct sock *sk, struct sk_buff *skb)
                return false;
        }
 
-       /* old data, keep it simple and drop the whole pkt, sender
-        * will retransmit as needed, if needed.
+       /* Completely old data? */
+       if (!after64(MPTCP_SKB_CB(skb)->end_seq, msk->ack_seq)) {
+               MPTCP_INC_STATS(sock_net(sk), MPTCP_MIB_DUPDATA);
+               mptcp_drop(sk, skb);
+               return false;
+       }
+
+       /* Partial packet: map_seq < ack_seq < end_seq.
+        * Skip the already-acked bytes and enqueue the new data.
         */
-       MPTCP_INC_STATS(sock_net(sk), MPTCP_MIB_DUPDATA);
-       mptcp_drop(sk, skb);
-       return false;
+       copy_len = MPTCP_SKB_CB(skb)->end_seq - msk->ack_seq;
+       MPTCP_SKB_CB(skb)->offset += msk->ack_seq - MPTCP_SKB_CB(skb)->map_seq;
+       MPTCP_SKB_CB(skb)->map_seq += msk->ack_seq -
+                                     MPTCP_SKB_CB(skb)->map_seq;
+       msk->bytes_received += copy_len;
+       WRITE_ONCE(msk->ack_seq, msk->ack_seq + copy_len);
+
+       skb_set_owner_r(skb, sk);
+       __skb_queue_tail(&sk->sk_receive_queue, skb);
+       return true;
 }
 
 static void mptcp_stop_rtx_timer(struct sock *sk)