Implement ChildSessionCallback#onIpSecTransformsMigrated
This change implements the Migrated callback, proxying to onIpSecTransformCreated Bug: 180163196 Test: atest FrameworksVcnTests Change-Id: Ibf07be667882ea35a4d7191b87d1193f38f9db3e
This commit is contained in:
@@ -1325,7 +1325,7 @@ public class VcnGatewayConnection extends StateMachine {
|
||||
@NonNull IpSecTransform transform,
|
||||
int direction) {
|
||||
try {
|
||||
// TODO: Set underlying network of tunnel interface
|
||||
// TODO(b/180163196): Set underlying network of tunnel interface
|
||||
|
||||
// Transforms do not need to be persisted; the IkeSession will keep them alive
|
||||
mIpSecManager.applyTunnelModeTransform(tunnelIface, direction, transform);
|
||||
@@ -1455,6 +1455,7 @@ public class VcnGatewayConnection extends StateMachine {
|
||||
// mUnderlying assumed non-null, given check above.
|
||||
// If network changed, migrate. Otherwise, update any existing networkAgent.
|
||||
if (oldUnderlying == null || !oldUnderlying.network.equals(mUnderlying.network)) {
|
||||
Slog.v(TAG, "Migrating to new network: " + mUnderlying.network);
|
||||
mIkeSession.setNetwork(mUnderlying.network);
|
||||
} else {
|
||||
// oldUnderlying is non-null & underlying network itself has not changed
|
||||
@@ -1707,6 +1708,15 @@ public class VcnGatewayConnection extends StateMachine {
|
||||
childTransformCreated(mToken, transform, direction);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onIpSecTransformsMigrated(
|
||||
@NonNull IpSecTransform inIpSecTransform,
|
||||
@NonNull IpSecTransform outIpSecTransform) {
|
||||
Slog.v(TAG, "ChildTransformsMigrated; token " + mToken);
|
||||
onIpSecTransformCreated(inIpSecTransform, IpSecManager.DIRECTION_IN);
|
||||
onIpSecTransformCreated(outIpSecTransform, IpSecManager.DIRECTION_OUT);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onIpSecTransformDeleted(@NonNull IpSecTransform transform, int direction) {
|
||||
// Nothing to be done; no references to the IpSecTransform are held, and this transform
|
||||
|
||||
@@ -120,6 +120,20 @@ public class VcnGatewayConnectionConnectedStateTest extends VcnGatewayConnection
|
||||
assertEquals(mGatewayConnection.mConnectedState, mGatewayConnection.getCurrentState());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testMigratedTransformsAreApplied() throws Exception {
|
||||
getChildSessionCallback()
|
||||
.onIpSecTransformsMigrated(makeDummyIpSecTransform(), makeDummyIpSecTransform());
|
||||
mTestLooper.dispatchAll();
|
||||
|
||||
for (int direction : new int[] {DIRECTION_IN, DIRECTION_OUT}) {
|
||||
verify(mIpSecSvc)
|
||||
.applyTunnelModeTransform(
|
||||
eq(TEST_IPSEC_TUNNEL_RESOURCE_ID), eq(direction), anyInt(), any());
|
||||
}
|
||||
assertEquals(mGatewayConnection.mConnectedState, mGatewayConnection.getCurrentState());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testChildOpenedRegistersNetwork() throws Exception {
|
||||
final VcnChildSessionConfiguration mMockChildSessionConfig =
|
||||
|
||||
Reference in New Issue
Block a user