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

Commit 7960d9f8 authored by repo sync's avatar repo sync
Browse files

Fix IPv6 on wifi

Bug: 5388757
Change-Id: I3c8c776c26dad1daa9801d0455fde749c0206401
parent 3d0d7b41
Loading
Loading
Loading
Loading
+10 −0
Original line number Diff line number Diff line
@@ -78,6 +78,16 @@ interface INetworkManagementService
     */
    void setInterfaceIpv6PrivacyExtensions(String iface, boolean enable);

    /**
     * Disable IPv6 on an interface
     */
    void disableIpv6(String iface);

    /**
     * Enable IPv6 on an interface
     */
    void enableIpv6(String iface);

    /**
     * Retrieves the network routes currently configured on the specified
     * interface
+22 −0
Original line number Diff line number Diff line
@@ -508,6 +508,28 @@ public class NetworkManagementService extends INetworkManagementService.Stub
        }
    }

    public void enableIpv6(String iface) throws IllegalStateException {
        mContext.enforceCallingOrSelfPermission(
                android.Manifest.permission.CHANGE_NETWORK_STATE, "NetworkManagementService");
        try {
            mConnector.doCommand(String.format("interface ipv6 %s enable", iface));
        } catch (NativeDaemonConnectorException e) {
            throw new IllegalStateException(
                    "Unable to communicate to native daemon for enabling ipv6");
        }
    }

    public void disableIpv6(String iface) throws IllegalStateException {
        mContext.enforceCallingOrSelfPermission(
                android.Manifest.permission.CHANGE_NETWORK_STATE, "NetworkManagementService");
        try {
            mConnector.doCommand(String.format("interface ipv6 %s disable", iface));
        } catch (NativeDaemonConnectorException e) {
            throw new IllegalStateException(
                    "Unable to communicate to native daemon for disabling ipv6");
        }
    }

    public void addRoute(String interfaceName, RouteInfo route) {
        modifyRoute(interfaceName, ADD, route);
    }
+27 −3
Original line number Diff line number Diff line
@@ -1560,8 +1560,9 @@ public class WifiStateMachine extends StateMachine {

        try {
            mNwService.clearInterfaceAddresses(mInterfaceName);
            mNwService.disableIpv6(mInterfaceName);
        } catch (Exception e) {
            Log.e(TAG, "Failed to clear IP addresses on disconnect" + e);
            Log.e(TAG, "Failed to clear addresses or disable ipv6" + e);
        }

        /* Reset data structures */
@@ -1841,6 +1842,21 @@ public class WifiStateMachine extends StateMachine {
            mWifiP2pManager = (WifiP2pManager) mContext.getSystemService(Context.WIFI_P2P_SERVICE);
            mWifiP2pChannel.connect(mContext, getHandler(), mWifiP2pManager.getMessenger());

            /* IPv6 is disabled at boot time and is controlled by framework
             * to be enabled only as long as we are connected to an access point
             *
             * This fixes issues, a few being:
             * - IPv6 addresses and routes stick around after disconnection
             * - When connected, the kernel is unaware and can fail to start IPv6 negotiation
             * - The kernel sometimes starts autoconfiguration when 802.1x is not complete
             */
            try {
                mNwService.disableIpv6(mInterfaceName);
            } catch (RemoteException re) {
                Log.e(TAG, "Failed to disable IPv6: " + re);
            } catch (IllegalStateException e) {
                Log.e(TAG, "Failed to disable IPv6: " + e);
            }
        }
    }

@@ -2734,6 +2750,14 @@ public class WifiStateMachine extends StateMachine {
            if (DBG) Log.d(TAG, getName() + "\n");
            EventLog.writeEvent(EVENTLOG_WIFI_STATE_CHANGED, getName());

            try {
                mNwService.enableIpv6(mInterfaceName);
            } catch (RemoteException re) {
                Log.e(TAG, "Failed to enable IPv6: " + re);
            } catch (IllegalStateException e) {
                Log.e(TAG, "Failed to enable IPv6: " + e);
            }

            if (!WifiConfigStore.isUsingStaticIp(mLastNetworkId)) {
                //start DHCP
                mDhcpStateMachine = DhcpStateMachine.makeDhcpStateMachine(