This reverts commit 4bc9fa6b8c.
Reason for revert: b/288450518
Some iterations over mNetworkAgentInfos result in networks being
disconnected, which removes them from mNetworkAgentInfos during
iteration. This crashes with NPE or OOB exceptions.
Bug: 286649301
Bug: 288149251
Bug: 288450518
(cherry picked from https://android-review.googlesource.com/q/commit:3160bc0825490353d79c6586e21a7fc5893c678d)
Merged-In: I6e0b5b614d9e88267db77cb807ae4bf09f88c0f6
Change-Id: I6e0b5b614d9e88267db77cb807ae4bf09f88c0f6
Jean Chalardauthored and Android Build Cherrypicker Workercommited 2023-11-10 07:42:25 +00:00
Currently, various codepaths in ConnectivityService disconnect
networks using NetworkAgentInfo#disconnect. This posts a message
to the NetworkAgent to disconnect and also posts a message to
ConnectivityService to call disconnectAndDestroyNetwork, which
performs all cleanup in ConnectivityService. These two messages
race and the order is non-deterministic.
Instead, always disconnect using disconnectAndDestroyNetwork,
and have disconnectAndDestroyNetwork post the message to the
agent to disconnect.
This fixes a bug where if wifi uses unregisterAfterReplacement
twice in quick succession, when the third agent connects it
doesn't work because the interface is still being used by the
second network.
Also remove the import of IllegalArgumentException to keep the
linter happy (java.lang.* never needs to be imported).
Bug: 286649301
Test: covered by existing tests
(cherry picked from https://android-review.googlesource.com/q/commit:4bc9fa6b8cefca88f1065e95df06532979c202ee)
Merged-In: Ie01f5589d6839ac6db25f0ba98fc929fbb5b0a96
Change-Id: Ie01f5589d6839ac6db25f0ba98fc929fbb5b0a96
Lorenzo Colittiauthored and Cherrypicker Workercommited 2023-06-15 03:50:18 +00:00
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
(cherry picked from https://android-review.googlesource.com/q/commit:233f2d1d19bd36701e0dcfed6a57c85fac678e12)
Merged-In: I28bda08a006978ab760fe8891bf5cf15b536201a
Change-Id: I28bda08a006978ab760fe8891bf5cf15b536201a
Lorenzo Colittiauthored and Cherrypicker Workercommited 2023-06-14 06:08:58 +00:00
Test: new test for this behavior in the preliminary change
Test: FrameworksNetTests NetworkStackTests
Fixes: 138810051
Fixes: 140610528
(cherry picked from https://android-review.googlesource.com/q/commit:9fe47bee099125cf01fa153cdef28e100b9f3a0c)
Merged-In: I95a979d232fb60ece2e33e972bf5d66d20357a1f
Change-Id: I95a979d232fb60ece2e33e972bf5d66d20357a1f
Bug: 263074841
Aaron Huangauthored and Cherrypicker Workercommited 2023-06-08 03:58:12 +00:00
This patch mocks the SDK level and/or change IDs to help
developing functionality that depends on these without
having to flash a new device every time.
Test: TH
(cherry picked from https://android-review.googlesource.com/q/commit:df29a85ee70e56a888c82e4e885ab6f775416ff7)
Bug: 284253763
Merged-In: I1011193c99e123a0e5501ed313c9cecbceebdae6
Change-Id: I1011193c99e123a0e5501ed313c9cecbceebdae6
Chalard Jeanauthored and Motomu Utsumicommited 2023-06-05 10:11:45 +00:00
See system/netd/include/Fwmark.h which reserves the bottom 21 bits
of skb->mark for netid, etc... so out of necessity these have to be
in the top 11 bits.
In practice the only values that really make sense are either:
mark == mask == 0 (disabled)
or (mark == mask) being one of the top 11 available bits, for example:
mark == mask == 0x80000000 (enabled, using top-most bit)
(only a single bit makes sense, as this is really just a boolean signal,
and only the topmost is known to be used on any real devices)
Let's just force the use of 0x80000000 for ecosystem consistency.
Bug: 284334830
Test: TreeHugger
Signed-off-by: Maciej Żenczykowski <maze@google.com>
(cherry picked from https://android-review.googlesource.com/q/commit:767cf7f1cfc6d612bc8554fef8c354fdd660695b)
Merged-In: I199e9b00de845b3747940426ea6644426ab72e87
Change-Id: I199e9b00de845b3747940426ea6644426ab72e87
Maciej Żenczykowskicommited 2023-06-05 07:44:18 +00:00
aosp/2490881 updated to use InetDiagMessage.destroyLiveTcpSocket for all
devices.
But it is possible that netd socketDestory is modified in T- devices.
So this CL revert changes to keep using netd socketDestroy in T-
devices.
Test: atest FrameworksNetTests
Bug: 284253763
(cherry picked from https://android-review.googlesource.com/q/commit:1d137267108a28881e399d62311b1a42a60616fc)
Merged-In: I9b61f10e975d2e38e9829a8c01d3af706e2518ef
Change-Id: I9b61f10e975d2e38e9829a8c01d3af706e2518ef
Motomu Utsumiauthored and Cherrypicker Workercommited 2023-06-05 03:13:28 +00:00
Network state is not changed to disconnected when a networkagent
is disconnected and network state is SUSPENDED.
So the function requiresClat return true. Clat is not stoped.
Bug: 277682237
Test: atest FrameworksNetTests
(cherry picked from https://android-review.googlesource.com/q/commit:fd5d3d90e1da7411104902ddfe859ebd0e4a02fb)
Merged-In: I5edfcf64aca5d2d34325d722dd29fab41bcf2600
Change-Id: I5edfcf64aca5d2d34325d722dd29fab41bcf2600
wangshengrjxtjcbauthored and Cherrypicker Workercommited 2023-05-17 02:42:14 +00:00
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
(cherry picked from https://android-review.googlesource.com/q/commit:4f87aa3f13d8972d7525bb7231cf7ad6aaa0b7eb)
Merged-In: I26bfa8630c085422175558645c47a6c64be96ae6
Change-Id: I26bfa8630c085422175558645c47a6c64be96ae6
Lorenzo Colittiauthored and Cherrypicker Workercommited 2023-05-11 06:24:47 +00:00
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
(cherry picked from https://android-review.googlesource.com/q/commit:7c999d8d4cc4cd092d2de52ae98037ca4861e71f)
Merged-In: I93f174811aef726145a18ea90443ddfc1456478e
Change-Id: I93f174811aef726145a18ea90443ddfc1456478e
Mark Fashehauthored and Cherrypicker Workercommited 2023-05-11 02:25:35 +00:00
* changes:
Fix isFeatureEnabled namespace and overload usage
Add a dependency object in TetheringConfiguration
Use DeviceConfigUtils for ConnectivityResources
Move ConnectivityResources to service-connectivity
Motomu Utsumiauthored and Android (Google) Code Reviewcommited 2023-05-10 11:22:35 +00:00
Netd is not updatable since it's not mainlined.
To make socket destroy code updatable, the code was re-implemented in
java and moved to Connectivity.
Bug: 270298713
Test: atest FrameworksNetTests
(cherry picked from https://android-review.googlesource.com/q/commit:93a2218e41384d106f1c14c239e1bf4795af43d5)
Merged-In: I5439c0c76c42a9f738a1b25a1f62e701755cbd05
Change-Id: I5439c0c76c42a9f738a1b25a1f62e701755cbd05
Motomu Utsumiauthored and Cherrypicker Workercommited 2023-05-10 03:15:45 +00:00
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
(cherry picked from https://android-review.googlesource.com/q/commit:278db58bf536551158e8082d3e7572650a908b05)
Merged-In: I2b4b6a13c048c20beef52b1f43b9e21aca0c637a
Change-Id: I2b4b6a13c048c20beef52b1f43b9e21aca0c637a
Motomu Utsumiauthored and Cherrypicker Workercommited 2023-05-10 03:11:11 +00:00
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
(cherry picked from https://android-review.googlesource.com/q/commit:bee2ee14f34ff028236b393523d1174a375d2a08)
Merged-In: I3c9a77c580b5ab87c922c32778bce15dc33b4d1d
Change-Id: I3c9a77c580b5ab87c922c32778bce15dc33b4d1d
Remi NGUYEN VANauthored and Cherrypicker Workercommited 2023-05-10 03:10:42 +00:00
Cellular networks are now supported for marking wakeup packets. As a
result onWakeupEvent now also reports data relevant to the cell
transport.
These unit tests should add coverage for these new behaviors.
Test: atest FrameworksNetTests
Bug: 276498460
Change-Id: I0b8a03fff6255e067b736f3dbfb53de56420f90b
Merged-In: I0b8a03fff6255e067b736f3dbfb53de56420f90b
Starting with Android U, the config_networkWakeupPacketMark and
config_networkWakeupPacketMask values will be used to mark packets that
woke up the AP on the cellular transport also.
Test: Manual, by inspecting the output of `iptables -L -t -n -v mangle`
Bug: 276498460
Change-Id: I4c7d2801532604d436bfda96c4c52a791995a9ed
Merged-In: I4c7d2801532604d436bfda96c4c52a791995a9ed
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
This is also needed in other classes in subsequent CLs, move to
a common place to prevent from code duplication.
Test: TH
Bug: 275532605
Change-Id: If7c757cecba8027b2f3b5209e6ea67733da50bf3
Using packageManager from ConnectivityService context to get the caller
application info in binder calls can cause the permission issue. Calling
the Binder.clearCallingIdentity() before interact with packageManager
can fix the permission issue.
Test: atest CtsHostsideNetworkTests
Bug: 272165411
Change-Id: I0a289afc6fb0e42a92aa3ffa0c77ed396c4485c3
This includes two restriction changes of simulateDataStall:
- Allow simulation on a network that has an underlying test
network
- Allow simulation on networks created by the system server
This commit allows VCN and VPN to CTS test their abilities of
handling suspected data stall.
This commit is safe because #simulateDataStall is already protected
by two signature permissions MANAGE_TEST_NETWORKS and NETWORK_STACK,
and those permissions are granted to only preinstalled apps.
Bug: 263415068
Test: atest VcnManagerTest (new tests)
Change-Id: Ic0cdb66abb291fbf4a7545efe4114179e965d2b6
API council has requested that the recently added BroadcastOptions
APIs be modified to better match API guidelines.
Bug: 267646347
Test: treehugger
Change-Id: Ia701ae31079476d0cc05079d62cd90ba81279cdd
When the network requester process has been killed, lots of
binderDied logs would be spewed out. These logs haven't been
useful for debugging but to be very spammy. Thus, remove this log
entirely.
Bug: 223128960
Test: Manual test
Change-Id: Ic3096bfee41167b1a54a9d04b474263d15217217
CM#setTestLowTcpPollingTimerForKeepalive() is hidden method for
CTS. The debuggable restriction will prevent it from running on
actual CTS. The method is protected by permission with parameter
range constraint. It should be enough for incorrect usage from
normal apps. Remove it to allow test case to run on actual CTS.
Bug: 259000745
Test: CTS is the follow up commit
Change-Id: I3d4627c75bae7411c6a72799643d3b29bbae4f2f
chiachangwangauthored and Chiachang Wangcommited 2023-03-02 07:54:21 +00:00
This is useful in the system server for better attribution of wakeup
events.
The logic for encoding the data in the prefix is still maintained ad-hoc
and should be standardized in the future.
Test: Builds, boots. Manually triggering a wifi wakeup doesn't result
in anything unexpected.
Test: atest FrameworksNetTests
Bug: 265742148
Change-Id: I7ef8a606459bb9f0630f629c01d3b34643ae5319
When the application wants to request network with
NET_CAPABILITY_PRIORITIZE_BANDWIDTH or
NET_CAPABILITY_PRIORITIZE_LATENCY, it has to declare
PackageManager.PROPERTY_NETWORK_SLICE_DECLARATIONS property and also
adds the declaration in a separate XML files. Otherwise, the request
will fail with a SecurityException being thrown.
Test: atest FrameworksNetTests CtsNetTestCases
Bug: 266524688
Change-Id: I6affc857b803211517368da288e1b2fdc06a955b
Test: 1. Patch local built module on T device
2. atest ConnectivityCoverageTests:android.net.connectivity.com.android.server.ConnectivityServiceTest
Fix: 267968887
Change-Id: I86e5be9a0cee0621ff9ef0996d56a51fc5f408c2
Take a Network parameter to have an one-to-one mapping between
keepalive and its underpinned network on the automatic keepalive.
Existing design could not really tell which network should the
automatic keepalive check for the TCP socket status if there are
multiple automatic keepalives enabled, e.g. Bothe IWLAN and VPN
on WiFi enable the automatic keepalive. The keepalive for IWLAN
should check if there are any TCP sockets on the IWLAN network
instead of VPN network.
Bug: 259000745
Test: atest FrameworksNetTests
Test: Cts in the follow up commit
Change-Id: I7353f4ef43e8fdad02c4d4a0bb5f6efa7d94c1b4
Print state and keepalive information in the dump.
Also update ConnectivityService and the corresponding test to
create AutomaticOnOffKeepaliveTracker from a Dependencies class.
ConnectivityService#dump() will require READ_DEVICE_CONFIG
permission because of the new dump() in AutomaticOnOffKeepaliveTreacker.
ConnectivityServiceTest should focus on verifying design in
ConnectivityService, so skipping the DeviceConfig check via a fake
Dependencies class in the unit test.
Sample dump:
AutomaticOnOff enabled: true
AutomaticOnOffKeepalive [KeepaliveInfo [ type=1 network=100 startedS ... ], state=STATE_ENABLED ]
Bug: 259000745
Test: m ; atest FrameworksNetTests CtsNetTestCases
Change-Id: I9ac725bcef7daec1d1a12bad592b7fa6856a1707
registerSystemDefaultNetworkCallback is required by WifiTrackerLib to
detect the system default network for UI purposes. Currently this API is
allowed for holders of the NETWORK_SETTINGS permission, but not
NETWORK_SETUP_WIZARD. Since SUW also uses WifiTrackerLib, we should
allow this API for NETWORK_SETUP_WIZARD as well.
Bug: 230643853
Test: atest ConnectivityServiceTest
Change-Id: Ic01a186f91ed67b4603b6b8964921be7473a483a
The default TCP polling alarm timer is very large(2 mins).
It's expensive in the CTS to wait for a couple alarms.
The polling alarm should be deprecated soon and replace
with callback design, so add the hidden method for testing
purpose to support the short term usage until design is
replaced with callbacks.
With the hidden method, the alarm timer will decrease to
1 second for a specified time period. The TCP sockets status
could be verified every 1 second.
Bug: 259000745
Test: m ; atest HostsideVpnTests with the follow up test
Change-Id: I99d494d3b50b2fbee73b926e92e97b1e194d43d4