Commit Graph

43869 Commits

Author SHA1 Message Date
Lorenzo Colitti
38bbdbd1aa Fix a couple of JavaDoc errors in NetworkAgentInfo.
These don't break compilation because NetworkAgentInfo doesn't
expose any APIs and thus doesn't generate javadoc, but they
are flagged by the IDE.

Test: treehugger
Change-Id: I2b63c24b2afbc98950f53c38f80d27474aab0622
2022-02-22 16:39:44 +09:00
Lorenzo Colitti
8c7a8860f9 Add an IS_DESTROYED flag to FullScore.
This is being added as the lowest priority score factor, just
above the tie-breakers. It ensures that a network that has been
destroyed will lose to another identical network that has not
been destroyed, but will otherwise be scored identically.

The flag is a CS-managed flag that is stored in NetworkAgentInfo.
Currently it is always false, but it will be populated in
future CLs.

Bug: 216567577
Test: atest FrameworksNetTests
Change-Id: Ib1cd342ab7dfc4df45715da19b743d711fe8d605
2022-02-22 16:39:44 +09:00
Lorenzo Colitti
c6d3f3cf25 Use MessageUtils instead of hardcoded strings in policyNameOf.
This makes the code easier to maintain because we do not need to
manually add string representations, and because it will throw at
static initialization time if the clas contains duplicate
POLICY_xxx values. The memory overhead is likely negligible.

Bug: 216567577
Test: new coverage in FullScoreTest
Change-Id: Iab23d414c8e28ff7f26060ad44fa996f277d361f
2022-02-19 19:45:43 +09:00
Lorenzo Colitti
0261ced634 Rename one of the two EVENT_NETWORK_TESTED messages.
Currently, there are two EVENT_NETWORK_TESTED message types in
ConnectivityService. One is used by the ConnectivityService
handler to process validation results, and one is used by
ConnectivityDiagnosticsHandler to send connectivity reports.

The two messages have different contents so it is confusing that
they have the same integer and the same name. Rename the second
one to CMD_SEND_CONNECTIVITY_REPORT.

Test: atest ConnectivityServiceTest
Test: atest CtsNetTestCases:android.net.cts.ConnectivityDiagnosticsManagerTest
Change-Id: I77d63dad477315e1fcc7225a5ef03aff2bed8c35
2022-02-19 02:24:02 +09:00
Lorenzo Colitti
dbb9280abc Merge "Don't check validation state in waitForAvailable(..., Network)." 2022-02-18 17:04:27 +00:00
Taras Antoshchuk
d42d1645cb Merge "Fix HostsideVpnTest#testExcludedRoutes" 2022-02-18 13:25:21 +00:00
Wayne Ma
5545291ef5 Address comment from aosp/1948169
Bug: 202086915
Test: m; flash; boot;
Change-Id: I9bd627cc4ec77e1ab6da3e3acc7d4d8bba7d43de
2022-02-18 14:18:06 +08:00
Maciej Żenczykowski
b194d551bf Merge "BpfBitmap Test" 2022-02-18 01:55:43 +00:00
Maciej Żenczykowski
bce8cbabbb Merge "Support "dumpsys connectivity trafficcontroller"" 2022-02-17 23:10:10 +00:00
Maciej Żenczykowski
83acb39c6c Merge "libclat: Remove redundant "using android::net::.*"" 2022-02-17 22:59:44 +00:00
Maciej Żenczykowski
c301b4412b Merge changes Iddd50583,I7e6e84ba,If5ade0c0
* changes:
  Improve logging when using ingress rate limits
  Allow test networks to be rate limited
  Fix rate limiting settings observer
2022-02-17 22:14:04 +00:00
Patrick Rohr
64592df482 Improve logging when using ingress rate limits
Add some happy path logging that informs about active rate limits.

Test: TreeHugger
Bug: 218840346
Change-Id: Iddd50583ca2e90afe83a5c68611418fa794afb3f
2022-02-17 18:28:58 +01:00
Patrick Rohr
ff3b3f8d96 Allow test networks to be rate limited
Test: atest FrameworksNetTests
Change-Id: I7e6e84baf446ecf4b395f6a611e625871745a20e
2022-02-17 18:28:58 +01:00
Patrick Rohr
cdac749eb0 Fix rate limiting settings observer
The obvserver accidentally observed Settings.Secure instad of
Settings.Global.

Test: atest CtsNetTestCases:RateLimitTest
Bug: 218840346
Change-Id: If5ade0c0e269c01b76428d5635d0913330d7015e
2022-02-17 18:28:58 +01:00
Treehugger Robot
e7eb8b156f Merge "Ensure all NetworkMonitor messages store the netId in arg2." 2022-02-17 17:26:19 +00:00
Yi Kong
9de79582a2 libclat: Remove redundant "using android::net::.*"
They are already under the same namespace.

Test: presubmit
Bug: 219872355
Change-Id: I5f51cf2c38755c99f220870c2ffe66ee8c454514
2022-02-17 16:36:13 +00:00
Lorenzo Colitti
d1b11dc70f Ensure all NetworkMonitor messages store the netId in arg2.
All NetworkMonitor messages contain the netId of the source
NetworkMonitor. But the netId is in various places in the
message. It's most frequently in arg2, but sometimes it's boxed
into an Integer in obj, and sometimes it's in another object.

Always pass the netId into arg2. This allows us to write
common code at the beginning of the function that extracts the
netId and nai, and performs common actions on all messages.

Bug: 216567577
Test: atest FrameworksNetTests FrameworksNetIntegrationTests
Test: atest CtsNetTestCases:ConnectivityManageTest
Test: atest CtsNetTestCases:NetworkAgentTest
Change-Id: Idbbe3cddfc5475a2d56df387f840439dc4c9514c
2022-02-18 00:28:01 +09:00
Remi NGUYEN VAN
3035f6c554 Merge "Cleanup and refine connectivity test config" 2022-02-17 09:45:39 +00:00
Lorenzo Colitti
d2bd9db36a Don't check validation state in waitForAvailable(..., Network).
The version of ConnectivityManagerTest#waitForAvailable that
takes a callback and a Network implicitly requires that the
network be validated, because it calls expectAvailableCallbacks
with validated=true.

This is incorrect because a network can become available without
being validated. In particular, testMobileDataPreferredUids is
flaky due to this problem, because it calls connectToCell, which
does not wait for validation, and then calls waitForAvailable,
which expects that the network is already validated.

Fix it by not requiring any particular validation state. This
method is only used by a few tests and they should not be
affected by this change:
- The first two calls in testSetOemNetworkPreferenceForTestPref
  happen after waiting for validation, so the network is
  validated already. The third call waits for a test network,
  and test networks are always validated.
- The first call in testSetOemNetworkPreferenceForTestOnlyPref
  waits for a test network, which is always validated. The
  second is incorrect because ensureWifiConnected does not
  wait for validation, and is fixed by this CL.
- The calls in testMobileDataPreferredUids similarly incorrectly
  assume that wifi is validated and are fixed by this CL.

Test: atest CtsNetTestCases:android.net.cts.ConnectivityManagerTest#testMobileDataPreferredUids
Change-Id: I614d0ba87c3931fcbe4011fed379e1736f5c4a44
2022-02-17 18:29:11 +09:00
Ken Chen
e6d511f785 Support "dumpsys connectivity trafficcontroller"
Enable ConnectivityService to dump BPF maps from libtraffic_controller.

Bug: 202086915
Test: adb shell dumpsys connectivity trafficcontroller
Test: atest CtsNetTestCases:ConnectivityManagerTest#testDumpBpfNetMaps
Test: run CTS in I021789813f116940d581e2c4a1fd357ff47bfa08
Change-Id: Ib0e935ee2b714ac61daceba6d13fa7a20f97f68f
2022-02-17 16:58:47 +08:00
Treehugger Robot
5a2f079722 Merge "DscpPolicyTest Check Kernel Version" 2022-02-17 07:15:11 +00:00
James Mattis
700774f34e Merge "CTS tests for EthernetNetworkSpecifier" 2022-02-17 03:10:36 +00:00
Nucca Chen
dc62c75b1e Merge "Add test for IPv4 UDP forwarding rules in BPF map" 2022-02-17 02:59:07 +00:00
James Mattis
deaeefb283 CTS tests for EthernetNetworkSpecifier
Bug: 210485380
Test: atest CtsNetTestCasesLatestSdk
:android.net.cts.EthernetNetworkSpecifierTest

Change-Id: I080bc111aa57c7889a6bf9564b8fc2c1dddd944d
2022-02-16 16:46:49 -08:00
Patrick Rohr
3226bfb631 Merge "Fix NetworkStatsServiceTest after adding deleteKernelTagData" 2022-02-16 19:59:14 +00:00
Remi NGUYEN VAN
73da478927 Cleanup and refine connectivity test config
Remove the include for Connectivity/Tethering TEST_MAPPING as there is
no such file in that directory, add comments on ConnectivityModuleTest
usage, and skip the whole NetworkAgentTest on non-connectivity module
MTS runs.

Bug: 218611855
Test: atest CtsNetTestCasesLatestSdk
Change-Id: Id96ab8a5ae631b0c64f20faedd4a0430eb9318d4
2022-02-16 20:34:31 +09:00
Maciej Żenczykowski
7d30b56f06 Merge "Skip BpfExistenceTest#TestPrograms on BPF unsupported device" 2022-02-16 11:22:47 +00:00
Hungming Chen
0456900bf2 Skip BpfExistenceTest#TestPrograms on BPF unsupported device
BPF is supported after kernel 4.9. Skip the test on BPF
unsupported device. Ex: walleye.

Bug: 219696135
Test: atest bpf_existence_test on walleye
Change-Id: I583a858587c0501582c9e77c8b584b3136312cd5
2022-02-16 16:06:59 +08:00
Remi NGUYEN VAN
3b81323e4a Fix testing with/without connectivity module
Add missing @ConnectivityModuleTest annotations to tests that cover
functionalities that were introduced in a newer connectivity module
update.

Also add CtsNetTestCasesLatestSdk to postsubmit with only APK modules
installed, and with only the connectivity/tethering module installed.
This can then be moved to presubmit to catch such issues before they are
merged.

While doing this cleanup the TEST_MAPPING file in tests/ and merge its
contents into the root TEST_MAPPING file. This does not change anything
for "postsubmit" tests as they are run independently of changes. It only
causes FrameworksNetIntegrationTests to run in presubmit on any change
in modules/Connectivity/ instead of only on modules/Connectivity/tests/
changes, which is how it should be.

Bug: 218611855
Test: TH needs to test TEST_MAPPING
Change-Id: I26629a35d8c2df3db33180ecc22d49d538ad3b8b
2022-02-16 15:22:30 +09:00
Patrick Rohr
7c52b69b3e Fix NetworkStatsServiceTest after adding deleteKernelTagData
Test: atest NetworkStatsServiceTest
Change-Id: I667a5d86e0df8505fef549e598f3b4141637fb90
2022-02-16 14:01:29 +08:00
Tyler Wear
c2926f45f2 DscpPolicyTest Check Kernel Version
Check kernel version to ensure current kernel supports
BPF logic for testcase.

Bug: 217209172
Test: atest DscpPolicyTest
Change-Id: I9e0df7d2e4eb320bd5324e2d13410bd960b75174
2022-02-16 04:53:19 +00:00
Tyler Wear
6d80f10bb3 Add ThrowableBiConsumer to BpfCoordinatorShim
Change-Id: Iecf001ac6d9f53a64f903f5b8ab069d6be93f50a
2022-02-15 16:59:07 -08:00
Tyler Wear
c23ffbdf7e BpfBitmap Test
Privileged test case for BpfBitmap.

Test: atest BpfBitmapTest
Bug: 179733303
Change-Id: I9c32d8843176815a725eccfd1f0400ec129cd94d
2022-02-15 22:19:58 +00:00
Treehugger Robot
c05d86b850 Merge "Add KeepalivePacketData toString()" 2022-02-15 10:54:37 +00:00
Wayne Ma
622c72ea49 Merge "Address comment from aosp/1948169" 2022-02-15 10:33:23 +00:00
Taras Antoshchuk
0817bb2906 Fix HostsideVpnTest#testExcludedRoutes
One of VpnTest#startVpn overloads didn't propagate "excludedRoutes"
param, due to mistake during conflict resolution in aosp/1941233.

Bug: 214398350
Test: atest HostsideVpnTests --iterations
Change-Id: Icbbe7394f1ff1f676cc671a1fa1c4449f4d585e3
2022-02-15 09:14:03 +00:00
Hungming Chen
a525e24fbc Add test for IPv4 UDP forwarding rules in BPF map
Parse the dumpsys output strings to check that the IPv4 UDP
forwarding rule is added by the UDP conntrack event on
the tethering interface.

Test: atest EthernetTetheringTest
Change-Id: I2f04af72e51ca6b7a37ba51daa4f5125cb11144c
2022-02-15 16:24:22 +08:00
Wayne Ma
510c2f463f Address comment from aosp/1948169
Bug: 202086915
Test: m; flash; boot;
Change-Id: Ic989fa2a58edb15155fba175d4cdf8952b511ae7
2022-02-15 14:54:45 +08:00
Treehugger Robot
a828eb711c Merge "Move permissions allowlist for Tethering" 2022-02-15 04:43:27 +00:00
Nucca Chen
61ef984d52 Merge "Dump BPF map in base64 encoded strings for testing" 2022-02-14 10:07:09 +00:00
Remi NGUYEN VAN
106569b856 Merge "Allow test+other networks to have specifiers" 2022-02-14 05:31:20 +00:00
Jean Chalard
d537aa42e1 Merge "Add new methods to redact NetworkCapabilities & LinkProperties" 2022-02-12 11:56:36 +00:00
lucaslin
c582d50b8e Add new methods to redact NetworkCapabilities & LinkProperties
Some system components like VPN need to know how to redact
NetworkCapabilities & LinkProperties that they received from
the system but need to send to third-party applications with
less privilege than themselves. To make sure the redaction is
consistent, expose system API methods to do it that are wired
to the same redaction code used by ConnectivityService.

Bug: 191413541
Test: atest CtsNetTestCases, which includes new CTS for these
Change-Id: Ia3ae4755b5192884c147d6828f96cedac000a25b
2022-02-12 15:21:13 +09:00
Ling Ma
4d782d6d74 Add KeepalivePacketData toString()
Test: build
Bug: 218569712
Change-Id: I24c0e7ab94212ddf71812ebcc81a5fa69abfa860
2022-02-11 19:17:10 +00:00
Mark Chien
c8f38c77a9 Merge "Remove unused BpfNetMap jni function" 2022-02-11 13:32:36 +00:00
Treehugger Robot
d6751bd159 Merge "Fix tab by replacing it with spaces" 2022-02-11 09:35:32 +00:00
Treehugger Robot
5be94579d4 Merge "Refer to SDK constant defined in DevSdkIgnoreRule" 2022-02-11 09:23:02 +00:00
markchien
4dd5be6606 Remove unused BpfNetMap jni function
native_deleteTagData and native_setCounterSet is replaced as BpfMap java
implementation inside NetworkStatsService.java

Test: atest traffic_controller_unit_test
Change-Id: Ic33ca9d9887380d39becbd0dc3a0e159b3dc82a2
2022-02-11 08:04:55 +00:00
Chiachang Wang
137bbed860 Refer to SDK constant defined in DevSdkIgnoreRule
Refer to the same constant definition as other tests instead of
hard coding locally, so that it won't be missed as changing to
Build.VERSION_CODES.SC_V2.

Bug: 184750836
Test: atest FrameworksNetTests
Change-Id: I3c17c414d830af03e2719c5dab1a664c55f6df2a
2022-02-11 07:40:58 +00:00
Aaron Huang
b5af0fe5dc Fix tab by replacing it with spaces
Test: no code changes
Change-Id: I3644c4914486189d58c8e59ac62c6856296cce08
2022-02-11 13:52:29 +08:00