Commit Graph

199 Commits

Author SHA1 Message Date
Hungming Chen
51fecf19e2 libclat: Use space indentation instead of tab
Correct the indentation style of libclat in the follows
bpf_headers/Android.bp
bpf_syscall_wrappers/Android.bp

Test: build
Change-Id: I7cdd354141124fa8f7b4a864ddd937bef4676302
2022-01-25 20:09:09 +08:00
Maciej Żenczykowski
ba9eeabd14 Merge "Add BPF_ANNOTATE_KV_PAIR to BPF map definition macros" 2022-01-25 02:31:59 +00:00
Maciej Żenczykowski
4772d859a7 Merge changes from topic "configure_bpf_for_clat"
* changes:
  make bpf_headers visible to libclat
  make bpf_syscall_wrappers visible to libclat
2022-01-24 19:14:35 +00:00
Maciej Żenczykowski
b7bc68fd76 Merge changes from topic "bpfinterfacemap"
* changes:
  Decouple "net-utils-framework-common" from "net-utils-device-common-bpf"
  Add visibility for use bpfmap by BpfInterfaceMapUpdater
2022-01-24 19:05:27 +00:00
Ken Chen
945c8b2638 Clean up bpf_headers visibility
The bpf_headers no need to explicitly specify visibility for
system/netd/libnetdbpf. The libnetdbpf depends on
bpf_connectivity_headers, which exports bpf_headers already.

Bug: 202086915
Test: m
Change-Id: I09a073b14dc74511ba9dc09a89ae6e89dff51f4d
2022-01-23 15:57:25 +08:00
markchien
32a6e9cbde Add visibility for use bpfmap by BpfInterfaceMapUpdater
Bug: 215095957
Test: m
Change-Id: Idbb8e3cbf520a29444ccdfd2d1c42553c886a7f0
2022-01-21 22:33:38 +08:00
Connor O'Brien
56875455c2 Add BPF_ANNOTATE_KV_PAIR to BPF map definition macros
BPF_ANNOTATE_KV_PAIR is used by libbpf to associate each map with its
BTF information. This is ignored for programs compiled without BTF
information.

Bug: 203823368
Test: build & boot; confirm all bpf progs load successfully
Test: compile time_in_state.o with -g; confirm BTF is loaded
Signed-off-by: Connor O'Brien <connoro@google.com>
Change-Id: I45f294945d48106d39d1d105ac4f49311459a19d
2022-01-20 21:22:24 -08:00
Maciej Żenczykowski
171da02e3f Merge changes from topic "tc-police"
* changes:
  Move logging helper to own file
  Add tc police support in TcUtils.java
  Add tc police support to jni lib
  Add functionality to attach tc-police action to ingress qdisc
  Add tests for adding / deleting bpf filter
  Add support to attach / replace / detach clsact qdisc to libtcutils
  Add tests for libtcutils
  Fix kernelversion.h
2022-01-21 01:52:42 +00:00
Ken Chen
76ee6106f5 Add libnettestutils as a networking test utility
The library provides a helper function that can retrieve dumpsys
results from a specific service. It can also take dumpsys arguments.

Bug: 29761778
Bug: 202086915
Test: test in Ib4aeb385ab80187feb39b659274a0aee20a4a5ed

Change-Id: Ib2ab8b6e4136bd3cbc52b025e53a1fa0c4e91709
2022-01-20 01:38:00 +08:00
Patrick Rohr
28c717a03e Move logging helper to own file
And rename to ALOGE to be in line with liblog.

Test: builds
Change-Id: I6c33f78a0649b273f75ebf05ea5ba3689beabc24
2022-01-19 14:54:37 +01:00
Patrick Rohr
eb3a8c734b Add tc police support to jni lib
Bug: 157552970
Test: TreeHugger
Change-Id: I63b4324bbb8d20b7d401921dad1f8e73ccc26a39
2022-01-19 14:20:27 +01:00
Patrick Rohr
e815a7462f Add functionality to attach tc-police action to ingress qdisc
This is used for go/bandwidth-limiting.

Bug: 157552970
Test: atest LibTcUtilsTest
Change-Id: Ic8e4d8dc016b14a6d4fc8ddbb3949941e9ef95af
2022-01-19 14:20:27 +01:00
Patrick Rohr
1f7ba259c3 Add tests for adding / deleting bpf filter
Bug: 202086915
Bug: 157552970
Test: atest LibTcUtilsTest
Change-Id: I8adcb3df29e4b3e0c558714f90b2840698e40cb9
2022-01-19 14:20:27 +01:00
Patrick Rohr
42b58ae836 Add support to attach / replace / detach clsact qdisc to libtcutils
Bug: 202086915
Bug: 157552970
Test: atest LibTcUtilsTest
Change-Id: I2f2e2f66acb7590e8951ac6e178c5893ba635597
2022-01-19 14:20:27 +01:00
Patrick Rohr
27846ff7a2 Add tests for libtcutils
Add tests for isEthernet(). Before I can add tests for the other
functions, I need to move tcQdiscAddDevClsact into libtcutils.

Bug: 202086915
Bug: 157552970
Test: atest LibTcUtilsTest
Change-Id: Id51e87bb76bc42a055f71027c94c51fcb76be209
2022-01-19 14:20:27 +01:00
Patrick Rohr
0c34e9a084 Fix kernelversion.h
Add missing pragma once and static inline all functions.

Bug: 202086915
Bug: 157552970
Test: builds
Change-Id: I8aca683e9e60c33bf5a5ac45cc20c2e59c8eecde
2022-01-19 14:20:27 +01:00
Hungming Chen
cd3f28f35d make bpf_headers visible to libclat
Needed because ClatdController and clatd binary are moved
into apex. libclat is used for accessing BPF map.

Bug: 212345928
Test: manual test
    1. Connect to ipv6-only wifi.
    2. Try IPv4 traffic.
       $ ping 8.8.8.8
Change-Id: If3fb00e12ef365ccf3ac782c4e6ecbfd01d2dd4c
2022-01-16 13:52:45 +08:00
Hungming Chen
37b2575137 make bpf_syscall_wrappers visible to libclat
Needed because ClatdController and clatd binary are moved
into apex. libclat is used for accessing BPF map.

Bug: 212345928
Test: manual test
    1. Connect to ipv6-only wifi.
    2. Try IPv4 traffic.
       $ ping 8.8.8.8
Change-Id: I95a1c21927ba95f6094152e1013761d79c73e981
2022-01-16 13:50:34 +08:00
Ken Chen
a973c0be7d Add bpf_headers visibility for CtsNativeNetPlatformTestCases
The CtsNativeNetPlatformTestCases uses BpfUtils.h in bpf_headers.

Bug: 29761778
Bug: 202086915
Test: atest CtsNativeNetPlatformTestCases on signed user build
Change-Id: Ibbb10392a283b88328ae17d9aa54322f50878e76
2022-01-15 02:27:22 +08:00
Wayne Ma
321a9f0719 Merge "[NETD-TC#12] Fix dependency on libtraffic_controller" 2022-01-14 10:44:52 +00:00
Wayne Ma
67a69e7396 [NETD-TC#12] Fix dependency on libtraffic_controller
1. Add visibility for libtraffic_control
2. Add com.android.tethering into apex_available statement

Bug: 202086915
Test: m; flash; boot
Change-Id: I817e22c24dd205f09ef62a2a7ff85b2a970f6d3a
2022-01-14 12:24:13 +08:00
Patrick Rohr
e7f26e2a4d Move BpfUtils -- move kernelVersion code to its own header
Move kernelVersion and isAtLeastKernelVersion to a local kernelversion.h,
since we cannot use bpf_headers' version of BpfUtils.

Bug: 202086915
Bug: 157552970
Test: builds
Change-Id: I83149b76cc5125991bdb52ce6160c497eb52b48b
2022-01-13 22:24:29 +01:00
Patrick Rohr
f714f1b116 Move BpfUtils -- add JNI wrapper for libtcutils
This CL adds the copied JNI wrappers for tcutils.

Bug: 202086915
Bug: 157552970
Test: atest TetheringTests
Change-Id: Ib3f8b24a12a18f1ba64fd17304274c4dba37fc47
2022-01-13 22:24:29 +01:00
Patrick Rohr
299a85e4f5 Move BpfUtils -- make libtcutils visible to package/modules/Connectivity
Bug: 202086915
Bug: 157552970
Test: builds
Change-Id: Ie9b34bbe5263e34c592a73a2ca828d0f3f48e564
2022-01-13 22:24:29 +01:00
Patrick Rohr
776c40cf65 Move BpfUtils -- add libtcutils
This CL is copying the "generic" parts of BpfUtils to
frameworks/libs/net/common. "Generic" meaning the parts that will be
used by both TcUtils in frameworks/libs/net/common and netd.

Bug: 202086915
Bug: 157552970
Test: atest TetheringTests
Change-Id: I9e780fc22e30d046f44953a8cac7687cb6c721c7
2022-01-12 21:34:52 +01:00
Patrick Rohr
a408d3cc06 Move BpfUtils -- make BpfSyscallWrappers visible to libtcutils
Bug: 202086915
Bug: 157552970
Test: atest TetheringTests
Change-Id: I698f492e30e4108037d1b72c5bebc7d6ab85e410
2022-01-12 21:34:48 +01:00
Maciej Żenczykowski
15d8ebee41 bpf_connectivity_headers -> bpf_headers -> bpf_syscall_wrappers
Test: TreeHugger
Signed-off-by: Maciej Żenczykowski <maze@google.com>
Change-Id: Idf158fa33670522b43e34c67a77087648b8b97a4
2021-12-28 17:56:27 -08:00
Hungming Chen
aa4d8483de Add apex_available and min_sdk_version to libip_checksum
Prepare to package libclat library and clatd binary into tethering
apex. This library is required.

Bug: 212345928
Test: build
Change-Id: I768c6358d9f4f15b37f73b3cfe2ff54a095a1bca
2021-12-28 06:01:57 +00:00
Ken Chen
45c7b15553 [NETD-BPF#23] Move a few headers to frameworks/libs/net
BPF headers used by both platform and mainline modules should be in
frameworks/libs/net.

Bug: 202086915
Test: build and boot
Test: cd packages/modules/Connectivity/netd; atest
Change-Id: Ie6f257b022cdea6bab3389a9fa41791f893e54c3
2021-12-23 09:57:29 +08:00
Ken Chen
0f1ee4ca81 Rename bpf_map_utils to bpf_headers
Use a generic name so that it can contain more bpf related headers.

Bug: 202086915
Test: build
Change-Id: I5a76948db394d8d7bb6eaedb570a2ca5bc99a289
2021-12-21 16:16:20 +08:00
Lorenzo Colitti
c57b00d863 Clarify that JNI libraries used for jarjar'd classes must be statically linked.
This appears to be necessary for safety.

Change-Id: I1db3c38a5e4bbcfd1b785e310313ab25ef557280
Test: documentation-only change
2021-12-15 02:28:17 +00:00
Maciej Żenczykowski
98dfa5354c Merge "Move libipchecksum to frameworks/libs/net." 2021-12-14 06:52:47 +00:00
Lorenzo Colitti
0aab036101 Move libipchecksum to frameworks/libs/net.
This code is used by the DNS resolver mainline module, so it
should be in a directory that is automerged to sc-mainline-prod,
not in /system/core.

Test: m
Change-Id: I2d953afa3d2766ca2b4529e9e49151c098b466aa
2021-12-13 19:59:14 -08:00
Bob Badour
2b71c97f99 [LSC] Add LOCAL_LICENSE_KINDS to frameworks/libs/net
Added SPDX-license-identifier-Apache-2.0 to:
  common/native/bpf_map_utils/Android.bp

Bug: 68860345
Bug: 151177513
Bug: 151953481

Test: m all
Change-Id: I4f254c63df574bcce60aa5854107fccbb888f424
2021-12-09 13:57:00 -08:00
Ken Chen
38edd75a6f Merge "[NETD-BPF#30] bpf_map_utils add visibility for libnetd_mainline" 2021-12-07 05:52:57 +00:00
Ken Chen
4bce28bc2a [NETD-BPF#25] Add bpf_syscall_wrappers visibility for libnetd_mainline
retrieveProgram() in bpf_syscall_wrappers is used by libnetd_mainline.

Bug: 202086915
Test: m; flash; boot
Change-Id: I69573a6925fd9f5fcd65935d681e7a340ee73f17
2021-12-07 02:42:32 +00:00
Ken Chen
eb911f1cf1 [NETD-BPF#30] bpf_map_utils add visibility for libnetd_mainline
libnetd_mainline uses WaitForProgsLoaded() in bpf_map_utils.

Bug: 202086915
Test: m; flash; boot
Change-Id: Ia9546002b66e0ff7918c0f1145d38cbc6e28790c
2021-12-06 03:19:20 +00:00
Ken Chen
de0bb52562 [NETD-BPF#15] Move BPF map definition and utils to frameworks/libs/net/
1. Move BPF map definition and utilities to a common place that easy to
be referenced from both mainline module and platform code.

2. Create cc_library_headers bpf_map_utils which includes BPF map
definition and utils.

Bug: 202086915
Test: m; flash; boot
Test: cd system/netd/ && atest
Test: cd packages/modules/Connectivity && atest
Test: m gpuservice_unittest libtimeinstate_test bpf_module_test
      CtsAppOpsTestCases libbpf_load_test VtsBootconfigTest
      vts_test_binary_bpf_module bpf_benchmark libbpf_load_test
      libbpf_android_test
Change-Id: I4d54b0d69029f593b8da3099d7ae16279692dabd
2021-12-04 11:46:53 +00:00
Alessio Balsini
9efcabc929 Allow MediaProvider to use BPF utilities
The FUSE daemon in MediaProvider needs to access the file descriptor of
its pinned BPF program.
The BPF syscall wrappers are handy and would avoid code duplication,
thus extend this project visibility to MediaProvider.

Bug: 202785178
Test: adb logcat FuseDaemon:V \*:S (in git_master)
Signed-off-by: Alessio Balsini <balsini@google.com>
Change-Id: I406c760bb96d74597ca7d8f701cd12c3bd318f68
2021-12-03 01:54:31 +00:00
Maciej Żenczykowski
307c3db71d switch to using OWNERS from master branch of Connectivity module
Test: N/A
Signed-off-by: Maciej Żenczykowski <maze@google.com>
Change-Id: If8c59abaf706b4c787be6454c08be3e26212ba21
2021-11-17 10:58:14 -08:00
markchien
f3448f905a Separate bpf and struct util from netlink util library
1. Separate bpf and struct libraries from netlink library.
2. Rename bpfmap jni library to respect its java side library.
3. Add README to explain the rules of adding shared jni library.
4. Also allow packages/modules/Connectivity to use bpf library.

Bug: 205088391
Test: atest TetheringTests
      atest CtsTetheringTest
      atest TetheringPrivilegedTests
      atest ConnectivityCoverageTests
Change-Id: I6e668818bede63b241cd901c0967f401613ddaf6
2021-11-11 18:50:53 +08:00
Tyler Wear
aafd9c18fb bpfmap: Move to Common Util Location
Multiple packages need access to bpf maps. Moving to common
location to allow access from all necessary packages.

Test: atest BpfMapTest
Bug: 179733303

Change-Id: Idae7b620c15c781b2e7980c3a3157f396cfaf66e
2021-10-29 12:38:05 -07:00
Tyler Wear
ae05481b9a export bpf headers to Connectivity Service
Export BPF headers to connectivity service for use with
VendorConnectivityService aidl.

Bug: 179733303
Change-Id: Ibc098facde54aeb621e53b73ac59eb6416ba9ebb
2021-10-20 01:02:31 +00:00
Suren Baghdasaryan
1bd069f24d Allow lmkd to use bpf_syscall_wrappers
LMKD needs access to map_gpu_mem_gpu_mem_total_map
BPF map to record the total size of GPU allocations
at the time of a kill. Change bpf_syscall_wrappers
visibility to allow lmkd to use bpf_syscall_wrappers
library.

Bug: 189366037
Test: lmkd_unit_test
Signed-off-by: Suren Baghdasaryan <surenb@google.com>
Change-Id: Ia1f75852a853f62b504351271119714f3fd95232
2021-06-11 21:00:06 +00:00
Orion Hodson
88dfe23949 Move to renamed NDK symbol AFileDescriptor_getFd
Bug: 185256332
Test: TH
Change-Id: I77f7551a97d015fe5cc54c053020504f5fb93ab7
2021-05-12 09:43:35 +01:00
Bob Badour
1b8c744bcd [LSC] Add LOCAL_LICENSE_KINDS to frameworks/libs/net
Added SPDX-license-identifier-Apache-2.0 to:
  client-libs/Android.bp
  client-libs/tests/unit/Android.bp
  common/Android.bp
  common/native/bpf_syscall_wrappers/Android.bp
  common/native/netjniutils/Android.bp
  common/tests/unit/Android.bp

Bug: 68860345
Bug: 151177513
Bug: 151953481

Test: m all

Exempt-From-Owner-Approval: janitorial work

Change-Id: I2d4abaee12c1f20c39a7e2c9e02e2fccb96fa3ee
Merged-in: I6942c6844c89048f785f2b6eaa4bb33a24fa6f93
2021-02-17 17:22:02 -08:00
Maciej Żenczykowski
0d05d57b89 add maze to OWNERS for common/native
(there's bpf related stuff in here)

Test: N/A
Signed-off-by: Maciej Żenczykowski <maze@google.com>
Change-Id: I7fcc19cdf48e468dfcbe5ee34f7bc07e261756b8
2021-01-19 18:34:13 -08:00
Maciej Żenczykowski
a728a70497 Wrap BPF system calls into a versioned module
This isn't new code, this is basically copied verbatim from
  //system/bpf/libbpf_android/include/bpf/BpfUtils.h

Test: atest BpfMapTest, TreeHugger
Signed-off-by: Maciej Żenczykowski <maze@google.com>
Change-Id: I80523c9ee0c1e4431f3192eb409ad68c737390a6
2021-01-13 18:29:56 -08:00
Orion Hodson
4ec55ea007 Share JNI file descriptor helper code
Move JNI File descriptor code from NetworkStack into a common native
static library.

Bug: 158749603
Test: atest NetworkStaticLibTests / treehugger
Change-Id: I3d14587ee8e8590b727736d7d2e29cba687e5514
2020-12-11 23:15:44 +00:00