Commit Graph

1238 Commits

Author SHA1 Message Date
Remi NGUYEN VAN
a60ccc7c6e Merge "Make ConnectivityCheckTargetPreparer more generic" 2023-05-17 02:55:56 +00:00
Remi NGUYEN VAN
90edff826a Disable Play auto-update during tests
For devices using Play services, disable auto-update during tests, as it
may interfere with them. For example, Webview may be killed if it is
opened while the update is applied.

Bug: 263665773
Test: atest
Change-Id: I9613d739ad0763c882a1971879aa743f4541a75c
2023-05-16 15:14:53 +09:00
Remi NGUYEN VAN
e2b5213774 Make ConnectivityCheckTargetPreparer more generic
Rename ConnectivityCheckTargetPreparer to
ConnectivityTestTargetPreparer, and the ConnectivityChecker app to
ConnectivityTestPreparer, and remove the assumption that the app only
does connectivity checks.

This will allow overriding the app with versions that have more specific
setup steps in downstream branches.

Bug: 263665773
Bug: 267413275
Test: tests using this preparer
Merged-In: Icb9b1eb8eb1c75f89cb751e0ca696ea96359e6d0
Change-Id: Icb9b1eb8eb1c75f89cb751e0ca696ea96359e6d0
2023-05-16 15:14:30 +09:00
Xiao Ma
e16a000e82 Allow subclass of FdEventsReader to process the zero-length packet.
Bug: 269692093
Test: atest TetheringIntegrationTests
Change-Id: I3afa5791d23e21a5bc3191cdd7bb61f6a4c494f8
2023-05-15 13:26:53 +00:00
Treehugger Robot
5b9c8cbeff Merge "Change IaPrefixOption prefix length type to byte." 2023-05-12 04:37:12 +00:00
Treehugger Robot
a1f16d0245 Merge "Define DNS-over-TLS port in static lib" 2023-05-11 11:48:27 +00:00
Motomu Utsumi
2976065935 Add message length check in parseNetlinkErrorMessage
Address review comment on aosp/2501578

Bug: 280553055
Test: TH, atest CtsNetTestCases
Change-Id: I945afc3dcc33dc85de6b00742fcf54e9c1901585
2023-05-10 17:47:28 +09:00
Treehugger Robot
2f240ff0b7 Merge "Close sockets from ConnectivityService#setFirewallChainEnabled" 2023-05-09 06:38:48 +00:00
Treehugger Robot
f01d29eae6 Merge "Add packet filters for IPv6 UDP" 2023-05-08 08:45:34 +00:00
Motomu Utsumi
2686cea965 Close sockets from ConnectivityService#setFirewallChainEnabled
And replace netd.socketDestroy by Java implementation

Bug: 270298713
Test: atest FrameworksNetTests CtsNetTestCases
Change-Id: I744b98ac1be04a1aede9d96787305e5a1a9d9ae6
2023-05-08 16:44:26 +09:00
Paul Hu
c28e11716e Merge "Enable error-prone checking in the net-utils-framework-common" 2023-05-08 02:03:25 +00:00
Maciej Żenczykowski
f402dd1575 Merge "add key/value Size to fdCache key" 2023-05-07 14:53:34 +00:00
Xiao Ma
f5847ba9f2 Change IaPrefixOption prefix length type to byte.
Given the maximum prefix length of IPv6 address is 128 and it
should not be assigned via IA prefix option to client, so S8
is enough to represent the prefix-length field.

Bug: 260934173
Test: m
Change-Id: Ia7fc52f7495775f3a29141d75adffafd84c38a02
2023-05-07 21:33:56 +08:00
Treehugger Robot
e9133fb957 Merge "Revert "Allow BpfMap to be accessed from NetworkStack"" 2023-05-05 01:46:38 +00:00
Maciej Żenczykowski
6b8144a07c Revert "Allow BpfMap to be accessed from NetworkStack"
This reverts commit fbe95d914c707c34d2c9d150a467d51c73414fcd.

Reason for revert: I've reconsidered.  This is a bad idea.
(and there are not yet any users)

The NetworkStack is an apk, not an apex, and as such it cannot
ship any bpf .o files (since that requires apex disk image format
instead of apk/jar zip file format).

There's no support for this (NetworkStack shipping bpf) in the
current tip-of-tree bpfloader.
As such there's no chance of this happening before V.
And even in V+ it is *super* unlikely, because... apk...
(We'd have to add apk zip traversal into the bpfloader...)

As such NetworkStack cannot possibly own any bpf programs/maps,
and could only potentially access platform/system bpf maps or
bpf maps owned by another module (ie. the Tethering apex).

Using any bpf maps from the system is not viable, as these
are owned by the platform, and as such may be modified by
vendors/oems.  Ie. their number, names, key/value layout, etc...
cannot be guaranteed.  As such using them from mainline
code is simply not safe.

Furthermore none of the platform bpfs are network related
(and indeed bpfloader enforces this).

As such this the only potential use of this would be
for NetworkStack to use Tethering apex bpf maps/programs.
However, this is also unsafe.

On older devices (pre-S) we don't even have support for
tethering apex shipped programs/maps.

On pre-T only the offload program is shipped, while
roughly equivalent netd.o maps/programs for the other
stuff are still provided by the platform.
(but the format of these cannot be relied upon)

As such use would have to be limited to T+.
(because the offload bpf map isn't interesting
to the network stack)

But on T+ we run into a cross-module versioning problem:
the source (and thus bpf map name/format/struct definitions)
used to build the NetworkStack apk and Tethering apex may differ.
Even modules shipped in tandem are build from separate release branches.  Additionally there's potential for only one module
to update, while the other remains older.  Thus making this
work cross-module would require freezing the map name & format.
ie. they would need to become cross-module API.
This is not something I'm willing to do.

Basically, this can be summarized as:
there is no *safe* way for NetworkStack apk to use bpf maps.

Test: TreeHugger
Bug: 276230058
Signed-off-by: Maciej Żenczykowski <maze@google.com>
Change-Id: I65ecf6ffca6ae88a1b72f6f4c8a5739991d78fe3
2023-05-04 10:18:46 +00:00
Junyu Lai
80c797a945 Define DNS-over-TLS port in static lib
The DNS-over-TLS port is a commonly used port number that is
typically set to 853 and is unlikely to be changed. To prevent
from code duplication in various modules, it would be beneficial
to include the port number definition in a static library.

Test: TH
Bug: 276230058
Change-Id: I7e6d0056ba15c932d9b4c3dd8760924278bde8fe
2023-05-04 17:14:06 +08:00
Paul Hu
8d47d844de Enable error-prone checking in the net-utils-framework-common
Enable error-prone checking in the net-utils-framework-common to
catch NullablePrimitive errors during build time.

Also fix any NullablePrimitive errors that are found in the
library classes.

Bug: 256991804
Test: Enable error-prone checking and check if the build fails
      with any NullablePrimitive errors. If it does, fix the
      errors and build again.
Change-Id: I7e1508d166f258f5232ff39388ac984fbdc6169e
2023-05-04 14:03:58 +08:00
Maciej Żenczykowski
296f847ea5 Merge "Allow BpfMap to be accessed from NetworkStack" 2023-05-02 13:45:28 +00:00
Junyu Lai
783a3b82ae Allow BpfMap to be accessed from NetworkStack
When loading BpfMap class, JNI part is needed for native
methods. Allow the static lib can be compiled with NetworkStack
JNI library.

Test: atest FrameworksNetTests:android.net.connectivity.com.android.server.BpfNetMapsTest
Bug: 276230058
Change-Id: I72ebe801dacd02de6711558d2058c1b756cf3080
2023-05-02 11:03:48 +00:00
Yuyang Huang
e4eb87ae3a Move Hexdump.java to framework/
Move Hexdump.java to framework/ to make it accessible from other
framework class.

Test: m
Change-Id: If92b7f0e09edc65071152197c3894d4a652c1853
2023-05-02 18:44:51 +09:00
Motomu Utsumi
747c9b9af5 Merge "Allow using isFeatureEnabled on APEX module init" 2023-04-29 05:24:29 +00:00
Maciej Żenczykowski
c846e0f0c1 Merge "Add ICMP header length constant" 2023-04-28 08:49:55 +00:00
Remi NGUYEN VAN
8c4fd4bf0b Allow using isFeatureEnabled on APEX module init
isFeatureEnabled is not usable in APEX module service initialization,
as it relies on PackageManager.getModuleInfo, which is only available
once the module controller is initialized. Also, there is no module
metadata in base AOSP.

Avoid this by guessing the tethering module name based on its
APK-in-APEX packages, which can be queried at that time.
ConnectivityServiceResources will indicate the package prefix used on
the device.

If querying with prefix + "tethering" fails, retry querying with prefix
+ "go.tethering" for Go devices.

This should allow using isFeatureEnabled in services (like
ConnectivityService) constructors, and allows removing the
FIXED_PACKAGE_VERSION hack when Tethering is not considered a module.

getConnectivityResourcesPackageName is implemented based on existing
code in ConnectivityResources.java. aosp/2446026 updates
ConnectivityResources to use getConnectivityResourcesPackageName.

Bug: 279108992
Test: atest
Change-Id: I277f4583e92ba41d53bd19666f1e8e29f68dfcd1
2023-04-28 16:39:52 +09:00
Maciej Żenczykowski
bc89547ed3 Merge "Remove mentions of bploader versions between S and T" 2023-04-27 19:37:36 +00:00
Treehugger Robot
82b6bd25f3 Merge "Bump the default bpfloader version for platform code." 2023-04-27 19:17:59 +00:00
chiachangwang
873548b3f8 Add ICMP header length constant
Bug: 277376698
Test: m
Change-Id: I7edcf0f809bb9d5fa72e2c70110efabbaa349adf
2023-04-27 15:09:31 +00:00
Maciej Żenczykowski
265b5ec189 Merge "Added a new #define for U BpfLoader version" 2023-04-27 14:40:49 +00:00
Yuyang Huang
c8022b3e00 Merge "Refactors common scope id setup code into utility function" 2023-04-27 07:39:58 +00:00
Yuyang Huang
58546f4046 Refactors common scope id setup code into utility function
Bug: 279691947
Test: atest NetworkStackIntegrationTests NetworkStackRootTests
Test: atest CtsNetTestCases:android.net.cts.NsdManagerTest
Change-Id: I81ab8d53a9c3b2641915a3cbfaf182c0962a3d55
2023-04-27 11:38:01 +09:00
Maciej Żenczykowski
9ee26f72eb Remove mentions of bploader versions between S and T
(they're only of historical interest at this point)

Test: TreeHugger
Signed-off-by: Maciej Żenczykowski <maze@google.com>
Change-Id: I0e52efda62626091c3023c5fd3622ffcdcd00ee1
2023-04-26 23:17:07 +00:00
Maciej Żenczykowski
59934d185a Bump the default bpfloader version for platform code.
This is the default for BPFLOADER_MIN_VER if not otherwise specified.

This does not affect mainline code, see:
  cs/p:aosp-master file:packages/modules/Connectivity/bpf_progs define.*BPFLOADER_MIN_VER

Test: TreeHugger
Signed-off-by: Maciej Żenczykowski <maze@google.com>
Change-Id: Ice5b14c3b580653f8889a5292abaa89cf8434da1
2023-04-26 23:13:24 +00:00
Maciej Żenczykowski
1e697e5514 Added a new #define for U BpfLoader version
See http://cs/h/googleplex-android/platform/superproject/+/udc-dev:system/bpf/libbpf_android/Loader.cpp?l=40

Test: TreeHugger
Signed-off-by: Maciej Żenczykowski <maze@google.com>
Change-Id: If0d75a30f8432f62a1c56aef12efba644fb458d6
2023-04-26 23:06:38 +00:00
Treehugger Robot
6e4762d627 Merge "Add InetDiagMessage.destroyLiveTcpSocket" 2023-04-26 04:49:20 +00:00
Motomu Utsumi
ba2e01d067 Add InetDiagMessage.destroyLiveTcpSocket
Implement NetdNativeService::socketDestroy in Java

Bug: 270298713
Test: atest NetworkStaticLibTests
Change-Id: I514abed84655cbdbf708cac159a6325eefb8d06b
2023-04-25 13:20:24 +09:00
Maciej Żenczykowski
4cd3d40c9a Merge "fix typo in NetlinkUtilsTest TAG" 2023-04-21 13:04:20 +00:00
Maciej Żenczykowski
2689f8fcb1 fix typo in NetlinkUtilsTest TAG
Test: TreeHugger
Signed-off-by: Maciej Żenczykowski <maze@google.com>
Change-Id: I2776eda17f4998129056a432029f6040365662f8
2023-04-21 10:29:00 +00:00
Maciej Żenczykowski
99d78d81b0 NetlinkUtilsTest: add an assumption to testGetNeighborsQuery
after:
  com.android.net.moduletests.util.netlink.NetlinkUtilsTest#testGetNeighborsQuery: ASSUMPTION_FAILED

Bug: 200221182
Test: TreeHugger, atest NetworkStaticLibTests
Signed-off-by: Maciej Żenczykowski <maze@google.com>
Change-Id: I556a3a52339e5e2343b02d2b2b67b486cb9b2033
2023-04-21 02:11:25 -07:00
Maciej Żenczykowski
90d41b22a4 Merge "IpUtils - make checksum work with empty/zero buffer" 2023-04-19 19:39:53 +00:00
Maciej Żenczykowski
5f95a67eef IpUtils - make checksum work with empty/zero buffer
also:
- document buffer endianness assumption
- simplify fold logic - it cannot overflow

Test: TreeHugger, atest NetworkStaticLibTests
Signed-off-by: Maciej Żenczykowski <maze@google.com>
Change-Id: I521a7377d1310c0e9c46a5dff95dca451e5f889e
2023-04-19 08:17:29 +00:00
Igor Chernyshev
810be2b456 Add async BufferedFile and StreamingPacketFile impls
Bug: 245971639

Change-Id: Ief1719262c2cb68819f6feb955e97793f3638ec0
2023-04-17 21:26:58 +00:00
Gopal Krishna Shukla
2632888a10 bpf_headers: add bpf_probe_read_user
Change-Id: I2b106cf8e34ec97f1efa2dd735b70aab8e4e1b4e
2023-04-15 00:58:34 +05:30
Junyu Lai
b39f440035 Merge "Move checkAnyPermissionOf to PermissionUtils" 2023-04-14 09:54:49 +00:00
Motomu Utsumi
8b9af43053 Merge "Split netlink ack check code to individual function" 2023-04-13 05:59:58 +00:00
Junyu Lai
a4b2b56a33 Move checkAnyPermissionOf to PermissionUtils
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: Id460cd231bbc520ebdcfe988a7507c6959500ac4
2023-04-11 14:54:24 +08:00
Maciej Żenczykowski
3f2ca45688 add key/value Size to fdCache key
Test: TreeHugger
Signed-off-by: Maciej Żenczykowski <maze@google.com>
Change-Id: I44fab9d485cb6516c0a03324809e02ad511c6f77
2023-04-10 14:14:26 +00:00
Treehugger Robot
021e3178b2 Merge changes Ief507b3f,I45256bb1
* changes:
  Add InetDiagMessage.inetDiagReqV2 with different args
  Fix StructInetDiagSockId parsing for v4-mapped v6 address
2023-04-10 12:14:07 +00:00
Treehugger Robot
6ba46f963a Merge "Add util to compare getAllAddresses" 2023-04-10 10:38:42 +00:00
Motomu Utsumi
d7a1d968cf Split netlink ack check code to individual function
Upcoming CL uses this function

Bug: 270298713
Test: atest NetworkStaticLibTests
Change-Id: I4b969024206b3bc58965e44849e426cc91344425
2023-04-10 18:09:43 +09:00
Motomu Utsumi
95681172a9 Add InetDiagMessage.inetDiagReqV2 with different args
This CL also adds SOCK_DESTROY constants.
These changes will be used by upcoming CLs that implement socket destroy
in ConnectivityService.

Bug: 270298713
Test: atest NetworkStaticLibTests
Change-Id: Ief507b3f8cc4fe23c08699e7fc8f3f62e5acfcdc
2023-04-10 18:09:43 +09:00
Motomu Utsumi
64a711a618 Fix StructInetDiagSockId parsing for v4-mapped v6 address
Before this CL, StructInetDiagSockId.parse convert v4-mapped v6 address
to Inet4Address that is inconsistent with the value in
inet_diag_msg.idiag_family.
Also, due to this behavior, input of parse and output of pack could be
different.
This is the issue specifically when SOCK_DESTROY request is populated
based on the InetDiagMessage from the kernel.

Bug: 270298713
Test: atest NetworkStaticLibTests
Change-Id: I45256bb1069cfc4e01662b3a533077933f3f019a
2023-04-10 18:01:17 +09:00