๐Ÿš€ go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Thread View: linux.kernel.netdev
1 messages
1 total messages Started by netdev-bot+sashiko Wed, 18 Nov 2026 20:36
Re: [PATCH v1 net 2/8] tcp: Don't use inner IP TTL for IP_MINTTL in tcp_v4_err().
#18755
Author: netdev-bot+sashiko
Date: Wed, 18 Nov 2026 20:36
104 lines
11700 bytes
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
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