๐Ÿš€ go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: linux.kernel.netdev
Article #17705

Re: [PATCH v1 net 4/8] tcp: Fix reqsk abort condition on ICMP errors.

#17705
From: Eric Dumazet
Date: Tue, 17 Nov 2026 08:49
125 lines
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
>
Technical Details
Message-ID: <CAL4WiipmG_J4ASJ3LRhhvS7X+pFMdvq1CM_UnXRYH2M0ajZahQ@mail.gmail.com>
Path: mbox-mo1.pugleaf.net!news-lax.pugleaf.net!srl.newsdeef.eu!newsfeed.bofh.team!nntp.comgw.net!eternal-september.org!feeder.eternal-september.org!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-365065-linux-kernel-netdev=dewy.ru
References: <20261117053543.84032-1-kuniyu@google.com> <20261117053543.84032-5-kuniyu@google.com>

Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!news-lax.pugleaf.net!srl.newsdeef.eu!newsfeed.bofh.team!nntp.comgw.net!eternal-september.org!feeder.eternal-september.org!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-365065-linux-kernel-netdev=dewy.ru
From: edumazet@kernel.org (Eric Dumazet)
Newsgroups: linux.kernel.netdev
Subject: Re: [PATCH v1 net 4/8] tcp: Fix reqsk abort condition on ICMP errors.
Date: Tue, 17 Nov 2026 09:49:35 +0100
Organization: Usenet Network
Message-ID: <CAL4WiipmG_J4ASJ3LRhhvS7X+pFMdvq1CM_UnXRYH2M0ajZahQ@mail.gmail.com>
References: <20261117053543.84032-1-kuniyu@google.com> <20261117053543.84032-5-kuniyu@google.com>
MIME-Version: 1.0
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
Injection-Info: usenet.network;
	logging-data="2282831"; mail-complaints-to="abuse@usenet.network"
Cancel-Lock: sha1:I326sySxY9PSlAKnh5sv6KjTjeM= sha256:XW06QqIY5u/ZrgqDt9/BcYe7Z2ejCvnRlOyytWozVhw=
	sha1:8Vm9CkMN66dnXGM9E58/8w/ay6g= sha256:HfeJPmSMmoI1ZlF2c+GQ9DhS5xmW94/BVGPY0pOeoFY=
List-ID: <netdev.vger.kernel.org>
X-Mailpost-Empty-Hdrs: X-Spam-Level
X-Received: from localhost (localhost [127.0.0.1])
	by mail.dewy.ru (Postfix) with ESMTP id 6A516114EA2; Tue, 17 Nov 2026 11:50:12 +0300 (MSK)
X-Virus-Scanned: Debian amavisd-new at usenet.network
X-Spam-Flag: NO
X-Spam-Score: -3.401
X-Spam-Status: No, score=-3.401 tagged_above=-9999 required=6.31
	tests=[DCC_REPUT_70_89=0.1, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1,
	DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1,
	MAILING_LIST_MULTI=-1, RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_NONE=0.001,
	SPF_PASS=-0.001] autolearn=ham autolearn_force=no
X-Authentication-Results: mail.dewy.ru (amavisd-new); dkim=pass (2048-bit key)
	header.d=kernel.org
X-Received: from mail.dewy.ru ([127.0.0.1])
	by localhost (mail.dewy.ru [127.0.0.1]) (amavisd-new, port 10024)
	with ESMTP id 0o8AWDoRXNnp;
	Tue, 17 Nov 2026 11:50:05 +0300 (MSK)
X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.234.253.10; helo=sea.lore.kernel.org; envelope-from=netdev+bounces-365065-linux-kernel-netdev=dewy.ru@vger.kernel.org; receiver=<UNKNOWN> 
X-Authentication-Results: OpenDMARC; dmarc=pass (p=quarantine dis=none) header.from=kernel.org
X-Received: from sea.lore.kernel.org (sea.lore.kernel.org [172.234.253.10])
	by mail.dewy.ru (Postfix) with ESMTPS id B92FC114E9E; Tue, 17 Nov 2026 11:49:55 +0300 (MSK)
X-Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.77.114.92])
	by sea.lore.kernel.org (Postfix) with ESMTP id 257882D9CD; Tue, 17 Nov 2026 08:49:49 +0000 (UTC)
X-Authentication-Results: smtp.subspace.kernel.org; arc=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1
X-ARC-Seal: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=pass;
	t=1794905389;
	b=T4RXYmeucHhPFV7RMJsObVzaVVx98p6VTvjzZPTTYZ9m17fgTj2hy1Mor0WK0eNF02xr
	 8l38fbWiRvdrHSfWdhoZTn6nJvH378f9UuTmgooMX38ASKR1Es5GJJXHkgERXqoXsAd+w
	 CEhcfOj86o5mAJUEz5BfYUuNEr0kkX6CRWg78DFvIPJusARG8IREVTKU3nyAkzfUnLWps
	 939v39DhZXr6AKjJN8oFObyrAXDbCyOWF4Lyt3a8GNj7yecyNanlnN0dYThoztyQ4D923
	 3jTfEIL+C9bPJo6+nzRjB9BmqlSjf/4LT6A8qCHHyBCs67wp4iITlX13M+QbTPuzfoQ==
X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1794905389;
	h=X-Original-To:Received:Received:DKIM-Signature:Received:
	 X-Forwarded-Encrypted:X-Gm-Message-State:X-Received:X-Mailing-List:
	 List-Id:List-Post:List-Help:List-Subscribe:List-Unsubscribe:
	 List-Owner:Precedence:MIME-Version:References:In-Reply-To:From:Date:
	 X-Gmail-Original-Message-ID:X-Gm-Features:Message-ID:Subject:To:Cc:
	 Content-Type:Content-Transfer-Encoding;
	bh=fyhBKlpPcQyT2myiX0EScmV8WklZyGW831jALJF8TyM=;
	b=Ug0o7Z/TjsilyEvhY71JEx7W7e5+a1H8+6L3azIriLOAdwE7d5QeXCDW27OFRng0g5mt
	 MR8+2y4DVNMTmL79JQBLODbwIDfHyPJHxXeAhmcbb45WF8RmPcag65W8FbUa2YzRxNY3b
	 C5tjniKNkALOv/ThvEu2pZ15TLgKzkHwqOhFDMTwDT5O5BZrNWFxUi/RpFyhLkpI9n9vI
	 gHdU10ip5qHT+hKECr4gQm7Ds+4Hhf9YoEToPyqO5XOFO+nmhbA+6xPStg+nK/jBtxgc4
	 od5uNAxbbGjXwHEZsEsUyEUf3Gj2VTczuwoSc5WZ9w3XLbI1U4KGVKqpz7GkTAIjE/g==
X-ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; 
	dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b="D4fZO33/";
	arc=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1
X-Received: from localhost.localdomain (localhost [127.0.0.1])
	by smtp.subspace.kernel.org (Postfix) with ESMTP id EFFBA606A887;
	Tue, 17 Nov 2026 08:49:48 +0000 (UTC)
X-Authentication-Results: smtp.subspace.kernel.org;
	dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=D4fZO33/
X-Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18
X-ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none;
	t=1794905388;
	b=p6zUyseDVWT4a84X0hfIBWAdik+0xlq7F90mIIqSXpg76FjhAdCQbKBik37C1gZgWgQR
	 rFPN2t+z2x27RWc2I+sAo78XpodYkw7dRumO3/ONRrCv5pMRLN0PSsZffuzdtp6KXnYak
	 8eXhUnheDf6W/brrb3v3qFebEuDkK4OFG9GwBYsnhddiKLIToZE/ir/uN0tkS1upPcYKZ
	 zFyyEQqFGvigbtafcEWWeWLSdTGbZsJ490YiSApdj+PkpJpD9M8KiD+KnEcFJgvaV01hF
	 m4xZibeOouwfzZIZQWZFd8zPGQXzVu2qFENEF4FHiiGI2Nz+IgfNsuPzwXekm+3AoDQ==
X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1794905388;
	h=Received:DKIM-Signature:Received:X-Forwarded-Encrypted:
	 X-Gm-Message-State:X-Received:MIME-Version:References:In-Reply-To:
	 From:Date:X-Gmail-Original-Message-ID:X-Gm-Features:Message-ID:
	 Subject:To:Cc:Content-Type:Content-Transfer-Encoding;
	bh=fyhBKlpPcQyT2myiX0EScmV8WklZyGW831jALJF8TyM=;
	b=vpv9jZibQnl2Re+7LuA/RT3jz4AOgU3fSY685g1YN52n4JrcbjDdVVql4SJe7B4IudMn
	 aC7rj0Y94PDXvJMOWebLiBdrykVoXfd7VUTi0L5A2P+Fp8QxM03ZYhSx9gVa+pvMjSvjm
	 1bWgUqUkc3ICj8xTB92z40Bwj/i0o/ync0dyQ4wyhZdU7fMrpcVcnmnp62P4NumIy/oVw
	 +ASEq7um6O+rXRgeWiorcxhe6mwyN9vKc8ufU4kZqLoudVCKdKASqiwhbQ/ips6DRxnqx
	 5VLl8/yLw/WYf+QuLA1ohuaYVveCADwlYaFwwI+I0lmlLpEibfDeEGbf2cqONGdoROg==
X-ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; 
	dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b="D4fZO33/";
	arc=none smtp.remote-ip=100.103.45.18
X-Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18])
	(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)
	 key-exchange X25519 server-signature ECDSA (prime256v1))
	(No client certificate requested)
	by smtp.subspace.kernel.org (Postfix) with ESMTPS id 1946F606A884
	for <netdev@vger.kernel.org>; Tue, 17 Nov 2026 08:49:47 +0000 (UTC)
X-Received: by smtp.kernel.org (Postfix) with ESMTPSA id B89411F000C8
	for <netdev@vger.kernel.org>; Tue, 17 Nov 2026 08:49:47 +0000 (UTC)
X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org;
	s=k20260515; t=1794905387;
	bh=fyhBKlpPcQyT2myiX0EScmV8WklZyGW831jALJF8TyM=;
	h=References:In-Reply-To:From:Date:Subject:To:Cc;
	b=D4fZO33/jlfiiS09+9aSgBnyctBrFN7jmdl2Tqp1CiIAKXofBGQYD34rDw6RoUX0k
	 JxsZMIOVWcJYnLfg3HQWKcKqAiyr0FtQBXe7eWgMkIMi860DUSDDYc9I2o7bkI67Ne
	 UrkR8SJN7zbidu6iKqIcpC1UtmvRdcb+AThG5Q/CKZGquKCBNB9Jk37C3KIVqHGZfH
	 kgerzsnuresXhl+7DkZxy4GgrrH2wapBfMStFZcVhocCq3Y0iy/LsFWwXUjCzkvlXH
	 4pKPAvyE1jAq65raTvC+MgaP24mk9b5V2W6ak8UNqP7741XIQCIclAGYb90WO8tQd1
	 Av6AEfO0x2FQg==
X-Received: by mail-oo1-f47.google.com with SMTP id 006d021491bc7-71af0656bedso1096986eaf.0
        for <netdev@vger.kernel.org>; Tue, 17 Nov 2026 00:49:47 -0800 (PST)
X-Forwarded-Encrypted: i=1; AL+hErFvspG4r0lZa3mNmFOzQ6Rrf7Q6ouGeWLpaPvLKdha6iV8E6jxOsAfjyXhOZNQMrCtSw2chziw=@vger.kernel.org
X-Gm-Message-State: APuU4Z+ZJ3s2kH867S4ancBrpaNEdHAk3X/o4HZQGZ1qshXpaWGU1R4X
	A8OAkLtWWfQc7x3tXfWC0EYJrwJ+Q3wE/+xzJ81oMzdjyEd/BR/rFhE+9cgP+h1M50Q7CIzmzaH
	E8dDDSbD+iA6tJOboQtI5HKY/WpA7smA=
X-Received: by 2002:a05:6820:f00d:b0:71a:f4ed:7013 with SMTP id
 006d021491bc7-71af4ed9b17mr3862417eaf.87.1794905385929; Tue, 17 Nov 2026
 00:49:45 -0800 (PST)
X-Mailing-List: netdev@vger.kernel.org
X-List-Post: <mailto:netdev@vger.kernel.org>
X-List-Help: <mailto:netdev+help@vger.kernel.org>
X-List-Subscribe: <mailto:netdev+subscribe@vger.kernel.org>
X-List-Unsubscribe: <mailto:netdev+unsubscribe@vger.kernel.org>
X-List-Owner: <mailto:netdev+owner@vger.kernel.org>
X-Precedence: list
X-In-Reply-To: <20261117053543.84032-5-kuniyu@google.com>
X-Gmail-Original-Message-ID: <CAL4WiipmG_J4ASJ3LRhhvS7X+pFMdvq1CM_UnXRYH2M0ajZahQ@mail.gmail.com>
X-Gm-Features: AclHuK-MB_hicykrnPahJRX4E3k4bFWtUvkPGORfWT_7RkYK8C4v0tNFSGCQvfM
X-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