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

Commit a88b12ce authored by Joel Scherpelz's avatar Joel Scherpelz Committed by Gerrit Code Review
Browse files

Merge "Use RFC 7217 stable privacy addresses"

parents 4ff3cf1e 2db1074e
Loading
Loading
Loading
Loading
+6 −0
Original line number Diff line number Diff line
@@ -96,6 +96,12 @@ interface INetworkManagementService
     */
    void enableIpv6(String iface);

    /**
     * Set IPv6 autoconf address generation mode.
     * This is a no-op if an unsupported mode is requested.
     */
    void setIPv6AddrGenMode(String iface, int mode);

    /**
     * Enables or enables IPv6 ND offload.
     */
+9 −0
Original line number Diff line number Diff line
@@ -1028,6 +1028,15 @@ public class NetworkManagementService extends INetworkManagementService.Stub
        }
    }

    @Override
    public void setIPv6AddrGenMode(String iface, int mode) throws ServiceSpecificException {
        try {
            mNetdService.setIPv6AddrGenMode(iface, mode);
        } catch (RemoteException e) {
            throw e.rethrowAsRuntimeException();
        }
    }

    @Override
    public void disableIpv6(String iface) {
        mContext.enforceCallingOrSelfPermission(CONNECTIVITY_INTERNAL, TAG);
+32 −8
Original line number Diff line number Diff line
@@ -20,16 +20,17 @@ import com.android.internal.util.MessageUtils;
import com.android.internal.util.WakeupMessage;

import android.content.Context;
import android.net.apf.ApfCapabilities;
import android.net.apf.ApfFilter;
import android.net.DhcpResults;
import android.net.INetd;
import android.net.InterfaceConfiguration;
import android.net.LinkAddress;
import android.net.LinkProperties;
import android.net.LinkProperties.ProvisioningChange;
import android.net.LinkProperties;
import android.net.ProxyInfo;
import android.net.RouteInfo;
import android.net.StaticIpConfiguration;
import android.net.apf.ApfCapabilities;
import android.net.apf.ApfFilter;
import android.net.dhcp.DhcpClient;
import android.net.metrics.IpConnectivityLog;
import android.net.metrics.IpManagerEvent;
@@ -38,7 +39,9 @@ import android.os.INetworkManagementService;
import android.os.Message;
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;
@@ -319,6 +322,16 @@ public class IpManager extends StateMachine {
                return this;
            }

            public Builder withIPv6AddrGenModeEUI64() {
                mConfig.mIPv6AddrGenMode = INetd.IPV6_ADDR_GEN_MODE_EUI64;
                return this;
            }

            public Builder withIPv6AddrGenModeStablePrivacy() {
                mConfig.mIPv6AddrGenMode = INetd.IPV6_ADDR_GEN_MODE_STABLE_PRIVACY;
                return this;
            }

            public ProvisioningConfiguration build() {
                return new ProvisioningConfiguration(mConfig);
            }
@@ -331,6 +344,7 @@ public class IpManager extends StateMachine {
        /* package */ StaticIpConfiguration mStaticIpConfig;
        /* package */ ApfCapabilities mApfCapabilities;
        /* package */ int mProvisioningTimeoutMs = DEFAULT_TIMEOUT_MS;
        /* package */ int mIPv6AddrGenMode = INetd.IPV6_ADDR_GEN_MODE_STABLE_PRIVACY;

        public ProvisioningConfiguration() {}

@@ -354,6 +368,7 @@ public class IpManager extends StateMachine {
                    .add("mStaticIpConfig: " + mStaticIpConfig)
                    .add("mApfCapabilities: " + mApfCapabilities)
                    .add("mProvisioningTimeoutMs: " + mProvisioningTimeoutMs)
                    .add("mIPv6AddrGenMode: " + mIPv6AddrGenMode)
                    .toString();
        }
    }
@@ -1044,16 +1059,25 @@ public class IpManager extends StateMachine {
        return true;
    }

    private void setIPv6AddrGenModeIfSupported() throws RemoteException {
        try {
            mNwService.setIPv6AddrGenMode(mInterfaceName, mConfiguration.mIPv6AddrGenMode);
        } catch (ServiceSpecificException e) {
            if (e.errorCode != OsConstants.EOPNOTSUPP) {
                throw e;
            }
        }
    }

    private boolean startIPv6() {
        // Set privacy extensions.
        try {
            mNwService.setInterfaceIpv6PrivacyExtensions(mInterfaceName, true);

            setIPv6AddrGenModeIfSupported();
            mNwService.enableIpv6(mInterfaceName);
        } catch (RemoteException re) {
            logError("Unable to change interface settings: %s", re);
            return false;
        } catch (IllegalStateException ie) {
            logError("Unable to change interface settings: %s", ie);
        } catch (IllegalStateException | RemoteException | ServiceSpecificException e) {
            logError("Unable to change interface settings: %s", e);
            return false;
        }