Commit graph android_packages_modules_Co.../service/src/com/android
Message SHA1
Merge changes I7184eaa0,I2c5951ab into main
* changes:
  Do not crash when adding UID ranges to a destroyed network.
  Test that UID ranges can incorrectly be added to a destroyed network.

Lorenzo Colitti   authored and   Gerrit Code Review   commited 2024-10-23 04:39:07 +00:00
6bf2ce44e4
Do not crash when adding UID ranges to a destroyed network.
aosp/3218864 fixed the crash when ranges are removed from a
destroyed network, but did not fix the case where the ranges are
added to a destroyed network.

This can happen if a multilayer request is filed when a network
has already been destroyed.

Fix: 368989698
Test: updated existing tests for this bug
Change-Id: I7184eaa01141f56b7ad774277c7dee03d5812298

Lorenzo Colitti   commited 2024-10-22 11:41:21 +00:00
dfe98fc5be
Standardize handler thread checks
Use HandlerUtils#ensureRunningOnHandlerThread to perform handler
thread checks instead of individual methods within the class.

Test: TH
Change-Id: I6d893dc9eedc588660797768a03e7ad7ab636479

Paul Hu   commited 2024-10-17 06:14:05 +00:00
c0e709700c
Introduce PrivateAddressCoordinator methods at RoutingCoordinatorManager
This CL exposes PrivateAddressCoordinator methods at
RoutingCoordinatorManager and implements the methods in
RoutingCoordinatorService.

The objective is to allow a system service like Thread to request an
IPv4 address allocation.

Bug: 350699020

Change-Id: I65dc309f0b503d544e0fddc1168131fa6174796c

Handa Wang   commited 2024-10-16 23:54:25 +00:00
e5e06f9f7c
bpf: merge block.c into netd.c
Since this is just a special case of a bpf cgroup hook,
it really should be in netd.o with all other such hooks.

Besides moving/renaming the map & programs this should be a no-op.

Test: TreeHugger, atest bpf_existence_test
Signed-off-by: Maciej Żenczykowski <maze@google.com>
Change-Id: I4a2aedaf77f89a9c0a96fa1c369d80659535eabe

Maciej Żenczykowski   commited 2024-09-19 00:40:53 +00:00
3ad3794efa
Merge "Fix threading issue for mDefaultNetworkRequests" into main
Motomu Utsumi   authored and   Gerrit Code Review   commited 2024-09-06 13:10:58 +00:00
a5a549bfd8
Fix threading issue for mDefaultNetworkRequests
Handler thread updates mDefaultNetworkRequests and Multiple threads
read/iterate mDefaultNetworkRequests without locking.
This caused NPE when there is concurrent updates and iterations.
This CL fixed this issue by using CopyOnWriteArraySet.
CopyOnWriteArraySet is suitable since number of default network request
is small (system default network request + per-app default network
requests) and updated infrequently but read frequently.

Bug: 293978451
Test: TH
Change-Id: Iaefe8e6e31c2b5257ebc51b4f848c3a7197781cb

Motomu Utsumi   commited 2024-09-06 11:04:00 +09:00
7b906dea29
DscpPolicyValue: just use '!= null' on original src/dst46 argument
See Lorenzo's comment on aosp/3243843 for why.

Test: TreeHugger, atest CtsNetTestCases:android.net.cts.DscpPolicyTest
Signed-off-by: Maciej Żenczykowski <maze@google.com>
Change-Id: I43cab1ee009ec53174fb102ca60ee91b3049857c

Maciej Żenczykowski   commited 2024-09-04 21:32:04 +00:00
5e7247d922
Merge "Skip TestDropPacketToVpnAddress if the feature is disabled" into main
Motomu Utsumi   authored and   Gerrit Code Review   commited 2024-09-02 07:52:02 +00:00
b8950d144a
Skip TestDropPacketToVpnAddress if the feature is disabled
INGRESS_TO_VPN_ADDRESS_FILTERING is disabled due to b/352424251 and
testDropPacketToVpnAddress fails if the feature is disabled.
So skip testDropPacketToVpnAddress if the feature is disabled.

Bug: 362434644
Test: adb shell device_config put tethering
      ingress_to_vpn_address_filtering -1
Test: atest CtsHostsideNetworkTests

Change-Id: Ib16a7550dcf93dd9ecf29047b1c4f101ff6d610d

Motomu Utsumi   commited 2024-09-02 15:21:30 +09:00
9d5d7d0779
Merge "Add mIngressToVpnAddressFiltering to dump" into main
Treehugger Robot   authored and   Gerrit Code Review   commited 2024-08-29 11:57:24 +00:00
00969a2835
Add mIngressToVpnAddressFiltering to dump
Example output:

Multicast routing supported: true
Background firewall chain enabled: true
IngressToVpnAddressFiltering: false

Bug: 362434644
Test: adb shell dumpsys connectivity
Change-Id: I36e0726d7b7ffe873ed6498a45f57c459cc884cc

Motomu Utsumi   commited 2024-08-29 19:24:47 +09:00
727dd5dea4
dscpPolicy: switch to bool
Bug: 361492282
Test: TreeHugger, atest CtsNetTestCases:android.net.cts.DscpPolicyTest
Signed-off-by: Maciej Żenczykowski <maze@google.com>
Change-Id: I3bd83e19a814d811028f8bd60d3e0a794050338e

Maciej Żenczykowski   commited 2024-08-26 16:44:17 -07:00
d6c0db3b41
Merge "Inform DNS resolver whether DDR is enabled." into main
Lorenzo Colitti   authored and   Gerrit Code Review   commited 2024-08-26 06:43:19 +00:00
ea68942848
Inform DNS resolver whether DDR is enabled.
This is needed to cleanly flag on/off DDR and to ensure that
when it is flagged on, DnsResolver ignores the hardcoded list of
DoH providers and only uses DDR.

Bug: 240259333
Test: updated existing tests
Change-Id: I84c103a5a4d18294b6a4cc3301d0037d1a6673a4

Lorenzo Colitti   commited 2024-08-23 18:23:42 +09:00
7cde306fa3
Check network destroy status before networkRemoveUidRangesParcel
networkRemoveUidRangesParcel throws ServiceSpecificException if the
native network is already destroyed.
This can happen when
1) per-app default network request is satisfied by network1
2) unregisterAfterReplacement is called to the network1. This calls
   netd.networkDestroy and network is removed from netd.
3) per-app default network request is removed. This calls
   netd.networkRemoveUidRangesParcel but netd does not know about this
   netid anymore.

This CL fixes this issue by skip calling networkRemoveUidRangesParcel if
the request satisfier is already destroyed.

Bug: 336961452
Bug: 357974842
Test: CSSatelliteNetworkTest
Change-Id: Id775cca6fffd03545f1c4bc5016d0de4813f17df

Motomu Utsumi   commited 2024-08-19 16:25:39 +09:00
471f20142f
Merge "Pass DoH information to DnsResolver" into main
Remi NGUYEN VAN   authored and   Gerrit Code Review   commited 2024-08-14 07:50:42 +00:00
af569157d5
Skip adding ingress discard rule to OEM VPN
OEM VPNs might need to receive packets to VPN address via
non-VPN interface.

Bug: 352424251
Test: CsIngressDiscardRuleTest
Change-Id: Ia9000bcbb5b3b9e1e0d396ba78946be36e2fc5ba

Motomu Utsumi   commited 2024-08-06 19:02:33 +09:00
c14288f7c7
Merge changes If787d3f3,I6de357ac into main
* changes:
  Rename getShrinkedBackingArray to getMinimized*
  Suspend callbacks for frozen apps

Remi NGUYEN VAN   authored and   Gerrit Code Review   commited 2024-08-05 00:15:39 +00:00
057369c840
Merge "Skip adding ingress discard rule to legacy VPN" into main
Treehugger Robot   authored and   Gerrit Code Review   commited 2024-08-02 23:44:47 +00:00
c4b4feed19
Rename getShrinkedBackingArray to getMinimized*
"Shrinked" should actually be "shrunk" or "shrunken"; in any case
"minimized" is simpler and possibly more accurate (it's the minimum size
required to hold the values).

Test: atest
Change-Id: If787d3f3d6e1046338d4e89ed924bce183e74bd6

Remi NGUYEN VAN   commited 2024-08-02 19:27:41 +09:00
dfb159289b
Suspend callbacks for frozen apps
To avoid filling the binder buffers, and sending unnecessary callbacks
when apps are unfrozen (for example successive LinkProperties changes or
onAvailable+onLost are not useful), queue and aggregate callbacks for
apps that are suspended.

Test: atest
Bug: 327038794
Bug: 279392981
Change-Id: I6de357ac2834f1f7e960dfbaa63adfc3825f2a82

Remi NGUYEN VAN   commited 2024-08-02 19:24:17 +09:00
2d78124348
Skip adding ingress discard rule to legacy VPN
Some legacy VPNs need to receive packets to VPN address via
non-VPN interface.

Bug: 352424251
Test: CsIngressDiscardRuleTest
Change-Id: Iad06dc69c5bf5ccda476e89ed9b0fc1bc63d2ebe

Motomu Utsumi   commited 2024-08-02 19:15:59 +09:00
1b376f0fc4
Merge "Close the socket fd in case of an exception during setupSocket method to avoid socket leak." into main
Treehugger Robot   authored and   Gerrit Code Review   commited 2024-07-30 00:29:54 +00:00
24289ea9b3
Fix import order
Reorganize imports to make linter happy.

Test: m
Change-Id: If0e290cf9f2d12d8479848b6a74690412b673439

Remi NGUYEN VAN   commited 2024-07-19 11:59:40 +09:00
42dc6e49e0
Merge "No-op refactoring for suspending callbacks" into main
Treehugger Robot   authored and   Gerrit Code Review   commited 2024-07-17 02:45:42 +00:00
aebc6317d3
Merge changes I6cc2507d,I187ea15d into main
* changes:
  Add flag for QUEUE_CALLBACKS_FOR_FROZEN_APPS
  Add a CallbackQueue class

Remi NGUYEN VAN   authored and   Gerrit Code Review   commited 2024-07-16 08:46:11 +00:00
16828bdeba
No-op refactoring for suspending callbacks
No-op refactoring of ConnectivityService, in preparation for a change to
suspend callbacks for frozen apps.

Test: atest
Bug: 327038794
Bug: 279392981
Change-Id: I55bdd6c1244d6829d40223883ca148ce9ac5dca8

Remi NGUYEN VAN   commited 2024-07-16 15:53:09 +09:00
a65af5f8e1
Add flag for QUEUE_CALLBACKS_FOR_FROZEN_APPS
Add a flag to be used for an optimization to queue callbacks while apps
are frozen, instead of filling the binder buffer.

Bug: 327038794
Bug: 279392981
Test: atest
Change-Id: I6cc2507de88fae3d0866f9831e1e9026200297e4

Remi NGUYEN VAN   commited 2024-07-16 13:36:51 +09:00
48d2527e43
Add a CallbackQueue class
The class will be used to build memory-efficient objects (int arrays)
used to queue ConnectivityService callbacks while an app is frozen.

This is very similar to an ArrayList<Pair<Short, Short>>, but avoids
object boxing which would use a lot more memory.

This is intended to be used by ConnectivityService both as a builder,
and as a utility to read lists of callbacks that it stores. Long-lived
references to the CallbackQueue would not be kept to minimize memory
usage; only the array returned by toArray needs to be stored.

Test: atest
Bug: 327038794
Bug: 279392981
Change-Id: I187ea15d14dfd160e577e9e9e87b1aded27b1938

Remi NGUYEN VAN   commited 2024-07-16 13:36:49 +09:00
c3621e6012
Check system and phone UID in multiple-user-aware way
This CL calls UserHandle.getAppId to make sure the UID check with
Process.SYSTEM_UID and PHONE_UID are multiple-user-aware.

In multiuser context, Process.SYSTEM_UID or PHONE_UID is NOT the UID
of system/phone but the app id. The complete UID is prefixed with
user id (e.g. 1001001 is phone UID for user 10).

Bug: 328511085
Test: atest FrameworksNetCommonTests
Flag: EXEMPT Tiny bug fix
Change-Id: I97bbfcff37374ba367fc8d62400ae140136cd012

rambowang   authored and   Rambo Wang   commited 2024-07-09 17:37:27 +00:00
1879bc3033
Refactor RoutingCoordinator
- This CL puts RoutingCoordinator into staticlibs to make it usable by
both Tethering and ConnectivityService on R.
- This CL also changes the return type of
  ConnectivityInternalApi#getRoutingCoordinatorManager() to IBinder so
  it has fewer dependencies.

Bug: 350699020
Test: CI

Change-Id: Iba096e940795cd33e61c5141721394ad39e5ce6d

Handa Wang   commited 2024-07-05 05:26:54 +00:00
8f2c30664d
Merge "Improve NetworkCallback declared methods toString" into main
Treehugger Robot   authored and   Gerrit Code Review   commited 2024-07-04 04:11:52 +00:00
5289382f04
Improve NetworkCallback declared methods toString
Instead of printing the flags as hex, use flag names for known flags.

Bug: 327038794
Bug: 279392981
Test: atest
Change-Id: I11ba4de1e8e60d5468a72b275cd724be669b32bc

Remi NGUYEN VAN   commited 2024-07-03 19:09:51 +09:00
baf7c1184f
Close the socket fd in case of an exception during setupSocket method to avoid socket leak.
Bug: 350514743

When dump of networkDiagnostics is triggered, if there is any error when performing IcmpCheck and DnsUdpCheck measurements, the failure is recorded and the method is returned.
The socket fds are not closed leading to open sockets and file descriptor leak.
This change is to call close() on the open sockets in case of an error in the catch block.

The following is logs collected by dumping network diagnostics via "adb shell dumpsys connectivity --diag", and introducing an exception in setupSocket method.
===
//Without the fix, an error in setupSocket leaves open fds.
01-01 00:25:45.611  1179 32581 I NetworkDiagnostics: setupSocket mFileDescriptor = java.io.FileDescriptor@b9983db
01-01 00:25:45.612  1179 32580 I NetworkDiagnostics: IcmpCheck catchblock open mFileDescriptor = java.io.FileDescriptor@cec0e78

01-01 00:25:45.612  1179 32582 I NetworkDiagnostics: setupSocket mFileDescriptor = java.io.FileDescriptor@5bae951
01-01 00:25:45.613  1179 32582 I NetworkDiagnostics: DnsUdpCheck catchblock open mFileDescriptor = java.io.FileDescriptor@5bae951

//With the fix, the open fds are closed.
01-01 00:30:00.884  1179  8744 I NetworkDiagnostics: setupSocket mFileDescriptor = java.io.FileDescriptor@1aa20a2
01-01 00:30:00.885  1179  8744 I NetworkDiagnostics: IcmpCheck catchblock open mFileDescriptor = java.io.FileDescriptor@1aa20a2
01-01 00:30:00.885  1179  8744 I NetworkDiagnostics: IcmpCheck catchblock closing  mFileDescriptor= java.io.FileDescriptor@1aa20a2
01-01 00:30:00.885  1179  8744 I NetworkDiagnostics: closeQuietly mFileDescriptor = java.io.FileDescriptor@1aa20a2

01-01 00:30:00.885  1179  8746 I NetworkDiagnostics: setupSocket mFileDescriptor = java.io.FileDescriptor@aad7133
01-01 00:30:00.886  1179  8746 I NetworkDiagnostics: DnsUdpCheck catchblock open mFileDescriptor = java.io.FileDescriptor@aad7133
01-01 00:30:00.886  1179  8746 I NetworkDiagnostics: DnsUdpCheck catchblock closing  mFileDescriptor= java.io.FileDescriptor@aad7133
01-01 00:30:00.886  1179  8746 I NetworkDiagnostics: closeQuietly mFileDescriptor = java.io.FileDescriptor@aad7133
===

Change-Id: I92f30af1b7b98813bd946bd3d9fd506f15367eab
Signed-off-by: Alekhya Karavadi <akaravad@ford.com>

Alekhya Karavadi   commited 2024-07-02 11:59:11 -04:00
3c5d4e05a1
Merge "Refactor enforceMeteredApnPolicy" into main
Motomu Utsumi   authored and   Gerrit Code Review   commited 2024-06-28 02:24:06 +00:00
9f3b991a7a
Refactor enforceMeteredApnPolicy
Address review comment on aosp/3027487
This CL also adds test for enforceMeteredApnPolicy

Test: CSBlockedReasonsTest
Bug: 344800107
Change-Id: Ib531bf5b34566fc91fec9f977c5257b332189706

Motomu Utsumi   commited 2024-06-27 22:25:47 +09:00
e9c07ffd72
Merge "Document reason for not using SingleWriterBpfMap in ClatCoordinator" into main
Yuyang Huang   authored and   Gerrit Code Review   commited 2024-06-27 02:10:04 +00:00
865fcc72c3
Merge "Revert "ClatCoordinator - use SingleWriterBpfMap"" into main
Yuyang Huang   authored and   Gerrit Code Review   commited 2024-06-27 02:09:09 +00:00
08af0d01e6
Merge "Revert "Prepare for @RequiresApi class retention"" into main
Treehugger Robot   authored and   Gerrit Code Review   commited 2024-06-26 11:47:49 +00:00
270f0064f6
Document reason for not using SingleWriterBpfMap in ClatCoordinator
Test: m
Change-Id: Ic781baf65be092612db20da73fe3fd340f9828dd

KH Shi   commited 2024-06-26 11:30:05 +00:00
fbe570b69d
Revert "Prepare for @RequiresApi class retention"
This reverts commit 53da9ac34c.
And fixes the linter errors.

Bug: 328190227
Test: TH
Change-Id: I92e0f268c770b6e46bdc781d4867f1e0b505d4ad

Motomu Utsumi   commited 2024-06-26 19:14:30 +09:00
a1a0034f0e
Revert "ClatCoordinator - use SingleWriterBpfMap"
This reverts commit I93b8b94dcad8f2bc4d022314372fb97109ed8f2f.

Reason for revert: ClatIngress6Value and ClatEgress4Value are written to by the clatd.c program (reference aosp/3002596). Due to this, SingleWriterBpfMap is unsuitable in this scenario, as it can only be used when no BPF program ever writes to the map.

Change-Id: I382bbfc8554391c6c83a39bbea155114202b71a8

Yuyang Huang   commited 2024-06-26 10:09:52 +00:00
a793772808
Merge "Only send callbacks when overridden" into main
Treehugger Robot   authored and   Gerrit Code Review   commited 2024-06-26 07:35:45 +00:00
e1c10b08a2
Only send callbacks when overridden
Most users of NetworkCallback do not override all methods, so callbacks
from ConnectivityService end up being unused by the app.

To save resources, check which callback methods are overridden in
ConnectivityManager, and inform ConnectivityService so it can skip
preparing and sending the corresponding binder calls when the callback
is not used by the app.

This is flagged off by default.

Test: flag enabled: atest CtsNetTestCases ConnectivityCoverageTests
Bug: 327038794
Bug: 279392981

Change-Id: Iaf490f416fb6e1437d40497fba1a40a899a9f523

Remi NGUYEN VAN   commited 2024-06-26 12:39:47 +09:00
2fd3823cbc
Revert "Add a temporary hack to CS to report netbpfload result"
This reverts commit fe956d9189.

This is targetting mainline release M-2024-09.

Test: TreeHugger
Signed-off-by: Maciej Żenczykowski <maze@google.com>
Change-Id: If89337854d677fdef1389b85cea645715a5e8491

Maciej Żenczykowski   commited 2024-06-21 15:14:33 +00:00
8e7276b482
Revert "Add a Log.wtf() on user builds to test Pitot reporting pipeline"
This reverts commit 9161b153b4.

This is targetting mainline release M-2024-09.

Test: TreeHugger
Signed-off-by: Maciej Żenczykowski <maze@google.com>
Change-Id: I3d053f8c006eee8c1cbc7918f6fc5e30f5d09375

Maciej Żenczykowski   commited 2024-06-21 15:14:20 +00:00
2a911d6c18
bpf: attach a *bunch* more cgroup hooks
We attach trivial programs to:
  {connect,recvmsg,sendmsg}{4,6}
  inet_release
  {g,s}etsockopt

Test: TreeHugger
Signed-off-by: Maciej Żenczykowski <maze@google.com>
Change-Id: Ifd3a6dff20a5881f4fdb5d1b4b7b03a55988fd74

Maciej Żenczykowski   commited 2024-06-16 10:04:35 -07:00
22db590580
ConnectivityService - do not dumpBpfProgramStatus before T
this is to fix some lint issues

Test: TreeHugger
Signed-off-by: Maciej Żenczykowski <maze@google.com>
Change-Id: I8c4dff0c8a6ba28596a346fef40f698962e7094b

Maciej Żenczykowski   commited 2024-06-16 05:22:58 -07:00
f0da1bee5e
Merge "Add a Log.wtf() on user builds to test Pitot reporting pipeline" into main
Treehugger Robot   authored and   Gerrit Code Review   commited 2024-06-16 00:05:26 +00:00
904ae8f327