Netdev List
 help / color / mirror / Atom feed
From: netdev-bot+sashiko@kernel.org
To: kuniyu@google.com
Cc: edumazet@kernel.org, ncardwell@google.com, davem@davemloft.net,
	kuba@kernel.org, pabeni@redhat.com, horms@kernel.org,
	kuni1840@gmail.com, netdev@vger.kernel.org
Subject: Re: [PATCH v1 net 2/8] tcp: Don't use inner IP TTL for IP_MINTTL in tcp_v4_err().
Date: Wed, 18 Nov 2026 20:36:25 +0000	[thread overview]
Message-ID: <179503418534.3136.4229241226669762008@kernel.org> (raw)
In-Reply-To: <20261117053543.84032-3-kuniyu@google.com>

Thank you for your contribution! Sashiko AI review found 1 potential
issue(s) to consider.

Critical: 0 · High: 0 · Medium: 1 · Low: 0

If you believe none of the issues are legitimate, please reply to each
issue of Medium severity or higher and explain why the AI is wrong.
If any of them are legitimate and you plan to respin, please let patchwork
know by including "pw-bot: cr" as a separate line at the end of your reply
(one such reply per series is enough).

- [Medium] In tcp_v4_err() (net/ipv4/tcp_ipv4.c), the IP_MINTTL check now
  compares ip_hdr(skb)->ttl, the outer TTL, with min_ttl.

--

tcp: Don't use inner IP TTL for IP_MINTTL in tcp_v4_err().

This commit changes the IP_MINTTL check in tcp_v4_err(). The check now
compares min_ttl against the TTL of the outer IP header that carries the
ICMP error, instead of the TTL in the quoted inner IP header. This makes
IPv4 behave like tcp_v6_err(), which checks ipv6_hdr(skb)->hop_limit.

> diff --git a/net/ipv4/tcp_ipv4.c b/net/ipv4/tcp_ipv4.c
> index 7d58f522068d6..bf8542368032f 100644
> --- a/net/ipv4/tcp_ipv4.c
> +++ b/net/ipv4/tcp_ipv4.c
> @@ -546,7 +546,7 @@ int tcp_v4_err(struct sk_buff *skb, u32 info)
>  
>  	if (static_branch_unlikely(&ip4_min_ttl)) {
>  		/* min_ttl can be changed concurrently from do_ip_setsockopt() */
> -		if (unlikely(iph->ttl < READ_ONCE(inet_sk(sk)->min_ttl))) {
> +		if (unlikely(ip_hdr(skb)->ttl < READ_ONCE(inet_sk(sk)->min_ttl))) {
>  			__NET_INC_STATS(net, LINUX_MIB_TCPMINTTLDROP);
>  			goto out;
>  		}

[Severity: Medium]
Will this drop ICMP errors that the host generates about its own TCP
packets on GTSM sockets?

__icmp_send() never sets a TTL, so __ip_make_skb() falls back to:

net/ipv4/ip_output.c:__ip_make_skb() {
    ...
	else
		ttl = ip_select_ttl(inet, &rt->dst);
    ...
}

The ICMP socket's uc_ttl is -1, so this gives the default hop limit,
normally sysctl_ip_default_ttl = 64. The error is delivered over
loopback without being decremented, so ip_hdr(skb)->ttl is 64 here.

A typical GTSM socket (IP_TTL 255, IP_MINTTL 254 or 255) now takes the
goto out path and counts TCPMINTTLDROP. Before this patch, the quoted
inner header was our own packet. It had not been forwarded, so it still
carried TTL 255 and passed the check.

One local source of these errors is ip_fragment(), for DF packets that
exceed the route MTU:

net/ipv4/ip_output.c:ip_fragment() {
    ...
		icmp_send(skb, ICMP_DEST_UNREACH, ICMP_FRAG_NEEDED,
			  htonl(mtu));
    ...
}

tnl_update_pmtu() and vti_xmit() send ICMP_FRAG_NEEDED locally through
icmp_ndo_send(). The link failure path sends ICMP_HOST_UNREACH.

tcp_v4_err() already expects these local errors:

	/* If too many ICMPs get dropped on busy
	 * servers this needs to be solved differently.
	 * We do take care of PMTU discovery (RFC1191) special case :
	 * we can receive locally generated ICMP messages while socket is held.
	 */

With this change, a GTSM socket no longer reaches the ICMP_FRAG_NEEDED
handling for a local PMTU drop. tcp_v4_mtu_reduced() is skipped, so
recovery waits for an RTO or for tcp_current_mss() to see the new dst
MTU.

Also, a connect() in TCP_SYN_SENT no longer fails fast with EHOSTUNREACH
on a local link failure. It runs the full SYN retry timeout instead.

The commit message says:

    Now GTSM is applied to locally generated ICMP errors, but this
    behaviour matches tcp_v6_err().

Could the commit message describe these effects on locally generated
PMTU and host unreachable errors? The Fixes: tag will bring this to
stable for all IPv4 GTSM users, such as BGP with ttl-security.

Would it make sense to exempt locally generated or loopback ICMP errors
from the outer TTL check? As far as I can tell, the final state of the
series keeps the outer TTL check without such an exemption.

-- 
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261117053543.84032-1-kuniyu%40google.com

  parent reply	other threads:[~2026-11-18 20:36 UTC|newest]

Thread overview: 27+ 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-18 20:36   ` netdev-bot+sashiko [this message]
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-18 20:36   ` netdev-bot+sashiko
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
2026-11-18 20:36   ` netdev-bot+sashiko
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-18 20:36   ` netdev-bot+sashiko
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=179503418534.3136.4229241226669762008@kernel.org \
    --to=netdev-bot+sashiko@kernel.org \
    --cc=davem@davemloft.net \
    --cc=edumazet@kernel.org \
    --cc=horms@kernel.org \
    --cc=kuba@kernel.org \
    --cc=kuni1840@gmail.com \
    --cc=kuniyu@google.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