From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 4A46D156C6C; Tue, 23 Jul 2024 16:08:22 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1721750902; cv=none; b=audxKlsRj5QCWxGPLzjUm+tjLQJRg2K6UTFElE1zJxKhGsHrz+1xoenAFBlPqXtIfglWTY6kCaHirSC5GWrQhIeNBOJNESf8hE2fMKQvW6BSj3cSTSUcNGiFWgfNT2yIgkoBpBbkvoy5oEBo83mFO+Kb+KGxF15ENvp8kR0tBgY= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1721750902; c=relaxed/simple; bh=pZBZ7AgRH53/JGtlfofcX9i7ApPL58N1dLliLlryDcw=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=BRFh6GdYnnE1SYLlxxJIZxVwUmNTmL4LBCAcx71rnGQrz2oPCPNDRL0KErT8ERE1w3/UzKQizNRMp5qA5Awpv2KP1dceBn2VNef4hFWzqjQgqrZNroAiGhA/zuBWUJTaAkHiSCG0GR4CbjIjY+4lFkWOESodcBJSzYjaKw+cD9E= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=iPLcf1bU; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="iPLcf1bU" Received: by smtp.kernel.org (Postfix) with ESMTPSA id C69C7C4AF09; Tue, 23 Jul 2024 16:08:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1721750902; bh=pZBZ7AgRH53/JGtlfofcX9i7ApPL58N1dLliLlryDcw=; h=Date:Subject:To:Cc:References:From:In-Reply-To:From; b=iPLcf1bUXJDjFMRYNfuiSP3Leae/96X+NvX/wIg/glt2Xz9Fmw8sepuDgNskMQ3Wq YvCZFq8W0CkzeuYdOyrtTce04dV5rHeOT8uFLNGhfWqz68JAuVJ1ErylNq2M9q3JmM Ksw9o6Us1JmhtkFfZjgxU5OjjopztU/GKkmbscoWStzBF2hmk2CuM6GlVktLkwhehe gyqSKBWwBAuW/q1/Y8KP+9fqoZhF3NWXG5zLd+gkkDIJrTygejZ2RMhX6qh5ei1twk SnMMO9WG7iK+jmSK/knFzTSYvxtwmjiZ6z4TlQJRa+SThvpW82EYGq8AEeHFxDJyJH nWYMI0259PrYA== Message-ID: <4558399b-002b-40ff-8d9b-ac7bf13b3d2e@kernel.org> Date: Tue, 23 Jul 2024 18:08:17 +0200 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Beta Subject: Re: [PATCH net v2 1/2] tcp: process the 3rd ACK with sk_socket for TFO/MPTCP Content-Language: en-GB To: Eric Dumazet Cc: "David S. Miller" , David Ahern , Jakub Kicinski , Paolo Abeni , Kuniyuki Iwashima , netdev@vger.kernel.org, mptcp@lists.linux.dev, linux-kernel@vger.kernel.org, Neal Cardwell References: <20240718-upstream-net-next-20240716-tcp-3rd-ack-consume-sk_socket-v2-0-d653f85639f6@kernel.org> <20240718-upstream-net-next-20240716-tcp-3rd-ack-consume-sk_socket-v2-1-d653f85639f6@kernel.org> <2583642a-cc5f-4765-856d-4340adcecf33@kernel.org> From: Matthieu Baerts Autocrypt: addr=matttbe@kernel.org; keydata= xsFNBFXj+ekBEADxVr99p2guPcqHFeI/JcFxls6KibzyZD5TQTyfuYlzEp7C7A9swoK5iCvf YB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LJIv Hl7iqPF+JDCjB5sAEQEAAcLBXwQYAQIACQUCVeP56QIbDAAKCRD2t4JPQmmgc5VnD/9YgbCr HR1FbMbm7td54UrYvZV/i7m3dIQNXK2e+Cbv5PXf19ce3XluaE+wA8D+vnIW5mbAAiojt3Mb 6p0WJS3QzbObzHNgAp3zy/L4lXwc6WW5vnpWAzqXFHP8D9PTpqvBALbXqL06smP47JqbyQxj Xf7D2rrPeIqbYmVY9da1KzMOVf3gReazYa89zZSdVkMojfWsbq05zwYU+SCWS3NiyF6QghbW voxbFwX1i/0xRwJiX9NNbRj1huVKQuS4W7rbWA87TrVQPXUAdkyd7FRYICNW+0gddysIwPoa KrLfx3Ba6Rpx0JznbrVOtXlihjl4KV8mtOPjYDY9u+8x412xXnlGl6AC4HLu2F3ECkamY4G6 UxejX+E6vW6Xe4n7H+rEX5UFgPRdYkS1TA/X3nMen9bouxNsvIJv7C6adZmMHqu/2azX7S7I vrxxySzOw9GxjoVTuzWMKWpDGP8n71IFeOot8JuPZtJ8omz+DZel+WCNZMVdVNLPOd5frqOv mpz0VhFAlNTjU1Vy0CnuxX3AM51J8dpdNyG0S8rADh6C8AKCDOfUstpq28/6oTaQv7QZdge0 JY6dglzGKnCi/zsmp2+1w559frz4+IC7j/igvJGX4KDDKUs0mlld8J2u2sBXv7CGxdzQoHaz lzVbFe7fduHbABmYz9cefQpO7wDE/Q== Organization: NGI0 Core In-Reply-To: Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Hi Eric, On 23/07/2024 17:38, Eric Dumazet wrote: > On Tue, Jul 23, 2024 at 4:58 PM Matthieu Baerts wrote: >> >> Hi Eric, >> >> +cc Neal >> -cc Jerry (NoSuchUser) >> >> On 23/07/2024 16:37, Eric Dumazet wrote: >>> On Thu, Jul 18, 2024 at 12:34 PM Matthieu Baerts (NGI0) >>> wrote: >>>> >>>> The 'Fixes' commit recently changed the behaviour of TCP by skipping the >>>> processing of the 3rd ACK when a sk->sk_socket is set. The goal was to >>>> skip tcp_ack_snd_check() in tcp_rcv_state_process() not to send an >>>> unnecessary ACK in case of simultaneous connect(). Unfortunately, that >>>> had an impact on TFO and MPTCP. >>>> >>>> I started to look at the impact on MPTCP, because the MPTCP CI found >>>> some issues with the MPTCP Packetdrill tests [1]. Then Paolo suggested >>>> me to look at the impact on TFO with "plain" TCP. >>>> >>>> For MPTCP, when receiving the 3rd ACK of a request adding a new path >>>> (MP_JOIN), sk->sk_socket will be set, and point to the MPTCP sock that >>>> has been created when the MPTCP connection got established before with >>>> the first path. The newly added 'goto' will then skip the processing of >>>> the segment text (step 7) and not go through tcp_data_queue() where the >>>> MPTCP options are validated, and some actions are triggered, e.g. >>>> sending the MPJ 4th ACK [2] as demonstrated by the new errors when >>>> running a packetdrill test [3] establishing a second subflow. >>>> >>>> This doesn't fully break MPTCP, mainly the 4th MPJ ACK that will be >>>> delayed. Still, we don't want to have this behaviour as it delays the >>>> switch to the fully established mode, and invalid MPTCP options in this >>>> 3rd ACK will not be caught any more. This modification also affects the >>>> MPTCP + TFO feature as well, and being the reason why the selftests >>>> started to be unstable the last few days [4]. >>>> >>>> For TFO, the existing 'basic-cookie-not-reqd' test [5] was no longer >>>> passing: if the 3rd ACK contains data, and the connection is accept()ed >>>> before receiving them, these data would no longer be processed, and thus >>>> not ACKed. >>>> >>>> One last thing about MPTCP, in case of simultaneous connect(), a >>>> fallback to TCP will be done, which seems fine: >>>> >>>> `../common/defaults.sh` >>>> >>>> 0 socket(..., SOCK_STREAM|SOCK_NONBLOCK, IPPROTO_MPTCP) = 3 >>>> +0 connect(3, ..., ...) = -1 EINPROGRESS (Operation now in progress) >>>> >>>> +0 > S 0:0(0) >>>> +0 < S 0:0(0) win 1000 >>>> +0 > S. 0:0(0) ack 1 >>>> +0 < S. 0:0(0) ack 1 win 65535 >>>> >>>> +0 write(3, ..., 100) = 100 >>>> +0 > . 1:1(0) ack 1 >>>> +0 > P. 1:101(100) ack 1 >>>> >>>> Simultaneous SYN-data crossing is also not supported by TFO, see [6]. >>>> >>>> Link: https://github.com/multipath-tcp/mptcp_net-next/actions/runs/9936227696 [1] >>>> Link: https://datatracker.ietf.org/doc/html/rfc8684#fig_tokens [2] >>>> Link: https://github.com/multipath-tcp/packetdrill/blob/mptcp-net-next/gtests/net/mptcp/syscalls/accept.pkt#L28 [3] >>>> Link: https://netdev.bots.linux.dev/contest.html?executor=vmksft-mptcp-dbg&test=mptcp-connect-sh [4] >>>> Link: https://github.com/google/packetdrill/blob/master/gtests/net/tcp/fastopen/server/basic-cookie-not-reqd.pkt#L21 [5] >>>> Link: https://github.com/google/packetdrill/blob/master/gtests/net/tcp/fastopen/client/simultaneous-fast-open.pkt [6] >>>> Fixes: 23e89e8ee7be ("tcp: Don't drop SYN+ACK for simultaneous connect().") >>>> Suggested-by: Paolo Abeni >>>> Suggested-by: Kuniyuki Iwashima >>>> Signed-off-by: Matthieu Baerts (NGI0) >>>> --- >>>> Notes: >>>> - We could also drop this 'goto consume', and send the unnecessary ACK >>>> in this simultaneous connect case, which doesn't seem to be a "real" >>>> case, more something for fuzzers. But that's not what the RFC 9293 >>>> recommends to do. >>>> - v2: >>>> - Check if the SYN bit is set instead of looking for TFO and MPTCP >>>> specific attributes, as suggested by Kuniyuki. >>>> - Updated the comment above >>>> - Please note that the v2 has been sent mainly to satisfy the CI (to >>>> be able to catch new bugs with MPTCP), and because the suggestion >>>> from Kuniyuki looks better. It has not been sent to urge TCP >>>> maintainers to review it quicker than it should, please take your >>>> time and enjoy netdev.conf :) >>>> --- >>>> net/ipv4/tcp_input.c | 7 ++++++- >>>> 1 file changed, 6 insertions(+), 1 deletion(-) >>>> >>>> diff --git a/net/ipv4/tcp_input.c b/net/ipv4/tcp_input.c >>>> index ff9ab3d01ced..bfe1bc69dc3e 100644 >>>> --- a/net/ipv4/tcp_input.c >>>> +++ b/net/ipv4/tcp_input.c >>>> @@ -6820,7 +6820,12 @@ tcp_rcv_state_process(struct sock *sk, struct sk_buff *skb) >>>> if (sk->sk_shutdown & SEND_SHUTDOWN) >>>> tcp_shutdown(sk, SEND_SHUTDOWN); >>>> >>>> - if (sk->sk_socket) >>>> + /* For crossed SYN cases, not to send an unnecessary ACK. >>>> + * Note that sk->sk_socket can be assigned in other cases, e.g. >>>> + * with TFO (if accept()'ed before the 3rd ACK) and MPTCP (MPJ: >>>> + * sk_socket is the parent MPTCP sock). >>>> + */ >>>> + if (sk->sk_socket && th->syn) >>>> goto consume; >>> >>> I think we should simply remove this part completely, because we >>> should send an ack anyway. >> >> Thank you for having looked, and ran the full packetdrill test suite! >> >>> >>> diff --git a/net/ipv4/tcp_input.c b/net/ipv4/tcp_input.c >>> index ff9ab3d01ced89570903d3a9f649a637c5e07a90..91357d4713182078debd746a224046cba80ea3ce >>> 100644 >>> --- a/net/ipv4/tcp_input.c >>> +++ b/net/ipv4/tcp_input.c >>> @@ -6820,8 +6820,6 @@ tcp_rcv_state_process(struct sock *sk, struct >>> sk_buff *skb) >>> if (sk->sk_shutdown & SEND_SHUTDOWN) >>> tcp_shutdown(sk, SEND_SHUTDOWN); >>> >>> - if (sk->sk_socket) >>> - goto consume; >>> break; >>> >>> case TCP_FIN_WAIT1: { >>> >>> >>> I have a failing packetdrill test after Kuniyuki patch : >>> >>> >>> >>> // >>> // Test the simultaneous open scenario that both end sends >>> // SYN/data. Although we don't support that the connection should >>> // still be established. >>> // >>> `../../common/defaults.sh >>> ../../common/set_sysctls.py /proc/sys/net/ipv4/tcp_timestamps=0` >>> >>> // Cache warmup: send a Fast Open cookie request >>> 0 socket(..., SOCK_STREAM, IPPROTO_TCP) = 3 >>> +0 fcntl(3, F_SETFL, O_RDWR|O_NONBLOCK) = 0 >>> +0 sendto(3, ..., 0, MSG_FASTOPEN, ..., ...) = -1 EINPROGRESS >>> (Operation is now in progress) >>> +0 > S 0:0(0) >>> +.01 < S. 123:123(0) ack 1 win 14600 >> 1460,nop,nop,sackOK,nop,wscale 6,FO abcd1234,nop,nop> >>> +0 > . 1:1(0) ack 1 >>> +.01 close(3) = 0 >>> +0 > F. 1:1(0) ack 1 >>> +.01 < F. 1:1(0) ack 2 win 92 >>> +0 > . 2:2(0) ack 2 >>> >>> >>> // >>> // Test: simulatenous fast open >>> // >>> +.01 socket(..., SOCK_STREAM, IPPROTO_TCP) = 4 >>> +0 fcntl(4, F_SETFL, O_RDWR|O_NONBLOCK) = 0 >>> +0 sendto(4, ..., 1000, MSG_FASTOPEN, ..., ...) = 1000 >>> +0 > S 0:1000(1000) >> abcd1234,nop,nop> >>> // Simul. SYN-data crossing: we don't support that yet so ack only remote ISN >>> +.005 < S 1234:1734(500) win 14600 >> 6,FO 87654321,nop,nop> >>> +0 > S. 0:0(0) ack 1235 >>> >>> // SYN data is never retried. >>> +.045 < S. 1234:1234(0) ack 1001 win 14600 >> 940,nop,nop,sackOK,nop,wscale 6,FO 12345678,nop,nop> >>> +0 > . 1001:1001(0) ack 1 >> >> I recently sent a PR -- already applied -- to Neal to remove this line: >> >> https://github.com/google/packetdrill/pull/86 >> >> I thought it was the intension of Kuniyuki's patch not to send this ACK >> in this case to follow the RFC 9293's recommendation. This TFO test >> looks a bit similar to the example from Kuniyuki's patch: >> >> >> --------------- 8< --------------- >> 0 socket(..., SOCK_STREAM|SOCK_NONBLOCK, IPPROTO_TCP) = 3 >> +0 connect(3, ..., ...) = -1 EINPROGRESS (Operation now in progress) >> >> +0 > S 0:0(0) >> +0 < S 0:0(0) win 1000 >> +0 > S. 0:0(0) ack 1 >> +0 < S. 0:0(0) ack 1 win 1000 >> >> /* No ACK here */ >> >> +0 write(3, ..., 100) = 100 >> +0 > P. 1:101(100) ack 1 >> --------------- 8< --------------- >> >> >> >> But maybe here that should be different for TFO? >> >> For my case with MPTCP (and TFO), it is fine to drop this 'goto consume' >> but I don't know how "strict" we want to be regarding the RFC and this >> marginal case. > > Problem of this 'goto consume' is that we are not properly sending a > DUPACK in this case. > > +.01 socket(..., SOCK_STREAM, IPPROTO_TCP) = 4 > +0 fcntl(4, F_SETFL, O_RDWR|O_NONBLOCK) = 0 > +0 sendto(4, ..., 1000, MSG_FASTOPEN, ..., ...) = 1000 > +0 > S 0:1000(1000) abcd1234,nop,nop> > // Simul. SYN-data crossing: we don't support that yet so ack only remote ISN > +.005 < S 1234:1734(500) win 14600 6,FO 87654321,nop,nop> > +0 > S. 0:0(0) ack 1235 > > +.045 < S. 1234:1234(0) ack 1001 win 14600 940,nop,nop,sackOK,nop,wscale 6,FO 12345678,nop,nop> > +0 > . 1001:1001(0) ack 1 // See here I'm sorry, but is it normal to have 'ack 1' with 'sack 0:1' here? > Not sending a dupack seems wrong and could hurt. Indeed, I thought the RFC 9293 was not allowing that, but I didn't see anything forbidding this DUPACK: https://www.rfc-editor.org/rfc/rfc9293.html#section-3.5-7 > I had reservations about this part, if you look back to the discussion. > > This is why Kuniyuki added in his changelog : > > Note that tcp_ack_snd_check() in tcp_rcv_state_process() is skipped not to > send an unnecessary ACK, but this could be a bit risky for net.git, so this > targets for net-next. I understand, I can send a v3 dropping this part, and not including patch 2/2 for -net. I can also send a PR to Neal re-adding the ACK with 'sack' (if it is normal). Cheers, Matt -- Sponsored by the NGI0 Core fund.