Commit graph

37,006 commits

Message SHA1
Remove reference when active listener is unregistered
The registered listeners are added into internal ArrayMap as a
reference but are not removed when the listeners are
unregistered. The actions for registration should be done in
pairs.

Test: atest FrameworksNetTests
Change-Id: Id9e674f5104d1471dd81224b6a271a8a92172e34

Chiachang Wang   commited 2021-09-30 10:30:35 +00:00
2de41686e7
Add test for CM#[add|remove]DefaultNetworkActiveListener
Bug: 199753782
Test: atest FrameworksNetTests CtsNetTestCases
Change-Id: I2520f7f5feef61502479767aa023e281d1335ee4

Chiachang Wang   commited 2021-09-30 18:29:29 +08:00
859218c893
Merge "Check NetworkAgentInfo Map Before Destroying Network"
Chalard Jean   authored and   Gerrit Code Review   commited 2021-09-29 06:03:56 +00:00
9d31c63e03
Merge "Modify Nsd{Service,Manager}Test to conform to its change"
Luke Huang   authored and   Gerrit Code Review   commited 2021-09-29 03:35:20 +00:00
38f82199ab
Check NetworkAgentInfo Map Before Destroying Network
updateNetworkInfo is called with the argument in a message,
which is initialized with `this` in NetworkAgentRegistry.
That means it's technically possible that CS calls
tearDownUnneededNetwork, calling nai.disconnect() and
queuing up a message to call this, but before it's done
the NA calls sendNetworkInfo with DISCONNECTED, which
never looks up the agent from the map. Throwing a
ServiceSpecificException and resulting in a System crash.

Bug: 196423147
Change-Id: Ia52f2b794f32c263200c14b8dc2eb6b184bff5ff

Tyler Wear   commited 2021-09-28 17:41:23 -07:00
614b27badd
Fix NetworkOffer Death link does not exist
unregisterNetworkProvider is being called from binderDied()
and handleUnregisterNetworkProvider() at the same time. This results
in NoSuchElementException being thrown.

Check than noi can be removed from network offers before unregistering
death link.

Bug: 196423150
Change-Id: If5bd5f2894fa0509a89340efdc85180c54e72e0e

Tyler Wear   commited 2021-09-20 10:40:19 -07:00
3ec7e6d9fb
Merge "Add a mode for cell radios unable to time share"
Chalard Jean   authored and   Gerrit Code Review   commited 2021-09-18 12:39:24 +00:00
c80a5d56db
Add a mode for cell radios unable to time share
Upon changing the default SIM card, the radio will create a
new connection to the new subscription. If that subscription
works correctly, the stack will prefer it to the old one as
the new subscription will be marked with a Primary policy
flag it its score.

Normally, at this point the old network lingers to give apps
an opportunity to gracefully migrate their connections. But
with some radios, this may have a dramatic effect on the
performance of the new connection.

This patch introduces a flag so that devices with such radios
can be marked. In this case the stack will move to a degraded
mode and eschew the grace delay for apps and give them a hard
break instead, so that the new network can reach a good
performance immediately. Apps with existing connections will
suffer a worse experience.

If there is a request that can only be served by the old
connection, still keep it, as arguably the user still
expects their MMS be sent on the old connection, even if the
new connection doesn't work well until it's done.

Test: new test in this patch, and add relevant tests in both modes
      also manually change the value of the flag and run
      FrameworksNetTests and CtsNetTestCasesLatestSdk
Bug: 200226979
Change-Id: I4ace82f90e873bf06298cc689bb1d794ed5124bd

Chalard Jean   commited 2021-09-18 04:03:13 +00:00
0702f98edc
Merge "Remove ForceAllNetworkTypes from test"
Aaron Huang   authored and   Gerrit Code Review   commited 2021-09-17 12:08:59 +00:00
f7762c823a
Merge "Test a template matches mobile and mobile wildcard"
Aaron Huang   authored and   Gerrit Code Review   commited 2021-09-16 09:42:22 +00:00
3cbd991ab4
Merge "Correct the calling method in removeDefaultNetworkActiveListener"
Chiachang Wang   authored and   Gerrit Code Review   commited 2021-09-16 06:29:36 +00:00
a6e3069c27
Correct the calling method in removeDefaultNetworkActiveListener
The removeDefaultNetworkActiveListener should do the
unregisteration but it's incorrectly calling
registerNetworkActivityListener into the ConnectivityService.

Bug: 199753782
Test: atest FrameworksNetTests CtsNetTestCases
Change-Id: I65a2ddc82989d736316d51f5058e707f5b261a82

Chiachang Wang   commited 2021-09-16 02:25:48 +00:00
e54c8199aa
Test QosSocketInfo.getNetwork
Bug: 183239152
Test: atest NetworkAgentTest
Change-Id: I9848608e0aa500ff7668350a080537dd4a549214

markchien   authored and   Mark Chien   commited 2021-09-15 03:09:26 +00:00
059bfa6149
Test a template matches mobile and mobile wildcard
Add two test cases for matchesMobile and matchesMobileWildcard

Bug: 183776809
Test: FrameworksNetTests:NetworkTemplateTest
Change-Id: I14d31071655204fe6ad36c71f7f521640e01c96e

Aaron Huang   commited 2021-09-14 23:36:04 +08:00
cbb4d498c2
Merge "Add logging on UnfinishedStubbingException"
Treehugger Robot   authored and   Gerrit Code Review   commited 2021-09-13 02:34:27 +00:00
f2ddb4151c
Modify Nsd{Service,Manager}Test to conform to its change
(clean cherry-pick from downstream branch)
Test: atest NsdManagerTest NsdServiceTest
Bug: 191844585
Merged-In: I3cf658498bef5755dcb01127a94fff913b6e6298

Change-Id: I3cf658498bef5755dcb01127a94fff913b6e6298

Luke Huang   authored and   Remi NGUYEN VAN   commited 2021-09-13 10:18:04 +09:00
df75378ad4
Merge "Remove NetworkUtils.queryUserAccess in test"
Paul Hu   authored and   Gerrit Code Review   commited 2021-09-11 05:56:45 +00:00
c7d5ea0bbd
Remove ForceAllNetworkTypes from test
Before sForceAllNetworkTypes is removed, the network
type and meteredness will be ignored when matchesMobile
or matchesMobileWildcard is called.

After sForceAllNetworkTypes is removed, the matches
method should check the network type and the meteredness.
Thus, if the test data contains different type or it's
not metered should not be counted.

Bug: 183776809
Test: FrameworksNetTests
Change-Id: Ie7194495d26c0f5ef7a247733f43c64688626c67

Aaron Huang   commited 2021-09-11 10:45:16 +08:00
7b4a4cbdd4
Delete AirplaneModeTest
It is flaky and redundant, functionality is covered in
ConnectivityManagerTest

Bug: 191856806
Test: N/A
Change-Id: I786f69f6f6cfb73e99cc5dea867024007f44d134

Sergey Troshin   authored and   Dorin Drimus   commited 2021-09-10 09:17:39 +00:00
2e0b45004c
Merge "Wait for validation of WiFi in OEM pref test"
Treehugger Robot   authored and   Gerrit Code Review   commited 2021-09-09 18:51:32 +00:00
c60c1bc24e
Merge "Include suspended network when getAllNetworkStateSnapshots"
Junyu Lai   authored and   Gerrit Code Review   commited 2021-09-09 09:24:04 +00:00
48426bb2a4
Wait for validation of WiFi in OEM pref test
OEM_NETWORK_PREFERENCE_TEST prefers NOT_METERED&VALIDATED networks
then TEST networks. If the WiFi isn't validated by the time the
preference is set, then the TEST network is preferred and the test
fails. The best solution is simply to wait for the WiFi network to
validate before setting the preference.

Besides, some of the *wait* methods wait for validation and some
don't, creating confusion. Make this explicit on the
setWifiMeteredStatusAndWait method with a boolean argument, which
forces all users to make an explicit choice.

testSetOemNetworkPreferenceForTestOnlyPref is not affected, as
it does not change WiFi meteredness.

Bug: 195365654
Test: testSetOemNetworkPreferenceForTestPref
Change-Id: Icb9d7ff1ca5c3d93286ea3a79c27f15630d17ee6

Chalard Jean   commited 2021-09-08 18:43:09 +09:00
ae4c414c1f
Include suspended network when getAllNetworkStateSnapshots
Suspended network should be considered as temporary shortage of
connectivity of a connected network. Thus, it should not be
excluded from network state snapshots and causes data usage to
stop accounting or iptables rules to be removed on the interface
of the suspended network.

This change also address the naming confusion of default networks
parameter of expectNotifyNetworkStatus.

Test: atest ConnectivityServiceTest#testGetAllNetworkStateSnapshots
Bug: 196079981
Change-Id: I8096356f9a472fb1c1246fbdf3fd5f981387fb1c

Junyu Lai   commited 2021-09-08 06:02:28 +00:00
ddecb66246
Remove NetworkUtils.queryUserAccess in test
- This method always reuturns false which is not able to use for
  testing.
- Use test restricted network for testing instead.

Bug: 183485986
Test: atest ConnectivityManagerTest
Change-Id: If34d4f1952162f118d53be8074a96b07415a5c85

paulhu   commited 2021-09-07 15:18:06 +00:00
e02bb6052d
Merge changes Id2ffb056,I2a4e298b
* changes:
  Adjust some behaviors on PermissionMonitorTest
  Use common code

Paul Hu   authored and   Gerrit Code Review   commited 2021-09-07 06:01:54 +00:00
420fa2baef
Merge "Remove a forgotten log"
Chalard Jean   authored and   Gerrit Code Review   commited 2021-09-07 04:37:23 +00:00
3d872e662e
Merge "Add debug logs to CaptivePortalTests"
Chalard Jean   authored and   Gerrit Code Review   commited 2021-09-07 04:36:55 +00:00
fe1a4f6e60
Merge "Separate test into reasonable multiple tests"
Chiachang Wang   authored and   Gerrit Code Review   commited 2021-09-07 02:40:13 +00:00
26a7e61417
Adjust some behaviors on PermissionMonitorTest
- This is a test only change.
- Remove calling startMonitoring() in setup() because this method
  should be called only once, so each test needs to call
  startMonitoring() if the testing function is running on it.
- Return empty list instead of null when getting installed
  pacakges in setup(). This can help test to have default user
  MOCK_USER1 when they call startMonitoring().

Bug: 192431153
Test: atests FrameworksNetTests
Change-Id: Id2ffb056b378873c3ba6a8bb31b7dedb56ad6d46

paulhu   commited 2021-09-07 09:46:23 +08:00
941fa70744
Use common code
- Some code are used many times, it's better to make them as
  common code for reducing inconsist behavior.
- Also stop using Boolean to represent network permissions and
  replace them with int value. Because using Boolean for
  permission comparison is really complicated and bizarre.
- Use PERMISSION_* for netd network permission directly.

Bug: 189705071
Test: atests FrameworksNetTests
Change-Id: I2a4e298b9a01f4b2874ae68e9d9539a0ab4aff4c

paulhu   commited 2021-09-07 09:25:31 +08:00
b7dd7a3f4b
Merge "Correct uid to app id for netd traffic permission methods"
Paul Hu   authored and   Gerrit Code Review   commited 2021-09-07 01:13:56 +00:00
9fe8c8fc76
Merge "Reduce duplicated code"
Paul Hu   authored and   Gerrit Code Review   commited 2021-09-06 16:17:45 +00:00
1d04d8362f
Add debug logs to CaptivePortalTests
The point is to help with debugging flakes of this test by
clarifying the timing of these calls with respect to when
NetworkMonitor reads the settings and the values it obtains.

Test: CaptivePortalTest
Change-Id: I29ac1d8cff1f96c91be2459e9a8f34f8ba1f38e3

Chalard Jean   commited 2021-09-06 18:08:45 +09:00
d0d5c64bab
Add logging on UnfinishedStubbingException
The test flakes with UnfinishedStubbingException, but the root cause
could not be identified. Add some logging to try to get more information
when that happens.

Bug: 195626111
Test: atest ConnectivityServiceTest

Change-Id: If12c1ea809789148ca9251386e5ee6ca6d74ff74

Remi NGUYEN VAN   commited 2021-09-06 15:13:09 +09:00
f68905683f
Correct uid to app id for netd traffic permission methods
Some uids should be app ids, correct them for avoiding confusion
and incorrect use.

Bug: 189705071
Test: atests FrameworksNetTests
Change-Id: I4a5930e5dc63b4d901e1567f8935ad7203866c89

paulhu   commited 2021-09-06 00:12:23 +08:00
1d4ec79020
Reduce duplicated code
- This is a test only change.
- Some methods are very similar and duplicated. So merge them to
  improve readability and reduce code complexity.
- Stop spying PermissionMonitor.

Bug: 189705071
Test: atests FrameworksNetTests
Change-Id: I8ec17bd2d396c4d49dd8b64be85d89d0145f4c3c

paulhu   commited 2021-09-03 15:58:15 +08:00
7a29739f2f
Merge "Remove unused libbacktrace library."
Christopher Ferris   authored and   Gerrit Code Review   commited 2021-09-02 21:25:02 +00:00
f7e6b7f424
Merge "Replace inexact alarm setRepeasting with setExact alarm"
Treehugger Robot   authored and   Gerrit Code Review   commited 2021-08-30 13:42:25 +00:00
507de1cac6
Refactor the offload permission check and add tests
- Rename the conntrack destination port check function
- Use CollectionUtils.contains to check the denied ports
- Add tests for the streams with ftp and pptp tcp port are
  not able to be offloaded

Bug: 195914327
Test: atest TetheringCoverageTests
Change-Id: I7e2591bea1f6db46271efb0c30970fb8d4efe1e4

Hungming Chen   commited 2021-08-26 21:21:05 +08:00
b344870ea0
Merge "Fix IpSecAlgorithmTest on S"
Orion Hodson   authored and   Gerrit Code Review   commited 2021-08-26 07:47:33 +00:00
0084591e94
Fix IpSecAlgorithmTest on S
The test may be run on S builds older than itself, in which case the
resource ID may not match. Query the resource ID dynamically instead of
using the constant.

IpSecAlgorithm is not updatable in S, which is why it can use
hidden/unstable platform resources, so the test could also be skipped
altogether on S. But considering that keeping it around is not very
costly yet, this change fixes it for running on S.

Bug: 197489543
Test: atest IpSecAlgorithmTest
Change-Id: I533eede3a360a8db9089e65e017b9d7453b35539

Remi NGUYEN VAN   commited 2021-08-25 18:10:22 +09:00
ae7508f9b5
Merge "Tethering/bpf_progs/offload - replace all TC_ACT_OK with TC_ACT_PIPE"
Maciej Żenczykowski   authored and   Gerrit Code Review   commited 2021-08-25 07:19:28 +00:00
dc8388ca08
Remove a forgotten log
Test: ConnectivityServiceTest
Change-Id: Idc3b91422263bf5d062ee1682f41fc28616376b6

Chalard Jean   commited 2021-08-25 13:19:04 +09:00
1347844336
Tethering/bpf_progs/offload - replace all TC_ACT_OK with TC_ACT_PIPE
The correct return code to keep on processing any further TC
attached programs is 'TC_ACT_PIPE' and not 'TC_ACT_OK' (which
is terminal).

Without this the ipv6 tether offload program causes termination
of processing and the ipv6 clatd offload program never actually
handles any packets (while tethering is active).

This results in lack of bpf xlat64 offloading for tethered ipv4
traffic on an ipv6-only (cellular) network.

This in turn means incoming TCP packets get GRO'ed, do not get
bpf offloaded, and get delivered to the clat daemon, which
due to them being bigger than the mtu (due to gro) cannot
handle them and discards them.

This results in poor performance, since tcp falls back to 1 mss/mtu
sized packet per rtt.

Tested via tethering a linux laptop on an ipv6-only cellular connection
and downloading the linux kernel from kernel.org via 'wget -6' and 'wget -4'.
Before:
  IPv6: over 2MB/s, observed:
    5805 packets, including 4 sackOK
  IPv4: under 1MB/s, observed:
    9300 packets, including 8 sackOK, 387 sack 1, 501 sack 2, 2310 sack 3
After:
  IPv6: over 7MB/s, observed:
    16702 packets, including 4 sackOK
  IPv4: over 9MB/s, observed:
    32755 packets, including 2 sackOK

Test: builds, TreeHugger, see above
Bug: 195624908
Signed-off-by: Maciej Żenczykowski <maze@google.com>
Change-Id: I623dacb5a37dc689cea34499c3906c11fcaf946c

Maciej Żenczykowski   commited 2021-08-24 23:24:19 +00:00
6e66a36367
Remove unused libbacktrace library.
Bug: 120606663

Test: Builds.
Change-Id: I733defd03670b01a30c4be5742498d62db7a9b6b

Christopher Ferris   commited 2021-08-24 15:57:29 -07:00
2b63a2f92a
Give EthernetTetheringTest the restricted networks permission.
This test fails on devices where physical Ethernet interfaces are
available but marked restricted, like cuttlefish.

Bug: 197462993
Test: test-only change
Change-Id: I15c991b2e43e2d5e823dcdcfbd74adfd9b2f6f08

Lorenzo Colitti   commited 2021-08-24 15:18:54 +09:00
8fbadf4ac5
Merge "Fix an infinite loop with network offers"
Chalard Jean   authored and   Gerrit Code Review   commited 2021-08-20 06:17:31 +00:00
77992bbfbb
Merge "bpf: don't offload IPv4 packets with TCP port 21 (ftp) and 1723 (pptp)"
Lorenzo Colitti   authored and   Gerrit Code Review   commited 2021-08-20 03:24:09 +00:00
ad8fb7fce4
bpf: don't offload IPv4 packets with TCP port 21 (ftp) and 1723 (pptp)
Bypass the IPv4 TCP packets with port 21 (ftp) and 1723 (pptp) from
BPF offload because these packets need the netfilter conntrack helper.

Bug: 195914327
Test: manual test as the follows
1. Connect to ftp.slackware.com with port 21 in active mode.
2. Check the PORT command success.
   Command:  PORT 192,168,62,128,174,17
   Response: 200 PORT command successful.
3. Download a file.

Change-Id: I8e3b8d9323eb0e572f20c74442b55d4ee95abc2f

Hungming Chen   authored and   Nucca Chen   commited 2021-08-19 14:29:25 +00:00
bc85178435
Fix an infinite loop with network offers
When the avoidBadWifi configuration is false and not overridden,
a WiFi network that was validated in the past but becomes
unvalidated needs to outscore a cell network that is validated.
This is happening correctly when the stack compares two networks.
However, when the stack compares an existing network to an offer
for a cellular network, the offer was automatically considered
not to yield. This would mean the stack would be requesting cell
out of the telephony factory, only for that network to lose to
WiFi and be discarded immediately, then recreated again etc.

When there is some other reason cell should be up (such as the
"mobile always on" setting being active), this would not be
visible because the cell network would have another reason not
to be torn down.

Have offers correctly account for the current value of the
configuration and setting. This has the ranking of the offer
lose against WiFi like the actual network loses, meaning the
offer is not needed.

This also requires updating the offers whenever the value of
the setting changes.

Test: new test for this, also ConnectivityServiceTest
Bug: 195441367
Change-Id: I4fe5de98bc15bcf9bbbe25c6c7c8a7ba382f8db7

Chalard Jean   commited 2021-08-19 22:53:41 +09:00
bb902a5fee