Clean up IKE SPI resources if Create IKE is interrupted
This CL ensures IKE SPI resources are released if IKE Session
is terminated after Create IKE for IKE INIT or Rekey is sent
and before any response is received.
Without this fix, this is how SPI resources will get leaked
before caught by a CloseGuard:
- IKE enters CreateIkeLocalIkeInit and allocates an SPI
for mLocalIkeSpiResource
- IkeSession#killSession or handleIkeFatalError is called;
IKE state machine quits
- mLocalIkeSpiResource still holds the SPI resource until
it is released by the CloseGuard
This will not be a problem for any functional code because it is
impossible to run out of IKE SPI values. However, for any tests
that are based on test-mode IKE and expect the IKE SPI to
always be a specific value, they may fail because the expected
SPI might be blocked by a previous test.
Bug: 357151634
Test: atest FrameworksIkeTests(new tests)
atest CtsIkeTestCases
Flag: EXEMPT low risk bug fix
(cherry picked from https://android-review.googlesource.com/q/commit:7a1df1c43b5b8985e1da3a248c0c5204b71e4401)
Merged-In: I9059236989667ade113f844145f5813826cebf6a
Change-Id: I9059236989667ade113f844145f5813826cebf6a
7 files changed