tcp: add missing tcp_skb_can_collapse() test in tcp_shift_skb_data()
Subsystems (3)
PATCH 1/1 tcp: add missing tcp_skb_can_collapse() test in tcp_shift_skb_data()
From: Eric Dumazet <[email protected]>
tcp_shift_skb_data() might collapse three packets into a larger one.
P_A, P_B, P_C -> P_ABC
Historically, it used a single tcp_skb_can_collapse_to(P_A) call, because it was enough.
In commit 85712484110d ("tcp: coalesce/collapse must respect MPTCP extensions"), this call was replaced by a call to tcp_skb_can_collapse(P_A, P_B)
But the now needed test over P_C has been missed.
This probably broke MPTCP.
Then later, commit 9b65b17db723 ("net: avoid double accounting for pure zerocopy skbs") added an extra condition to tcp_skb_can_collapse(), but the missing call from tcp_shift_skb_data() is also breaking TCP zerocopy, because P_A and P_C might have different skb_zcopy_pure() status.
--- net/ipv4/tcp_input.c | 2 ++ 1 file changed, 2 insertions(+)
net/ipv4/tcp_input.c +2 -0
@@ -1660,6 +1660,8 @@ static struct sk_buff *tcp_shift_skb_data(struct sock *sk, struct sk_buff *skb, (mss != tcp_skb_seglen(skb))) goto out; +if (!tcp_skb_can_collapse (prev, skb)) + goto out; len = skb->len; pcount =tcp_skb_pcount (skb);if (tcp_skb_shift (prev, skb, pcount, len))
Signature · 1 line
2.35.0.rc2.247.g8bbb082509-goog
Quoted 22 lines · Eric Dumazet
From: Eric Dumazet <[email protected]>
tcp_shift_skb_data()might collapse three packets into a larger one.
P_A,P_B,P_C->P_ABCHistorically, it used a single
tcp_skb_can_collapse_to(P_A)call, because it was enough.In commit
85712484110d("tcp: coalesce/collapse must respect MPTCP extensions"), this call was replaced by a call totcp_skb_can_collapse(P_A, P_B)But the now needed test over
P_Chas been missed.This probably broke MPTCP.
Then later, commit
9b65b17db723("net: avoid double accounting for pure zerocopy skbs") added an extra condition totcp_skb_can_collapse(), but the missing call fromtcp_shift_skb_data()is also breaking TCP zerocopy, becauseP_AandP_Cmight have differentskb_zcopy_pure()status.
Quoted 9 lines
Fixes 85712484110d ("tcp: coalesce/collapse must respect MPTCP extensions")Fixes 9b65b17db723 ("net: avoid double accounting for pure zerocopy skbs")Signed-off-by Eric Dumazet <[email protected]>Cc Paolo Abeni <[email protected]>Cc Mat Martineau <[email protected]>Cc Talal Ahmad <[email protected]>Cc Arjun Roy <[email protected]>Cc Soheil Hassas Yeganeh <[email protected]>Cc Willem de Bruijn <[email protected]>
I wish there were some packetdrill tests for MPTCP. Thank you for the fix!
Quoted 20 lines
--- net/ipv4/tcp_input.c | 2 ++ 1 file changed, 2 insertions(+)net/ipv4/tcp_input.c +2
-1@@ -1660,6 +1660,8 @@ static struct sk_buff *tcp_shift_skb_data(struct sock *sk, struct sk_buff *skb, (mss != tcp_skb_seglen(skb))) goto out; +if (!tcp_skb_can_collapse (prev, skb)) + goto out; len = skb->len; pcount =tcp_skb_pcount (skb);if (tcp_skb_shift (prev, skb, pcount, len)) --2.35.0.rc2.247.g8bbb082509-goog
Quoted 33 lines · Soheil Hassas Yeganeh
Quoted 22 lines · Eric Dumazet
From: Eric Dumazet <[email protected]>
tcp_shift_skb_data()might collapse three packets into a larger one.
P_A,P_B,P_C->P_ABCHistorically, it used a single
tcp_skb_can_collapse_to(P_A)call, because it was enough.In commit
85712484110d("tcp: coalesce/collapse must respect MPTCP extensions"), this call was replaced by a call totcp_skb_can_collapse(P_A, P_B)But the now needed test over
P_Chas been missed.This probably broke MPTCP.
Then later, commit
9b65b17db723("net: avoid double accounting for pure zerocopy skbs") added an extra condition totcp_skb_can_collapse(), but the missing call fromtcp_shift_skb_data()is also breaking TCP zerocopy, becauseP_AandP_Cmight have differentskb_zcopy_pure()status.Quoted 9 lines
Fixes 85712484110d ("tcp: coalesce/collapse must respect MPTCP extensions")Fixes 9b65b17db723 ("net: avoid double accounting for pure zerocopy skbs")Signed-off-by Eric Dumazet <[email protected]>Cc Paolo Abeni <[email protected]>Cc Mat Martineau <[email protected]>Cc Talal Ahmad <[email protected]>Cc Arjun Roy <[email protected]>Cc Soheil Hassas Yeganeh <[email protected]>Cc Willem de Bruijn <[email protected]>
Quoted 4 lines
I wish there were some packetdrill tests for MPTCP. Thank you for the fix!
Soheil -
I have good news, there are packetdrill tests for MPTCP:
https://github.com/multipath-tcp/packetdrill
This is still in a fork. I think Davide has talked to Neal about upstreaming the MPTCP changes before but there may be some code that needs refactoring before that could happen.
Quoted 12 lines
Quoted 12 lines
--- net/ipv4/tcp_input.c | 2 ++ 1 file changed, 2 insertions(+)net/ipv4/tcp_input.c +0
-0@@ -1660,6 +1660,8 @@ static struct sk_buff *tcp_shift_skb_data(struct sock *sk, struct sk_buff *skb, (mss != tcp_skb_seglen(skb))) goto out;
Quoted 9 lines
Quoted 8 lines
net/ipv4/tcp_input.c +2
-1+if (!tcp_skb_can_collapse (prev, skb)) + goto out; len = skb->len; pcount =tcp_skb_pcount (skb);if (tcp_skb_shift (prev, skb, pcount, len)) --2.35.0.rc2.247.g8bbb082509-goog
--
Mat Martineau
Intel
Quoted 13 lines · Mat Martineau
Quoted 11 lines · Soheil Hassas Yeganeh
Quoted 10 lines · Eric Dumazet
From: Eric Dumazet <[email protected]>
tcp_shift_skb_data()might collapse three packets into a larger one.
P_A,P_B,P_C->P_ABCHistorically, it used a single
tcp_skb_can_collapse_to(P_A)call, because it was enough.
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
In commit
85712484110d("tcp: coalesce/collapse must respect MPTCP extensions"), this call was replaced by a call totcp_skb_can_collapse(P_A, P_B)But the now needed test over
P_Chas been missed.This probably broke MPTCP.
Indeed it looks like it could cause MPTCP data stream corruption, in case of multiple substreams, if we hit this code-path. Thanks for catching and fixing it!
Quoted 15 lines
Quoted 15 lines
Quoted 14 lines
Then later, commit
9b65b17db723("net: avoid double accounting for pure zerocopy skbs") added an extra condition totcp_skb_can_collapse(), but the missing call fromtcp_shift_skb_data()is also breaking TCP zerocopy, becauseP_AandP_Cmight have differentskb_zcopy_pure()status.Fixes 85712484110d ("tcp: coalesce/collapse must respect MPTCP extensions")Fixes 9b65b17db723 ("net: avoid double accounting for pure zerocopy skbs")Signed-off-by Eric Dumazet <[email protected]>Cc Paolo Abeni <[email protected]>Cc Mat Martineau <[email protected]>Cc Talal Ahmad <[email protected]>Cc Arjun Roy <[email protected]>Cc Soheil Hassas Yeganeh <[email protected]>Cc Willem de Bruijn <[email protected]>
Quoted 1 line
Quoted 1 line
Quoted 2 lines
Quoted 2 lines
I wish there were some packetdrill tests for MPTCP. Thank you for the fix!
Do you have by chance a drill for the zero-copy case? it may help creating the MPTCP one, too.
Thanks!
Paolo
This patch was applied to netdev/net.git (master) by Jakub Kicinski <[email protected]>:
Hello:
This patch was applied to netdev/net.git (master)
by Jakub Kicinski <[email protected]>:
Quoted 10 lines · On Tue, 1 Feb 2022 10:46:40 -0800 you wrote:
From: Eric Dumazet <[email protected]>
tcp_shift_skb_data()might collapse three packets into a larger one.
P_A,P_B,P_C->P_ABCHistorically, it used a single
tcp_skb_can_collapse_to(P_A)call, because it was enough.[...]
Here is the summary with links:
- [net] tcp: add missing tcp_skb_can_collapse() test in tcp_shift_skb_data()
https://git.kernel.org/netdev/net/c/b67985be4009
You are awesome, thank you!
Signature · 2 lines
Deet-doot-dot, I am a bot. https://korg.docs.kernel.org/patchwork/pwbot.html