From eac13f7677f5d48720eaa446001236436b2d5471 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bram=20Bonn=C3=A9?= Date: Tue, 20 Oct 2020 11:07:54 +0200 Subject: Use EUI64 IPv6 link-local address generation only when randomizing MAC When connected MAC address randomization is used, generate IPv6 link-local addresses using EUI64 with the per-network defined MAC address. Networks that do not use MAC address randomization keep using RFC7217 stable privacy address generation instead. Bug: 154114734 Test: atest ClientModeImplTest Test: atest WifiManagerTest Test: Connect to network Test: Set up hotspot Test: Observe that IPv6 link-local address differs for two networks using randomization Test: Observe that stable-privacy link-local address is used for network when not using randomization Merged-In: Iefb027b17657031116e068bbccdb7b2231a65238 Merged-In: I0a59c750511aacddb38b19bf64b56fd18ff545c5 Merged-In: I4512b87459d036630925ca5ac5ea42179c42ea71 Change-Id: Ief51232b6a4c284331afba74f1fe467dd1b254c8 --- .../com/android/server/wifi/WifiStateMachine.java | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/service/java/com/android/server/wifi/WifiStateMachine.java b/service/java/com/android/server/wifi/WifiStateMachine.java index 390a10238..994b0d048 100644 --- a/service/java/com/android/server/wifi/WifiStateMachine.java +++ b/service/java/com/android/server/wifi/WifiStateMachine.java @@ -4969,12 +4969,17 @@ public class WifiStateMachine extends StateMachine { final WifiConfiguration currentConfig = getCurrentWifiConfiguration(); final boolean isUsingStaticIp = (currentConfig.getIpAssignment() == IpConfiguration.IpAssignment.STATIC); + final boolean isUsingMacRandomization = + currentConfig.macRandomizationSetting + == WifiConfiguration.RANDOMIZATION_PERSISTENT + && isConnectedMacRandomizationEnabled(); if (mVerboseLoggingEnabled) { final String key = currentConfig.configKey(); log("enter ObtainingIpState netId=" + Integer.toString(mLastNetworkId) + " " + key + " " + " roam=" + mIsAutoRoaming - + " static=" + isUsingStaticIp); + + " static=" + isUsingStaticIp + + " randomMac=" + isUsingMacRandomization); } // Send event to CM & network change broadcast @@ -5001,25 +5006,25 @@ public class WifiStateMachine extends StateMachine { if (!TextUtils.isEmpty(mTcpBufferSizes)) { mIpClient.setTcpBufferSizes(mTcpBufferSizes); } - final IpClient.ProvisioningConfiguration prov; + final IpClient.ProvisioningConfiguration.Builder prov; if (!isUsingStaticIp) { prov = IpClient.buildProvisioningConfiguration() .withPreDhcpAction() .withApfCapabilities(mWifiNative.getApfCapabilities(mInterfaceName)) .withNetwork(getCurrentNetwork()) .withDisplayName(currentConfig.SSID) - .withRandomMacAddress() - .build(); + if (isUsingMacRandomization) { + prov.withRandomMacAddress(); + } } else { StaticIpConfiguration staticIpConfig = currentConfig.getStaticIpConfiguration(); prov = IpClient.buildProvisioningConfiguration() .withStaticConfiguration(staticIpConfig) .withApfCapabilities(mWifiNative.getApfCapabilities(mInterfaceName)) .withNetwork(getCurrentNetwork()) - .withDisplayName(currentConfig.SSID) - .build(); + .withDisplayName(currentConfig.SSID); } - mIpClient.startProvisioning(prov); + mIpClient.startProvisioning(prov.build()); // Get Link layer stats so as we get fresh tx packet counters getWifiLinkLayerStats(); } -- cgit v1.2.3