Commit graph android_packages_modules_Co.../service/src/com/android/server/ConnectivityService.java
Message SHA1
remove dead portions of BpfUtils.java
(mostly to improve code coverage)

We can always revert if it ever turns out this is useful,
but I'd prefer for cgroup attach to be a once-at-boot
thing and handled either from bpfloader or the netd updatable
which are both directly C++ code.

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

Maciej Żenczykowski   commited 2023-10-25 17:40:35 +00:00
de9d367ab2
Merge "Add a routing coordinator class" into main
Jean Chalard   authored and   Gerrit Code Review   commited 2023-10-25 09:13:16 +00:00
4e47533688
Merge "Revert "Revert "[BR07.1] Expose setDataSaverEnabled from Connect..."" into main
Junyu Lai   authored and   Gerrit Code Review   commited 2023-10-25 01:59:12 +00:00
0cfaea8d98
Add a routing coordinator class
Test: In followup changes : RoutingCoordinatorManagerTest
Change-Id: Ia6811d614e02123a072c7638291828745abae051

Chalard Jean   commited 2023-10-24 22:12:26 +09:00
2fb66f1b28
Revert "Revert "[BR07.1] Expose setDataSaverEnabled from Connect..."
Revert submission 2799494-revert-2745215-npmsbpf-OBOPDXREUI

Reason for revert: Need to 1. Merge API first. 2. Wait for prebuilt. 3. Merge the caller.

Reverted changes: /q/submissionid:2799494-revert-2745215-npmsbpf-OBOPDXREUI

Change-Id: Icd5f3d40595a0d2a221b016cec70568bf3597c16

Junyu Lai   commited 2023-10-24 07:30:23 +00:00
df210365fe
Merge "Revert "[BR07.1] Expose setDataSaverEnabled from ConnectivityManager"" into main
Jordan Silva   authored and   Gerrit Code Review   commited 2023-10-23 15:12:50 +00:00
118c2646f3
Revert "[BR07.1] Expose setDataSaverEnabled from ConnectivityManager"
Revert submission 2745215-npmsbpf

DroidMonitor: Potential culprit for Bug 307256512 - verifying through ABTD before revert submission. This is part of the standard investigation process, and does not mean your CL will be reverted.


Reason for revert: 307256512

Reverted changes: /q/submissionid:2745215-npmsbpf

Change-Id: I27119a7484453d1369bbdf71ad2479edec7d664f

Jordan Silva   authored and   Gerrit Code Review   commited 2023-10-23 13:23:01 +00:00
457ae0f00f
Merge "[BR07.1] Expose setDataSaverEnabled from ConnectivityManager" into main
Junyu Lai   authored and   Gerrit Code Review   commited 2023-10-23 11:21:53 +00:00
d88205a1ae
Merge "Reapply "Add LocalNetworkConfig"" into main
Jean Chalard   authored and   Gerrit Code Review   commited 2023-10-20 06:25:14 +00:00
e32bf36be8
Merge "Support shell command to get bpf program id" into main
Maciej Żenczykowski   authored and   Gerrit Code Review   commited 2023-10-19 22:35:04 +00:00
5c2b517d6a
[BR07.1] Expose setDataSaverEnabled from ConnectivityManager
Currently, data saver switch is controlled in NPMS, which
calls into NetworkManagementService and netd when switching
status. In netd, BandwidthController manipulates the
bw_data_saver chain to control the overall behavior.

However, this code are all platform implementation, which
are not updatable. In order to migrate data saver switch
from iptables to bpf, this API is needed for Connectivity to
change the implementation to directly write bpf in later
patches.

Test: atest CtsHostsideNetworkTests:com.android.cts.net.HostsideRestrictBackgroundNetworkTests
Test: atest FrameworksServicesTests:NetworkManagementServiceTest
Bug: 297836825
Change-Id: I71fa41ca739fef8e191fba91b02758ad5f732d5c

Junyu Lai   commited 2023-10-19 17:43:44 +08:00
c279f1830e
Merge "Dump bpf program status in dumpsys" into main
Junyu Lai   authored and   Gerrit Code Review   commited 2023-10-19 09:33:27 +00:00
eb75416136
Support shell command to get bpf program id
Test: atest NetworkStatsIntegrationTest#testBpfProgramAttachStatus
Bug: 292156770

Change-Id: I815be0f3f3592442939872f98e3ad9d224a6aeb6

Junyu Lai   commited 2023-10-18 16:06:15 +08:00
452e464ee9
Dump bpf program status in dumpsys
Sample output:
Bpf Program Status:
  CGROUP_INET_INGRESS: 21
  CGROUP_INET_EGRESS: 22
  CGROUP_INET_SOCK_CREATE: 28
  CGROUP_INET4_BIND: 30
  CGROUP_INET6_BIND: 31

Test: adb shell dumpsys connectivity
Test: atest FrameworksNetTests:android.net.connectivity.com.android.server.ConnectivityServiceTest#testDumpDoesNotCrash
Test: atest ConnectivityCoverageTests:android.net.connectivity.com.android.server.ConnectivityServiceTest#testDumpDoesNotCrash
Bug: 292156770
Change-Id: I312c90c524af12d093536156d6d5c6febd64305a

Junyu Lai   commited 2023-10-18 16:05:55 +08:00
155760b57b
Reapply "Add LocalNetworkConfig"
This reverts commit 6eea22b18c.

Change-Id: I0a2cef4ee992577674c92ecd384dc6f4361afa02

Chalard Jean   commited 2023-10-18 15:50:02 +09:00
f9d0e3e94f
Merge "Reapply "Tell netd about local networks"" into main
Jean Chalard   authored and   Gerrit Code Review   commited 2023-10-17 13:00:46 +00:00
de0f4e5b87
Move dumpsys to handler thread
I0afdda023208c3f8620cb5b89add66448af596d7 added some assertions
to ensure NetworkAgentInfo can only be accessed from the handler
thread. This is good to eliminate any potential concurrent
accessing problem. Howver, dumpsys runs on binder thread, this
change breaks dumpsys functionality.

Thus, this change:
  1. Copy Handler#runWithScissors() and related class
     locally since they are @hide methods.
  2. Run doDump on the handler thread and waits for return.

Test: adb shell dumpsys connectivity
Test: atest FrameworksNetTests:android.net.connectivity.com.android.server.HandlerUtilsTest
Fix: 303348620
Change-Id: Ic3a22f5d370bbf8c18b1972e86d695b6ad61bd0d

Junyu Lai   commited 2023-10-17 17:16:04 +08:00
f8dba342f1
Reapply "Tell netd about local networks"
This reverts commit cc409153b4.

Change-Id: Ied6bdb9b94e08e2bfe1092765d0f4591e603c3eb

Chalard Jean   commited 2023-10-17 17:39:23 +09:00
e0aaca5ac6
Revert "Tell netd about local networks"
Revert submission 2777667

Reason for revert: DroidMonitor-triggered revert due to breakage, bug b/305187495

Reverted changes: /q/submissionid:2777667

Bug: 305187495

Change-Id: Icb46558d17b56f9f6fd402f1489de9ed2b8f7644

Anton Kulakov   commited 2023-10-13 15:23:59 +00:00
cc409153b4
Revert "Add LocalNetworkConfig"
Revert submission 2777667

Reason for revert: DroidMonitor-triggered revert due to breakage, bug b/305187495

Reverted changes: /q/submissionid:2777667

Bug: 305187495

Change-Id: Iae4ef936a4c111ae5668e539ce4cdbbb14c811f4

Anton Kulakov   commited 2023-10-13 15:18:55 +00:00
6eea22b18c
Merge changes I3b6ee1db,I70e13303,I6fb7dfe4 into main
* changes:
  Simplify addRoutesToLocalNetwork calls
  Add LocalNetworkConfig
  Tell netd about local networks

Jean Chalard   authored and   Gerrit Code Review   commited 2023-10-13 09:57:18 +00:00
a6190bd658
Add LocalNetworkConfig
This doesn't do anything at this patchset, but the whole
pipe from the agent to ConnectivityService is built.

LocalNetworkInfo will be the name of the public information
sent in callbacks to clients.

Test: CSLocalAgentTests
Change-Id: I70e133031ef3b0aaf6c3e59ccc2ad895c66d339c

Chalard Jean   commited 2023-10-13 14:40:45 +09:00
fa21cafc1c
Tell netd about local networks
This patch does the following :
• When a network is local but the system doesn't support it,
  throw in registerNetworkAgent.
• When a network is local, tell netd about it.
• Add tests for the above, as well as a test for callbacks
  being sent correctly when the caps are set and not when
  they aren't and that the new keep connected flag is
  respected.

Telling netd about the network being local has it add two
routes that do not exist if the network is not local :
• One at PRIORITY_LOCAL_NETWORK matching unmarked sockets
  and looking up the table for the interface.
20000: from all fwmark 0x0/0x10000 lookup xxxx
• One at PRIORITY_EXPLICIT_NETWORK matching explicitly on
  network 99, so that dnsmasq traffic and any OEM traffic
  marked for network 99 flowing there.
16000: from all fwmark 0x10063/0x1ffff iif lo lookup xxxx
IMPLICIT_NETWORK and EXPLICIT_NETWORK rules are installed
by connectivity service as a matter of course whether the
network is local or not.

See commit If8729fc6f3716a580c936584b851bc38000b5de5 for
implementation details of this mechanic.

There is no need to implement anything in particular for the
new connected reason, as the current implementation will
already keep it connected. A new test makes sure of that.

Test: FrameworksNetTests
      CtsNetTestCases
      FrameworksNetIntegrationTests
      NetworkStackTests
      NetworkStaticLibTests
      TetheringTests
      MtsTetheringTestLatestSdk
      TetheringIntegrationTests
Change-Id: I6fb7dfe4c232eea8cac9ac268897ddb36bb794d1

Chalard Jean   commited 2023-10-13 14:40:38 +09:00
774dc3cd51
Merge changes I22d67a7e,Ida4a4bc7,Ie8522862,Id55d8d6c into main
* changes:
  Ensure nri is satisfied before returning.
  Add testLockdownVpn that mocks platform VPN.
  Make variables in testLegacyLockdownVpn() final.
  Update testLegacyLockdownVpn to mock VPN.

Hansen Kurli   authored and   Gerrit Code Review   commited 2023-10-13 05:00:29 +00:00
ccfc52145b
Ensure nri is satisfied before returning.
When a network preference is set, the highest priority nri will
be a managed default request that disallows default networking.
In the case where there is no satisfying network,
mNoServiceNetwork is used as the satisfier instead of null.
(see computeNetworkReassignment)

mNoServiceNetwork should not be returned in any public API.
Check for the nri being satisfied before returning the satisfier
to ensure mNoServiceNetwork is not returned.

Fixes: 301222648
Test: atest FrameworksNetTests
Change-Id: I22d67a7e8d0274d8ad4f6123fbedf6d37eed18e7

Hansen Kurli   commited 2023-10-12 18:48:57 +08:00
ed972a6fd2
Merge "Update mActiveIdleTimers to use netId as a key" into main
Motomu Utsumi   authored and   Gerrit Code Review   commited 2023-10-12 09:10:22 +00:00
9b6420bc13
Allow for mocking an SDK in the tests
Test: in followup patches
Change-Id: I540ce2a455c92be52eb94fbd4b54a2081d04d25e

Chalard Jean   commited 2023-10-10 14:57:22 +09:00
eb66389d6a
Update mActiveIdleTimers to use netId as a key
Following CL update +U devices to use netId as an idle timer label.
Using netId as key for mActiveIdleTimers makes it easier to handle
network activity change event in U+ devices.

Bug: 267870186
Bug: 279380356
Test: atest FrameworksNetTests
Change-Id: I4cba6fa546ab403b9a462cc7b77393ac0227f690

Motomu Utsumi   commited 2023-10-06 18:45:54 +09:00
473c38d1aa
Merge changes Ifd7abd8a,I39cab8ff,I6b3270d6,Ia28c6abc,If47d7e23 into main am: 1d600f4300
Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/2405726

Change-Id: I9867b0c48537dd0164a3858328c865c667847289
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>

Jean Chalard   authored and   Automerger Merge Worker   commited 2023-09-29 07:07:23 +00:00
6d5e0ad07e
Merge changes Ifd7abd8a,I39cab8ff,I6b3270d6,Ia28c6abc,If47d7e23 into main
* changes:
  Move the MULTI_SIM_ACTION receiver inline
  Inline registerForCarrierChanges
  Make mThread a local
  Introduce a flag for using the carrier service changed callbacks.
  Have DevSdkIgnoreRunner support @Parameterized parameters

Jean Chalard   authored and   Gerrit Code Review   commited 2023-09-29 06:46:08 +00:00
1d600f4300
Introduce a flag for using the carrier service changed callbacks.
Test: CarrierPrivilegeAuthenticatorTest
Change-Id: Ia28c6abca67866c1de953cb61953a0d2882cd7e2

Chalard Jean   commited 2023-09-28 21:37:32 +09:00
84dfa9f104
Merge "wear proxy behind portal" into main am: 6aec2583cd
Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/2762234

Change-Id: Ib5c5489b6abdf3427ccfa2112908b6d42ffd9961
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>

Andriy Naborskyy   authored and   Automerger Merge Worker   commited 2023-09-27 17:54:22 +00:00
f891a01eb5
wear proxy behind portal
Do not avoid captive portal on wear proxy network; keep network agent
after detecting portal.

Bug: 291112432
Test: atest FrameworksNetTests:android.net.connectivity.com.android.server.ConnectivityServiceTest
Change-Id: I8f6669da62ebd76b6a46d2aec9b3ea563a08cb5e

Andriy Naborskyy   commited 2023-09-27 07:28:05 +00:00
d032dd42ea
Merge "Nat464Xlat: rely on netd events being called on handler thread." into main am: d196fab898
Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/2763405

Change-Id: Ice4d84ec6ff98098475e21e8ae96052d1827903a
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>

Remi NGUYEN VAN   authored and   Automerger Merge Worker   commited 2023-09-27 03:03:52 +00:00
04085fd688
Merge "Nat464Xlat: rely on netd events being called on handler thread." into main
Remi NGUYEN VAN   authored and   Gerrit Code Review   commited 2023-09-27 02:01:58 +00:00
d196fab898
Nat464Xlat: rely on netd events being called on handler thread.
aosp/2724918 moved processing netd events for 464xlat to the
handler thread.

This CL makes 464xlat run the code that processes those events
inline. This simplifies the code and makes the ordering of events
more similar to what it was before.

Bug: 293965195
Fix: 302071735
Test: existing unit tests
Change-Id: I18b0d491aff94646b878a3d3488b5519fd42783c

Lorenzo Colitti   commited 2023-09-26 11:00:37 +00:00
3b817cbad3
Merge changes I8843ce7c,I90566998 into main am: 487191dbe6
Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/2747260

Change-Id: Id79dec22a90513c68716de5cb6d0ec110a20dd00
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>

Jean Chalard   authored and   Automerger Merge Worker   commited 2023-09-22 02:51:11 +00:00
7b803e68c8
Add a command to block networking for an app
Test: Manual
Bug: 284534251
Change-Id: I90566998501c215de350965e3bffcd852d487bfe

Chalard Jean   commited 2023-09-21 12:57:08 +09:00
c8fefb36d8
Merge changes I0afdda02,I1c47f616 into main am: 5f730c6ab5
Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/2460069

Change-Id: I7f6aedf1424751e067e4396016bc525393381487
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>

Jean Chalard   authored and   Automerger Merge Worker   commited 2023-09-11 19:00:06 +00:00
da62c511c0
Implement ConnectivityStateMetrics sample
Test: ConnectivitySampleMetricsTest
Change-Id: I0afdda023208c3f8620cb5b89add66448af596d7

Chalard Jean   commited 2023-09-11 17:12:46 +09:00
f95e2de35a
Merge "Remove unnecessary arguments from isTetheringFeatureEnabled" into main am: 656e42e16f
Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/2709175

Change-Id: Ie05295a8a59cf957ac3c3da4ef87a64fe8ffa206
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>

Motomu Utsumi   authored and   Automerger Merge Worker   commited 2023-09-08 10:09:42 +00:00
97ed1eef10
Remove unnecessary arguments from isTetheringFeatureEnabled
This CL also updates not to use isTetheringFeatureEnabled for
TETHER_FORCE_UPSTREAM_AUTOMATIC_VERSION which is wrongly configured in
Connectivity namespace.

Test: m
Bug: 279108992
Change-Id: If4f3a57c749bbaeb85454c31248c5bc5feaab936

Motomu Utsumi   commited 2023-09-08 16:11:28 +09:00
3e0be398a2
Merge "Delay frozen app sockets close until the cellular modem wakes up" into main am: 4e95ea0740
Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/2608568

Change-Id: I8d5127f1adf82fa6924175a68efa08692f874fc7
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>

Motomu Utsumi   authored and   Automerger Merge Worker   commited 2023-09-05 09:40:50 +00:00
25bc872fc2
Delay frozen app sockets close until the cellular modem wakes up
Closing TCP sockets sends RST packets. If the cellular modem is idle,
sending RST packets will wake the modem up and consume battery.

This CL adds delay_destroy_frozen_sockets_version flag.
When this flag and destroy_frozen_sockets_version is enabled,
ConnectivityService delays closing socket until the cellular modem wakes up.
Pending frozen sockets are closed also when cellular network becomes no
longer the default network.

This CL also adds flag status and pending uids to the dump.

Bug: 284900338
Test: FrameworksNetTests
Change-Id: I2562568390dda36d02f72afb3a96f824788964c0

Motomu Utsumi   commited 2023-09-04 18:04:31 +09:00
188bfd36da
Merge Android U (ab/10368041)
Bug: 291102124
Merged-In: Iff29b090c0b41d0103997a80788f09c2602df074
Change-Id: I5b03523defc88ffbc3aeab9ac8a29b4ca5a11f57

Xin Li   commited 2023-08-25 13:52:17 -07:00
4a6c653160
Merge "Execute netd callbacks on CS handler thread" into main
Treehugger Robot   authored and   Gerrit Code Review   commited 2023-08-24 08:33:03 +00:00
f180b14d9a
Execute netd callbacks on CS handler thread
Test: TH
Bug: 293965195
Change-Id: I178a9904d2ee090ed1fb487c061226909cbde1d6

Chalard Jean   commited 2023-08-24 15:44:15 +09:00
5d05c4b9d1
Rename to isTetheringFeatureEnabled
DeviceConfigUtils has isFeatureEnabled for NetworkStack and Tethering
which were confusing since the difference was only the arguments.
This CL renames isFeatureEnabled for Tethering module to
isTetheringFeatureEnabled to avoid confusion.

Bug: 279108992
Test: m
Change-Id: I05255bb38619afbe621d29524d7910d206a149f1

Motomu Utsumi   commited 2023-08-17 17:47:19 +09:00
624aeb4274
Merge "Use destroyLiveTcpSocketsByOwnerUids for frozen apps" into main
Treehugger Robot   authored and   Gerrit Code Review   commited 2023-08-09 05:17:14 +00:00
b7d3f3fd77
Revert isDefaultNetworkActive behavior when there is no default network
aosp/2605757 updated isDefaultNetworkActive returns false when there is
no default network.
But this change was not merged to U release branch and this change was
not well tested by dogfooding.
So this CL reverts the isDefaultNetworkActivity behavior change.

Bug: 279380356
Bug: 291870075
Test: atest FrameworksNetTests
Change-Id: Id88662faea9eeaba93d59ab2729f6204a3631ab1

Motomu Utsumi   commited 2023-08-01 12:50:00 +09:00
51e7a60359