summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorLorenzo Colitti <lorenzo@google.com>2020-05-04 13:27:37 +0900
committerLorenzo Colitti <lorenzo@google.com>2020-05-04 13:39:20 +0900
commitcf37ca43cbb6c7fe37f7854a26eb02c260598575 (patch)
tree466c11bc59d01cbeb0add8a0d8b9e6e52416868e /tests
parenta47091526a93be34808727b5897c948dfaf5884c (diff)
Don't crash if the PREF64 expires when IpClient is stopped.
Currently the code does not cancel the PREF64 alarm when IpClient is stopped. If the alarm fires when IpClient has disconnected, it will call updatePref64 with a null prefix, which will crash. Ensure that the alarm is cancelled when IpClient is stopped. Bug: 153694684 Bug: 155559286 Test: new unit tests Change-Id: I397eb36c1a8ecf1324de33e720577fe2e4e07056
Diffstat (limited to 'tests')
-rw-r--r--tests/integration/src/android/net/ip/IpClientIntegrationTest.java19
1 files changed, 19 insertions, 0 deletions
diff --git a/tests/integration/src/android/net/ip/IpClientIntegrationTest.java b/tests/integration/src/android/net/ip/IpClientIntegrationTest.java
index 225f598..4a3f445 100644
--- a/tests/integration/src/android/net/ip/IpClientIntegrationTest.java
+++ b/tests/integration/src/android/net/ip/IpClientIntegrationTest.java
@@ -1527,6 +1527,25 @@ public class IpClientIntegrationTest {
mIpc.getHandler().post(() -> lastAlarm.onAlarm());
expectAlarmCancelled(inOrder, pref64Alarm);
expectNat64PrefixUpdate(inOrder, null);
+
+ // Re-announce the prefix.
+ pref64 = new StructNdOptPref64(prefix, 600).toByteBuffer();
+ ra = buildRaPacket(pio, rdnss, pref64);
+ mPacketReader.sendResponse(ra);
+ final OnAlarmListener clearAlarm = expectAlarmSet(inOrder, "PREF64", 600);
+ expectNat64PrefixUpdate(inOrder, prefix);
+ reset(mCb, mAlarm);
+
+ // Check that the alarm is cancelled when IpClient is stopped.
+ mIpc.stop();
+ HandlerUtilsKt.waitForIdle(mIpc.getHandler(), TEST_TIMEOUT_MS);
+ expectAlarmCancelled(inOrder, clearAlarm);
+ expectNat64PrefixUpdate(inOrder, null);
+
+ // Check that even if the alarm was already in the message queue while it was cancelled, it
+ // is safely ignored.
+ mIpc.getHandler().post(() -> clearAlarm.onAlarm());
+ HandlerUtilsKt.waitForIdle(mIpc.getHandler(), TEST_TIMEOUT_MS);
}
private void addIpAddressAndWaitForIt(final String iface) throws Exception {