diff options
author | Bram Bonné <brambonne@google.com> | 2020-04-15 18:19:34 +0200 |
---|---|---|
committer | Bram Bonné <brambonne@google.com> | 2020-06-02 09:46:47 +0000 |
commit | 9cd977f9f469bba280e7875d0fac0b1565da4f17 (patch) | |
tree | 451577be28fb635924202b1c754c4042bc95d364 | |
parent | 4d77b3f79c3e44a9c227e2901020951ca274fda9 (diff) |
Use EUI64 IPv6 link-local address generation 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: Cast from device
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
Change-Id: Iefb027b17657031116e068bbccdb7b2231a65238
(cherry picked from commit d870eee583e9300fbdaa1620325fe3c13d30817d)
-rw-r--r-- | service/java/com/android/server/wifi/ClientModeImpl.java | 30 |
1 files changed, 20 insertions, 10 deletions
diff --git a/service/java/com/android/server/wifi/ClientModeImpl.java b/service/java/com/android/server/wifi/ClientModeImpl.java index 5b616dd0a..b5bd479db 100644 --- a/service/java/com/android/server/wifi/ClientModeImpl.java +++ b/service/java/com/android/server/wifi/ClientModeImpl.java @@ -6447,12 +6447,17 @@ public class ClientModeImpl extends StateMachine { final boolean isUsingStaticIp = (config.getIpAssignment() == IpConfiguration.IpAssignment.STATIC); + final boolean isUsingMacRandomization = + config.macRandomizationSetting + == WifiConfiguration.RANDOMIZATION_PERSISTENT + && isConnectedMacRandomizationEnabled(); if (mVerboseLoggingEnabled) { final String key = config.getKey(); log("startIpClient netId=" + Integer.toString(mLastNetworkId) + " " + key + " " + " roam=" + mIsAutoRoaming + " static=" + isUsingStaticIp + + " randomMac=" + isUsingMacRandomization + " isFilsConnection=" + isFilsConnection); } @@ -6471,15 +6476,18 @@ public class ClientModeImpl extends StateMachine { return false; } setConfigurationsPriorToIpClientProvisioning(config); - final ProvisioningConfiguration prov = + final ProvisioningConfiguration.Builder prov = new ProvisioningConfiguration.Builder() .withPreDhcpAction() .withPreconnection() .withApfCapabilities( mWifiNative.getApfCapabilities(mInterfaceName)) - .withLayer2Information(layer2Info) - .build(); - mIpClient.startProvisioning(prov); + .withLayer2Information(layer2Info); + if (isUsingMacRandomization) { + // Use EUI64 address generation for link-local IPv6 addresses. + prov.withRandomMacAddress(); + } + mIpClient.startProvisioning(prov.build()); } else { sendNetworkChangeBroadcast(DetailedState.OBTAINING_IPADDR); // We must clear the config BSSID, as the wifi chipset may decide to roam @@ -6521,7 +6529,7 @@ public class ClientModeImpl extends StateMachine { } } - final ProvisioningConfiguration prov; + final ProvisioningConfiguration.Builder prov; ProvisioningConfiguration.ScanResultInfo scanResultInfo = null; if (scanResult != null) { final List<ScanResultInfo.InformationElement> ies = @@ -6542,8 +6550,7 @@ public class ClientModeImpl extends StateMachine { .withNetwork(getCurrentNetwork()) .withDisplayName(config.SSID) .withScanResultInfo(scanResultInfo) - .withLayer2Information(layer2Info) - .build(); + .withLayer2Information(layer2Info); } else { StaticIpConfiguration staticIpConfig = config.getStaticIpConfiguration(); prov = new ProvisioningConfiguration.Builder() @@ -6551,10 +6558,13 @@ public class ClientModeImpl extends StateMachine { .withApfCapabilities(mWifiNative.getApfCapabilities(mInterfaceName)) .withNetwork(getCurrentNetwork()) .withDisplayName(config.SSID) - .withLayer2Information(layer2Info) - .build(); + .withLayer2Information(layer2Info); + } + if (isUsingMacRandomization) { + // Use EUI64 address generation for link-local IPv6 addresses. + prov.withRandomMacAddress(); } - mIpClient.startProvisioning(prov); + mIpClient.startProvisioning(prov.build()); } return true; |