Merge "Set accept_ra_rt_info_max_plen to 64 before enabling IPv6 interfaces"
am: 52f8421b77
Change-Id: I5b5d5460f9fe7ed228ab32b2c63cb601be5e1edb
This commit is contained in:
@@ -16,6 +16,8 @@
|
||||
|
||||
package com.android.server.connectivity.tethering;
|
||||
|
||||
import static android.net.util.NetworkConstants.RFC7421_PREFIX_LENGTH;
|
||||
|
||||
import android.net.INetd;
|
||||
import android.net.IpPrefix;
|
||||
import android.net.LinkAddress;
|
||||
@@ -48,7 +50,6 @@ import java.util.Objects;
|
||||
public class IPv6TetheringInterfaceServices {
|
||||
private static final String TAG = IPv6TetheringInterfaceServices.class.getSimpleName();
|
||||
private static final IpPrefix LINK_LOCAL_PREFIX = new IpPrefix("fe80::/64");
|
||||
private static final int RFC7421_IP_PREFIX_LENGTH = 64;
|
||||
|
||||
private final String mIfName;
|
||||
private final INetworkManagementService mNMService;
|
||||
@@ -124,7 +125,7 @@ public class IPv6TetheringInterfaceServices {
|
||||
params.hasDefaultRoute = v6only.hasIPv6DefaultRoute();
|
||||
|
||||
for (LinkAddress linkAddr : v6only.getLinkAddresses()) {
|
||||
if (linkAddr.getPrefixLength() != RFC7421_IP_PREFIX_LENGTH) continue;
|
||||
if (linkAddr.getPrefixLength() != RFC7421_PREFIX_LENGTH) continue;
|
||||
|
||||
final IpPrefix prefix = new IpPrefix(
|
||||
linkAddr.getAddress(), linkAddr.getPrefixLength());
|
||||
@@ -206,7 +207,7 @@ public class IPv6TetheringInterfaceServices {
|
||||
for (Inet6Address dns : deprecatedDnses) {
|
||||
final String dnsString = dns.getHostAddress();
|
||||
try {
|
||||
netd.interfaceDelAddress(mIfName, dnsString, RFC7421_IP_PREFIX_LENGTH);
|
||||
netd.interfaceDelAddress(mIfName, dnsString, RFC7421_PREFIX_LENGTH);
|
||||
} catch (ServiceSpecificException | RemoteException e) {
|
||||
Log.e(TAG, "Failed to remove local dns IP: " + dnsString, e);
|
||||
}
|
||||
@@ -223,7 +224,7 @@ public class IPv6TetheringInterfaceServices {
|
||||
for (Inet6Address dns : addedDnses) {
|
||||
final String dnsString = dns.getHostAddress();
|
||||
try {
|
||||
netd.interfaceAddAddress(mIfName, dnsString, RFC7421_IP_PREFIX_LENGTH);
|
||||
netd.interfaceAddAddress(mIfName, dnsString, RFC7421_PREFIX_LENGTH);
|
||||
} catch (ServiceSpecificException | RemoteException e) {
|
||||
Log.e(TAG, "Failed to add local dns IP: " + dnsString, e);
|
||||
newDnses.remove(dns);
|
||||
|
||||
@@ -16,6 +16,8 @@
|
||||
|
||||
package android.net.ip;
|
||||
|
||||
import static android.net.util.NetworkConstants.RFC7421_PREFIX_LENGTH;
|
||||
|
||||
import com.android.internal.util.MessageUtils;
|
||||
import com.android.internal.util.WakeupMessage;
|
||||
|
||||
@@ -42,6 +44,7 @@ import android.os.RemoteException;
|
||||
import android.os.ServiceManager;
|
||||
import android.os.ServiceSpecificException;
|
||||
import android.os.SystemClock;
|
||||
import android.system.OsConstants;
|
||||
import android.text.TextUtils;
|
||||
import android.util.LocalLog;
|
||||
import android.util.Log;
|
||||
@@ -1028,15 +1031,36 @@ public class IpManager extends StateMachine {
|
||||
return true;
|
||||
}
|
||||
|
||||
private boolean startIPv6() {
|
||||
// Set privacy extensions.
|
||||
private void enableInterfaceIPv6PrivacyExtensions() {
|
||||
final String PREFER_TEMPADDRS = "2";
|
||||
NetdService.run((INetd netd) -> {
|
||||
netd.setProcSysNet(
|
||||
INetd.IPV6, INetd.CONF, mInterfaceName, "use_tempaddr", PREFER_TEMPADDRS);
|
||||
});
|
||||
}
|
||||
|
||||
private void setInterfaceIPv6RaRtInfoMaxPlen(int plen) {
|
||||
// Setting RIO max plen is best effort. Catch and ignore most exceptions.
|
||||
try {
|
||||
NetdService.run((INetd netd) -> {
|
||||
netd.setProcSysNet(
|
||||
INetd.IPV6, INetd.CONF, mInterfaceName, "use_tempaddr",
|
||||
PREFER_TEMPADDRS);
|
||||
});
|
||||
netd.setProcSysNet(
|
||||
INetd.IPV6, INetd.CONF, mInterfaceName, "accept_ra_rt_info_max_plen",
|
||||
Integer.toString(plen));
|
||||
});
|
||||
} catch (ServiceSpecificException e) {
|
||||
// Old kernel versions without support for RIOs do not export accept_ra_rt_info_max_plen
|
||||
// in the /proc filesystem. If the kernel supports RIOs we should never see any other
|
||||
// type of error.
|
||||
if (e.errorCode != OsConstants.ENOENT) {
|
||||
logError("unexpected error setting accept_ra_rt_info_max_plen %s", e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private boolean startIPv6() {
|
||||
try {
|
||||
enableInterfaceIPv6PrivacyExtensions();
|
||||
setInterfaceIPv6RaRtInfoMaxPlen(RFC7421_PREFIX_LENGTH);
|
||||
mNwService.enableIpv6(mInterfaceName);
|
||||
} catch (IllegalStateException|RemoteException|ServiceSpecificException e) {
|
||||
logError("Unable to change interface settings: %s", e);
|
||||
|
||||
@@ -97,6 +97,7 @@ public final class NetworkConstants {
|
||||
public static final int IPV6_SRC_ADDR_OFFSET = 8;
|
||||
public static final int IPV6_DST_ADDR_OFFSET = 24;
|
||||
public static final int IPV6_ADDR_LEN = 16;
|
||||
public static final int RFC7421_PREFIX_LENGTH = 64;
|
||||
|
||||
/**
|
||||
* ICMPv6 constants.
|
||||
|
||||
Reference in New Issue
Block a user