Commit Graph

1258 Commits

Author SHA1 Message Date
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
Treehugger Robot
68783d0260 Merge "Remove pollOrThrow" 2023-04-10 04:58:22 +00:00
Jean Chalard
10dd699d9f Merge "Add javadoc descriptions for family of methods" 2023-04-08 02:02:43 +00:00
Jean Chalard
32a735e8fa Merge "Remove eventuallyExpectOrNull" 2023-04-08 02:02:22 +00:00
Treehugger Robot
5fc2bcf360 Merge "Update StructInetDiagMsg to parse all the fields" 2023-04-07 11:48:37 +00:00
Yuyang Huang
2a1e2288ed Merge "Add a build rule for files used by mdns" 2023-04-06 02:08:46 +00:00
Motomu Utsumi
80c53fa4fd Update StructInetDiagMsg to parse all the fields
Bug: 270298713
Test: atest NetworkStaticLibTests
Change-Id: I782eca50b6db6dca88ee933edb5d5d19223886dd
2023-04-06 11:03:52 +09:00
Yuyang Huang
f67388b0ff Add a build rule for files used by mdns
mdns may be imported in other non-AOSP projects as a library, along with
its dependencies from net-utils-device-common. While all of
net-utils-device-common may not build against system API, this requires
the files used by mdns to build against system API.

Add a library to allow checking that the dependencies can still build
against system API.

Test: m
Bug: 272392042
Change-Id: I468f53b47ef55c23137594a79599b148084f4535
2023-04-05 19:31:31 +09:00
Maciej Żenczykowski
fb914d8226 update comment about synchronizeKernelRCU() still working
Since it just came up again, and I just verified this still works

Test: N/A
Signed-off-by: Maciej Żenczykowski <maze@google.com>
Change-Id: I292c94cf9af63488ed30a6ac367ac83c8912e97e
2023-04-04 22:24:31 +00:00
Xiao Ma
6559a91e3e Add constants for a DHCP packet maximum length and maximum option length.
Bug: 260934173
Test: m
Change-Id: I484a7a04c73906b11edb70e1053ee7f3172e8ffd
2023-04-04 10:27:34 +09:00
Chalard Jean
b56b9f2dcc Add util to compare getAllAddresses
Bug: 269715746
Test: New test in this patch
Change-Id: I243940df693d984a8adfa5c55b49088f7d8bc5ff
2023-03-31 21:35:44 +09:00
Maciej Żenczykowski
7c8bdba450 Merge "bpf_headers: add bpf_probe_read_user_str" 2023-03-29 02:15:09 +00:00
Steven Moreland
59e343367a bpf_headers: add bpf_probe_read_user_str
Bug: 269407130
Test: N/A
Change-Id: I735bffefd41ea3edcafd846041f8c237e860ee6c
2023-03-29 00:12:36 +00:00
Treehugger Robot
eab30c4fe7 Merge "[ST07] Add more documentation for PacketReflector" 2023-03-28 07:09:29 +00:00
Junyu Lai
63ff33b9e0 [ST07] Add more documentation for PacketReflector
Test: TH
Bug: 139774492
Change-Id: I778a8392a01806da313335b8103d27295b3e96e4
2023-03-28 10:37:26 +08:00
Junyu Lai
6210d4df5c Merge changes from topics "st05", "st06"
* changes:
  [ST06.2] Read http body for PUT or POST http request
  [ST05.3] Support PacketBridge
2023-03-28 02:25:52 +00:00
Junyu Lai
8fef4f726a [ST06.2] Read http body for PUT or POST http request
Currently, the test http server will respond whenever
http request is read, no matter how much data was declared
in the Content-Length header. For tests that uses POST
request to test uplink traffic this is not good enough.

Invoke parseBody to read data from input stream to make
sure the http body is read.

Test: atest android.net.NetworkStatsIntegrationTest \
      --rerun-until-failure 100
Bug: 139774492
Change-Id: I1b71f3e55747d104e4a8796611517d93f178321f
2023-03-27 18:45:46 +08:00
Junyu Lai
86c95b4925 [ST05.3] Support PacketBridge
For testing purposes, a TestNetworkInterface provides a
FileDescriptor which allows content injection on the test
network. However, this could be hard to use because the
callers need to compose IP packets in order to inject
content to the test network.

In order to remove the need of composing the IP packets,
this class forwards IP packets between two
TestNetworkInterface instances. Thus, the TCP/IP headers
could be parsed/composed automatically by the protocol stack of
this additional TestNetworkInterface, while the payload is
supplied by the servers run on the interface.

Test: 1. atest android.net.NetworkStatsIntegrationTest
      2. atest com.android.cts.net.HostsideVpnTests
Bug: 139774492
Change-Id: I8fe5a434d6d727a81d106a967dcdca157424e12e
2023-03-27 18:25:29 +08:00
Motomu Utsumi
b0c6afda18 Merge "Fix StructInetDiagMsg#parse bug" 2023-03-24 08:44:55 +00:00
Motomu Utsumi
06e615e3ce Fix StructInetDiagMsg#parse bug
StructInetDiagMsg#parse used absolute position to parse id and idiag_uid
fields.
This causes an issue when byte buffer contains multiple netlink messages
and parsed netlink message starts from the middle of byte buffer.

This CL fixes above issue and adds test for the case that single byte
buffer contains multiple netlink messages.

Test: atest NetworkStaticLibTests
Change-Id: I771daf17b4a606915d5edefd9f0e90ef01abf168
2023-03-24 12:34:04 +09:00
Xiao Ma
f15914cccf Merge "Support NLM_F_REPLACE flag when sending a RTM_NEWADDR message." 2023-03-24 02:51:53 +00:00
Xiao Ma
9a1359b46c Support NLM_F_REPLACE flag when sending a RTM_NEWADDR message.
NLM_F_REPLACE is helpful when we only want to update the preferred and
valid lifetime for a specific IPv6 address. DHCPv6 prefix delegation
gives a concrete example, once client refreshes the delegated prefix
successfully in RENEW or REBIND state, it also needs to extend the
preferred and valid lifetime of an IPv6 address, otherwise, it becomes
depreacated when the lifetime expires. Add the NLM_F_REPLACE flag to
replace the existing matching address object with updated fields.

Bug: 260934173
Test: atest NetworkStaticLibsTests
Change-Id: Ic001ddf9cfb031a586bbe177819e7666eaf7cde0
2023-03-23 15:59:40 +09:00
Junyu Lai
460c042999 Merge "Fix lint errors and adding nullability annotations in PacketReflector" 2023-03-20 05:49:19 +00:00
Junyu Lai
621c1b739d Merge "[ST04.1] Move PacketReflector to static library" 2023-03-16 13:23:14 +00:00
Junyu Lai
388204218b Fix lint errors and adding nullability annotations in PacketReflector
This is a no-op refactoring.

Test: TH
Bug: 139774492
Change-Id: Ibb6605a9f7add8319321e5b4960a0b9b637f1434
2023-03-15 13:53:36 +08:00
Junyu Lai
5622c37a85 [ST04.1] Move PacketReflector to static library
This is also needed by integration test in NetworkStack module
in follow-up CLs. Move to a common place first.
This is a no-op refactoring.

Test: atest com.android.cts.net.HostsideVpnTests
Bug: 139774492
Change-Id: Ifc7ed4c93edfb0f6f8eb47231f6df40332d2c10c
2023-03-15 13:35:00 +08:00
Maciej Żenczykowski
6ba8685aba minor checksum changes
main change is checksum of zero buffer is now 0 instead of
the equivalent, but technically incorrect 0xFFFF.

Test: TreeHugger
Bug: 265591307
Signed-off-by: Maciej Żenczykowski <maze@google.com>
Change-Id: I1a8b0ace704009f82d3b7ad1c299bf8a6d8964d8
2023-03-15 02:58:28 +00:00
Yuyang Huang
048a452551 Adds constructors for RtNetlinkAddressMessage and StructIfaddrMsg
Adds constructors for RtNetlinkAddressMessage and StructIfaddrMsg to
make it possible to directly construct RtNetlinkAddressMessage in the
test cases.

Bug: 267980538
Test: m
Change-Id: I21bf0cbef888495dc9a165a0fe6d5b39135e4c18
2023-03-14 11:30:28 +09:00
Treehugger Robot
88370eaae3 Merge "introduce BpfClassic.h" 2023-03-11 04:54:53 +00:00
Maciej Żenczykowski
aab04f1455 introduce BpfClassic.h
with helper macros for writing classic bpf code

Bug: 265591307
Test: TreeHugger
Signed-off-by: Maciej Żenczykowski <maze@google.com>
Change-Id: Ibffad51668303ddc5d6850409f9058dfc2894ef6
2023-03-10 23:46:42 +00:00
Jean Chalard
ead06ac681 Merge "Remove eventuallyExpectOrNull usages from AOSP" 2023-03-09 08:45:00 +00:00