From bd3d103436b4db957e0f2da4577de16ace5ba507 Mon Sep 17 00:00:00 2001 From: Patrick Rohr Date: Fri, 1 Aug 2025 12:40:50 -0700 Subject: [PATCH] Clamp the advertised IPv6 MTU to 1280-1400 RaParams is populated with the upstream IPv4 MTU, rather than the IPv6 or route MTU. This change clamps that value between 1280 and 1400. 1280 as it is the minimum IPv6 MTU and 1400 to keep QUIC working. A follow up change could improve on this by either adding the IPv6 MTU to LinkProperties, or (possibly better) binding and connecting a UDP socket to determine the MTU. Note that at that point the MTU in the Tether6Key should also be fixed. Test: TH Flag: EXEMPT low risk Bug: 432676104 Change-Id: I1d900039caf84c58cd04fdb52bdeaf2d1b846268 --- Tethering/src/android/net/ip/IpServer.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Tethering/src/android/net/ip/IpServer.java b/Tethering/src/android/net/ip/IpServer.java index e8796b9647..ee0487bc6d 100644 --- a/Tethering/src/android/net/ip/IpServer.java +++ b/Tethering/src/android/net/ip/IpServer.java @@ -856,7 +856,8 @@ public class IpServer extends StateMachineShim { upstreamIfIndex = upstreamIfaceParams.index; } params = new RaParams(); - params.mtu = v6only.getMtu(); + // Clamp v6 MTU to 1280-1400 range. + params.mtu = Math.max(1280, Math.min(1400, v6only.getMtu())); params.hasDefaultRoute = v6only.hasIpv6DefaultRoute(); if (params.hasDefaultRoute) params.hopLimit = getHopLimit(upstreamIface, ttlAdjustment);