From: Kuniyuki Iwashima <kuniyu@google.com>
To: Eric Dumazet <edumazet@kernel.org>
Cc: Neal Cardwell <ncardwell@google.com>,
"David S . Miller" <davem@davemloft.net>,
Jakub Kicinski <kuba@kernel.org>,
Paolo Abeni <pabeni@redhat.com>, Simon Horman <horms@kernel.org>,
Kuniyuki Iwashima <kuni1840@gmail.com>,
netdev@vger.kernel.org
Subject: Re: [PATCH v1 net 4/8] tcp: Fix reqsk abort condition on ICMP errors.
Date: Tue, 17 Nov 2026 23:44:34 +0000 [thread overview]
Message-ID: <avzmgUDfPybeinKE@google.com> (raw)
In-Reply-To: <CAL4WiipmG_J4ASJ3LRhhvS7X+pFMdvq1CM_UnXRYH2M0ajZahQ@mail.gmail.com>
On Tue, 17 Nov 2026 09:49:35 +0100, Eric Dumazet wrote:
> Le mar. 17 nov. 2026 à 06:35, Kuniyuki Iwashima <kuniyu@google.com> a écrit :
> >
> > RFC 1122 Section 4.2.3.9 states the following soft errors
> > must not abort connections:
> >
>
> Linux has never followed this for non-synchronized states.
>
> tcp_v4_err() and tcp_v6_err() call tcp_done_with_error() for any error
> in TCP_SYN_SENT and TCP_SYN_RECV, soft or hard. RFC 5461 section 4.1
> documents this, and names Linux.
Ah interesting, I missed that.
>
> Tests 1 and 2 in patch 6 actually depend on it : host_unreachable
> aborts the TCP_SYN_SENT socket.
>
>
> > o Destination Unreachable -- codes 0, 1, 5
> >
> > Since these Unreachable messages indicate soft error
> > conditions, TCP MUST NOT abort the connection, and it
> > SHOULD make the information available to the
> > application.
> >
> > o Time Exceeded -- codes 0, 1
> > o Parameter Problem
> >
> > This should be handled the same way as Destination
> > Unreachable codes 0, 1, 5 (see above).
> >
> > Commit 9cf7490360bf ("tcp: do not drop syn_recv on all icmp
> > reports") introduced the abort arg to tcp_req_err() to avoid
> > aborting connection on ICMP_REDIRECT.
> >
> > However, tcp_v4_err() still abort on soft errors (ICMP_NET_UNREACH
> > (0), ICMP_HOST_UNREACH (1)) and ignore hard errors.
> >
> > For example, we can see SYN+ACK retransmitted after receiving
> > hard error:
> >
> > --ip_version=ipv4
> > 0 socket(..., SOCK_STREAM, IPPROTO_TCP) = 3
> > +0 bind(3, ..., ...) = 0
> > +0 listen(3, 10) = 0
> >
> > +0 < S 0:0(0) win 65535 <mss 1460,nop,nop,sackOK>
> > +0 > S. 0:0(0) ack 1 <mss 1460,nop,nop,sackOK>
> > +0 < icmp unreachable port_unreachable [0:0(0)]
> > +1 > S. 0:0(0) ack 1 <mss 1460,nop,nop,sackOK>
> >
> > Also, tcp_v6_err() uses icmpv6_err_convert(), which handles
> > ICMPV6_PARAMPROB messages as hard error while RFC 5461 defines
> > as soft error.
> >
> > But we should handle ICMPV6_UNK_NEXTHDR as hard error because
> > it is used as IPv6 version ICMP_PROT_UNREACH.
> >
> > Let's correct the abort condition in tcp_v4_err() and
> > tcp_v6_err().
> >
> > Note that icmpv6_err_convert() is used by other protocols.
> >
> > Fixes: 9cf7490360bf ("tcp: do not drop syn_recv on all icmp reports")
> > Signed-off-by: Kuniyuki Iwashima <kuniyu@google.com>
> > ---
> > net/ipv4/tcp_ipv4.c | 7 ++-----
> > net/ipv6/tcp_ipv6.c | 3 ++-
> > 2 files changed, 4 insertions(+), 6 deletions(-)
> >
> > diff --git a/net/ipv4/tcp_ipv4.c b/net/ipv4/tcp_ipv4.c
> > index fd9588bba967..f11e090d04fb 100644
> > --- a/net/ipv4/tcp_ipv4.c
> > +++ b/net/ipv4/tcp_ipv4.c
> > @@ -529,11 +529,8 @@ int tcp_v4_err(struct sk_buff *skb, u32 info)
> >
> > seq = ntohl(th->seq);
> > if (sk->sk_state == TCP_NEW_SYN_RECV) {
> > - tcp_req_err(sk, seq, type == ICMP_PARAMETERPROB ||
> > - type == ICMP_TIME_EXCEEDED ||
> > - (type == ICMP_DEST_UNREACH &&
> > - (code == ICMP_NET_UNREACH ||
> > - code == ICMP_HOST_UNREACH)));
> > + tcp_req_err(sk, seq, (type == ICMP_DEST_UNREACH &&
> > + icmp_err_convert[code].fatal));
>
>
> After this patch, a TCP_SYN_SENT socket and a Fast Open TCP_SYN_RECV
> child abort on net/host unreachable, but a request socket does not.
>
> We also lose the ability to get rid of a request for an unreachable
> client, and keep retransmitting SYNACK instead.
>
> If the problem is that hard errors are ignored for IPv4 request
> sockets, I would rather add them than remove the soft ones :
>
> abort = type == ICMP_PARAMETERPROB ||
> type == ICMP_TIME_EXCEEDED ||
> (type == ICMP_DEST_UNREACH && code != ICMP_FRAG_NEEDED);
>
> This matches what we do for TCP_SYN_SENT. The IPv6 side would then
> need the same treatment instead of using 'fatal'.
I'll update both in that way.
Thanks!
next prev parent reply other threads:[~2026-11-17 23:44 UTC|newest]
Thread overview: 23+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-17 5:35 [PATCH v1 net 0/8] tcp: Misc fixes for tcp_v[46]_err() Kuniyuki Iwashima
2026-11-17 5:35 ` [PATCH v1 net 1/8] tcp: Don't accept ICMP for SND.NXT in TCP_SYN_SENT Kuniyuki Iwashima
2026-11-17 8:35 ` Eric Dumazet
2026-11-17 23:30 ` Kuniyuki Iwashima
2026-11-17 5:35 ` [PATCH v1 net 2/8] tcp: Don't use inner IP TTL for IP_MINTTL in tcp_v4_err() Kuniyuki Iwashima
2026-11-17 8:42 ` Eric Dumazet
2026-11-17 23:35 ` Kuniyuki Iwashima
2026-11-17 5:35 ` [PATCH v1 net 3/8] tcp: Don't bypass GTSM check for reqsk Kuniyuki Iwashima
2026-11-17 8:45 ` Eric Dumazet
2026-11-17 23:42 ` Kuniyuki Iwashima
2026-11-17 5:35 ` [PATCH v1 net 4/8] tcp: Fix reqsk abort condition on ICMP errors Kuniyuki Iwashima
2026-11-17 8:49 ` Eric Dumazet
2026-11-17 23:44 ` Kuniyuki Iwashima [this message]
2026-11-17 5:35 ` [PATCH v1 net 5/8] tcp: Check ip_sk_accept_pmtu() in tcp_v4_err() Kuniyuki Iwashima
2026-11-17 8:54 ` Eric Dumazet
2026-11-17 5:35 ` [PATCH v1 net 6/8] selftest: net: packetdrill: Add ICMP and ICMPv6 tests Kuniyuki Iwashima
2026-11-17 8:58 ` Eric Dumazet
2026-11-17 23:45 ` Kuniyuki Iwashima
2026-11-17 5:35 ` [PATCH v1 net 7/8] tcp: Pass inet_sdif() to __inet_lookup_established() in tcp_v4_err() Kuniyuki Iwashima
2026-11-17 9:01 ` Eric Dumazet
2026-11-17 5:35 ` [PATCH v1 net 8/8] tcp: Pass inet6_iif() to __inet6_lookup_established() in tcp_v6_err() Kuniyuki Iwashima
2026-11-17 9:03 ` Eric Dumazet
2026-11-17 23:56 ` Kuniyuki Iwashima
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=avzmgUDfPybeinKE@google.com \
--to=kuniyu@google.com \
--cc=davem@davemloft.net \
--cc=edumazet@kernel.org \
--cc=horms@kernel.org \
--cc=kuba@kernel.org \
--cc=kuni1840@gmail.com \
--cc=ncardwell@google.com \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox