summaryrefslogtreecommitdiff
path: root/tests/net/java/com/android/server/IpSecServiceParameterizedTest.java
AgeCommit message (Collapse)Author
2021-05-13Move net unit tests to packages/ConnectivityRemi NGUYEN VAN
Move the tests together with packages/Connectivity code, so both can be moved to packages/modules/Connectivity together. Also reorganize unit tests in a unit/ directory, as other tests (integration/, common/ etc.) have been added in tests/net since they were created. This makes the directory structure consistent. Test: atest FrameworksNetTests Bug: 187814163 Ignore-AOSP-First: needs per-branch move for merge conflicts Change-Id: I254ffd1c08ec058d594b4ea55cbae5505f8497cc
2021-05-07Add internal support for IPsec forward policiesBenedict Wong
This change adds support for IPsec forward policies, which are necessary for packets to be allowed to be forwarded to another interface, as is the case with tethering. This is necessary and useful only within the system server, and as such is not exposed as a public API. This change is safe, since the addition of a FWD policy on IPsec tunnel interfaces will by default block forwarded traffic (as would be the case without this patch). In the event that the (system) owner of the tunnel requires support for forwarded packets (eg tethering), this patch allows application of transforms in the FWD direction as well. This will be used to ensure that the VCN can be used as the underlying network for the purposes of tethering. Bug: 185495453 Test: atest IpSecServiceTest Test: atest IpSecServiceParameterizedTest Test: manual testing with tethering over VCN Change-Id: I74ecea71f1954029f6fbdbe34598c82e0aac386b
2021-02-22Merge changes I852e3a53,I86755647,I0ed8b0c6Lucas Lin
* changes: Remove unused INetworkManagementService from IpSecService Use NetdUtils instead of NetworkManagementService in Vpn Use NetdUtils instead of NetworkManagementService in IpSecService
2021-02-10Update underlying network of IpSecTunnelInterfaceYan Yan
Bug: 169855650 Test: atest IpSecManagerTunnelTest Change-Id: I6d1b8d0e49f89c67ddc2caf4ba63fb0b1eb062c0
2021-02-08Remove unused INetworkManagementService from IpSecServicelucaslin
IpSecService is no longer using any methods of INetworkManagementService, so remove it from IpSecService and related files. Bug: 170598012 Test: atest FrameworksNetTests Change-Id: I852e3a534e0ffd26b4b22420754f3ec8a6f153ad
2021-02-08Use NetdUtils instead of NetworkManagementService in IpSecServicelucaslin
NetdUtils has the same method(e.g. setInterfaceUp) as NetworkManagementService so using the one inside NetdUtils instead and try to remove NetworkManagementService from IpSecService in the following commit. Bug: 170598012 Test: atest FrameworksNetTests Change-Id: I0ed8b0c678b067a655b51b938b6b40eadd985321
2020-12-06[Mainline Migration] Migrate NetworkUtilsSerik Beketayev
Migrating makeStrings(), numericToInetAddress() APIs Bug: 173089079 Test: atest FrameworksNetTests Change-Id: Ie914fd41bc3ce16d07f5d2768b89ce805b9245a9
2020-04-24Merge "Add tests for Tunnel, Transport mode application with released SPIs"Benedict Wong
2020-04-24Merge "Use TransformRecord to get SPI instead of SpiRecord"Benedict Wong
2020-03-11Add tests for Tunnel, Transport mode application with released SPIsBenedict Wong
This change adds tests to validate that both transport and tunnel mode transforms continue to work even after the SPI resource has been released. Specifically, since SPI resources are effectively subsumed by the creation of a Transform, the SPI resource is still "alive", but removed from the user-tracking sparse arrays. Bug: 142072071 Test: Added these new tests. Failing prior to aosp/1133555, passes with. Change-Id: I37dd459d08b57b14f72f3b28ea80fa231b152f10
2020-03-10Automatically set IPsec tunnel interface as upBenedict Wong
This change makes IPsec tunnel interfaces automatically get brought up once they are created. Originally this was considered to be an additional safety check, as they would not be start routing traffic until explicitly brought up. However, in the intervening time, the NetworkManagementController now requires the NETWORK_STACK permission to set an interface as up. Additionally, that call is a hidden API, and thus not usable for use cases such as IWLAN. Bug: 149348618 Test: FrameworksNetTests, CtsNetTestCases passing. Change-Id: I55b63a748463a388e1e2991d2d5d6b3023545e60
2019-10-18Use TransformRecord to get SPI instead of SpiRecordBenedict Wong
IpSecService.applyTunnelModeTransform() currently does not take an SpiRecord instance, yet implicitly requires that the SpiRecord instance is still alive based on the stored SpiRecord resourceId in the TransformRecord's IpSecConfig. This check is unnecessary, as the SpiRecord has been subsumed into the TransformRecord, and the kernel resources are kept alive whether or not the SpiRecord is still held by the user. This allows users of the IpSecManager API to allocate short-lived SPIs during the creation of an IpSecTransform, without having to keep track of both of them (even though the SPI is no longer usable). The TransformRecord.getSpiRecord() call is already used in multiple other places in the same method. Bug: 142072071 Test: New tests added, passing. Change-Id: I1959f3080946267243564459ff4207647922566e
2019-05-08Add IPsec checks for IPSEC_TUNNEL featureBenedict Wong
This patch adds checks to ensure that the IPSEC_TUNNEL feature flag is enabled. Bug: 117183273 Test: Compiles & tests passing Change-Id: I2699dda29e1eed139bc6fd1b70071e5ab33cad88
2019-03-05Migrate frameworks/base/tests/net/ to androidx.testBrett Chabot
Test: atest FrameworksNetTests Change-Id: Iaa59d606f5e1678cc5aaca9ed37e184fad894e5d
2019-01-18Merge "Avoid calling ParcelFileDescriptor.fromSocket on new Sockets."Josh Gao
2018-11-28Use ParcelFileDescriptor instead of FileDescriptor in INetd.aidlLuke Huang
Stable aidl won't support FileDescriptor but ParcelFileDescriptor. In order to migrate to stable aidl, replace all FileDescriptor in INdetd.aidl. Test: runtest frameworks-net passes Change-Id: Icdf37aed0e0cce0352070a437066e77c0f2fd85a
2018-11-21Add XFRM-I support to IpSecServiceBenedict Wong
This change adds support for XFRM-I to all IpSecService netd calls. Fallback logic is in netd, and thus both VTI and XFRM-I parameters are always passed down to IpSecService. Bug: 78589502 Test: All java, CTS tests passing Change-Id: Ie4186f0ad7e50763b21831f6fa411b5ee436de78
2018-11-09Avoid calling ParcelFileDescriptor.fromSocket on new Sockets.Josh Gao
Previously, we were calling ParcelFileDescriptor.fromSocket on a newly initialized Socket, which doesn't actually create a file descriptor until the Socket is bound or connected. Bind the Socket to a random port to force the file descriptor to be allocated. Test: treehugger Change-Id: Id92a3e1316881d1c5382485aa2d6a41fc37e9651
2018-10-04Check to ensure UDP-encap is used only for IPv4evitayan
This commit checks if UDP-encapsulation is used for unsupported address family and throws IllegalArgumentException when it happens. Bug: 74213459 Test: Tests added in testCreateTransportModeTransformWithEncap and testCreateTunnelModeTransformWithEncap. Command: runtest frameworks-net Verified on taimen. Change-Id: I10c01f2bad6aca23430849ea9ef6c1eb157ae131
2018-10-04Add UDP encapsulation tests for IpSecService.evitayan
This commit adds tests to ensure that IpSecService properly handles UDP-encapsulation transforms correctly. Bug: 76110065 Test: Added: testCreateTransportModeTransformWithEncap, testCreateTunnelModeTransformWithEncap. Command: runtest frameworks-net Verified on taimen. Change-Id: Ie05bc5354266806c2d03b0b3d73a4696a89eccf2
2018-09-04Use UID as requestIDBenedict Wong
This change makes all requestIDs use the UID of the creator, ensuring that rekeys always use the same requestID. This also has the nice property of separating app's resources from each other, and allowing for identification of which app/UID allocated the resources from command-line dumps (eg ip xfrm state show) Bug: 111841561 Test: Updated tests & passing taimen Change-Id: I4f1eadcdb795766ae4682b15e41727359c52fa38
2018-06-07Disable the AppOp Restriction for IpSec TunnelsNathan Harold
This CL temporarily removes the AppOp restriction that disallows creation of IpSec tunnels due to the lack of the appropriate AppOp in AOSP/master. When the relevant framework merges out to master, this CL should be reverted. Bug: none Test: compilation Change-Id: Ic06c193f85f6bcdd0ead4238825c1add78703cde
2018-06-07Add AppOps Checks for MANAGE_IPSEC_TUNNELSNathan Harold
Adds support for a new AppOp to permit services to use IpSec tunnel mode. The IpSecService now needs a context so change the service mode to a cached service rather than a static service. Bug: 66955045 Test: runtest frameworks-net Merged-In: I17a4a286225b432c3e15ea1587d946189931b4f4 Change-Id: I17a4a286225b432c3e15ea1587d946189931b4f4 (cherry picked from commit 592dadbd43fcb7c5d67e737adb34d07923da90c4)
2018-03-20Check mOwnedByTransform to avoid DELSA on SPINathan Harold
The owned by transform flag prevents the removal of an SPI from accidentally deleting an associated SA in the kernel. That flag wasn't actually being checked, so deleting an SPI would result in the transform being removed. The existing code already guarantees that the SA is deleted when the transform is deleted Bug: 73258845 Test: runtest frameworks-net Change-Id: I4c26aea7af817a5d9e54da5db1cdf4f943bcae06
2018-03-16Added implementation for VTI add/remove addressBenedict Wong
This change adds implementation details for add/remove addresses onto a VTI. Bug: 73675031 Test: New tests added, passing on Walleye Change-Id: Idde9d943a5285d2c13c5c6b0f7b8a9faf718e6a5
2018-02-26Frameworks: Annotate JUnit4 test with @TestAndreas Gampe
Mollify Errorprone. Bug: 72076216 Test: m javac-check RUN_ERROR_PRONE=true Test: atest IpSecServiceParameterizedTest Change-Id: Ia3a253c4c5994937efc0f498ac047c5fb4eee3e9
2018-01-24Add tunnel-mode calls to netd in IpSecServiceBenedict Wong
Adds calls to relevant netd methods in IpSecService, enabling Tunnel mode functionality. Bug: 63588681 Test: Compiles, passing CTS + unit tests Change-Id: I6deb68584cddb03f21bd76370d4ef69cadc1bf16
2018-01-24Merge "Add xfrm mark in IpSecConfig"Benedict Wong
2018-01-22Add checks to ensure SPIs are not reusedBenedict Wong
This change adds an additional check in CheckIpsecConfig to prevent users from using the same SPI twice. This allows for a more granular error message. Bug: 70642141 Test: Tests added in IpSecServiceParameterizedTest Change-Id: I9621fb05c6b162bd8ae8db4ac1e64feaa9d0ac73
2018-01-19Rename create/delete transform methodsBenedict Wong
CreateTransportModeTransform and DeleteTransportModeTransform are both agnostic as far as which mode of transform it creates/deletes. As such, to facilitate the implementation of tunnel mode, this patch renames them to CreateTransform and DeleteTransform, along with all test names. Bug: 63588681 Test: frameworks/base unit tests and CTS tests run, passed Change-Id: I1f015eb7ad0e85fca966658a9402485ca2b44091
2018-01-18Add xfrm mark in IpSecConfigDi Lu
Bug: 63589600 Test: runtest frameworks-net Change-Id: I2d38d781b8b31d8bf39fd4e9a7e31509f15a9e16
2018-01-17IpSec - API Tweak for removeTransportModeTransformNathan Harold
Because IpSecTransforms are now unidirectional, and because the only mechanism for removing Transforms removes it from both directions, the API can no longer use the Transform parameter to meaningfully validate that the caller had applied a transform. Since that functionality was as-yet unimplemented and is now infeasible, the transform parameter is removed. Bug: 72079356 Test: cts - IpSecManagerTest; runtest frameworks-net Change-Id: If19b0d34bdc6daf31a40d6d62bff326dcbca08c0
2018-01-16Update IpSecService UnitTestsNathan Harold
The IpSecService Unit tests relied on the directionality of the IpSecConfig and previously did not specify a source address. Unit tests updated without functional change other than to address these two requirements. Bug: 71717213 Test: runtest frameworks-net Change-Id: Iedbed735bc50fd4fdfe985f9e173956062a7b0d1
2018-01-16Make Transforms UnidirectionalNathan Harold
Convert the IpSecTransform from being a bi-directional pair of SAs to a unidirectional single SA. This CL also removes the concept of "direction from SAs meaning that a IpSecTransform may now be applied to a socket in either direction. -Make transforms unidirectional -Add Convert allocateSpi() to use destination rather than direction and remote address -Remove directionality from builders for IpSecTransform -Change applyTransportModeTransform() to take a direction in which to apply the transform object. -Additional minor naming updates -Restrict IpSecConfig to only print keys on eng builds -Move DIRECTION constants to IpSecManager -Add sourceAddress parameter to IpSecTransform to provide additional guarantees about the source address of data; (explicit failure rather than implicit failure). -Move SPI to the build() method of IpSecTransform Bug: 71717213 Test: runtest frameworks-net, CTS - IpSecManagerTest Change-Id: I0824b37f443f4b8c62536d9801238c63ed8f2a1c
2018-01-04Add validation to IpSecConfig algorithm settersBenedict Wong
Adds checks to ensure that users can only set the correct types of algorithms for the Authentication, Encryption and Authenticated Encryption algorithms. Bug: 65223935 Test: Added tests in IpSecConfigTest, and passed on aosp_marlin-eng Change-Id: I462c77d9eb5710b8d03a48866453649d3b6fc6bf
2017-12-14Fix broken test due to API renameNathan Harold
A race condition during an Api rename has caused the name change from reserveSecurityParameterIndex to allocateSecurityParameterIndex to be wrong in a test. Fixing. Bug: 69128142 Test: runtest frameworks-net Change-Id: I12fb9832cb938dc19f463b1f1124127435d7b173
2017-12-14Merge "Use consistent naming for allocating SPI."nharold
2017-12-13Convert IpSecService resources to use refcountingBenedict Wong
This is part 2 of 2 of the refcounting refactor for IpSecService resources. Switched ManagedResources to use RefcountedResource structure for managing reference counts and eventual cleanup. Further, resource arrays and quota management have been aggregated into a UserRecord for better isolation. UID access checking has been similarly moved into the UserRecordTracker, and resourceId checking has been rolled into RefcountedResourceArray's accessor methods. Bug: 63409385 Test: CTS, all unit tests run on aosp_marlin-eng, new tests added Change-Id: Iee52dd1c9d2583bb6bfaf65be87569e9d50a5b63
2017-12-12Use consistent naming for allocating SPI.Jonathan Basseri
Throughout the IPsec code (API, system server, netd) we use "reserve" SPI and "allocate" SPI interchangeably. This renames to use "allocate" everywhere for self-consistency and consistency with the kernel (ALLOCSPI). In javadoc, I am leaving the word "reserve" in several places because it is still an accurate description of how the method behaves. Bug: 69128142 Test: TreeHugger should be enough Change-Id: I8ea603b4612303b0393beef04032671fa53d2106
2017-11-07Update documentation for AES-GCM-ESP keymat lengthBenedict Wong
Added notes that keymat length must include 32 bits of salt. Bug: 68672051 Test: Frameworks-net unit tests & IpSecManager CTS tests run Change-Id: I0ae0c5be8a45b2374783b3bd1fa8bf930f15e687
2017-10-26Fixed NullPointerException in IpSecService-Netd binder layerManoj Boopathi Raj
Replaced null with empty byte array in createTransportModeTransform for null auth.getKey, crypt.getKey() and authCrypt.getKey() Test: Ran CTS test Bug: 68052730 Change-Id: I5110b1297b4bfbb5766e8ecfd3d64f8110b52945
2017-10-18Add support for AES-GCM-ESP as an IPSec algorithmBenedict Wong
Allows native AES-GCM-ESP to be used as an IPSec transport/tunnel mode algorithm with kernel support Bug: 63589918 Test: IPsecService tests added, existing ones pass Change-Id: Ie1a9a902be205f269aa37bf956198f2e5b177c21
2017-10-03Split IpSecServiceTest to add IPv6 TestsNathan Harold
-Split IpSecServiceTest into parameterized and single tests. -Add IPv6 parameters Bug: 66954381 Test: this Change-Id: Ib98c112560014f73bccc3d2842c31d297c7a07ef