diff options
author | TreeHugger Robot <treehugger-gerrit@google.com> | 2020-06-10 14:18:09 +0000 |
---|---|---|
committer | Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com> | 2020-06-10 14:18:09 +0000 |
commit | 25c23226eaa6f858c05b60e011c0b250bd6c07be (patch) | |
tree | 1c2f6536d661a2214e304a425515b77399d80c62 /src | |
parent | 40c5a03f15ee4c53b1f3cae0befa3ae384c15d70 (diff) | |
parent | f152f468ebd9d1160d1f23b4c111ea6fbb765043 (diff) |
Merge "Disable IPv6 stack when IPv6 provisioning is lost but IPv4 is still alive." into rvc-dev am: 49053ad506 am: f152f468eb
Original change: https://googleplex-android-review.googlesource.com/c/platform/packages/modules/NetworkStack/+/11807300
Change-Id: I033101e9ad4b4f17d105751816d80be0487f2ced
Diffstat (limited to 'src')
-rw-r--r-- | src/android/net/dhcp/DhcpClient.java | 6 | ||||
-rw-r--r-- | src/android/net/ip/IpClient.java | 26 |
2 files changed, 25 insertions, 7 deletions
diff --git a/src/android/net/dhcp/DhcpClient.java b/src/android/net/dhcp/DhcpClient.java index 5564503..4404273 100644 --- a/src/android/net/dhcp/DhcpClient.java +++ b/src/android/net/dhcp/DhcpClient.java @@ -503,9 +503,9 @@ public class DhcpClient extends StateMachine { * check whether or not to support caching the last lease info and INIT-REBOOT state. * * INIT-REBOOT state is supported on Android R by default if there is no experiment flag set to - * disable this feature explicitly, meanwhile we still hope to be able to control this feature - * on/off by pushing experiment flag for A/B testing and metrics collection on both of Android - * Q and R version, however it's disbled on Android Q by default. + * disable this feature explicitly, meanwhile turning this feature on/off by pushing experiment + * flag makes it possible to do A/B test and metrics collection on both of Android Q and R, but + * it's disabled on Android Q by default. */ public boolean isDhcpLeaseCacheEnabled() { final boolean defaultEnabled = diff --git a/src/android/net/ip/IpClient.java b/src/android/net/ip/IpClient.java index 018d6ab..629d216 100644 --- a/src/android/net/ip/IpClient.java +++ b/src/android/net/ip/IpClient.java @@ -482,6 +482,7 @@ public class IpClient extends StateMachine { private boolean mMulticastFiltering; private long mStartTimeMillis; private MacAddress mCurrentBssid; + private boolean mHasDisabledIPv6OnProvLoss; /** * Reading the snapshot is an asynchronous operation initiated by invoking @@ -1137,9 +1138,9 @@ public class IpClient extends StateMachine { // Note that we can still be disconnected by IpReachabilityMonitor // if the IPv6 default gateway (but not the IPv6 DNS servers; see // accompanying code in IpReachabilityMonitor) is unreachable. - final boolean ignoreIPv6ProvisioningLoss = - mConfiguration != null && mConfiguration.mUsingMultinetworkPolicyTracker - && !mCm.shouldAvoidBadWifi(); + final boolean ignoreIPv6ProvisioningLoss = mHasDisabledIPv6OnProvLoss + || (mConfiguration != null && mConfiguration.mUsingMultinetworkPolicyTracker + && !mCm.shouldAvoidBadWifi()); // Additionally: // @@ -1163,7 +1164,23 @@ public class IpClient extends StateMachine { // IPv6 default route then also consider the loss of that default route // to be a loss of provisioning. See b/27962810. if (oldLp.hasGlobalIpv6Address() && (lostIPv6Router && !ignoreIPv6ProvisioningLoss)) { - delta = PROV_CHANGE_LOST_PROVISIONING; + // Although link properties have lost IPv6 default route in this case, if IPv4 is still + // working with appropriate routes and DNS servers, we can keep the current connection + // without disconnecting from the network, just disable IPv6 on that given network until + // to the next provisioning. Disabling IPv6 will result in all IPv6 connectivity torn + // down and all IPv6 sockets being closed, the non-routable IPv6 DNS servers will be + // stripped out, so applications will be able to reconnect immediately over IPv4. See + // b/131781810. + if (newLp.isIpv4Provisioned()) { + mInterfaceCtrl.disableIPv6(); + mHasDisabledIPv6OnProvLoss = true; + delta = PROV_CHANGE_STILL_PROVISIONED; + if (DBG) { + mLog.log("Disable IPv6 stack completely when the default router has gone"); + } + } else { + delta = PROV_CHANGE_LOST_PROVISIONING; + } } return delta; @@ -1591,6 +1608,7 @@ public class IpClient extends StateMachine { @Override public void enter() { stopAllIP(); + mHasDisabledIPv6OnProvLoss = false; mLinkObserver.clearInterfaceParams(); resetLinkProperties(); |