Add tests for Tunnel, Transport mode application with released SPIs
This change adds tests to validate that both transport and tunnel mode transforms continue to work even after the SPI resource has been released. Specifically, since SPI resources are effectively subsumed by the creation of a Transform, the SPI resource is still "alive", but removed from the user-tracking sparse arrays. Bug: 142072071 Test: Added these new tests. Failing prior to aosp/1133555, passes with. Change-Id: I37dd459d08b57b14f72f3b28ea80fa231b152f10 Merged-In: I37dd459d08b57b14f72f3b28ea80fa231b152f10 (cherry picked from commit 4d3f871a944d24cd7cbe3aa51a789a71020eafb5)
This commit is contained in:
@@ -547,6 +547,16 @@ public class IpSecServiceParameterizedTest {
|
||||
|
||||
@Test
|
||||
public void testApplyTransportModeTransform() throws Exception {
|
||||
verifyApplyTransportModeTransformCommon(false);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testApplyTransportModeTransformReleasedSpi() throws Exception {
|
||||
verifyApplyTransportModeTransformCommon(true);
|
||||
}
|
||||
|
||||
public void verifyApplyTransportModeTransformCommon(
|
||||
boolean closeSpiBeforeApply) throws Exception {
|
||||
IpSecConfig ipSecConfig = new IpSecConfig();
|
||||
addDefaultSpisAndRemoteAddrToIpSecConfig(ipSecConfig);
|
||||
addAuthAndCryptToIpSecConfig(ipSecConfig);
|
||||
@@ -554,6 +564,10 @@ public class IpSecServiceParameterizedTest {
|
||||
IpSecTransformResponse createTransformResp =
|
||||
mIpSecService.createTransform(ipSecConfig, new Binder(), "blessedPackage");
|
||||
|
||||
if (closeSpiBeforeApply) {
|
||||
mIpSecService.releaseSecurityParameterIndex(ipSecConfig.getSpiResourceId());
|
||||
}
|
||||
|
||||
Socket socket = new Socket();
|
||||
socket.bind(null);
|
||||
ParcelFileDescriptor pfd = ParcelFileDescriptor.fromSocket(socket);
|
||||
@@ -689,6 +703,15 @@ public class IpSecServiceParameterizedTest {
|
||||
|
||||
@Test
|
||||
public void testApplyTunnelModeTransform() throws Exception {
|
||||
verifyApplyTunnelModeTransformCommon(false);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testApplyTunnelModeTransformReleasedSpi() throws Exception {
|
||||
verifyApplyTunnelModeTransformCommon(true);
|
||||
}
|
||||
|
||||
public void verifyApplyTunnelModeTransformCommon(boolean closeSpiBeforeApply) throws Exception {
|
||||
IpSecConfig ipSecConfig = new IpSecConfig();
|
||||
ipSecConfig.setMode(IpSecTransform.MODE_TUNNEL);
|
||||
addDefaultSpisAndRemoteAddrToIpSecConfig(ipSecConfig);
|
||||
@@ -699,6 +722,10 @@ public class IpSecServiceParameterizedTest {
|
||||
IpSecTunnelInterfaceResponse createTunnelResp =
|
||||
createAndValidateTunnel(mSourceAddr, mDestinationAddr, "blessedPackage");
|
||||
|
||||
if (closeSpiBeforeApply) {
|
||||
mIpSecService.releaseSecurityParameterIndex(ipSecConfig.getSpiResourceId());
|
||||
}
|
||||
|
||||
int transformResourceId = createTransformResp.resourceId;
|
||||
int tunnelResourceId = createTunnelResp.resourceId;
|
||||
mIpSecService.applyTunnelModeTransform(tunnelResourceId, IpSecManager.DIRECTION_OUT,
|
||||
|
||||
Reference in New Issue
Block a user