Skip to content

Commit 25010bf

Browse files
author
Paolo Abeni
committed
Merge branch 'mptcp-fix-duplicate-data-handling'
Matthieu Baerts says: ==================== mptcp: fix duplicate data handling In some cases, the subflow-level's copied_seq counter was incorrectly increased, leading to an unexpected subflow reset. Patch 1/2 fixes the RCVPRUNED MIB counter that was attached to the wrong event since its introduction in v5.14, backported to v5.11. Patch 2/2 fixes the copied_seq counter issues, is present since v5.10. Signed-off-by: Matthieu Baerts (NGI0) <[email protected]> ==================== Link: https://patch.msgid.link/20240731-upstream-net-20240731-mptcp-dup-data-v1-0-bde833fa628a@kernel.org Signed-off-by: Paolo Abeni <[email protected]>
2 parents 2b4a32d + 68cc924 commit 25010bf

File tree

2 files changed

+16
-8
lines changed

2 files changed

+16
-8
lines changed

net/mptcp/protocol.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -350,8 +350,10 @@ static bool __mptcp_move_skb(struct mptcp_sock *msk, struct sock *ssk,
350350
skb_orphan(skb);
351351

352352
/* try to fetch required memory from subflow */
353-
if (!mptcp_rmem_schedule(sk, ssk, skb->truesize))
353+
if (!mptcp_rmem_schedule(sk, ssk, skb->truesize)) {
354+
MPTCP_INC_STATS(sock_net(sk), MPTCP_MIB_RCVPRUNED);
354355
goto drop;
356+
}
355357

356358
has_rxtstamp = TCP_SKB_CB(skb)->has_rxtstamp;
357359

@@ -844,10 +846,8 @@ void mptcp_data_ready(struct sock *sk, struct sock *ssk)
844846
sk_rbuf = ssk_rbuf;
845847

846848
/* over limit? can't append more skbs to msk, Also, no need to wake-up*/
847-
if (__mptcp_rmem(sk) > sk_rbuf) {
848-
MPTCP_INC_STATS(sock_net(sk), MPTCP_MIB_RCVPRUNED);
849+
if (__mptcp_rmem(sk) > sk_rbuf)
849850
return;
850-
}
851851

852852
/* Wake-up the reader only for in-sequence data */
853853
mptcp_data_lock(sk);

net/mptcp/subflow.c

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1230,14 +1230,22 @@ static void mptcp_subflow_discard_data(struct sock *ssk, struct sk_buff *skb,
12301230
{
12311231
struct mptcp_subflow_context *subflow = mptcp_subflow_ctx(ssk);
12321232
bool fin = TCP_SKB_CB(skb)->tcp_flags & TCPHDR_FIN;
1233-
u32 incr;
1233+
struct tcp_sock *tp = tcp_sk(ssk);
1234+
u32 offset, incr, avail_len;
12341235

1235-
incr = limit >= skb->len ? skb->len + fin : limit;
1236+
offset = tp->copied_seq - TCP_SKB_CB(skb)->seq;
1237+
if (WARN_ON_ONCE(offset > skb->len))
1238+
goto out;
1239+
1240+
avail_len = skb->len - offset;
1241+
incr = limit >= avail_len ? avail_len + fin : limit;
12361242

1237-
pr_debug("discarding=%d len=%d seq=%d", incr, skb->len,
1238-
subflow->map_subflow_seq);
1243+
pr_debug("discarding=%d len=%d offset=%d seq=%d", incr, skb->len,
1244+
offset, subflow->map_subflow_seq);
12391245
MPTCP_INC_STATS(sock_net(ssk), MPTCP_MIB_DUPDATA);
12401246
tcp_sk(ssk)->copied_seq += incr;
1247+
1248+
out:
12411249
if (!before(tcp_sk(ssk)->copied_seq, TCP_SKB_CB(skb)->end_seq))
12421250
sk_eat_skb(ssk, skb);
12431251
if (mptcp_subflow_get_map_offset(subflow) >= subflow->map_data_len)

0 commit comments

Comments
 (0)