Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 5b437d6f authored by Erik Kline's avatar Erik Kline Committed by Lorenzo Colitti
Browse files

Conditionally accept loss of on-link IPv6 DNS servers

Permit this if and only if we're not "avoiding bad wifi" in general.

Bug: 31827713
Change-Id: I0874ec2d1d09e913ccdbe9f6e178090400808a04
parent 065ab6ee
Loading
Loading
Loading
Loading
+2 −1
Original line number Diff line number Diff line
@@ -1068,7 +1068,8 @@ public class IpManager extends StateMachine {
                            public void notifyLost(InetAddress ip, String logMsg) {
                                mCallback.onReachabilityLost(logMsg);
                            }
                        });
                        },
                        mAvoidBadWifiTracker);
            }
        }

+19 −3
Original line number Diff line number Diff line
@@ -34,6 +34,7 @@ import android.net.netlink.RtNetlinkNeighborMessage;
import android.net.netlink.StructNdaCacheInfo;
import android.net.netlink.StructNdMsg;
import android.net.netlink.StructNlMsgHdr;
import android.net.util.AvoidBadWifiTracker;
import android.os.PowerManager;
import android.os.SystemClock;
import android.system.ErrnoException;
@@ -42,6 +43,7 @@ import android.system.OsConstants;
import android.util.Log;

import java.io.InterruptedIOException;
import java.net.Inet6Address;
import java.net.InetAddress;
import java.net.InetSocketAddress;
import java.net.NetworkInterface;
@@ -149,6 +151,7 @@ public class IpReachabilityMonitor {
    private final String mInterfaceName;
    private final int mInterfaceIndex;
    private final Callback mCallback;
    private final AvoidBadWifiTracker mAvoidBadWifiTracker;
    private final NetlinkSocketObserver mNetlinkSocketObserver;
    private final Thread mObserverThread;
    private final IpConnectivityLog mMetricsLog = new IpConnectivityLog();
@@ -219,8 +222,12 @@ public class IpReachabilityMonitor {
        return errno;
    }

    public IpReachabilityMonitor(Context context, String ifName, Callback callback)
                throws IllegalArgumentException {
    public IpReachabilityMonitor(Context context, String ifName, Callback callback) {
        this(context, ifName, callback, null);
    }

    public IpReachabilityMonitor(Context context, String ifName, Callback callback,
            AvoidBadWifiTracker tracker) throws IllegalArgumentException {
        mInterfaceName = ifName;
        int ifIndex = -1;
        try {
@@ -232,6 +239,7 @@ public class IpReachabilityMonitor {
        mWakeLock = ((PowerManager) context.getSystemService(Context.POWER_SERVICE)).newWakeLock(
                PowerManager.PARTIAL_WAKE_LOCK, TAG + "." + mInterfaceName);
        mCallback = callback;
        mAvoidBadWifiTracker = tracker;
        mNetlinkSocketObserver = new NetlinkSocketObserver();
        mObserverThread = new Thread(mNetlinkSocketObserver);
        mObserverThread.start();
@@ -355,8 +363,12 @@ public class IpReachabilityMonitor {
                        whatIfLp.removeRoute(route);
                    }
                }

                if (avoidingBadLinks() || !(ip instanceof Inet6Address)) {
                    // We should do this unconditionally, but alas we cannot: b/31827713.
                    whatIfLp.removeDnsServer(ip);
                }
            }

            delta = LinkProperties.compareProvisioning(mLinkProperties, whatIfLp);
        }
@@ -373,6 +385,10 @@ public class IpReachabilityMonitor {
        logNudFailed(delta);
    }

    private boolean avoidingBadLinks() {
        return (mAvoidBadWifiTracker != null) ? mAvoidBadWifiTracker.currentValue() : true;
    }

    public void probeAll() {
        Set<InetAddress> ipProbeList = new HashSet<InetAddress>();
        synchronized (mLock) {