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

Commit a3d5948c authored by Lorenzo Colitti's avatar Lorenzo Colitti
Browse files

Clear LinkProperties on interface removed.

When an interface is removed, all netlink events for that
interface are lost, because netd will no longer be able to
resolve the ifindex in the netlink event to an interface name,
and it only communicates to the framework events that include an
interface name.

This can cause us to end up with stale IP addresses if, for
example, wlan0 is removed because we switch wifi back from AP
mode to STA mode when exiting tethering. The presence of stale
IPv4 addresses can in turn lead us to miss a provisioning
notification because we already think we have an IPv4 address.

Change-Id: Ib64559a5a4fa261f483760b69fa7996314e7cc17
parent f7d28faa
Loading
Loading
Loading
Loading
+13 −0
Original line number Diff line number Diff line
@@ -101,6 +101,19 @@ public class NetlinkTracker extends BaseNetworkObserver {
        }
    }

    @Override
    public void interfaceRemoved(String iface) {
        maybeLog("interfaceRemoved", iface);
        if (mInterfaceName.equals(iface)) {
            // Our interface was removed. Clear our LinkProperties and tell our owner that they are
            // now empty. Note that from the moment that the interface is removed, any further
            // interface-specific messages (e.g., RTM_DELADDR) will not reach us, because the netd
            // code that parses them will not be able to resolve the ifindex to an interface name.
            clearLinkProperties();
            mCallback.update();
        }
    }

    @Override
    public void addressUpdated(String iface, LinkAddress address) {
        if (mInterfaceName.equals(iface)) {
+2 −0
Original line number Diff line number Diff line
@@ -302,6 +302,7 @@ public class IpManager extends StateMachine {
                }) {
            @Override
            public void interfaceAdded(String iface) {
                super.interfaceAdded(iface);
                if (mClatInterfaceName.equals(iface)) {
                    mCallback.on464XlatChange(true);
                }
@@ -309,6 +310,7 @@ public class IpManager extends StateMachine {

            @Override
            public void interfaceRemoved(String iface) {
                super.interfaceRemoved(iface);
                if (mClatInterfaceName.equals(iface)) {
                    mCallback.on464XlatChange(false);
                }