Thread View: linux.kernel.netdev
1 messages
1 total messages
Started by Eric Dumazet
Tue, 17 Nov 2026 08:49
Re: [PATCH v1 net 4/8] tcp: Fix reqsk abort condition on ICMP errors.
Author: Eric Dumazet
Date: Tue, 17 Nov 2026 08:49
Date: Tue, 17 Nov 2026 08:49
125 lines
13521 bytes
13521 bytes
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.
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'.
> return 0;
> }
>
> diff --git a/net/ipv6/tcp_ipv6.c b/net/ipv6/tcp_ipv6.c
> index 0f1523fff939..29fd0a084c91 100644
> --- a/net/ipv6/tcp_ipv6.c
> +++ b/net/ipv6/tcp_ipv6.c
> @@ -447,7 +447,8 @@ static int tcp_v6_err(struct sk_buff *skb, struct inet6_skb_parm *opt,
> seq = ntohl(th->seq);
> fatal = icmpv6_err_convert(type, code, &err);
> if (sk->sk_state == TCP_NEW_SYN_RECV) {
> - tcp_req_err(sk, seq, fatal);
> + tcp_req_err(sk, seq, type == ICMPV6_PARAMPROB ?
> + code == ICMPV6_UNK_NEXTHDR : fatal);
> return 0;
> }
>
> --
> 2.56.0.679.gc527c65306-goog
>
Thread Navigation
This is a paginated view of messages in the thread with full content displayed inline.
Messages are displayed in chronological order, with the original post highlighted in green.
Use pagination controls to navigate through all messages in large threads.
Back to All Threads