Revert "Enable TETHER_FORCE_RANDOM_PREFIX_BASE_SELECTION by default on 25Q2+"
This reverts commit 44f2eb6e42.
Reason for revert: Networking mainline release council review feedback at b/406955982
Flag: EXEMPT bugfix
Test: TH
Bug: 406955982
Change-Id: I89bc8f5863c3acb72b5c4af5aadc40d34f2380ce
This commit is contained in:
parent
ffb4561f59
commit
121a4f90ba
3 changed files with 13 additions and 18 deletions
|
|
@ -131,6 +131,9 @@ public class TetheringConfiguration {
|
|||
public static final String TETHER_ENABLE_WEAR_TETHERING =
|
||||
"tether_enable_wear_tethering";
|
||||
|
||||
public static final String TETHER_FORCE_RANDOM_PREFIX_BASE_SELECTION =
|
||||
"tether_force_random_prefix_base_selection";
|
||||
|
||||
public static final String TETHER_ENABLE_SYNC_SM = "tether_enable_sync_sm";
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -26,6 +26,7 @@ import static android.net.TetheringManager.TETHERING_WIFI;
|
|||
import static android.net.TetheringManager.TETHERING_WIFI_P2P;
|
||||
import static android.net.ip.IpServer.CMD_NOTIFY_PREFIX_CONFLICT;
|
||||
|
||||
import static com.android.net.module.util.PrivateAddressCoordinator.TETHER_FORCE_RANDOM_PREFIX_BASE_SELECTION;
|
||||
import static com.android.networkstack.tethering.util.PrefixUtils.asIpPrefix;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
|
@ -50,7 +51,6 @@ import android.net.LinkProperties;
|
|||
import android.net.Network;
|
||||
import android.net.NetworkCapabilities;
|
||||
import android.net.ip.IpServer;
|
||||
import android.os.Build;
|
||||
import android.os.IBinder;
|
||||
|
||||
import androidx.test.filters.SmallTest;
|
||||
|
|
@ -58,10 +58,8 @@ import androidx.test.runner.AndroidJUnit4;
|
|||
|
||||
import com.android.net.module.util.IIpv4PrefixRequest;
|
||||
import com.android.net.module.util.PrivateAddressCoordinator;
|
||||
import com.android.testutils.DevSdkIgnoreRule;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Rule;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.mockito.Mock;
|
||||
|
|
@ -73,9 +71,6 @@ import java.util.Arrays;
|
|||
@RunWith(AndroidJUnit4.class)
|
||||
@SmallTest
|
||||
public final class PrivateAddressCoordinatorTest {
|
||||
@Rule
|
||||
public final DevSdkIgnoreRule mIgnoreRule = new DevSdkIgnoreRule();
|
||||
|
||||
private static final String TEST_IFNAME = "test0";
|
||||
|
||||
@Mock private IpServer mHotspotIpServer;
|
||||
|
|
@ -236,9 +231,11 @@ public final class PrivateAddressCoordinatorTest {
|
|||
assertEquals(usbAddress, newUsbAddress);
|
||||
|
||||
final UpstreamNetworkState wifiUpstream = buildUpstreamNetworkState(mWifiNetwork,
|
||||
hotspotAddress, null, makeNetworkCapabilities(TRANSPORT_WIFI));
|
||||
new LinkAddress("192.168.88.23/16"), null,
|
||||
makeNetworkCapabilities(TRANSPORT_WIFI));
|
||||
updateUpstreamPrefix(wifiUpstream);
|
||||
verify(mHotspotIpServer).sendMessage(IpServer.CMD_NOTIFY_PREFIX_CONFLICT);
|
||||
verify(mUsbIpServer).sendMessage(IpServer.CMD_NOTIFY_PREFIX_CONFLICT);
|
||||
}
|
||||
|
||||
private UpstreamNetworkState buildUpstreamNetworkState(final Network network,
|
||||
|
|
@ -326,9 +323,10 @@ public final class PrivateAddressCoordinatorTest {
|
|||
assertFalse(localHotspotPrefix.containsPrefix(hotspotPrefix));
|
||||
}
|
||||
|
||||
@DevSdkIgnoreRule.IgnoreUpTo(Build.VERSION_CODES.VANILLA_ICE_CREAM)
|
||||
@Test
|
||||
public void testStartedPrefixRange() throws Exception {
|
||||
when(mDeps.isFeatureEnabled(TETHER_FORCE_RANDOM_PREFIX_BASE_SELECTION)).thenReturn(true);
|
||||
|
||||
startedPrefixBaseTest("192.168.0.0/16", 0);
|
||||
|
||||
startedPrefixBaseTest("192.168.0.0/16", 1);
|
||||
|
|
|
|||
|
|
@ -33,14 +33,12 @@ import android.net.LinkAddress;
|
|||
import android.net.LinkProperties;
|
||||
import android.net.Network;
|
||||
import android.net.NetworkCapabilities;
|
||||
import android.os.Build;
|
||||
import android.os.RemoteException;
|
||||
import android.util.ArrayMap;
|
||||
|
||||
import androidx.annotation.Nullable;
|
||||
|
||||
import com.android.internal.annotations.VisibleForTesting;
|
||||
import com.android.modules.utils.build.SdkLevel;
|
||||
|
||||
import java.io.PrintWriter;
|
||||
import java.net.Inet4Address;
|
||||
|
|
@ -69,6 +67,9 @@ public class PrivateAddressCoordinator {
|
|||
// WARNING: Keep in sync with chooseDownstreamAddress
|
||||
public static final int PREFIX_LENGTH = 24;
|
||||
|
||||
public static final String TETHER_FORCE_RANDOM_PREFIX_BASE_SELECTION =
|
||||
"tether_force_random_prefix_base_selection";
|
||||
|
||||
// Upstream monitor would be stopped when tethering is down. When tethering restart, downstream
|
||||
// address may be requested before coordinator get current upstream notification. To ensure
|
||||
// coordinator do not select conflict downstream prefix, mUpstreamPrefixMap would not be cleared
|
||||
|
|
@ -257,15 +258,8 @@ public class PrivateAddressCoordinator {
|
|||
return null;
|
||||
}
|
||||
|
||||
// TODO: Remove this method when SdkLevel.isAtLeastB() is fixed, aosp is at sdk level 36 or use
|
||||
// NetworkStackUtils.isAtLeast25Q2 when it is moved to a static lib.
|
||||
public static boolean isAtLeast25Q2() {
|
||||
return SdkLevel.isAtLeastB() || (SdkLevel.isAtLeastV()
|
||||
&& "Baklava".equals(Build.VERSION.CODENAME));
|
||||
}
|
||||
|
||||
private int getRandomPrefixIndex() {
|
||||
if (!isAtLeast25Q2()) return 0;
|
||||
if (!mDeps.isFeatureEnabled(TETHER_FORCE_RANDOM_PREFIX_BASE_SELECTION)) return 0;
|
||||
|
||||
final int random = getRandomInt() & 0xffffff;
|
||||
// This is to select the starting prefix range (/8, /12, or /16) instead of the actual
|
||||
|
|
|
|||
Loading…
Reference in a new issue