Commit graph

73,679 commits

Message SHA1
DO not throw exception for ERROR_NO_SUCH_SLOT error
There are multiple independent reasons a keepalive can stop. Some
are software (e.g. the app stops the keepalive) and some are hardware
(e.g. the SIM card gets removed). Therefore, there is a very low
probability that both of these happen at the same time, which would
result in the first stop attempt returning SUCCESS and the second
stop attempt returning NO_SUCH_SLOT. Such a race condition can be
ignored with a log, not to crash the system. Change to wtf log so
that the issue could still be visible since this implies possible
bugs in the system.

Also update the javadoc for SocketKeepalive.ERROR_NO_SUCH_SLOT.

Bug: 281484381
Test: atest FrameworksNetTests
Change-Id: I316a2193fc7302b04e074ff0b03dc43946fe5ce6

chiachangwang   commited 2023-05-23 05:08:45 +00:00
75673ba502
Merge "Immediately create native networks when NetworkAgents register."
Lorenzo Colitti   authored and   Gerrit Code Review   commited 2023-05-11 03:35:21 +00:00
18cdec34dd
Merge "Use a single SharedLog for all mdns components"
Paul Hu   authored and   Gerrit Code Review   commited 2023-05-11 00:45:18 +00:00
3e497c7b1e
Merge "Optionally have ConnectivityService kill sockets for frozen apps"
Mark Fasheh   authored and   Gerrit Code Review   commited 2023-05-10 23:08:00 +00:00
2d626e5632
Optionally have ConnectivityService kill sockets for frozen apps
To do this we register a UidFrozenStateChangedCallback with
ActivityManager. The callback then queues up work on the Handler thread
to consume the original callback args and kill appropriate sockets.

Test: atest ConnectivityServiceTests
Bug: 277100090
Change-Id: I93f174811aef726145a18ea90443ddfc1456478e

Mark Fasheh   commited 2023-05-10 21:04:54 +00:00
7c999d8d4c
Immediately create native networks when NetworkAgents register.
Currently, native networks for non-VPN networks are created only
when the NetworkAgent goes into the CONNECTED state. This is not
ideal, because until the network is connected:

- Nothing routes to the network, so no IP packets can be sent on
  it (except via packet sockets).
- Many network configuration changes (e.g., routes and DNS
  servers) fail to apply because the network does not exist yet.
  These cause ENONET errors in the logs.

Fix this starting in U by creating the native network as soon as
the agent registers. This should not impact apps because
NetworkCallbacks are not sent until networks are connected.

Bug: 143158421
Test: new coverage in NetworkAgentTest
Change-Id: I26bfa8630c085422175558645c47a6c64be96ae6

Lorenzo Colitti   commited 2023-05-10 20:01:07 +09:00
4f87aa3f13
Merge "Fix template for test network needs fine location permission"
Junyu Lai   authored and   Gerrit Code Review   commited 2023-05-10 02:22:18 +00:00
598ca1e284
Use a single SharedLog for all mdns components
Use a single SharedLog in NsdService, and making subcomponents
for DiscoveryManager/Advertiser/SocketProvider. Because each
logger has 500 maxRecords, so 2000 records in total, which take
too much memory.

Also address leftover comments in previous logging changes.

Before:
  2023-04-17T15:05:27.409895 - [Client10082-1] Register a DiscoveryListener 3 for service type:_nmt274981618._tcp.local
  2023-04-17T15:05:26.408015 - [Client10082-1] New client. useJavaBackend=true

Advertiser:
  2023-04-17T15:05:27.213023 - [testtap0] Probing finished for service 2
  2023-04-17T15:05:26.409607 - Adding service name: ^Nsd.Test|Non-#AsCiI\Characters&\ufffe テスト 測試, type: _nmt274981618._tcp, hostAddresses: , port: 12345, network: null, txtRecord:  with ID 2

DiscoveryManager:
  2023-04-17T15:05:28.227786 - [_nmt274981618._tcp.local-102] onServiceNameDiscovered: ^Nsd.Test|Non-#AsCiI\Characters&\ufffe テスト 測試
  2023-04-17T15:05:27.409104 - createServiceTypeClient for serviceType:_nmt274981618._tcp.local network:102
  2023-04-17T15:05:27.398075 - Registering listener for serviceType: _nmt274981618._tcp.local

SocketProvider:
  2023-04-17T15:05:28.292106 - Remove socket on net:102
  2023-04-17T15:05:26.441517 - Create socket on net:NetworkAsKey{ network=102 }, ifName:testtap0
  2023-04-17T15:05:26.409005 - Start monitoring sockets.

After:
Logs:
  2023-04-17T20:51:42.931769 - [MdnsDiscoveryManager._nmt682015268._tcp.local-101] onServiceNameDiscovered: Name: ^Nsd.Test|Non-#AsCiI\Characters&\ufffe テスト 測試, type: _nmt682015268._tcp.local, subtypes: , ip: [100.70.162.138], ipv6: [fe80::9c0e:d0ff:fe7d:e5aa, 2a00:79e1:abc:6f04:9c0e:d0ff:fe7d:e5aa, 2a00:79e1:abc:6f04:eb56:8e39:5e1f:1102], port: 12345, interfaceIndex: 47, network: 101, textStrings: [], textEntries: []
  2023-04-17T20:51:42.032465 - [NsdService.Client10082-1] Register a DiscoveryListener 3 for service type:_nmt682015268._tcp.local
  2023-04-17T20:51:42.026645 - [MdnsDiscoveryManager] createServiceTypeClient for type:_nmt682015268._tcp.local, net:101
  2023-04-17T20:51:41.091555 - [MdnsAdvertiser] Adding service name: ^Nsd.Test|Non-#AsCiI\Characters&\ufffe テスト 測試, type: _nmt682015268._tcp, hostAddresses: , port: 12345, network: null, txtRecord:  with ID 2
  2023-04-17T20:51:41.091037 - [MdnsSocketProvider] Start monitoring sockets.
  2023-04-17T20:51:41.089951 - [NsdService.Client10082-1] New client. useJavaBackend=true

Bug: 275004614
Test: atest FrameworksNetTests android.net.cts.NsdManagerTest
Change-Id: I1c9b7697cc95748f7fe4e6beecea217d39c56fb1

Paul Hu   commited 2023-05-10 02:18:43 +00:00
14667deefa
Merge "add congestion control test to CTS"
Maciej Żenczykowski   authored and   Gerrit Code Review   commited 2023-05-09 18:17:12 +00:00
be66108f84
add congestion control test to CTS
This is not a substantially new test, as VTS has already required
either reno or cubic, and reno is ancient and obsolete (and was
only ever included because it's builtin to the kernel), so in
practice everything should have already always been using cubic.

Bug: 281477097
Test: TreeHugger, atest ProcNetTest
Signed-off-by: Maciej Żenczykowski <maze@google.com>
Change-Id: I04622ae37265361f648bbcf46c0a10e22be3b24f

Maciej Żenczykowski   commited 2023-05-09 18:16:52 +00:00
6de6b3f106
Merge "Process all responses if the network is null in MdnsServiceTypeClient"
Paul Hu   authored and   Gerrit Code Review   commited 2023-05-09 10:23:24 +00:00
49078d7b0f
Merge "Fix flaky testUidTagStateDetails"
Treehugger Robot   authored and   Gerrit Code Review   commited 2023-05-09 08:03:51 +00:00
8ac7ad4d9a
Process all responses if the network is null in MdnsServiceTypeClient
If the network is null in MdnsServiceTypeClient, it should use
MdnsSocketClient for single socket only. So it's expected to
process any response from only the socket (network).

Move the stopDiscovery outside the listener check loop.
Because the stop should only be called once.

Add a test to verify the response processing with a non-null
network MdnsServiceTypeClient

Bug: 265787401
Test: atest FrameworksNetTests
Change-Id: I76965302037f050e0ac3b2cfdbaa5a855e2283c7

Paul Hu   commited 2023-05-09 15:19:29 +08:00
bdf82a2aa0
Merge "Update uiautomator references in packages/modules/Connectivity/tests/cts/hostside/app"
Yichun Li   authored and   Gerrit Code Review   commited 2023-05-08 19:29:49 +00:00
043c7f07e4
Merge "Prevent hotspot from being affected by the wifi retention feature"
Treehugger Robot   authored and   Gerrit Code Review   commited 2023-05-08 07:39:12 +00:00
ac7a0e3ee9
Merge "Fix isFeatureEnabled namespace and overload usage"
Treehugger Robot   authored and   Gerrit Code Review   commited 2023-05-08 03:19:27 +00:00
ab809e5ce0
Merge "Ignore keepalive tests before S and without Tethering module"
Treehugger Robot   authored and   Gerrit Code Review   commited 2023-05-08 03:16:18 +00:00
8438c257fc
Merge "ConnectivityManagerTest: clean up when connectToCell fails"
Maciej Żenczykowski   authored and   Gerrit Code Review   commited 2023-05-06 14:26:57 +00:00
fb4ab74a09
ConnectivityManagerTest: clean up when connectToCell fails
CtsNetUtils#connectToCell can fail if the device does not have a cell
network available in which case the allow bad wifi setting was not reset.

Test: TH
Change-Id: I2dc20c8982a427379f94a4b92774e149a78628d5

Patrick Rohr   commited 2023-05-05 15:47:59 -07:00
79c9aa8ecc
Merge "remove inprocess tethering"
Maciej Żenczykowski   authored and   Gerrit Code Review   commited 2023-05-05 20:31:58 +00:00
e95ec4afa7
Update uiautomator references in packages/modules/Connectivity/tests/cts/hostside/app
* Remove unused dependencies.
* Replace "ub-uiautomator" (v2.2.0) with
  "androidx.test.uiautomator_uiautomator" (v2.3.0).

Bug: 235842600
Test: presubmit
Change-Id: Ib72596d8fea3a9cefaeff8d54e9dcbb78538cf6a

Yichun Li   commited 2023-05-05 15:19:15 +00:00
b660c7f652
Merge "Avoid going over max service name length when renaming NSD services"
Treehugger Robot   authored and   Gerrit Code Review   commited 2023-05-04 06:06:24 +00:00
3903b1e91d
Avoid going over max service name length when renaming NSD services
As per  RFC 1034/1035, the max size of the label is 63 bytes. It should
also be guaranteed when the serviceName is renamed due to the conflict.

Bug: 265865456
Test: atest FrameworksNetTests
Change-Id: I077d8abdb91071db62b9618d9918e3a12682aaf4

Yuyang Huang   commited 2023-05-04 13:24:23 +09:00
de802c8dc4
Fix template for test network needs fine location permission
For a template with MATCH_TEST, since the wifi network key is
just a placeholder to identify a specific test network, it is
not related to track user location. Hence the check is not
really needed.

Test: 1. atest NetworkStatsIntegrationTest with use location turned off
      2. atest FrameworksNetTests:android.net.connectivity.com.android.server.net.NetworkStatsServiceTest
Fix: 280686048
Change-Id: Ic128cfbbb2d03c427c9030c99bf205eb65a33e58

Junyu Lai   commited 2023-05-04 11:01:33 +08:00
a58914b548
Merge "drop support for V gsi on pixel 5 R base kernel"
Treehugger Robot   authored and   Gerrit Code Review   commited 2023-05-03 19:25:39 +00:00
818d4480e8
Merge "Add an integration test to verify zero-length DHCP packet."
Xiao Ma   authored and   Gerrit Code Review   commited 2023-05-03 14:09:04 +00:00
8da5ff4b5f
Fix flaky testUidTagStateDetails
This includes:
  1. Specify a read timeout: At present, the test only specifies
     a connect timeout and terminates if the timeout is exceeded.
     However, if the connection takes a long time to establish,
     there may be very little time left for the test to perform
     a read operation.
  2. Read only the initial bytes: Since the exact amount of data
     is not important for the test, it is preferable to read only
     a small amount of data at the beginning rather than reading
     the entire content.

Test: atest CtsNetTestCases:android.net.cts.NetworkStatsManagerTest \
      --rerun-until-failure 100
Fix: 274835045
Change-Id: If53a8db7ab6c5df462757d80b563de89531c3c3f

Junyu Lai   commited 2023-05-03 13:35:16 +08:00
ddfb2382e0
Merge "Add null check for tupleOrig in ConntrackMessage"
Maciej Żenczykowski   authored and   Gerrit Code Review   commited 2023-05-02 22:29:45 +00:00
69b6ca4ff1
Merge "BpfNetMaps: do not register BpfNetMaps JNI before T"
Treehugger Robot   authored and   Gerrit Code Review   commited 2023-05-02 18:02:19 +00:00
277b236de3
clarify comment about uid check on abort()
Test: TreeHugger
Signed-off-by: Maciej Żenczykowski <maze@google.com>
Change-Id: I31f40622fee9833681ffa10307430cde7920eb16

Maciej Żenczykowski   commited 2023-05-02 16:23:02 +00:00
9461bb1f48
BpfNetMaps: do not register BpfNetMaps JNI before T
BpfNetMaps needs to go through netd before T and must *never* use the
JNI methods. BpfNetMaps already throws if this code path is called
before T.

Test: TH
Change-Id: I5f69c3673cfe86ef02f9b8e35a1db63f39c3da7e

Patrick Rohr   commited 2023-05-02 16:18:50 +00:00
31edd95c24
Add null check for tupleOrig in ConntrackMessage
ConntrackSocketTest#testIpv4ConntrackSocket always fail in cuttlefish
because it gets NullPointerException when accessing tupleOrig in
ConntrackMessage. tupleOrig can be null if it doesn't have source IP.

This situation happens when dumping the following conntrack entry:
vsoc_x86_64:/ # cat /proc/net/nf_conntrack
ipv4     2 unknown  2 570 src=0.0.0.0 dst=224.0.0.22 [UNREPLIED] \
src=224.0.0.22 dst=0.0.0.0 mark=0 secctx=u:object_r:unlabeled:s0 use=2

Bug: 280203901
Test: atest TetheringPrivilegedTests (on cuttlefish)
Change-Id: Iddc8cb390a4369190d535f4694e0e5fa4b6e590f

KH Shi   commited 2023-05-02 22:57:24 +08:00
9dfbb45bb6
Merge "Fix NetworkScoreTest flake"
Treehugger Robot   authored and   Gerrit Code Review   commited 2023-05-02 12:11:49 +00:00
f69ae23e01
drop support for V gsi on pixel 5 R base kernel
This will fail 'boot_test_rvc_pixel5' due to the pixel 5
RVC image's 4.19 kernel failing U VTS (and indeed likely
even earlier and other xTS tests as well),
due to not including:
  https://android-review.git.corp.google.com/c/kernel/common/+/1881533
  UPSTREAM: security: selinux: allow per-file labeling for bpffs

Additionally expecting us to support 4 OS upgrades (R->S->T->U->V)
is simply unreasonable.

Bug: 258879079
Bug: 280411222
Test: TreeHugger
Signed-off-by: Maciej Żenczykowski <maze@google.com>
Change-Id: I8f5009e772a0efbb0401ad466c0405e53a172ce6

Maciej Żenczykowski   commited 2023-05-02 11:48:17 +00:00
bbbd18a713
Fix NetworkScoreTest flake
Some tests flake because the previous test networks are
still registered. It's not very clear how this can happen
considering `tearDown` is waiting for each agent to be
torn down, but logs suggest that the array of agents may
not contain all agents at `tearDown` time, and `tearDown`
does not run on the same thread as the test. It's hard
to imagine that there isn't a memory barrier between the
end of the test and the start of `tearDown`, but that's
the only hypothesis at this point.

Also add logs that will help diagnose further in case
the (admittedly hard to believe) hypothesis is wrong.

Fixes: 280035560
Test: ran a few hundred times without failures, though
      I can't repro even without this change anyway
Change-Id: I620df32c43c855ca882e2e21201fe5b23b71a65a

Chalard Jean   commited 2023-05-02 18:07:45 +09:00
dcc1c3f50e
Ignore keepalive tests before S and without Tethering module
The tests do not need to run on devices where the module is not updated
or updatable.

Tests that are not in presubmit were missed when annotating keepalive
tests in a previous change.

Change-Id: I11ef44987b5a9cbcdf5b892807f65c4f9d04812f
Test: atest
Fixes: 280131407

Remi NGUYEN VAN   commited 2023-05-02 07:19:02 +00:00
058431df27
Merge "Expose internal representation of transport types."
Treehugger Robot   authored and   Gerrit Code Review   commited 2023-05-02 06:43:07 +00:00
c745e52e04
Merge "Support ICMP tests with larger packet size"
Chiachang Wang   authored and   Gerrit Code Review   commited 2023-05-02 06:17:05 +00:00
32319e85a2
Support ICMP tests with larger packet size
Add ping test with full MTU size and minimal IPv6 MTU size probes.
This helps to diagnose possible MTU issue in the bugreport.

Bug: 277376698
Test: adb shell dumpsys connectivity --diag
Change-Id: I0650de1f07fadcac189a40817bcc1a70be2e2b6c

chiachangwang   commited 2023-05-02 02:54:15 +00:00
ef0f518575
Merge "Add length option into ICMP packets"
Maciej Żenczykowski   authored and   Gerrit Code Review   commited 2023-04-29 19:26:08 +00:00
441a32e39d
Merge changes from topic "isfeatureenabled_onboot"
* changes:
  Add a dependency object in TetheringConfiguration
  Use DeviceConfigUtils for ConnectivityResources

Motomu Utsumi   authored and   Gerrit Code Review   commited 2023-04-29 05:24:29 +00:00
addca7cd13
remove inprocess tethering
It is just a constant source of bugs, with no real tests,
let's stop pretending this is a supported configuration.

The only tested configuration is out-of-process tethering
updatable apex.

Test: TreeHugger
Bug: 279942846
Change-Id: I4b659a3cd32b89a65549b56006b926a5ac755f7b

Maciej Żenczykowski   commited 2023-04-28 20:11:14 +00:00
7a03c187f5
Merge "Move ConnectivityResources to service-connectivity"
Motomu Utsumi   authored and   Gerrit Code Review   commited 2023-04-28 12:49:21 +00:00
a746ab1d68
Fix isFeatureEnabled namespace and overload usage
From service-connectivity, NAMESPACE_TETHERING must be used, as
NAMESPACE_CONNECTIVITY is used for the NetworkStack module. Also the
isFeatureEnabled with module name must be used, otherwise the "android"
package version is queried instead of the tethering module version.

BpfNetMaps is using flag value 1 to workaround this issue.
flags in NsdService, AutomaticOnOffKeepaliveTracker, and ConnectivityFlags
were not pushed currently.
So, this change has no effect to devices.

Bug: 279108992
Test: TH
Change-Id: I2b4b6a13c048c20beef52b1f43b9e21aca0c637a

Motomu Utsumi   commited 2023-04-28 19:18:43 +09:00
278db58bf5
Add a dependency object in TetheringConfiguration
Address a TODO in TetheringConfiguration to use a dependency object
instead of static mocking on DeviceConfig.

This avoids TetheringConfiguration dependencies on internal
implementation of DeviceConfigUtils, unblocking changes in
DeviceConfigUtils.

Bug: 279108992
Test: atest TetheringTests
Change-Id: I252eaadff85fa47b894e989b4f2527b00c5dca56

Remi NGUYEN VAN   authored and   Motomu Utsumi   commited 2023-04-28 19:18:43 +09:00
6d38c01852
Use DeviceConfigUtils for ConnectivityResources
De-duplicate the code by using
DeviceConfigUtils.getConnectivityResourcesPackageName.

Bug: 279108992
Test: atest
Change-Id: I54733016a9b902d5c209010161363c41bc8f1cce

Remi NGUYEN VAN   authored and   Motomu Utsumi   commited 2023-04-28 19:18:43 +09:00
219cc13b27
Move ConnectivityResources to service-connectivity
The ConnectivityResources class is only usable with QUERY_ALL_PACKAGES
permission, so it is not generally usable in framework-connectivity. It
is also backed by the ServiceConnectivityResources APK, which is
intended as resources for service-connectivity.

Move the class to service-connectivity and update callers. CTS needs a
way to determine the supported keepalive count as it used the
resources from KeepaliveUtils as @hide API, so provide a
ConnectivityManager @hide API for testing.

Bug: 279108992
Test: atest
Change-Id: I3c9a77c580b5ab87c922c32778bce15dc33b4d1d

Remi NGUYEN VAN   authored and   Motomu Utsumi   commited 2023-04-28 19:18:39 +09:00
bee2ee14f3
Add length option into ICMP packets
ICMP test does not support larger size probing currently. This
is a preliminary commit to support length parameter to config ICMP
packets size for the subsequent commit.

Bug: 277376698
Test: adb shell dumpsys connectivity --diag
Change-Id: Idf90ad716327f889630b943f8fb3452fc5bf5cfc

chiachangwang   commited 2023-04-28 10:03:42 +00:00
e51c81ad19
Cleanup to remove redundant 'public' modifier
Test: m
Change-Id: I4a09677bb355c3a6134a29ca8d2437e3212d4c67

chiachangwang   commited 2023-04-28 08:45:15 +00:00
8a835a8e55
Merge "Test the encap/timeout for the VCN"
Jean Chalard   authored and   Gerrit Code Review   commited 2023-04-28 05:18:59 +00:00
e50f1464bb