Commit Graph

91144 Commits

Author SHA1 Message Date
Hansen Kurli
946cafb87e Refactor helper method to return integer ranges.
Calls to setRequireVpnForUids() for Vpn lockdown actually uses a
List instead of a Set of integer ranges.
Add intRangesExcludingUids() to return the needed List of integer
ranges and replace relevant usages of UidRange.toIntRanges() with
it.

Bug: 230548427
Test: atest FrameworksNetTests
Change-Id: I61cd4751ce2faeb129daa5ad5da7181e3c1df73c
2023-10-23 15:12:21 +08:00
Junyu Lai
54e84ab05a Add test for cgroup bpf program status
This is useful to ensure cgroup bpf program is attached,
which would lead to hard-debugging uid stats missing problem.

Test: atest ConnectivityServiceIntegrationTest#testBpfProgramAttachStatus
Bug: 292156770
Change-Id: I16370497484aff29ed41cbb0d160e530731e1a4e
2023-10-23 13:38:04 +08:00
Sudheer Shanka
6c83f00b09 Merge "Increase the service bind timeout." into main 2023-10-22 02:16:22 +00:00
Jean Chalard
dab9125464 Merge "Reapply "Simplify addRoutesToLocalNetwork calls"" into main 2023-10-21 16:25:58 +00:00
Maciej Żenczykowski
1b36d2e2a3 Merge "execute platform bpfloader after netbpfload is done" into main 2023-10-21 16:06:44 +00:00
Maciej Żenczykowski
58c182291d execute platform bpfloader after netbpfload is done
Test: TreeHugger
Signed-off-by: Maciej Żenczykowski <maze@google.com>
Change-Id: I447880763bbc506f08b578f862f09be91ab3d14d
2023-10-21 09:20:03 +00:00
Treehugger Robot
28f16f4269 Merge "Correct LINT path on UidOwnerMatchType" into main 2023-10-21 03:22:32 +00:00
Maciej Żenczykowski
ef63fd1fa0 Merge "move the bpf.progs_loaded = 1 setting back to bpfloader" into main 2023-10-21 02:18:05 +00:00
Ken Chen
cf25a54909 Correct LINT path on UidOwnerMatchType
UidOwnerMatchType Java definition moved from BpfNetMaps.java to
BpfNetMapsConstants.java in change I6d7ea044e43180.

Bug: 297836825
Test: presubmit
Change-Id: I4fc28406750cac9143ea47e9304b455ab616d462
2023-10-21 01:47:05 +00:00
Maciej Żenczykowski
7db65c6d38 Revert "netbpfload: remove netbpfload.rc"
This mostly reverts commit 1d2c93d568.

Test: N/A
Signed-off-by: Maciej Żenczykowski <maze@google.com>
Change-Id: I0d7fdaeae508c0250114f7af8700d0fc40b0f27a
2023-10-21 00:15:00 +00:00
Maciej Żenczykowski
3f25b4ba8a move the bpf.progs_loaded = 1 setting back to bpfloader
change of design: we'll call netbpfload before bpfloader

Test: TreeHugger
Signed-off-by: Maciej Żenczykowski <maze@google.com>
Change-Id: I2d7a04a1bf1aa1d163f2b3936e2cde61308c4aa4
2023-10-20 15:18:50 -07:00
Jean Chalard
e32bf36be8 Merge "Reapply "Add LocalNetworkConfig"" into main 2023-10-20 06:25:14 +00:00
Junyu Lai
8f6df28f50 Merge "Add synchronized block when accessing global variables" into main 2023-10-20 06:06:37 +00:00
Xiao Ma
26af70f5fe Merge "Add method to check if IA prefix option takes 0 lifetimes." into main 2023-10-20 05:37:26 +00:00
Maciej Żenczykowski
5c2b517d6a Merge "Support shell command to get bpf program id" into main 2023-10-19 22:35:04 +00:00
Maciej Żenczykowski
edcc9425a0 Merge "tethering apex: add ethtool binary" into main 2023-10-19 19:53:13 +00:00
Sudheer Shanka
bbe0b27ed8 Increase the service bind timeout.
Bug: 305826147
Test: atest com.android.cts.net.HostsideRestrictBackgroundNetworkTests
(cherry picked from https://googleplex-android-review.googlesource.com/q/commit:4c137f7fa7827a9794165b86a5cc7ade85f017bf)
Merged-In: I1840e091ebbc9812da56a3522e009ba67a18c476
Change-Id: I1840e091ebbc9812da56a3522e009ba67a18c476
2023-10-19 19:19:51 +00:00
Junyu Lai
c279f1830e [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
2023-10-19 17:43:44 +08:00
Junyu Lai
eb75416136 Merge "Dump bpf program status in dumpsys" into main 2023-10-19 09:33:27 +00:00
Junyu Lai
6809bbde8e Merge "Respect SkipPresubmit annotation for ConnectivityCoverageTests" into main 2023-10-19 06:58:40 +00:00
Paul Hu
322a322687 Merge "Add expired services removal flag" into main 2023-10-19 06:19:43 +00:00
Junyu Lai
08a4a873b8 Respect SkipPresubmit annotation for ConnectivityCoverageTests
Follow-up from aosp/2788197, the CL does not work since
SkipPresubmit annotation is not excluded from TEST_MAPPING for
ConnectivityCoverageTests.

Test: TH
Bug: 302325928
Change-Id: Ibfa509aadc9e54da14738714be46abd25f46f3fb
2023-10-19 10:33:03 +08:00
Paul Hu
f3fe3333d3 Add expired services removal flag
The TTL check and removal of expired services is currently only
performed when a mDNS query is sent. This can result in expired
services remaining in the cache if no queries are sent. To
address this, the remaining TTL will be checked when retrieving
services from the MdnsServiceCache. Add a new flag to enable
the expired services removal feature. This feature will be
implemented in subsequent changes.

Bug: 265787401
Bug: 304649384
Test: atest FrameworksNetTests CtsNetTestCases
Change-Id: I30f0eea568ee45d363cc02821de0921d6040f981
2023-10-18 17:48:46 +08:00
Junyu Lai
452e464ee9 Support shell command to get bpf program id
Test: atest NetworkStatsIntegrationTest#testBpfProgramAttachStatus
Bug: 292156770

Change-Id: I815be0f3f3592442939872f98e3ad9d224a6aeb6
2023-10-18 16:06:15 +08:00
Junyu Lai
155760b57b 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
2023-10-18 16:05:55 +08:00
Chalard Jean
7f2b3dabcd Reapply "Simplify addRoutesToLocalNetwork calls"
This reverts commit 316346be6e.

Change-Id: I86977f6e7a5451d037c7ea6fee5c4bc7082935ff
2023-10-18 15:50:02 +09:00
Chalard Jean
f9d0e3e94f Reapply "Add LocalNetworkConfig"
This reverts commit 6eea22b18c.

Change-Id: I0a2cef4ee992577674c92ecd384dc6f4361afa02
2023-10-18 15:50:02 +09:00
Junyu Lai
8cefcdc1b2 Merge "Respect SkipPresubmit annotation for ConnectivityCoverageTests" into main 2023-10-18 05:16:13 +00:00
Jean Chalard
de0f4e5b87 Merge "Reapply "Tell netd about local networks"" into main 2023-10-17 13:00:46 +00:00
Junyu Lai
5606bba1f9 Merge "Move dumpsys to handler thread" into main 2023-10-17 11:08:19 +00:00
Junyu Lai
86298be5f8 Respect SkipPresubmit annotation for ConnectivityCoverageTests
Follow-up from aosp/2788197, the CL does not work since
SkipPresubmit annotation is not excluded from TEST_MAPPING for
ConnectivityCoverageTests.

Test: TH
Bug: 302325928
Change-Id: I2d953f19e5d5eb5f5d8fdf4faf335d603bae42a0
2023-10-17 17:25:10 +08:00
Junyu Lai
f8dba342f1 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
2023-10-17 17:16:04 +08:00
Chalard Jean
e0aaca5ac6 Reapply "Tell netd about local networks"
This reverts commit cc409153b4.

Change-Id: Ied6bdb9b94e08e2bfe1092765d0f4591e603c3eb
2023-10-17 17:39:23 +09:00
Junyu Lai
6d0bdd197a Add synchronized block when accessing global variables
This is catched by errorprone where global variables accessing
is not protected by the declared lock, which could lead to a
potiential race problem where these variables are changed but
cannot be seen for the invocation.

This is also safe since:
  1. The method called inside mDefaultNetworks is already holding
     the same lock.
  2. Multiple global variables are protected by this synchronized
     block.

Test: TH
Fix: 181642673
Change-Id: I58e7f124de1f0291e9323ab0b9cf8f52cec32818
2023-10-17 15:03:17 +08:00
Mark
bb6ecfcd58 Extend tethering enable/disable timeout to 30 seconds
The dnsmasq in R might block netd for 20 seconds, which can also
block tethering enable/disable for 20 seconds. To fix this, changing
the timeouts from 5 seconds to 30

Bug: 289881008
Test: TH
Change-Id: Ibed5895b2831465d454854d7250fcc44183596e2
2023-10-17 06:09:45 +00:00
Paul Hu
4479bd9f27 Merge "Include A/AAAA records in probing packet" into main 2023-10-17 02:24:10 +00:00
Patrick Rohr
bc17f31426 Merge "Disable flaky NetworkStatsHistoryTest#testFuzzing in presubmit" into main 2023-10-16 22:06:40 +00:00
Maciej Żenczykowski
f36ccc75de tethering apex: add ethtool binary
Afterwards:
  vsoc_x86:/ # ls -lZ /apex/com.android.tethering/bin/ethtool
  -rwxr-xr-x 1 root shell u:object_r:system_file:s0  96204 1969-12-31 16:00 /apex/com.android.tethering/bin/ethtool

  vsoc_x86:/ # ldd /apex/com.android.tethering/bin/ethtool
  linux-gate.so.1 => [vdso] (0xedc4d000)
  libc++.so => /apex/com.android.tethering/lib/libc++.so (0xed309000)
  libc.so => /apex/com.android.runtime/lib/bionic/libc.so (0xed3db000)
  libdl.so => /apex/com.android.runtime/lib/bionic/libdl.so (0xed2c3000)
  libm.so => /apex/com.android.runtime/lib/bionic/libm.so (0xed286000)

Apex-Size-Increase: (verify ~100kB)
Aosp-First: it is
Previous-Platform-Support: been debug only for a while
Test-Info: builds, boots, binary works
Test: TreeHugger
Signed-off-by: Maciej Żenczykowski <maze@google.com>
Change-Id: I1f7d12f2df2cf26476634e7eb84ca8f7622905f4
2023-10-16 17:43:59 +00:00
Hansen Kurli
a0cca02515 Add tests for onUserAdded and onUserRemoved
Test coverage of adding and removing a restricted user with and
without lockdown mode, using either setLockdown() and
setAlwaysOnPackage().

This change also refactors makeVpnUidRange() to return a list
and adds makeVpnUidRangeSet().

Bug: 230548427
Test: atest FrameworksNetTests
Change-Id: I47a25e9f0337f5c1d5754c279534640cd2753b5c
2023-10-16 18:11:41 +08:00
Junyu Lai
09ac34db85 Disable flaky NetworkStatsHistoryTest#testFuzzing in presubmit
Root cause not yet located, disable test to unblock TH.

Test: atest ConnectivityCoverageTests:android.net.connectivity.android.net.NetworkStatsHistoryTest
Bug: 302325928
Change-Id: I618090b67e428ab911ec88e7daab30c14cccbf64
2023-10-16 17:21:06 +08:00
Hansen Kurli
6f3e8aa4a0 Merge changes Ib7883f8a,I91ec59f7 into main
* changes:
  Mock Vpn.setUnderlyingNetworks()
  Mock Vpn.setLockdown()
2023-10-16 09:04:22 +00:00
Junyu Lai
e5c0a0fe56 Merge changes If7cb1cbb,I1d09ac01 into main
* changes:
  Adds more data points for benchmarking tests
  Move test zip file to assets
2023-10-16 06:50:12 +00:00
Paul Hu
1eeeb15f2e Merge "Add ServiceExpiredCallback" into main 2023-10-16 01:41:49 +00:00
Anton Kulakov
18d14d3e78 Merge changes from topic "revert-2777667-BKWNXIZQME" into main
* changes:
  Revert "Tell netd about local networks"
  Revert "Add LocalNetworkConfig"
2023-10-14 08:19:27 +00:00
Anton Kulakov
673d97b919 Merge "Revert "Simplify addRoutesToLocalNetwork calls"" into main 2023-10-14 08:19:27 +00:00
Patrick Rohr
0eab476f7a Merge "Fix broken documentation in Connectivity" into main 2023-10-13 19:30:52 +00:00
Anton Hansson
5ac6c0b05b Fix broken documentation in Connectivity
EthernetManager is @SystemApi, so cannot be referenced from public
API.

Bug: 303184203
Test: m docs
Change-Id: Ib5cc07c89b4ecfdeae704da131ebb307816e35fa
2023-10-13 15:25:26 +00:00
Anton Kulakov
cc409153b4 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
2023-10-13 15:23:59 +00:00
Anton Kulakov
6eea22b18c 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
2023-10-13 15:18:55 +00:00
Anton Kulakov
316346be6e Revert "Simplify addRoutesToLocalNetwork calls"
Revert submission 2777667

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

Reverted changes: /q/submissionid:2777667

Bug: 305187495

Change-Id: I516d40b20d775e9c61b2f825bc094329d016d0c3
2023-10-13 15:15:50 +00:00