Revert "only enable APFv6 ND offload if preloaded"
This reverts commit 43acd988da950d6d8cc7b664a300b5ca058f4646.
Reason for revert: As discussed, we don't create additional method to turn on the feature.
Change-Id: I6e9889631c62ba7acb2fe6a85d14d2a0ce7be26f
diff --git a/res/values/config.xml b/res/values/config.xml
index 29bb09a..16364d6 100644
--- a/res/values/config.xml
+++ b/res/values/config.xml
@@ -130,14 +130,4 @@
<!-- Configuration for including DHCP domain search list option -->
<bool name="config_dhcp_client_domain_search_list">false</bool>
-
- <!-- Configuration for force enable APFv6 ND offload.
- The APF ND offload code is enabled by default if the device preloads a NetworkStack module
- that is at least version 350090000. If a device is preloaded with an older NetworkStack
- module but still wants to enable this feature when it receives a mainline update, OEMs can
- use this overlay to force-enable the feature.
- If OEMs decide to opt in to this feature, they must ensure the APFv6 ND offload logic is
- tested properly.
- -->
- <bool name="config_force_enable_apfv6_nd_offload">false</bool>
</resources>
diff --git a/res/values/overlayable.xml b/res/values/overlayable.xml
index 88cbcde..08a2778 100644
--- a/res/values/overlayable.xml
+++ b/res/values/overlayable.xml
@@ -94,15 +94,6 @@
<item type="bool" name="config_validate_dun_networks"/>
<!-- Configuration for including DHCP client domain search list option. -->
<item type="bool" name="config_dhcp_client_domain_search_list"/>
- <!-- Configuration for force enable APFv6 ND offload.
- The APF ND offload code is enabled by default if the device preloads a NetworkStack
- module that is at least version 350090000. If a device is preloaded with an older
- NetworkStack module but still wants to enable this feature when it receives a
- mainline update, OEMs can use this overlay to force-enable the feature.
- If OEMs decide to opt in to this feature, they must ensure the APFv6 ND offload
- logic is tested properly.
- -->
- <item type="bool" name="config_force_enable_apfv6_nd_offload"/>
</policy>
</overlayable>
</resources>
diff --git a/src/android/net/ip/IpClient.java b/src/android/net/ip/IpClient.java
index 6e1d3e3..7e21116 100644
--- a/src/android/net/ip/IpClient.java
+++ b/src/android/net/ip/IpClient.java
@@ -64,7 +64,6 @@
import android.app.admin.DevicePolicyManager;
import android.content.ComponentName;
import android.content.Context;
-import android.content.pm.PackageInfo;
import android.content.pm.PackageManager;
import android.content.res.Resources;
import android.net.ConnectivityManager;
@@ -933,32 +932,6 @@
this(context, ifName, callback, nssManager, new Dependencies());
}
- /**
- * Check if the network stack module in the factory image is at least the specified version.
- */
- private boolean isFactoryNetworkStackVersionAtLeast(@NonNull Context context,
- long targetVersion) {
- final PackageManager pm = context.getPackageManager();
- try {
- final PackageInfo pktInfo = pm.getPackageInfo(context.getPackageName(),
- PackageManager.MATCH_FACTORY_ONLY);
- if (pktInfo == null) {
- Log.wtf(TAG, "Factory network stack package not found");
- return false;
- }
- long versionCode = pktInfo.getLongVersionCode();
- if (versionCode == 350090000) {
- // AOSP use default version code 350090000.
- // ref: build/soong/android/updatable_modules.go
- return true;
- }
- return versionCode >= targetVersion;
- } catch (PackageManager.NameNotFoundException e) {
- Log.wtf(TAG, "Factory network stack package not found", e);
- return false;
- }
- }
-
@VisibleForTesting
public IpClient(Context context, String ifName, IIpClientCallbacks callback,
NetworkStackServiceManager nssManager, Dependencies deps) {
@@ -1012,18 +985,8 @@
IPCLIENT_IGNORE_LOW_RA_LIFETIME_VERSION);
mApfShouldHandleArpOffload = mDependencies.isFeatureNotChickenedOut(
mContext, APF_HANDLE_ARP_OFFLOAD);
- mApfShouldHandleNdOffload =
- mDependencies.isFeatureNotChickenedOut(mContext, APF_HANDLE_ND_OFFLOAD)
- // The feature is enabled only if the factory network stack version is greater
- // than or equal to M-2024-09 or the OEM explicitly opts in through overlay value
- // override. If OEMs decide to opt in to this feature, they must ensure the APFv6
- // ND offload logic is tested properly.
- // This check ensures the APFv6 ND offload feature is tested before deployment to
- // production.
- && (isFactoryNetworkStackVersionAtLeast(context, 350911000)
- || context.getResources().getBoolean(
- R.bool.config_force_enable_apfv6_nd_offload)
- );
+ mApfShouldHandleNdOffload = mDependencies.isFeatureNotChickenedOut(
+ mContext, APF_HANDLE_ND_OFFLOAD);
mPopulateLinkAddressLifetime = mDependencies.isFeatureEnabled(context,
IPCLIENT_POPULATE_LINK_ADDRESS_LIFETIME_VERSION);
diff --git a/tests/unit/src/android/net/ip/IpClientTest.java b/tests/unit/src/android/net/ip/IpClientTest.java
index d1c764a..71f7ebf 100644
--- a/tests/unit/src/android/net/ip/IpClientTest.java
+++ b/tests/unit/src/android/net/ip/IpClientTest.java
@@ -35,7 +35,6 @@
import static com.android.net.module.util.netlink.NetlinkConstants.RTN_UNICAST;
import static com.android.net.module.util.netlink.StructNlMsgHdr.NLM_F_ACK;
import static com.android.net.module.util.netlink.StructNlMsgHdr.NLM_F_REQUEST;
-import static com.android.networkstack.util.NetworkStackUtils.APF_HANDLE_ND_OFFLOAD;
import static org.junit.Assert.assertArrayEquals;
import static org.junit.Assert.assertEquals;
@@ -66,8 +65,6 @@
import android.app.AlarmManager;
import android.content.ContentResolver;
import android.content.Context;
-import android.content.pm.PackageInfo;
-import android.content.pm.PackageManager;
import android.content.res.Resources;
import android.net.ConnectivityManager;
import android.net.INetd;
@@ -194,8 +191,6 @@
@Mock private PrintWriter mWriter;
@Mock private IpClientNetlinkMonitor mNetlinkMonitor;
@Mock private AndroidPacketFilter mApfFilter;
- @Mock private PackageManager mPackageManager;
- @Mock private PackageInfo mNetworkStackPackageInfo;
private InterfaceParams mIfParams;
private INetlinkMessageProcessor mNetlinkMessageProcessor;
@@ -221,14 +216,7 @@
when(mDependencies.makeIpClientNetlinkMonitor(
any(), any(), any(), anyInt(), any())).thenReturn(mNetlinkMonitor);
when(mNetlinkMonitor.start()).thenReturn(true);
- doReturn(mPackageManager).when(mContext).getPackageManager();
- doReturn("com.android.networkstack").when(mContext).getPackageName();
- doReturn(mNetworkStackPackageInfo).when(mPackageManager)
- .getPackageInfo("com.android.networkstack",
- PackageManager.MATCH_FACTORY_ONLY);
- doReturn(350820280L).when(mNetworkStackPackageInfo).getLongVersionCode();
- doReturn(true).when(
- mDependencies).isFeatureNotChickenedOut(mContext, APF_HANDLE_ND_OFFLOAD);
+
mIfParams = null;
}
@@ -1041,53 +1029,6 @@
@Test
@IgnoreUpTo(Build.VERSION_CODES.UPSIDE_DOWN_CAKE)
- public void testDisableApfNdOffloadIfFactoryNetworkStackVersionIsOld() throws Exception {
- final ArgumentCaptor<ApfConfiguration> configCaptor = ArgumentCaptor.forClass(
- ApfConfiguration.class);
- doReturn(mApfFilter).when(mDependencies).maybeCreateApfFilter(any(), any(), any(), any(),
- any(), anyBoolean());
- final IpClient ipc = makeIpClient(TEST_IFNAME);
- ProvisioningConfiguration config = new ProvisioningConfiguration.Builder()
- .withoutIPv4()
- .withoutIpReachabilityMonitor()
- .withApfCapabilities(new ApfCapabilities(APF_VERSION_6,
- 4096 /* maxProgramSize */, ARPHRD_ETHER))
- .build();
- ipc.startProvisioning(config);
- verify(mDependencies, timeout(TEST_TIMEOUT_MS)).maybeCreateApfFilter(any(),
- configCaptor.capture(), any(), any(), any(), anyBoolean());
- verifyShutdown(ipc);
- final ApfConfiguration apfConfiguration = configCaptor.getValue();
- assertFalse(apfConfiguration.shouldHandleNdOffload);
- }
-
- @Test
- @IgnoreUpTo(Build.VERSION_CODES.UPSIDE_DOWN_CAKE)
- public void testEnableApfNdOffloadIfFactoryNetworkStackVersionIsNewerEnough() throws Exception {
- final ArgumentCaptor<ApfConfiguration> configCaptor = ArgumentCaptor.forClass(
- ApfConfiguration.class);
- doReturn(mApfFilter).when(mDependencies)
- .maybeCreateApfFilter(any(), any(), any(), any(), any(), anyBoolean());
- doReturn(350911000L).when(mNetworkStackPackageInfo).getLongVersionCode();
- final IpClient ipc = makeIpClient(TEST_IFNAME);
- verify(mDependencies).isFeatureNotChickenedOut(mContext, APF_HANDLE_ND_OFFLOAD);
- verify(mNetworkStackPackageInfo).getLongVersionCode();
- ProvisioningConfiguration config = new ProvisioningConfiguration.Builder()
- .withoutIPv4()
- .withoutIpReachabilityMonitor()
- .withApfCapabilities(new ApfCapabilities(APF_VERSION_6,
- 4096 /* maxProgramSize */, ARPHRD_ETHER))
- .build();
- ipc.startProvisioning(config);
- verify(mDependencies, timeout(TEST_TIMEOUT_MS)).maybeCreateApfFilter(any(),
- configCaptor.capture(), any(), any(), any(), anyBoolean());
- verifyShutdown(ipc);
- final ApfConfiguration apfConfiguration = configCaptor.getValue();
- assertTrue(apfConfiguration.shouldHandleNdOffload);
- }
-
- @Test
- @IgnoreUpTo(Build.VERSION_CODES.UPSIDE_DOWN_CAKE)
public void testVendorNdOffloadDisabledWhenApfCapabilitiesUpdated() throws Exception {
when(mDependencies.maybeCreateApfFilter(any(), any(), any(), any(), any(), anyBoolean()))
.thenReturn(mApfFilter);