Commit Graph

19 Commits

Author SHA1 Message Date
Yan Yan
69eb8325c0 Revert "Support getting transform state in IpSecService"
This reverts commit ab5006c17d.

Reason for revert: b/316010034 breaking VCN unit tests

Change-Id: I68cb1a99bb6e492c16901972d201761cd00df6fa
2023-12-12 21:53:46 +00:00
Yan Yan
ab5006c17d Support getting transform state in IpSecService
Bug: 308011229
Test: IpSecServiceParameterizedTest (new tests)
Change-Id: I3f1c2ef60ee9b6ac17909e0ee083ee6f8483588e
2023-12-12 00:14:13 +00:00
Maciej Żenczykowski
c95f0d8abf Merge "fix argument to CloseGuard.open()" 2023-01-13 12:12:20 +00:00
Yan Yan
19aa23db7e Merge "Expose APIs to migrate IpSecTransform" 2023-01-11 18:52:59 +00:00
Yan Yan
81c2160a63 Expose APIs to migrate IpSecTransform
This commit exposes APIs to migrate a tunnel mode transform to
new source/destination addresses, as required by MOBIKE.

By calling the exposed API, the caller only caches the new
address in the transform. To complete the migration, caller
MUST apply the tranform to the appropriate tunnel.

This API design is mainly based on the kernel interface and use
cases. The Linux kernel requires Android to provide both the
IpSecTransform and the IpSecTunnelInterface to perform the
migration. And in most cases those two instances are managed
by different entities: IpSecTranform is managed by the key
exchange protocol (e.g. IKE) and IpSecTunnelInterface is managed by
the security tunnel provider (e.g. VPN, VCN, and IWLAN). Thus the
migration process has been designed to have two steps where the
key exchange protocol negotiates and caches the new address,
passes out the updated transform, and the security tunnel
provider applies the transform to a tunnel.

Another benefit of this API is it can also apply to the case
where the network peer does not support MOBIKE and thus cannot
update the existing transforms. In this case, the key exchange
protocol can create a new transform and give it to the security
tunnel provider, and the tunnel provider can still call "apply"
to perform migration without needing to know the details of the
transform update process.

Bug: 169171001
Test: atest FrameworksNetTests, IpSecManagerTunnelTest
Change-Id: I0658cdb09fb31f7e0fb9d0b07f37c2b72b6e705f
2023-01-10 19:09:05 +00:00
Maciej Żenczykowski
401122894d fix argument to CloseGuard.open()
Based on documentation, String parameter to CloseGuard.open() should be the name of the method to close the resource (in this case Resource.close()).

As currently written, the debug output from warnIfOpen() will be "Resource failed to call constructor."

Bug: 131838407
Test: TreeHugger
Signed-off-by: Maciej Żenczykowski <maze@google.com>
Change-Id: I25f005a7944bf3995ae6dc4c021ed1034f2187dd
2023-01-07 10:03:47 +00:00
Maciej Żenczykowski
223b5cc371 fix argument to CloseGuard.open()
Based on documentation, String parameter to CloseGuard.open() should be the name of the method to close the resource (in this case Resource.close()).

As currently written, the debug output from warnIfOpen() will be "Resource failed to call constructor."

Bug: 131838407
Test: TreeHugger
Signed-off-by: Maciej Żenczykowski <maze@google.com>
Change-Id: I9b8a71f9076712014bb883bbde5e5fbdb018b2d5
2023-01-07 01:00:18 +00:00
Yan Yan
a48dcd9d1f Require IPSEC_TUNNEL_MIGRATION feature flag to migrate transforms
Bug: 169169973
Test: atest IpSecServiceParameterizedTest (new tests added)
Change-Id: I3dd45b29163cd1e0cdbef08cb8aabdb629cf73bc
2022-12-21 23:12:48 +00:00
Yan Yan
e114b38f07 Support IPsec transform migration
This commit adds methods to support migrating tunnel mode
IpSecTransform to new source/destination addresses.

Bug: 169171001
Test: atest FrameworksNetTests (new tests added)
Change-Id: Ic177015fba5b62d3f73009633118109d3631086f
2022-12-21 23:12:35 +00:00
Yan Yan
be3eb3d56a Throw IAE when Network's LinkProperties is null
Improve the setUnderlyingNetwork method by throwing IAE
when Network's LinkProperties is null. Also update the
API doc to give caller more guidance in using this API

Bug: 232309601
Test: UT: IpSecServiceParameterizedTest, IpSecServiceTest,
      IpSecServiceRefcountedResourceTest, IpSecManagerTest, VpnTest
Test: CTS: IpSecManagerTest, IpSecManagerTunnelTest, Ikev2VpnTest
Test: make doc-comment-check-docs
Change-Id: Idab4706b0db42ed2222fb48b168589ed005d2f2f
2022-05-20 17:03:07 -07:00
Yan Yan
98a3a0381f Un-finalize IpSecManager
Allows VCN and IKE unit tests to mock IpSecManager and thus stop
depending on the hidden APIs in the Connectivity module
(e.g. IpSecService binder interface). Otherwise, any changes on
these related hidden APIs will require topic changes across multiple
projects.

Bug: 217572993
Test: make update-api
Test: atest IpSecManagerTest, IpSecManagerTunnelTest
Change-Id: I29f3ac96f83b4271f29a7051d33ccf47a0dd6c57
Merged-In: I29f3ac96f83b4271f29a7051d33ccf47a0dd6c57
2022-02-09 03:32:54 +00:00
Treehugger Robot
41fe9f7e31 Merge "Remove ServiceManager usage from IpSecTransform" 2022-01-19 07:59:56 +00:00
Aaron Huang
ca9c1df504 Add PolicyDirection InfDef annotation to IpSecManager
IpSec is going to be moved into Connectivity module and it needs to
use PolicyDirection annotation. Add PolicyDirection IntDef annotation
so that it can be used in the module.

Bug: 204153604
Test: FrameworksNetTests
Change-Id: Ib411d8c436d67574bfaf7f3aba43e5f31e7487e2
2022-01-13 10:43:54 +08:00
Aaron Huang
80a73fd6cc Remove ServiceManager usage from IpSecTransform
Remove ServiceManager hidden API dependency because this class
is going to be moved into mainline module. Thus have IpSecTransform
calls createTransform and deleteTransform through IpSecManager to
remove the ServiceManager usage.

Bug: 204153604
Test: FrameworksNetTests
Change-Id: Iba48da4aecac1080684d5a7e7e7ca2e31219591a
2021-12-28 02:59:26 +08:00
Treehugger Robot
dae874959a Merge "Replace Preconditions.checkNotNull with Objects.requireNonNull" 2021-12-22 11:37:42 +00:00
Aaron Huang
49eef6f7e1 Replace Preconditions.checkNotNull with Objects.requireNonNull
IpSec service is going to be moved into Connectivity module. Replace
Preconditions.checkNotNull with Objects.requireNonNull to remove
hidden API usages.

Bug: 204153604
Test: FrameworksNetTests
Change-Id: Iff7f76844d4126b0e17b62b4ce821449b5b6ce44
2021-12-22 16:35:13 +08:00
Aaron Huang
4989e95a08 Make IpSecManager.DIRECTION_FWD @SystemApi
IpSecManager.DIRECTION_FWD is used by VcnGatewayConnection and
it will be not visible to platform after IpSec was moved into
Connectivity mainline module. Therefore, make DIRECTION_FWD
@SystemApi so that it can be used by VcnGatewayConnection.

Bug: 204153604
Test: FrameworksNetTests
Change-Id: I80dc2a5b4940504820cee0d8e2d2e59ef3fcca18
2021-12-19 02:44:24 +08:00
Aaron Huang
fbae308e6a Fix style errors for IpSec associated files
Bug: 204153604
Test: build pass.
Change-Id: I940de8bef7f693dcce8808148a975bea1f36712c
2021-12-14 14:36:59 +08:00
Aaron Huang
9a708a4a19 Move IpSec associated files to f/b/packages/ConnectivityT
IpSecService is going to be moved into Connectivity mainline module.
Move all ipsec associated files to packages/ConnectivityT so that
it can be easily migrate these files to connectivity module after
clearing the hidden API usages.

Bug: 204153604
Test: build pass
      FrameworksNetTests
      CtsNetTestCases
Change-Id: I562b47f18e345988a2638cf886f86818f9144b91
2021-12-14 14:06:44 +08:00