CTS: Verify rekey-based tunnel migration with encapType change
Adds CTS to verify that the tunnel migration based on replacing
SAs can handle changes of encap type.
Verified on kernel 5.10.149 and 5.10.104
Bug: 266149275
Test: atest IpSecManagerTunnelTest(new tests added)
Change-Id: I33e945f8be2a472603c5f1b64697f62f2d69a186
diff --git a/tests/cts/net/src/android/net/cts/IpSecManagerTunnelTest.java b/tests/cts/net/src/android/net/cts/IpSecManagerTunnelTest.java
index 7683fcb..1ede5c1 100644
--- a/tests/cts/net/src/android/net/cts/IpSecManagerTunnelTest.java
+++ b/tests/cts/net/src/android/net/cts/IpSecManagerTunnelTest.java
@@ -532,13 +532,16 @@
private class MigrateIpSecTunnelTestRunnableFactory implements IpSecTunnelTestRunnableFactory {
private final IpSecTunnelTestRunnableFactory mTestRunnableFactory;
+ private final boolean mTestEncapTypeChange;
- MigrateIpSecTunnelTestRunnableFactory(boolean isOutputTest) {
+ MigrateIpSecTunnelTestRunnableFactory(boolean isOutputTest, boolean testEncapTypeChange) {
if (isOutputTest) {
mTestRunnableFactory = new OutputIpSecTunnelTestRunnableFactory();
} else {
mTestRunnableFactory = new InputPacketGeneratorIpSecTunnelTestRunnableFactory();
}
+
+ mTestEncapTypeChange = testEncapTypeChange;
}
@Override
@@ -584,10 +587,9 @@
seqNum);
tunnelIface.setUnderlyingNetwork(sTunWrapperNew.network);
- // TODO: Add CTS test for migration with encap type change
-
- // This test only verify migration without encap type change
- final boolean useEncapAfterMigrate = encapSocket != null;
+ final boolean useEncapBeforeMigrate = encapSocket != null;
+ final boolean useEncapAfterMigrate =
+ mTestEncapTypeChange ? !useEncapBeforeMigrate : useEncapBeforeMigrate;
// Verify migrating to IPv4 and IPv6 addresses. It ensures that not only
// can IPsec tunnel migrate across interfaces, IPsec tunnel can also migrate to
@@ -858,25 +860,33 @@
}
private void checkMigrateTunnelOutput(
- int innerFamily, int outerFamily, boolean useEncap, boolean transportInTunnelMode)
+ int innerFamily,
+ int outerFamily,
+ boolean useEncap,
+ boolean transportInTunnelMode,
+ boolean isEncapTypeChanged)
throws Exception {
checkTunnel(
innerFamily,
outerFamily,
useEncap,
transportInTunnelMode,
- new MigrateIpSecTunnelTestRunnableFactory(true));
+ new MigrateIpSecTunnelTestRunnableFactory(true, isEncapTypeChanged));
}
private void checkMigrateTunnelInput(
- int innerFamily, int outerFamily, boolean useEncap, boolean transportInTunnelMode)
+ int innerFamily,
+ int outerFamily,
+ boolean useEncap,
+ boolean transportInTunnelMode,
+ boolean isEncapTypeChanged)
throws Exception {
checkTunnel(
innerFamily,
outerFamily,
useEncap,
transportInTunnelMode,
- new MigrateIpSecTunnelTestRunnableFactory(false));
+ new MigrateIpSecTunnelTestRunnableFactory(false, isEncapTypeChanged));
}
private void checkMigrateTunnelModeTransformOutput(
@@ -1225,11 +1235,39 @@
}
private void doTestMigrateTunnel(
- int innerFamily, int outerFamily, boolean useEncap, boolean transportInTunnelMode)
+ int innerFamily,
+ int outerFamily,
+ boolean useEncap,
+ boolean transportInTunnelMode,
+ boolean testEncapTypeChange)
throws Exception {
assumeTrue(mCtsNetUtils.hasIpsecTunnelsFeature());
- checkMigrateTunnelOutput(innerFamily, outerFamily, useEncap, transportInTunnelMode);
- checkMigrateTunnelInput(innerFamily, outerFamily, useEncap, transportInTunnelMode);
+ checkMigrateTunnelOutput(
+ innerFamily, outerFamily, useEncap, transportInTunnelMode, testEncapTypeChange);
+ checkMigrateTunnelInput(
+ innerFamily, outerFamily, useEncap, transportInTunnelMode, testEncapTypeChange);
+ }
+
+ private void doTestMigrateTunnel(
+ int innerFamily, int outerFamily, boolean useEncap, boolean transportInTunnelMode)
+ throws Exception {
+ doTestMigrateTunnel(
+ innerFamily,
+ outerFamily,
+ useEncap,
+ transportInTunnelMode,
+ false /* testEncapTypeChange */);
+ }
+
+ private void doTestMigrateTunnelWithEncapTypeChange(
+ int innerFamily, int outerFamily, boolean useEncap, boolean transportInTunnelMode)
+ throws Exception {
+ doTestMigrateTunnel(
+ innerFamily,
+ outerFamily,
+ useEncap,
+ transportInTunnelMode,
+ true /* testEncapTypeChange */);
}
private void doTestMigrateTunnelModeTransform(
@@ -1266,6 +1304,12 @@
doTestMigrateTunnel(AF_INET, AF_INET, false, true);
}
+ @IgnoreUpTo(Build.VERSION_CODES.R)
+ @Test
+ public void testMigrateTransportInTunnelModeV4InV4_EncapTypeChange() throws Exception {
+ doTestMigrateTunnelWithEncapTypeChange(AF_INET, AF_INET, false, true);
+ }
+
@Test
public void testTransportInTunnelModeV4InV4Reflected() throws Exception {
assumeTrue(mCtsNetUtils.hasIpsecTunnelsFeature());
@@ -1285,6 +1329,12 @@
doTestMigrateTunnel(AF_INET, AF_INET, true, true);
}
+ @IgnoreUpTo(Build.VERSION_CODES.R)
+ @Test
+ public void testMigrateTransportInTunnelModeV4InV4UdpEncap_EncapTypeChange() throws Exception {
+ doTestMigrateTunnelWithEncapTypeChange(AF_INET, AF_INET, true, true);
+ }
+
@Test
public void testTransportInTunnelModeV4InV4UdpEncapReflected() throws Exception {
assumeTrue(mCtsNetUtils.hasIpsecTunnelsFeature());
@@ -1304,6 +1354,12 @@
doTestMigrateTunnel(AF_INET, AF_INET6, false, true);
}
+ @IgnoreUpTo(Build.VERSION_CODES.R)
+ @Test
+ public void testMigrateTransportInTunnelModeV4InV6_EncapTypeChange() throws Exception {
+ doTestMigrateTunnelWithEncapTypeChange(AF_INET, AF_INET6, false, true);
+ }
+
@Test
public void testTransportInTunnelModeV4InV6Reflected() throws Exception {
assumeTrue(mCtsNetUtils.hasIpsecTunnelsFeature());
@@ -1323,6 +1379,12 @@
doTestMigrateTunnel(AF_INET6, AF_INET, false, true);
}
+ @IgnoreUpTo(Build.VERSION_CODES.R)
+ @Test
+ public void testMigrateTransportInTunnelModeV6InV4_EncapTypeChange() throws Exception {
+ doTestMigrateTunnelWithEncapTypeChange(AF_INET6, AF_INET, false, true);
+ }
+
@Test
public void testTransportInTunnelModeV6InV4Reflected() throws Exception {
assumeTrue(mCtsNetUtils.hasIpsecTunnelsFeature());
@@ -1342,6 +1404,12 @@
doTestMigrateTunnel(AF_INET6, AF_INET, true, true);
}
+ @IgnoreUpTo(Build.VERSION_CODES.R)
+ @Test
+ public void testMigrateTransportInTunnelModeV6InV4UdpEncap_EncapTypeChange() throws Exception {
+ doTestMigrateTunnelWithEncapTypeChange(AF_INET6, AF_INET, true, true);
+ }
+
@Test
public void testTransportInTunnelModeV6InV4UdpEncapReflected() throws Exception {
assumeTrue(mCtsNetUtils.hasIpsecTunnelsFeature());
@@ -1361,6 +1429,12 @@
doTestMigrateTunnel(AF_INET, AF_INET6, false, true);
}
+ @IgnoreUpTo(Build.VERSION_CODES.R)
+ @Test
+ public void testMigrateTransportInTunnelModeV6InV6_EncapTypeChange() throws Exception {
+ doTestMigrateTunnelWithEncapTypeChange(AF_INET, AF_INET6, false, true);
+ }
+
@Test
public void testTransportInTunnelModeV6InV6Reflected() throws Exception {
assumeTrue(mCtsNetUtils.hasIpsecTunnelsFeature());
@@ -1381,6 +1455,12 @@
doTestMigrateTunnel(AF_INET, AF_INET, false, false);
}
+ @IgnoreUpTo(Build.VERSION_CODES.R)
+ @Test
+ public void testMigrateTunnelV4InV4_EncapTypeChange() throws Exception {
+ doTestMigrateTunnelWithEncapTypeChange(AF_INET, AF_INET, false, false);
+ }
+
@Test
public void testTunnelV4InV4Reflected() throws Exception {
assumeTrue(mCtsNetUtils.hasIpsecTunnelsFeature());
@@ -1400,6 +1480,12 @@
doTestMigrateTunnel(AF_INET, AF_INET, true, false);
}
+ @IgnoreUpTo(Build.VERSION_CODES.R)
+ @Test
+ public void testMigrateTunnelV4InV4UdpEncap_EncapTypeChange() throws Exception {
+ doTestMigrateTunnelWithEncapTypeChange(AF_INET, AF_INET, true, false);
+ }
+
@Test
public void testTunnelV4InV4UdpEncapReflected() throws Exception {
assumeTrue(mCtsNetUtils.hasIpsecTunnelsFeature());
@@ -1419,6 +1505,12 @@
doTestMigrateTunnel(AF_INET, AF_INET6, false, false);
}
+ @IgnoreUpTo(Build.VERSION_CODES.R)
+ @Test
+ public void testMigrateTunnelV4InV6_EncapTypeChange() throws Exception {
+ doTestMigrateTunnelWithEncapTypeChange(AF_INET, AF_INET6, false, false);
+ }
+
@Test
public void testTunnelV4InV6Reflected() throws Exception {
assumeTrue(mCtsNetUtils.hasIpsecTunnelsFeature());
@@ -1438,6 +1530,12 @@
doTestMigrateTunnel(AF_INET6, AF_INET, false, false);
}
+ @IgnoreUpTo(Build.VERSION_CODES.R)
+ @Test
+ public void testMigrateTunnelV6InV4_EncapTypeChange() throws Exception {
+ doTestMigrateTunnelWithEncapTypeChange(AF_INET6, AF_INET, false, false);
+ }
+
@Test
public void testTunnelV6InV4Reflected() throws Exception {
assumeTrue(mCtsNetUtils.hasIpsecTunnelsFeature());
@@ -1457,6 +1555,12 @@
doTestMigrateTunnel(AF_INET6, AF_INET, true, false);
}
+ @IgnoreUpTo(Build.VERSION_CODES.R)
+ @Test
+ public void testMigrateTunnelV6InV4UdpEncap_EncapTypeChange() throws Exception {
+ doTestMigrateTunnelWithEncapTypeChange(AF_INET6, AF_INET, true, false);
+ }
+
@Test
public void testTunnelV6InV4UdpEncapReflected() throws Exception {
assumeTrue(mCtsNetUtils.hasIpsecTunnelsFeature());
@@ -1476,6 +1580,12 @@
doTestMigrateTunnel(AF_INET6, AF_INET6, false, false);
}
+ @IgnoreUpTo(Build.VERSION_CODES.R)
+ @Test
+ public void testMigrateTunnelV6InV6_EncapTypeChange() throws Exception {
+ doTestMigrateTunnelWithEncapTypeChange(AF_INET6, AF_INET6, false, false);
+ }
+
@Test
public void testTunnelV6InV6Reflected() throws Exception {
assumeTrue(mCtsNetUtils.hasIpsecTunnelsFeature());