Commit Graph

11578 Commits

Author SHA1 Message Date
Treehugger Robot
333db9a5f0 Merge changes from topic "connectivitymanager-blockedreason-shim" am: bea56fbe11 am: 0cbabb7316
Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/1676430

Change-Id: I9f71c66d037a7e32b084951c01d46d9d01cc8f3a
2021-04-15 10:01:04 +00:00
Treehugger Robot
0cbabb7316 Merge changes from topic "connectivitymanager-blockedreason-shim" am: bea56fbe11
Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/1676430

Change-Id: I6d9dc4e6fd3fa832efbafa4893cc20dccfe3d7a3
2021-04-15 08:27:32 +00:00
Treehugger Robot
bea56fbe11 Merge changes from topic "connectivitymanager-blockedreason-shim"
* changes:
  Fix CtsNetTestCasesLatestSdk in AOSP.
  Use the non-API static UserHandle.getUid method in tests.
  Import ConnectivityManager.BLOCKED_REASON_* from ConstantsShim.
2021-04-15 07:30:24 +00:00
Lorenzo Colitti
ddeb269ca0 Fix CtsNetTestCasesLatestSdk in AOSP.
This test suite is broken in AOSP due to a number of tests that
depend on S APIs. We attempted to prevent those tests running on
R builds with:

@IgnoreUpTo(Build.VERSION_CODES.R)

but this is not sufficient for them to pass when the test is
compiled against the R SDK (e.g., in CtsNetTestCasesLatestSdk).
This is because when compiling against the R SDK, the test uses
the API 30 shims, which throw UnsupportedApiLevelException even
though the method actually exists on device.

Fix this using:

    assumeTrue(shouldTestSApis());

This is not great, but at least it unbreaks the tests for now.

Test: atest CtsNetTestCases:android.net.cts.ConnectivityManagerTest
Test: atest CtsNetTestCasesLatestSdk:android.net.cts.ConnectivityManagerTest
Change-Id: Ifee0aea5afef6bd4bc762a4b1f25fc05e562d49a
2021-04-15 13:30:02 +09:00
Lorenzo Colitti
7ba366de0b Use the non-API static UserHandle.getUid method in tests.
The code was updated in AOSP to use the new non-static
UserHandle#getUid(int), which is only available in S or above.
This fails to build in mainline-prod. Instead of defining a shim
for this, simply use an older method that takes a userId.

Bug: 165835257
Test: atest CtsNetTestCases:android.net.cts.ConnectivityManagerTest
Test: CtsNetTestCasesLatestSdk:android.net.cts.ConnectivityManagerTest
Change-Id: Id529f8b201cc871aa3155aef0f44574d88040c2d
2021-04-15 13:20:02 +09:00
Lorenzo Colitti
aa9db67edc Import ConnectivityManager.BLOCKED_REASON_* from ConstantsShim.
This is needed for the tests to compile in mainline-prod.

Bug: 165835257
Test: atest CtsNetTestCases:android.net.ConnectivityManagerTest
Change-Id: I32924824e9968996f379e31f1b28eb6a8f29bc5d
2021-04-15 10:25:46 +09:00
Lorenzo Colitti
fcdf0c2894 Merge "Test ConnectivityManager module-lib APIs for VPNs and blocking." am: f6875cc583 am: 682cb315ee
Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/1671528

Change-Id: Iaa2d6c4b497eba6a0340094294ba0c6f2ff74f04
2021-04-14 16:10:55 +00:00
Lorenzo Colitti
682cb315ee Merge "Test ConnectivityManager module-lib APIs for VPNs and blocking." am: f6875cc583
Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/1671528

Change-Id: I4d3f3c905fde3e9da08df5c3efa203fe570a2407
2021-04-14 15:29:03 +00:00
Lorenzo Colitti
f6875cc583 Merge "Test ConnectivityManager module-lib APIs for VPNs and blocking." 2021-04-14 14:46:29 +00:00
Remi NGUYEN VAN
237561ebdf Fix proguard rules for Struct in NetworkStack am: 9a82bbf368 am: 9aaeab539b
Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/1674688

Change-Id: I722885350e2514dbf7af5c58602e6b94bd876ff8
2021-04-14 05:45:19 +00:00
Remi NGUYEN VAN
9aaeab539b Fix proguard rules for Struct in NetworkStack am: 9a82bbf368
Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/1674688

Change-Id: I49cf42126e03c4fd449577bd1167dd74dec1b6a5
2021-04-14 05:03:26 +00:00
Remi NGUYEN VAN
9a82bbf368 Fix proguard rules for Struct in NetworkStack
All members of the Struct class need to be kept, not just the constructor.

Change-Id: I8705234eb2608c0dfe324c517b8885a93271b6c2
Test: m
2021-04-14 01:30:59 +00:00
Chiachang Wang
807d7f2e41 Merge "Update the method based on API feedback" am: 0a5d964242 am: 80a70a3679
Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/1671535

Change-Id: I13071221d470bd633ef8337889b803a388bcab05
2021-04-13 11:54:13 +00:00
Chiachang Wang
80a70a3679 Merge "Update the method based on API feedback" am: 0a5d964242
Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/1671535

Change-Id: I9d85af6567422f0b5a05173ba58593137cb1181d
2021-04-13 08:51:12 +00:00
Lorenzo Colitti
b84176e9f9 Test ConnectivityManager module-lib APIs for VPNs and blocking.
This CL adds tests for:
- ConnectivityManager#setsetLegacyLockdownVpnEnabled
- ConnectivityManager#setRequireVpnForUids
- NetworkCallback#onBlockedStatusChanged(Network, int)

Bug: 165835257
Test: atest CtsNetTestCases:android.net.cts.ConnectivityManagerTest
Change-Id: Ie9b73ec2a1634f3b3a3eb4d21acbe0803b77c70d
2021-04-13 17:30:49 +09:00
Chiachang Wang
0a5d964242 Merge "Update the method based on API feedback" 2021-04-13 08:15:47 +00:00
Lorenzo Colitti
ffc11490ca Fix a tethering crash when a 464xlat upstream disconnects. am: a329e8c984 am: dadc2fe3bb
Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/1671533

Change-Id: Ia7e17399aa5da6bbb84419ef2d840cf14ee70ea9
2021-04-12 16:15:17 +00:00
Lorenzo Colitti
dadc2fe3bb Fix a tethering crash when a 464xlat upstream disconnects. am: a329e8c984
Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/1671533

Change-Id: I985db044174ea0bb96c8ca588b380f0c11c0c48c
2021-04-12 15:32:50 +00:00
Lorenzo Colitti
a329e8c984 Fix a tethering crash when a 464xlat upstream disconnects.
When a 464xlat upstream disconnects, onLinkPropertiesChanged is
called after onLost. This breaks an UpstreamNetworkMonitor
assumption that no callback will ever arrive after onLost.

Bug: 173068192
Fix: 185117377
Test: new unit test
Change-Id: I4ff1eca6d5ed1680ff716c71b683891c8a0e5a77
2021-04-12 15:00:24 +00:00
Chiachang Wang
a31a9b6218 Update the method based on API feedback
UserHandle.getUid() is updated to a non-static API based on API
review feedback. Update the usage accordingly.

Bug: 184735865
Test: atest VpnTest
Change-Id: I884f427fae85b2b26973a0315b1ccf3d6f0824c6
2021-04-12 19:35:56 +08:00
Lorenzo Colitti
89d260c039 Merge changes from topic "peruidcallback-cts" am: 65bba3f6bc am: ab98c8119d
Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/1669609

Change-Id: Ifbd2f1615f9db9c499edc7d75d2bc3865043e1dc
2021-04-09 16:45:30 +00:00
Lorenzo Colitti
a8f8011851 Ensure the HostsideVpnTests passes with keyguard locked. am: fd3b95c1f7 am: 16d841048e
Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/1669608

Change-Id: I689f8a5e5028069753d377979eee14f97e611681
2021-04-09 16:45:29 +00:00
Lorenzo Colitti
97384c0121 Add CTS tests for registerDefaultNetworkCallbackAsUid. am: ed26ffe92d am: 6cbdc19b2c
Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/1669267

Change-Id: I6983acf968da429a0c036aa7e13a406f27ba7278
2021-04-09 16:45:27 +00:00
Lorenzo Colitti
ab98c8119d Merge changes from topic "peruidcallback-cts" am: 65bba3f6bc
Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/1669609

Change-Id: Ic9d3ef957feb979142d7b0adb3ec9525e432eb14
2021-04-09 15:59:16 +00:00
Lorenzo Colitti
16d841048e Ensure the HostsideVpnTests passes with keyguard locked. am: fd3b95c1f7
Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/1669608

Change-Id: Idabf4f50d54116d80dc349564bd9ab04cc7fd21a
2021-04-09 15:59:15 +00:00
Lorenzo Colitti
6cbdc19b2c Add CTS tests for registerDefaultNetworkCallbackAsUid. am: ed26ffe92d
Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/1669267

Change-Id: Id8d968130a52d419c65a628fb93e47e5ac48c81e
2021-04-09 15:59:13 +00:00
Lorenzo Colitti
65bba3f6bc Merge changes from topic "peruidcallback-cts"
* changes:
  Cleanups to VPN hostside tests.
  Ensure the HostsideVpnTests passes with keyguard locked.
  Add CTS tests for registerDefaultNetworkCallbackAsUid.
2021-04-09 15:16:47 +00:00
junyulai
2ece9db0de Fix NetworkCallback expecting wrong network am: 2e74377464 am: cfd7518bdc
Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/1657299

Change-Id: I9f14fae14fcb7ed5b2e63b067e8ea14404b484a2
2021-04-09 09:38:26 +00:00
junyulai
cfd7518bdc Fix NetworkCallback expecting wrong network am: 2e74377464
Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/1657299

Change-Id: Ia3e24d519ab7101e9cd1be7ec18f1ba7f7fff7e9
2021-04-09 08:53:47 +00:00
junyulai
2e74377464 Fix NetworkCallback expecting wrong network
By current wifi design, wifi will report disconnected and
re-connected when changing from non-metered to metered.
However, the cts test app listens for all network, which
will get mobile network as active network when wifi is
changing meteredness. This is not expected. And causes
test failures when DUT has both wifi and mobile connections.

Thus, this change pass request to track currently active
network to the test app and register only for transport
types of currently active network to prevent from getting
unexpected network.

Test: atest CtsHostsideNetworkTests:com.android.cts.net.HostsideNetworkCallbackTests
Bug: 182516128
Merged-In: I2dce6035b13472bbdc2609009d690aac96280033
Change-Id: I2dce6035b13472bbdc2609009d690aac96280033
  (cherry-picked from ag/14029457)
2021-04-09 10:16:18 +08:00
Nucca Chen
79206b9906 Merge "[NFCT.TETHER.11] Test TetherOffloadRule{Add, Remove} and set limit for IPv4" am: 68f6f5fe79 am: f0b3bb6e4e
Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/1563332

Change-Id: I44483470e1213716874dcdb07317f3ddb4c72b9d
2021-04-08 13:30:26 +00:00
Lorenzo Colitti
08b33ff7fb Cleanups to VPN hostside tests.
Use TestableNetworkCallback instead of a hand-rolled class.
Remove unnecessary runWithShellPermissionIdentity around
unregisterNetworkCallback calls.

Bug: 165835257
Test: test-only change
Change-Id: I4557dfc64136f9c0b4bdaa1248c33b13e96ba3ed
2021-04-08 22:09:10 +09:00
Lorenzo Colitti
fd3b95c1f7 Ensure the HostsideVpnTests passes with keyguard locked.
The test app used in CtsHostsideNetworkTests already dismisses
the keyguard for its own activity, but that doesn't work for the
VPN tests. This is because as soon as the VPN dialog appears, the
test activity is no longer in the foreground and the keyguard
comes back. As a result, the test cannot click on the VPN dialog.

Test: test-only change
Change-Id: I7be1d7fb46a2f9547bc5325d75b5bd5546e6dc18
2021-04-08 21:50:15 +09:00
Nucca Chen
f0b3bb6e4e Merge "[NFCT.TETHER.11] Test TetherOffloadRule{Add, Remove} and set limit for IPv4" am: 68f6f5fe79
Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/1563332

Change-Id: Id5f0d10b07b8fde23d627eaa7058b38512591f98
2021-04-08 12:46:23 +00:00
Lorenzo Colitti
ed26ffe92d Add CTS tests for registerDefaultNetworkCallbackAsUid.
Bug: 165835257
Test: test-only change
Change-Id: Ib3266665735ee587f3f8ae82dadd1e4ca7ce4353
2021-04-08 21:44:30 +09:00
Nucca Chen
68f6f5fe79 Merge "[NFCT.TETHER.11] Test TetherOffloadRule{Add, Remove} and set limit for IPv4" 2021-04-08 12:02:15 +00:00
Xiao Ma
d39b5b9888 Apply IPv6 utils struct stuff to build RA packet in the Daemon. am: 3e557d777a am: 7f8ae5c99d
Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/1614996

Change-Id: I640b6995bad3fb111bb4bd3e1b2194dac6aea101
2021-04-08 06:35:33 +00:00
Xiao Ma
7f8ae5c99d Apply IPv6 utils struct stuff to build RA packet in the Daemon. am: 3e557d777a
Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/1614996

Change-Id: Id6b170c8743ba3c7449183c9694cce54f0bdf1bf
2021-04-08 05:51:56 +00:00
Treehugger Robot
b8aa244e11 Merge "Improve RouterAdvertisementDaemonTest." am: 662237f2f8 am: 3b2ad2b764
Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/1669025

Change-Id: Ica070f535e0599b7729469a518ff550d273fc77a
2021-04-08 05:07:44 +00:00
Xiao Ma
3e557d777a Apply IPv6 utils struct stuff to build RA packet in the Daemon.
Traffic log of testSolicitRouterAdvertisement:
fe80::4473:4aff:fecb:7799 > ff02::1: ICMP6, router advertisement, length 88
fe80::1122:3344:5566:7788 > ff02::1: ICMP6, router solicitation, length 16
fe80::4473:4aff:fecb:7799 > fe80::1122:3344:5566:7788: ICMP6, router advertisement, length 88

Bug: 154669942
Test: atest TetheringPrivilegedTests --iterations
Change-Id: I7defb80ef9dd1832c9e04d154e1d06aed9e733dc
2021-04-08 04:50:49 +00:00
Treehugger Robot
3b2ad2b764 Merge "Improve RouterAdvertisementDaemonTest." am: 662237f2f8
Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/1669025

Change-Id: I9e9bb95e095fa1b8d907d56cc0e347746ae9a01c
2021-04-08 04:45:41 +00:00
Treehugger Robot
662237f2f8 Merge "Improve RouterAdvertisementDaemonTest." 2021-04-08 04:07:14 +00:00
Xiao Ma
597d253f18 Improve RouterAdvertisementDaemonTest.
Add separate testing for unicast and multicast RAs.
Make the test more realistic by:
- Enabling forwarding. This ensures that the daemon actually
  receives the RS.
- Adding a link-local route. This ensures that the daemon is
  actually able to send a unicast response.

Bug: 154669942
Test: atest TetheringPrivilegedTests
Change-Id: Ibb1f51b5b1871657d7feff39335d3c71586cf64f
2021-04-08 11:02:02 +09:00
Nucca Chen
8841c53701 Merge changes I515be275,Ied159454,I5a29bdd1 am: 8ba40704f3 am: 7cc20e1782
Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/1662791

Change-Id: Iecd18825990c22add32cdbb16b8ff86a8a06487c
2021-04-07 15:31:05 +00:00
Nucca Chen
7cc20e1782 Merge changes I515be275,Ied159454,I5a29bdd1 am: 8ba40704f3
Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/1662791

Change-Id: I220f3384baa2414dc7aad6e5754b59e6d3592bdc
2021-04-07 14:48:57 +00:00
Nucca Chen
8ba40704f3 Merge changes I515be275,Ied159454,I5a29bdd1
* changes:
  bpf_progs - adjust for dstMac addition
  Populate the key destination mac address
  Set the limit whenever any IPv4 or IPv6 rule exists.
2021-04-07 14:08:37 +00:00
Maciej Żenczykowski
4cfddb344c bpf offload - make sure bpf code can access packet headers am: 8e69ec111f am: 3129be7a3b
Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/1622559

Change-Id: I1e269e775a06d62ab1e106ed8c39d98d01c74e39
2021-04-07 02:00:06 +00:00
Maciej Żenczykowski
3129be7a3b bpf offload - make sure bpf code can access packet headers am: 8e69ec111f
Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/1622559

Change-Id: I303cd63ee424c8c4ef1c744e1893c06a5d53f50a
2021-04-07 01:19:05 +00:00
Maciej Żenczykowski
8e69ec111f bpf offload - make sure bpf code can access packet headers
If a tc ebpf program writes into a packet using direct packet access
then the packet will automatically be uncloned and pulled by
additional prologue inserted by the kernel itself.  See
tc_cls_act_prologue() & bpf_unclone_prologue() in kernel sources
(this is how the clat ebpf program works, which does DPA writes).

However in the forwarding programs we only *read* from the packets
using direct packet access, but never write.  All writes happen via
kernel bpf helpers (this is mostly an implementation detail: since
we need to use helpers for checksum updates, I decided to also use
checksums for the writes themselves).  As such the insert 'automatic
unclone/pull' logic doesn't trigger.

It is thus possible (it depends on the skb layout delivered by the
nic driver) for 0 bytes of the packet to be accessible for read
using direct packet access.  We thus need to explicitly try to pull
in the header of the packet so that we can inspect it.

In most cases (on most drivers for most packet types) this will
end up being a no-op (because the headers will already be in
the linear portion of the skb).  But on some drivers for some
packet types it ends up mattering.

Test: TreeHugger, makes icmpv6 tether forwarding work on bramble
Signed-off-by: Maciej Żenczykowski <maze@google.com>
Change-Id: I4b07e57728ce544ffb908527ea11ecc315e5acec
2021-04-06 21:50:17 +00:00
Chiachang Wang
a8cf72829c Merge "Update tests for onNetworkCreated and onNetworkDestroyed" am: 7d0e27bd7c am: d212efd8b0
Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/1652210

Change-Id: I00a93b5bf8c44ab5b05f27dc7312f2d996e1b501
2021-04-06 12:35:39 +00:00