Tethering: pass the mtu we announce via RA into updateIpv6UpstreamInterface()

Bug: 432676104
Test: TreeHugger, mm in p/m/C
Flag: EXEMPT mainline
Signed-off-by: Maciej Żenczykowski <maze@google.com>
Change-Id: Ie6d9d351be178085fa3d07947f1269058e18e376
This commit is contained in:
Maciej Żenczykowski 2025-08-12 19:48:16 -07:00
commit e92c190c38

View file

@ -848,6 +848,7 @@ public class IpServer extends StateMachineShim {
String upstreamIface = null;
InterfaceParams upstreamIfaceParams = null;
int upstreamIfIndex = NO_UPSTREAM;
int pmtu6 = 1400; // default 'safe-ish' value
if (v6only != null) {
upstreamIface = v6only.getInterfaceName();
@ -856,12 +857,14 @@ public class IpServer extends StateMachineShim {
upstreamIfIndex = upstreamIfaceParams.index;
}
params = new RaParams();
int mtu = v6only.getMtu();
pmtu6 = v6only.getMtu();
if (pmtu6 < 1280) pmtu6 = 1400; // we simply don't know what it is, 1400 is safe-ish
for (RouteInfo route : v6only.getRoutes()) {
if (route.getMtu() != 0) mtu = Math.min(mtu, route.getMtu());
if (route.getMtu() >= 1280) pmtu6 = Math.min(pmtu6, route.getMtu());
}
// Clamp v6 MTU to 1280-1400 range.
params.mtu = Math.max(1280, Math.min(1400, mtu));
pmtu6 = Math.max(1280, Math.min(1400, pmtu6));
params.mtu = pmtu6;
params.hasDefaultRoute = v6only.hasIpv6DefaultRoute();
if (params.hasDefaultRoute) params.hopLimit = getHopLimit(upstreamIface, ttlAdjustment);
@ -893,7 +896,7 @@ public class IpServer extends StateMachineShim {
// mLastIPv6UpstreamIfindex and mLastIPv6UpstreamPrefixes because BpfCoordinator will call
// IpServer#getIpv6UpstreamIfindex and IpServer#getIpv6UpstreamPrefixes to retrieve current
// upstream interface index and prefixes when handling upstream changes.
mBpfCoordinator.updateIpv6UpstreamInterface(this, upstreamIfIndex, upstreamPrefixes, 1400);
mBpfCoordinator.updateIpv6UpstreamInterface(this, upstreamIfIndex, upstreamPrefixes, pmtu6);
mLastIPv6LinkProperties = v6only;
mLastIPv6UpstreamIfindex = upstreamIfIndex;
mLastIPv6UpstreamPrefixes = upstreamPrefixes;