Commit graph android_packages_modules_Co.../service/src/com/android/server/ConnectivityService.java
Message SHA1
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
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
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
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
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
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
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
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 "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
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
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
Add a Log.wtf() on user builds to test Pitot reporting pipeline
Apparently, we have previously seen instances of the pipeline being
broken, so this is adding a Log.wtf() to test the pipeline.

It is only run on user builds to not randomly crash droidfood devices.

Test: cf boots
Change-Id: Ie4e6661adef6f1878529688561805f2485e58391

Patrick Rohr   commited 2024-06-15 14:11:55 -07:00
9161b153b4
Add a temporary hack to CS to report netbpfload result
Since BpfHandler::init() in the August module does not wait on
netbpfload (it only loads test.o), post on the ConnectivityService
handler and check that netbpfload ran to completion after 30s.

Log.wtf() on failure as these logs show up in Pitot even on release
builds.

Note that system server does not have access to any of the programs or
maps loaded from test.c, so all it can do is verify that mainline_done
exists.

Test: cuttlefish boots and does not crash
Change-Id: I6d2063f1d4f03207bbb6599b75954cfceb793af4

Patrick Rohr   authored and   Maciej Żenczykowski   commited 2024-06-15 03:58:43 -07:00
fe956d9189
Merge changes I62c990d0,I413bdb76,I020ba48e into main
* changes:
  Update NetworkRequestTest#testDefaultCapabilities
  Allow default messaging app to use constrained satellite network
  Introduce NET_CAPABILITY_NOT_BANDWIDTH_CONSTRAINED

Motomu Utsumi   authored and   Gerrit Code Review   commited 2024-06-07 09:29:06 +00:00
3e07102814
Allow default messaging app to use constrained satellite network
On V+, there could be satellite network which is not restricted but
bandwidth constrained.
These satellite network has NET_CAPABILITY_NOT_RESTRICTED but does not
have NET_CAPABILITY_NOT_BANDWIDTH_CONSTRAINED.
Since NET_CAPABILITY_NOT_BANDWIDTH_CONSTRAINED is set by default, this
CL remove this capability from per-app default network request for the
default messaging app.

Test: CSSatelliteNetworkTest
Bug: 343823469
Change-Id: I413bdb764ead42d67ce1315c365500dbb8508eb3

Motomu Utsumi   commited 2024-06-07 09:26:19 +09:00
ab750abf29
Add config flag for useDeclaredMethodsForCallbacks
Add a DeviceConfig flag that will be used to control whether callbacks
should be sent selectively based on whether the receiving method has
been overridden (will be implemented in a future change).

This adds utilities to allow ConnectivityManager to check whether a
ConnectivityService flag is enabled, as that feature will work across
ConnectivityManager and ConnectivityService. ConnectivityManager runs in
app process and does not necessarily have permissions to use
DeviceConfig. Also if it checked DeviceConfig separately from
ConnectivityService, values may be out-of-sync.

Test: atest, and see change using this
Change-Id: I204fa719cc627e84edc5c1e043d947f5ef3f8dee

Remi NGUYEN VAN   commited 2024-06-05 15:54:49 +09:00
aa355ac875
Merge "Explicitly log portal detections" into main
Remi NGUYEN VAN   authored and   Gerrit Code Review   commited 2024-05-31 11:27:11 +00:00
d1c52e3eb0
Merge "Clatd: add dump raw BPF map support" into main
Maciej Żenczykowski   authored and   Gerrit Code Review   commited 2024-05-31 08:11:44 +00:00
3812c394ba
Clatd: add dump raw BPF map support
Add dump raw BPF map command to connectivity service. The result will
be encoded as base64 strings. This is a preparation for Clatd's tests.

Usage:
    dumpsys connectivity {clatEgress4RawBpfMap|clatIngress6RawBpfMap}

Bug: 285124667
Test: test with MtsEthernetTetheringTest#testTetherClatBpfOffloadUdp
      which will be uploaded in a separated CL
Change-Id: I02c8efadb1c4b861d9bf6168667816b13412dc75

KH Shi   commited 2024-05-31 06:34:41 +00:00
855712aa55
Merge "Revert^2 "Add blocked reason for internet permission"" into main
Treehugger Robot   authored and   Gerrit Code Review   commited 2024-05-28 00:00:07 +00:00
d86bd6faca
Revert^2 "Add blocked reason for internet permission"
This reverts commit cb74c08979.

Reason for revert: This change is not a cause of b/342557183

Change-Id: Iee8d9b05bbe130a46b627b12da525177b4ee89b2

Motomu Utsumi   authored and   Gerrit Code Review   commited 2024-05-27 02:12:43 +00:00
cfd5a517da
Merge "Revert "Add blocked reason for internet permission"" into main
Priyanka Advani   authored and   Gerrit Code Review   commited 2024-05-24 18:56:26 +00:00
fb1b1b3773
Revert "Add blocked reason for internet permission"
This reverts commit ee96ba0e60.

Reason for revert: Droidmonitor triggered revert due to b/342557183. Will be verifying through ABTD before submission.

Change-Id: I7e185c3ac11da27c7bb9d95e4221f7dfc22cf48c

Priyanka Advani   authored and   Gerrit Code Review   commited 2024-05-24 18:11:45 +00:00
cb74c08979
Destroy sockets of apps under background firewall chain restriction
Currently, CS destroys sockets of apps under firewall chain restriction
only when the firewall chains get enabled by setFirewallChainEnabled.

This CL updates CS to also destroy sockets of apps when the
setUidFirewallRule and replaceFirewallChain update uid rule and apps
lose network access due to FIREWALL_CHAIN_BACKGROUND.
This socket destruction is delayed until the cell modem is up in the
same way that CS destroys sockets of frozen apps.

Test: CSSocketDestroyTest
Bug: 300681644
Change-Id: I6a6fb5d6d7b71c0949a4195b84d30efef95bff37

Motomu Utsumi   commited 2024-05-24 13:47:21 +09:00
ff555a709c
Add blocked reason for internet permission
Currently, even if apps don't have INTERNET permission and can not use
network, network access is considered not blocked and
ConnectivityService send onBlockedStatusChanged callback with
blocked=false.
This CL introduced BLOCKED_REASON_NETWORK_RESTRICTED and consider
network access from apps targetting W+ on V+ releases is blocked if apps
don't have INTERNET permission.
Permission is set when the user is added or package is installed and
permission is removed when the user is removed or packages is
uninstalled.
So ConnectivityService does not need to monitor permission change to
send onBlockedStatusChanged callback by permission change.

Test: CSBlockedReasonsTest
Bug: 339559837

Change-Id: I58d2a4eddc714e205f5b96219f95b637f2826c58

Motomu Utsumi   commited 2024-05-24 13:45:51 +09:00
ee96ba0e60
Send onBlockedStatusChanged callback based on bpf map contents
Currently, CS receives the blocked status change from
NetworkPolicyCallback.
This CL update CS to generate blocked status based on bpf map contents
on V+.
When the data saver and firewal chain status is updated, CS generate new
blocked reasons based on bpf map contents.
U- keeps listening to NetworkPolicyCallback.

Bug: 328732146
Test: testNetworkCallbackMaximum, CSBlockedReasonsTest
Change-Id: I6fa3f1a44eadc67d9cff17133905ef69203c044a

Motomu Utsumi   commited 2024-05-24 13:45:41 +09:00
d20727f3cc
Move perUidCounter increment to outside NetworkRequestInfo constructor
This CL moves mPerUidCounter.incrementCountOrThrow from
NetworkRequestInfo constructor to the caller of NetworkRequestInfo
constructor and stop incrementing counter for internal NetworkRequestInfo
(e.g. per-app default requests).
Also, this CL update CS not to modify perUidCounter when CS updates
apps' track default network request when the per-app default request is
updated since this does not change the number of request for each uids.

Test: testNetworkCallbackMaximum
Bug: 339106399
Change-Id: I82dbeb82b1c762c2c277d5794d54997b57009b6a

Motomu Utsumi   commited 2024-05-24 13:27:27 +09:00
b16f75c3eb
Support multiple reasons for socket destroy
This CL is a no-op and does not change any behavior.
Upcoming CL updates CS to destroy socket of background apps.
As a preparation, this CL updates socket destroy code non specific to
frozen apps.

Bug: 300681644
Test: ConnectivityServiceTest
Change-Id: I027766db342bf9a05d4532ecf9a60e6854e9456d

Motomu Utsumi   commited 2024-05-22 13:36:01 +09:00
8fad95cd61
Move mPendingFrozenUids empty check to destroyPendingSockets
Test: ConnectivityServiceTest
Bug: 300681644
Change-Id: Ic31f6b1ccea8bab8cce948736b74cf3e8e7fb2ba

Motomu Utsumi   commited 2024-05-22 13:35:56 +09:00
333f01d303
Rename closePendingFrozenSockets to destroyPendingSockets
As a preparation to update CS to destroy sockets for background apps,
renamed socket destroy methods to non specific to frozen apps

Bug: 300681644
Test: TH
Change-Id: I64c108aee1ee0d60df30ef055c8c9df8c6562d0f

Motomu Utsumi   commited 2024-05-22 13:35:50 +09:00
dff5df5b65
Enable delay destroy socket as default
delay_destroy_frozen_sockets_version is rolled out to public 100%.
So this CL enables this flag as default with kill switch.
This flag is no-op if destroy_frozen_sockets_version is disabled, and
destroy_frozen_sockets_version is also rolled out to public 100%.
So this CL does not change any behabior on the production devices.

Upcoming CLs will update CS to destroy sockets of apps that are under
FIREWALL_CHAIN_BACKGROUND restriction as well.
So this CL renames flag name from delay_destroy_frozen_sockets_version
to delay_destroy_sockets which is not specific to frozen apps.

Bug: 300681644
Test: TH
Change-Id: Icb9edff4e517fca57408d7d690fe9e172754c35e

Motomu Utsumi   commited 2024-05-22 13:35:44 +09:00
390be06f64
Merge "Add comment for per-app preference priority" into main
Treehugger Robot   authored and   Gerrit Code Review   commited 2024-05-21 09:48:06 +00:00
1243420eb1
Update APIs that depends on isUidNetworkingBlocked to follow compat flag
NETWORKINFO_WITHOUT_INTERNET_BLOCKED compat flag only changed the
behavior of getActiveNetworkInfo that depends on
bpfNetMaps#isUidNetworkingBlocked.
But isUidNetworkingBlocked is used from other APIs(e.g. getActiveNetwork)
This CL update all APIs that depends on isUidNetworkingBlocked to follow
the compat flag to make behavior consistent between APIs.

aosp/3079290 will update onBlockedStatusChanged callback to follow this
compat flag.

Bug: 340773991
Bug: 339780435
Test: TH
Change-Id: If64ec800f21c2adc613884838202e2dece4a8d95

Motomu Utsumi   commited 2024-05-16 16:54:17 +09:00
b15be228d2
Add compat flag for ActiveNetworkInfo blocked state
Before aosp/3001087, getNetworkActiveInfo did not return network info
with blocked state for apps without PERMISSION_INTERNET even if the
network is actually blocked.
aosp/3001087 updated getNetworkActiveInfo to return correct blocked
state on V+.
However, this broke some apps that use getNetworkActiveInfo in wrong way
and depends on the previous behavior.
So this CL introduces the compat flag to keep previous behavior for apps
targeting U or older releases.

Test: TH
Bug: 333340911
Change-Id: I0e0950f2148de0ffdb45495903a5a87e0d4c1c0b

Motomu Utsumi   commited 2024-05-08 21:08:35 +09:00
0b4be79e52
Reapply "Use bpf map based isUidNetworkingBlocked on V+"
This reverts commit a658220234.

Change-Id: I53acd7ff4821a65583b2ad936e22efaa21965a14

Maciej Żenczykowski   authored and   Motomu Utsumi   commited 2024-05-08 14:50:38 +09:00
a08692f7c7
Use Bpf map based isUidRestrictedOnMeteredNetworks on V+
Bug: 328732146
Test: BpfNetMapsTest
Change-Id: I2d3820bf4dd82649941eef2995ad237276937ba9

Motomu Utsumi   commited 2024-05-07 18:36:39 +09:00
e55bcd578b
Add comment for per-app preference priority
Clarify that only the highest priority preference is applied if the uid
is target of multiple preferences.

Test: TH
Change-Id: I55b6a37995bcfe876ed609cf653077df2b5e7615

Motomu Utsumi   commited 2024-04-26 18:33:16 +09:00
300a83cc15
Merge "Fix DO check on headless devices" into main
Kholoud Mohamed   authored and   Gerrit Code Review   commited 2024-04-25 09:51:23 +00:00
45f71b0b3d