Commit Graph

1551 Commits

Author SHA1 Message Date
Jean Chalard
2c930437e9 Merge "Test that VPN lockdown restarts the VPN agent." 2023-04-17 05:38:54 +00:00
Jean Chalard
ca35653803 Merge "Add test for updating IKE about IP address changes" 2023-04-17 05:36:35 +00:00
Jean Chalard
6213d571a8 Merge "Adjust tests for delay in restarting/migrating IKE" 2023-04-17 05:35:21 +00:00
Chiachang Wang
2cf6b2c4fd Merge "Separate events usage for starting socket keepalives" 2023-04-17 02:32:00 +00:00
Chiachang Wang
baefd61455 Merge "Fix inexact argument type warning" 2023-04-17 01:48:31 +00:00
Yuyang Huang
885854c9ee Merge "Handle downstream tethering interface addresses in MdnsSocketProvider" 2023-04-16 00:52:28 +00:00
Yuyang Huang
700778be70 Handle downstream tethering interface addresses in MdnsSocketProvider
MdnsSocketProvider currently does not fill addresses of downstream
tethering interfaces in its callbacks. The interface addresses should be
properly updated by listening to the Netlink messages.

Test: atest FrameworksNetTests CtsNetTestCases
Bug: 267980538
Change-Id: I753e547a1b092703fe59c6c9e922ee8aca245f67
2023-04-15 21:55:51 +09:00
Junyu Lai
9d25241337 Merge changes from topic "statsaccess"
* changes:
  Check MAINLINE_NETWORK_STACK as well to make GTS can access proper stats
  Move checkAnyPermissionOf to PermissionUtils
2023-04-14 09:54:49 +00:00
chiachangwang
f1b1fb4b7f Separate events usage for starting socket keepalives
This is a clean up commit to correct the javadoc of
NetworkAgent.CMD_START_SOCKET_KEEPALIVE. This event was used
between ConnectivityService/NetworkAgent, and also
ConnectivityService/KeepaliveTracker with different semantics.
This may confuse the developers to update the doc incorrectly,
so also separate the usage to different events.

Also move the event definitions together so that a new event
definition will not mis-use the existing values.

Test: atest FrameworksNetTests
Change-Id: I73ebd8abcc610531da3057da2d643a41befb2099
2023-04-14 07:43:56 +00:00
Chalard Jean
23197121a1 Test that VPN lockdown restarts the VPN agent.
Bug: 246162564
Test: atest FrameworksNetTests:VpnTest
Change-Id: I35f08bf263cec19bbfb1d656d1d89dbb0acf8944
2023-04-14 16:38:19 +09:00
Chalard Jean
2b9bcb7830 Add test for updating IKE about IP address changes
Bug: 269715746
Test: VpnTest
Change-Id: I2c3a7f0f0af193b5497beaff38d54a80020a7aa0
2023-04-14 12:22:46 +09:00
Chalard Jean
9d85c7aa4c Adjust tests for delay in restarting/migrating IKE
This patch only adjusts the existing tests for the change
in the companion patch. Actual tests will come as a followup
because this patch is already big enough.

Test: VpnTest
Bug: 269715746
Change-Id: I65542a8f4151b4857f1b3758b2cae887bfbfe261
2023-04-14 12:22:46 +09:00
chiachangwang
25c74bd250 Fix inexact argument type warning
Assign the corresponding VpnProfileState for the null argument.

The varargs parameter has type "VpnProfileState...".  It needs
to decide whether the implementation want the argument to be
treated as a single-element of type VpnProfileState or no
arguement. Otherwise, it will confuse the compiler and cause
warning.

Test: atest VpnTest
Change-Id: Ic1dee696bb50cd78849de4812fb46fd764b23c6e
2023-04-14 01:58:18 +00:00
Treehugger Robot
5864b59462 Merge "Include/exclude mDNS interfaces based on transport" 2023-04-12 05:28:02 +00:00
Remi NGUYEN VAN
145b16cb5a Include/exclude mDNS interfaces based on transport
Regardless of IFF_MULTICAST (and IFF_BROADCAST), always include wifi
transport interfaces, and always exclude cellular transport interfaces.

Some interfaces do not have the multicast or broadcast flag set
properly. Use the transport to determine whether to use them, rather
than the interface flags.

Bug: 268138840
Test: atest MdnsSocketProviderTest
Change-Id: Idbddfa9d2cc05ce1850786aa634da4c38afd3fc0
2023-04-12 12:43:00 +09:00
Maciej Żenczykowski
b548e191de bpf network stats - remove dead code
only the test code ever passes in anything that isn't
a limit {UID_ALL, INTERFACES_ALL, TAG_ALL} (ie. no limit)

Test: TreeHugger, atest libnetworkstats_test FrameworksNetTests
Bug: 276296921
Signed-off-by: Maciej Żenczykowski <maze@google.com>
Change-Id: Ida489f25c4da4b12541c6001b41d9e4b30804eff
2023-04-11 19:24:28 +00:00
Junyu Lai
e68c42b888 Check MAINLINE_NETWORK_STACK as well to make GTS can access proper stats
Follow up from aosp/1933093. The test failed because certain
devices use a flattened apex that lacks the NETWORK_STACK
permission for sharing with the GTS apk.
Additionally, the NetworkStatsAccess does not recognize the
GTS apk, which holds the MAINLINE_NETWORK_STACK permission.

Test: TH
Bug: 275532605
Change-Id: Icce80a3d3dbea4a84fbd369d9b5fbe0029ab463e
2023-04-11 14:56:15 +08:00
Yuyang Huang
cf55b1ba5f Merge "Avoid creating a Network with INetd.LOCAL_NET_ID" 2023-04-05 08:21:56 +00:00
Yuyang Huang
3bee9d4099 Avoid creating a Network with INetd.LOCAL_NET_ID
INetd.LOCAL_NET_ID cannot be referred to by system SDK. To make the
MdnsSocketProvider built with system SDK, the reference to
INetd.LOCAL_NET_ID must be removed.

This network is created in MdnsSocketProvider.java and propagated
through MdnsSocketProvider.java -> MdnsMultinetworkSocketClient.java ->
MdnsDiscoveryManager.java -> MdnsServiceTypeClient.java ->
NsdService.java. In NsdService.java, it was used in
handleMdnsDiscoveryManagerEvent() -> buildNsdServiceInfoFromMdnsEvent()
-> setServiceNetworkForCallback(). The setServiceNetworkForCallback() is
updated to handle the NETID_UNSET the same as LOCAL_NET_ID.

Test: atest CtsNetTestCases FrameworksNetTests
Bug: 272392042
Change-Id: I07c573948e9dc6249325f0733807bb7a7ffc281c
2023-04-05 13:06:13 +09:00
Junyu Lai
2c12f922de Do not crash when passing null into buildTemplateMobileAll
Test: atest FrameworksNetTests:android.net.connectivity.android.net.NetworkTemplateTest
Test: atest FrameworksNetTests:android.net.connectivity.android.net.netstats.NetworkTemplateTest
Bug: 273963543
Change-Id: I0a8f94df124147e92d35cf474b3d69d1dee6902c
2023-03-30 13:59:02 +08:00
Treehugger Robot
dafaf2a08b Merge "Request cell in #testExplicitlySelected" 2023-03-28 07:57:33 +00:00
Chiachang Wang
0342985117 Merge "Adjust polling interval for auto on/off keepalives" 2023-03-27 06:05:08 +00:00
chiachangwang
d953d0182a Adjust polling interval for auto on/off keepalives
The system polls TCP connections every 2 minutes for the auto
on/off keepalives. For some carriers, the NAT-T keepalive delay
is lower than this, which means it's possible a TCP connection
is opened seconds after the poll. This may cause connections
being disconnected because keepalive timed-out.

The minimal acceptable value should be the same as the keepalive
delay. But the system may take time to restart keepalive. Adjust
the delay of the polling alarm to be lower than the keepalive
delay to preserve some time for the system to restart the
keepalive.

Bug: 273411114
Test: atest FrameworksNetTests
Change-Id: I28f71ceb7b72d83e6e0f8f7d22d3d1e9dbdaa467
2023-03-25 09:15:08 +00:00
Chiachang Wang
ce1bc54e66 Merge "Verify the update of shouldLongLivedTcpExcluded in VpnTransportInfo" 2023-03-25 04:12:22 +00:00
Paul Hu
46eb5f4b5e Merge "Clean up the LinkProperties when stop monitoring sockets" 2023-03-21 01:30:05 +00:00
Paul Hu
13921b2cdc Clean up the LinkProperties when stop monitoring sockets
The active network LinkProperties are not cleaned up after stop
socket monitoring. Then the apps will have duplicate sockets
to discover on one interface if the interface has been toggled,
because requestSocket will return both the old socket (for the
old netId that is actually gone) and a new socket on the same
interface, for the new netId. Thus, clean up the LinkProperties
when stop monitoring sockets.

Bug: 274063187
Test: atest FrameworksNetTests android.net.cts.NsdManagerTest
Change-Id: I3d600169b069a1534bd740e711bc21db107b1201
2023-03-20 15:06:05 +08:00
Chiachang Wang
f6682143ac Merge changes from topics "nonAutoIPSelection", "preferredIpProtocol"
* changes:
  Test IP version and encap type set in non-auto IP selection mode
  Test reading preferred IP protocol from carrierconfig
2023-03-20 02:39:42 +00:00
Paul Hu
62503cfef1 Merge "Add a CompatChange flag to enable platform backend" 2023-03-17 13:14:19 +00:00
Patrick Rohr
98021b650b Connectivity Tests: join handler thread after calling quitSafely
Somewhat surprisingly, HandlerThread#quitSafely is *not* a synchronous
method, so the tearDown() method still needs to wait for the thread to
join.

Test: TH
Change-Id: I0433e2100adf9299a67af5c259a518cf44f4be57
2023-03-17 01:01:09 -07:00
Paul Hu
a08f8867f8 Merge "Factor out adding records to a generic" 2023-03-17 02:30:39 +00:00
chiachangwang
052dbb85d3 Verify the update of shouldLongLivedTcpExcluded in VpnTransportInfo
Bug: 273422889
Test: atest FrameworksNetTests
Change-Id: I5e25d1b8b1f86dc4474cef1616cb16668119240a
2023-03-17 02:04:13 +00:00
Paul Hu
2e0a88c0fa Add a CompatChange flag to enable platform backend
Apps targeting sdk < U are considered to use a legacy native
daemon as NsdManager backend, but other apps use a
platform-integration mDNS implementation as backend. So add a
CompatChange flag to enable platform backend for non-legacy
apps.

Bug: 270306772
Test: atest FrameworksNetTests CtsNetTestCases
Change-Id: I7ba58f8a5186fb49ad5f8aeacc8b8234bef1eabe
2023-03-17 09:10:46 +08:00
Chalard Jean
7cf34ec1cd Request cell in #testExplicitlySelected
When the test is very slow (e.g. in coverage tests) it's
possible this test takes > 30 seconds and cell finishes
lingering before the end of the test. This will cause a
disconnection of cell before wifi and fail the test.

Address this by requesting cell.

Bug: 273383734
Test: atest --iterations 100 'FrameworksNetTests:android.net.connectivity.com.android.server.ConnectivityServiceTest#testExplicitlySelected'
Change-Id: I06a7ef82de966b522e58a969c25a4c0335dbc497
2023-03-16 22:12:52 +09:00
chiachangwang
e1aacc797c Test IP version and encap type set in non-auto IP selection mode
Test: atest FrameworksNetTests
Change-Id: I8f4a54f7b35135806c940b5cee2c600f4454f2fb
2023-03-16 03:00:45 +00:00
Patrick Rohr
c641e019ef IpConfigStoreTest: increase timeout for waitForIdle
waitForIdle in readIpConfigurationFromFilePath times out.

Test: TH
Change-Id: I5bc8c5b4678b984ec6406d85725297a63faeaabf
2023-03-15 19:48:25 +00:00
chiachangwang
55dc7b6e9f Test reading preferred IP protocol from carrierconfig
Bug: 259000745
Test: atest FrameworksNetTests
Change-Id: Ie9f546ae60fcc2e21479e5d7cbc86c96cfbedc84
2023-03-15 05:20:22 +00:00
Chiachang Wang
c211511b64 Merge changes from topics "kpFromCarrier", "noNetCapNoMigration"
* changes:
  Verify no migration started without valid network capabilties
  Test reading keepalive timer from carrierconfig
2023-03-09 12:17:21 +00:00
Junyu Lai
7ee63b6895 Merge "Remove requireNonNull check from matchesWifiNetworkKey" 2023-03-09 09:13:40 +00:00
chiachangwang
334b8dba3a Verify no migration started without valid network capabilties
Bug: 269714970
Test: atest FrameworksNetTests
Change-Id: I0f1a8cbdcb0a8a102036388b39162dca775c3f5d
2023-03-09 09:02:40 +00:00
chiachangwang
3a91e2d4f6 Test reading keepalive timer from carrierconfig
Bug: 259000745
Test: atest FrameworksNetTests
Change-Id: I2e750a7b090dd09553fae921163e19fc99a2d582
2023-03-09 09:01:17 +00:00
Treehugger Robot
e9df7ca57f Merge "Remove unused augmentWithStackedInterfaces" 2023-03-09 06:55:24 +00:00
Jeff Sharkey
31b6c65f51 Merge "Update system APIs based on feedback." 2023-03-09 02:47:49 +00:00
Paul Hu
71c006bd14 Merge changes from topic "PerNetworkServiceTypeClient"
* changes:
  Create MdnsServiceTypeClient per network
  Wait for a socket to be created before sending packets
2023-03-08 11:14:57 +00:00
Paul Hu
ee0e6cd701 Merge "Migrate reigster service callback backend" 2023-03-08 10:27:57 +00:00
Junyu Lai
615610c3d1 Remove unused augmentWithStackedInterfaces
after the commit aosp/1948496, both mMobileIfaces and mWifiIfaces
already contain the stacked interfaces. Hence, the method is not
really useful.

Test: TH
Fix: 215633405
Change-Id: Id132a166e9cf94cab711f417a4f7ffc84eab6185
2023-03-08 13:49:00 +08:00
Paul Hu
da3c0fe857 Create MdnsServiceTypeClient per network
The running task in MdnsServiceTypeClient would be cancel if the
requests using other networks for the same service type start a
new discovery. Besides, the instanceNameToResponse cache would
be incorrect too. The service attributes may be different on
different networks, so there needs to be a different instance
of the cache. Thus, the MdnsServiceTypeClient needs to be
Network-specific.

Bug: 265787401
Test: atest FrameworksNetTests
Change-Id: Id5ac42f3522a774fe9789c0de4d5357501b63868
2023-03-08 10:01:50 +08:00
Paul Hu
bf9d2a0ea0 Wait for a socket to be created before sending packets
The required sockets may not have been created yet when
MdnsServiceTypeClient#startSendAndReceive is called on
MdnsDiscoveryManager#registerListener, so the first send would go
nowhere, and only later retries would be sent. Ideally the code
would wait for some sockets to be created before calling
startSendAndReceive.

Bug: 265787401
Bug: 264634275
Test: atest FrameworksNetTests
Change-Id: Id789d564d125c0192e742d7dd246367afdb93413
2023-03-07 19:21:24 +08:00
Aaron Huang
8ac1143594 Remove requireNonNull check from matchesWifiNetworkKey
matchesWifiNetworkKey expects a non-null value of the
wifiNetworkKey, however, it might be null in practice
and the null wifiNetworkKey will be stored into disk.
And then when the matchesWifiNetworkKey is called, the
requireNonNull will crash the system. Thus, remove the
requireNonNull from matchesWifiNetworkKey to avoid
system crash and handle if the wifiNetworkKey is null
then it should not match a template with non-empty
mMatchWifiNetworkKeys.

Check if WifiInfo contains a null network key then skip it
to prevent adding the identity to the network identity set.
Also, add a Log.wtf when setWifiNetworkKey(info.getNetworkKey()),
this might be useful to catch why the wifiNetworkKey is
null.

Bug: 267815242
Bug: 266598304
Test: FrmeworksNetTests
Change-Id: I9c21f7e3dca9482133c7e331741cf808105414e9
2023-03-07 18:16:55 +08:00
Jeff Sharkey
4ffd34cc42 Update system APIs based on feedback.
API council has requested that the recently added BroadcastOptions
APIs be modified to better match API guidelines.

Bug: 267646347
Test: treehugger
Change-Id: Ia701ae31079476d0cc05079d62cd90ba81279cdd
2023-03-06 14:10:34 -07:00
Remi NGUYEN VAN
2172a5a370 Merge "Keep case in MdnsServiceInfo attributes" 2023-03-06 13:03:46 +00:00