diff options
author | Bram Bonné <brambonne@google.com> | 2020-10-19 18:08:55 +0200 |
---|---|---|
committer | Bram Bonné <brambonne@google.com> | 2020-10-20 11:01:03 +0200 |
commit | becf46bfdff50dab319210b69d30185f87db7f17 (patch) | |
tree | 47d55317f8495187c8089543deaa148c59cb2f18 | |
parent | 7b701dfe989079784ff1076ce67cb2fb7665b798 (diff) |
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
Change-Id: I4512b87459d036630925ca5ac5ea42179c42ea71
-rw-r--r-- | service/java/com/android/server/wifi/ClientModeImpl.java | 21 |
1 files changed, 13 insertions, 8 deletions
diff --git a/service/java/com/android/server/wifi/ClientModeImpl.java b/service/java/com/android/server/wifi/ClientModeImpl.java index d98d022b7..cd6d8b269 100644 --- a/service/java/com/android/server/wifi/ClientModeImpl.java +++ b/service/java/com/android/server/wifi/ClientModeImpl.java @@ -5300,12 +5300,17 @@ public class ClientModeImpl 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 @@ -5334,26 +5339,26 @@ public class ClientModeImpl extends StateMachine { mIpClient.setTcpBufferSizes(mTcpBufferSizes); } } - final ProvisioningConfiguration prov; + final ProvisioningConfiguration.Builder prov; if (!isUsingStaticIp) { prov = new ProvisioningConfiguration.Builder() .withPreDhcpAction() .withApfCapabilities(mWifiNative.getApfCapabilities(mInterfaceName)) .withNetwork(getCurrentNetwork()) - .withDisplayName(currentConfig.SSID) - .withRandomMacAddress() - .build(); + .withDisplayName(currentConfig.SSID); + if (isUsingMacRandomization) { + prov.withRandomMacAddress(); + } } else { StaticIpConfiguration staticIpConfig = currentConfig.getStaticIpConfiguration(); prov = new ProvisioningConfiguration.Builder() .withStaticConfiguration(staticIpConfig) .withApfCapabilities(mWifiNative.getApfCapabilities(mInterfaceName)) .withNetwork(getCurrentNetwork()) - .withDisplayName(currentConfig.SSID) - .build(); + .withDisplayName(currentConfig.SSID); } if (mIpClient != null) { - mIpClient.startProvisioning(prov); + mIpClient.startProvisioning(prov.build()); } // Get Link layer stats so as we get fresh tx packet counters getWifiLinkLayerStats(); |