Commit Graph

73685 Commits

Author SHA1 Message Date
Lorenzo Colitti
233f2d1d19 Remove spurious WTF on pre-U devices.
aosp/2162425 added a WTF if a NetworkAgent changed state before
its native network has been created. This was intended to apply
only to the new U+ codepath, where networks are always created
immediately as soon as their agents register them. But the WTF is
logged on pre-U devices as well.

Fix this so that the WTF is only logged when the new codepath is
running.

Fix: 285999421
Test: TH
Change-Id: I28bda08a006978ab760fe8891bf5cf15b536201a
2023-06-07 11:42:20 +09:00
Lorenzo Colitti
f1a61ad83d Skip all of NetworkAgentTest in instant mode.
Recently, new test methods were added to NetworkAgentTest which
fail in instant mode because they are not marked @AppModeFull.

Because instant apps can't use NetworkAgent (it's a system API,
and it needs the NETWORK_FACTORY permission which is signature
only), just mark the whole test @AppModeFull so this cannot
happen again.

Bug: 283897713
Test: test is skipped in instant mode
Change-Id: Ib6ff07d9fdc329d3421a077532b8a434323053f8
2023-05-23 16:01:42 +09:00
Paul Hu
6f47b7d501 Merge "Remove the ServiceTypeClient after socket destroyed" 2023-05-11 11:50:57 +00:00
Treehugger Robot
b0c6da3f96 Merge "Use private dns port definition in static lib" 2023-05-11 11:48:27 +00:00
Paul Hu
f2a51ac5f8 Remove the ServiceTypeClient after socket destroyed
The ServiceTypeClient should be removed after socket destroyed
because it's no longer used by any request. The requests will be
matched to the newly created ServiceTypeClient.

Bug: 278635632
Test: atest FrameworksNetTests CtsNetTestCases
Change-Id: Ia917b14d3666f3bfe8e874606a34800a4ce65c5a
2023-05-11 15:17:21 +08:00
chiachangwang
afda1a5579 Clear calling identity before accessing DeviceConfig
Creating an AutomaticOnOffKeepalive object is an internal design
in the AutomaticOnOffKeepaliveTracker which should not require
callers' permission. Reading DeviceConfig will check if the
calling uid and calling package name are the same. Clear calling
identity to align the calling uid and package.

All these accesses require performing this action so move it into
the Dependencies.

Bug: 279381469
Test: atest FrameworksNetTests CtsHostsideNetworkTests
Change-Id: Icb4721ce8ca9c8fc7e9118b4e46300147be4e08e
2023-05-11 06:07:41 +00:00
Lorenzo Colitti
18cdec34dd Merge "Immediately create native networks when NetworkAgents register." 2023-05-11 03:35:21 +00:00
Paul Hu
3e497c7b1e Merge "Use a single SharedLog for all mdns components" 2023-05-11 00:45:18 +00:00
Mark Fasheh
2d626e5632 Merge "Optionally have ConnectivityService kill sockets for frozen apps" 2023-05-10 23:08:00 +00:00
Mark Fasheh
7c999d8d4c 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
2023-05-10 21:04:54 +00:00
Lorenzo Colitti
4f87aa3f13 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
2023-05-10 20:01:07 +09:00
Junyu Lai
598ca1e284 Merge "Fix template for test network needs fine location permission" 2023-05-10 02:22:18 +00:00
Paul Hu
14667deefa 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
2023-05-10 02:18:43 +00:00
Maciej Żenczykowski
be66108f84 Merge "add congestion control test to CTS" 2023-05-09 18:17:12 +00:00
Maciej Żenczykowski
6de6b3f106 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
2023-05-09 18:16:52 +00:00
Paul Hu
49078d7b0f Merge "Process all responses if the network is null in MdnsServiceTypeClient" 2023-05-09 10:23:24 +00:00
Treehugger Robot
8ac7ad4d9a Merge "Fix flaky testUidTagStateDetails" 2023-05-09 08:03:51 +00:00
Paul Hu
bdf82a2aa0 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
2023-05-09 15:19:29 +08:00
Yichun Li
043c7f07e4 Merge "Update uiautomator references in packages/modules/Connectivity/tests/cts/hostside/app" 2023-05-08 19:29:49 +00:00
Treehugger Robot
ac7a0e3ee9 Merge "Prevent hotspot from being affected by the wifi retention feature" 2023-05-08 07:39:12 +00:00
Treehugger Robot
ab809e5ce0 Merge "Fix isFeatureEnabled namespace and overload usage" 2023-05-08 03:19:27 +00:00
Treehugger Robot
8438c257fc Merge "Ignore keepalive tests before S and without Tethering module" 2023-05-08 03:16:18 +00:00
Maciej Żenczykowski
fb4ab74a09 Merge "ConnectivityManagerTest: clean up when connectToCell fails" 2023-05-06 14:26:57 +00:00
Patrick Rohr
79c9aa8ecc 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
2023-05-05 15:47:59 -07:00
Maciej Żenczykowski
e95ec4afa7 Merge "remove inprocess tethering" 2023-05-05 20:31:58 +00:00
Yichun Li
b660c7f652 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
2023-05-05 15:19:15 +00:00
Treehugger Robot
3903b1e91d Merge "Avoid going over max service name length when renaming NSD services" 2023-05-04 06:06:24 +00:00
Yuyang Huang
de802c8dc4 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
2023-05-04 13:24:23 +09:00
Junyu Lai
a58914b548 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
2023-05-04 11:01:33 +08:00
Junyu Lai
bf595bfeec Use private dns port definition in static lib
Test: TH
Bug: 276230058
Change-Id: Ie66350e32269351ce613f8cec549fafdb37ae4c1
2023-05-04 10:29:16 +08:00
Treehugger Robot
818d4480e8 Merge "drop support for V gsi on pixel 5 R base kernel" 2023-05-03 19:25:39 +00:00
Xiao Ma
8da5ff4b5f Merge "Add an integration test to verify zero-length DHCP packet." 2023-05-03 14:09:04 +00:00
Junyu Lai
ddfb2382e0 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
2023-05-03 13:35:16 +08:00
Maciej Żenczykowski
69b6ca4ff1 Merge "Add null check for tupleOrig in ConntrackMessage" 2023-05-02 22:29:45 +00:00
Treehugger Robot
277b236de3 Merge "BpfNetMaps: do not register BpfNetMaps JNI before T" 2023-05-02 18:02:19 +00:00
Maciej Żenczykowski
9461bb1f48 clarify comment about uid check on abort()
Test: TreeHugger
Signed-off-by: Maciej Żenczykowski <maze@google.com>
Change-Id: I31f40622fee9833681ffa10307430cde7920eb16
2023-05-02 16:23:02 +00:00
Patrick Rohr
31edd95c24 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
2023-05-02 16:18:50 +00:00
KH Shi
9dfbb45bb6 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
2023-05-02 22:57:24 +08:00
Treehugger Robot
f69ae23e01 Merge "Fix NetworkScoreTest flake" 2023-05-02 12:11:49 +00:00
Maciej Żenczykowski
bbbd18a713 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
2023-05-02 11:48:17 +00:00
Chalard Jean
dcc1c3f50e 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
2023-05-02 18:07:45 +09:00
Remi NGUYEN VAN
058431df27 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
2023-05-02 07:19:02 +00:00
Treehugger Robot
c745e52e04 Merge "Expose internal representation of transport types." 2023-05-02 06:43:07 +00:00
Chiachang Wang
32319e85a2 Merge "Support ICMP tests with larger packet size" 2023-05-02 06:17:05 +00:00
chiachangwang
ef0f518575 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
2023-05-02 02:54:15 +00:00
Maciej Żenczykowski
441a32e39d Merge "Add length option into ICMP packets" 2023-04-29 19:26:08 +00:00
Motomu Utsumi
addca7cd13 Merge changes from topic "isfeatureenabled_onboot"
* changes:
  Add a dependency object in TetheringConfiguration
  Use DeviceConfigUtils for ConnectivityResources
2023-04-29 05:24:29 +00:00
Maciej Żenczykowski
7a03c187f5 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
2023-04-28 20:11:14 +00:00
Motomu Utsumi
a746ab1d68 Merge "Move ConnectivityResources to service-connectivity" 2023-04-28 12:49:21 +00:00
Motomu Utsumi
278db58bf5 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
2023-04-28 19:18:43 +09:00