Merge "Implement ChildSessionCallback#onIpSecTransformsMigrated"
This commit is contained in:
@@ -1409,7 +1409,7 @@ public class VcnGatewayConnection extends StateMachine {
|
|||||||
@NonNull IpSecTransform transform,
|
@NonNull IpSecTransform transform,
|
||||||
int direction) {
|
int direction) {
|
||||||
try {
|
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
|
// Transforms do not need to be persisted; the IkeSession will keep them alive
|
||||||
mIpSecManager.applyTunnelModeTransform(tunnelIface, direction, transform);
|
mIpSecManager.applyTunnelModeTransform(tunnelIface, direction, transform);
|
||||||
@@ -1540,6 +1540,7 @@ public class VcnGatewayConnection extends StateMachine {
|
|||||||
// mUnderlying assumed non-null, given check above.
|
// mUnderlying assumed non-null, given check above.
|
||||||
// If network changed, migrate. Otherwise, update any existing networkAgent.
|
// If network changed, migrate. Otherwise, update any existing networkAgent.
|
||||||
if (oldUnderlying == null || !oldUnderlying.network.equals(mUnderlying.network)) {
|
if (oldUnderlying == null || !oldUnderlying.network.equals(mUnderlying.network)) {
|
||||||
|
Slog.v(TAG, "Migrating to new network: " + mUnderlying.network);
|
||||||
mIkeSession.setNetwork(mUnderlying.network);
|
mIkeSession.setNetwork(mUnderlying.network);
|
||||||
} else {
|
} else {
|
||||||
// oldUnderlying is non-null & underlying network itself has not changed
|
// oldUnderlying is non-null & underlying network itself has not changed
|
||||||
@@ -1807,6 +1808,15 @@ public class VcnGatewayConnection extends StateMachine {
|
|||||||
childTransformCreated(mToken, transform, direction);
|
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
|
@Override
|
||||||
public void onIpSecTransformDeleted(@NonNull IpSecTransform transform, int direction) {
|
public void onIpSecTransformDeleted(@NonNull IpSecTransform transform, int direction) {
|
||||||
// Nothing to be done; no references to the IpSecTransform are held, and this transform
|
// Nothing to be done; no references to the IpSecTransform are held, and this transform
|
||||||
|
|||||||
@@ -127,6 +127,20 @@ public class VcnGatewayConnectionConnectedStateTest extends VcnGatewayConnection
|
|||||||
assertEquals(mGatewayConnection.mConnectedState, mGatewayConnection.getCurrentState());
|
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
|
@Test
|
||||||
public void testChildOpenedRegistersNetwork() throws Exception {
|
public void testChildOpenedRegistersNetwork() throws Exception {
|
||||||
// Verify scheduled but not canceled when entering ConnectedState
|
// Verify scheduled but not canceled when entering ConnectedState
|
||||||
|
|||||||
Reference in New Issue
Block a user