From da0fb1bca8eda1ce8159289a2ea9e4f6933ce517 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Maciej=20=C5=BBenczykowski?= Date: Wed, 19 Feb 2020 01:24:39 -0800 Subject: [PATCH] Reduce advertised ipv6 mtu by 16 to fit ethernet header MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This is a temporary hack to workaround the inability of current kernel's ebpf bpf_skb_change_mode() function to prefix a 14-byte ethernet header on to a packet without going over the upstream (source, rawip) interface's mtu *before* we bpf_redirect() to the downstream (destination, ethernet) interface. Test: build, atest, atest TetheringTests Bug: 149816401 Signed-off-by: Maciej Żenczykowski Change-Id: I646148ebfd978a2489c0cd065e4b671b01150add --- Tethering/src/android/net/ip/IpServer.java | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/Tethering/src/android/net/ip/IpServer.java b/Tethering/src/android/net/ip/IpServer.java index 2653b6d23a..96da8f573f 100644 --- a/Tethering/src/android/net/ip/IpServer.java +++ b/Tethering/src/android/net/ip/IpServer.java @@ -541,7 +541,12 @@ public class IpServer extends StateMachine { if (v6only != null) { params = new RaParams(); - params.mtu = v6only.getMtu(); + // We advertise an mtu lower by 16, which is the closest multiple of 8 >= 14, + // the ethernet header size. This makes kernel ebpf tethering offload happy. + // This hack should be reverted once we have the kernel fixed up. + // Note: this will automatically clamp to at least 1280 (ipv6 minimum mtu) + // see RouterAdvertisementDaemon.java putMtu() + params.mtu = v6only.getMtu() - 16; params.hasDefaultRoute = v6only.hasIpv6DefaultRoute(); if (params.hasDefaultRoute) params.hopLimit = getHopLimit(v6only.getInterfaceName());