summaryrefslogtreecommitdiff
path: root/common/native
Commit message (Collapse)AuthorAgeFilesLines
* support per-map/prog selinux context and cross .o map sharingMaciej Żenczykowski2022-06-212-22/+68
| | | | | | | | | | | | | | | | Tested in pieces in aosp/master and it still successfully boots. So the struct extension infrastructure works as desired. This is a sqaush of 2 aosp/master commits: 64005dd91b0cf1722ccd1767f805e0524010920e a5c641141ff74bba025a65451628308c6cbb7e0f Ignore-AOSP-First: squash of 2 aosp/master patches Bug: 218408035 Test: TreeHugger Signed-off-by: Maciej Żenczykowski <maze@google.com> Change-Id: I7136253086eaccf79cf39e7a0143b425a1019390
* BpfMap - add BpfMapRO.init() supportMaciej Żenczykowski2022-06-211-18/+29
| | | | | | | | | | | | | | | | | Really we need to fix the inheritance to make BpfMapRO the parent class of BpfMap: but that's a far more difficult thing to do, so in the short term we punt like this. This makes BpfMapRO a little bit more usable, and allows a slow transition across the codebase... Bug: 218408035 Test: TreeHugger Signed-off-by: Maciej Żenczykowski <maze@google.com> Change-Id: I1c5112db70e9e523c113cba536fbe19422b4d3f3 (cherry picked from commit b54659706758641a0ff01770644cb189e3959b29) Merged-In: I1c5112db70e9e523c113cba536fbe19422b4d3f3
* Merge "bpf_helpers.h - add #define's for S/T bpfloader versions" into tm-devMaciej Żenczykowski2022-06-211-0/+11
|\
| * bpf_helpers.h - add #define's for S/T bpfloader versionsMaciej Żenczykowski2022-06-211-0/+11
| | | | | | | | | | | | | | | | | | | | | | (by request from Lorenzo) Bug: 218408035 Test: TreeHugger Signed-off-by: Maciej Żenczykowski <maze@google.com> Change-Id: I802d2aae8b103375d7cbe0ed5c35f0abf6c04ac9 (cherry picked from commit 974ee86ff71fdfaaa0305d1623efcef1d9a16b21) Merged-In: I802d2aae8b103375d7cbe0ed5c35f0abf6c04ac9
* | BpfMap key/value access size verificationMaciej Żenczykowski2022-06-212-9/+62
| | | | | | | | | | | | | | | | | | | | | | (beginning there of) Bug: 218408035 Test: TreeHugger Signed-off-by: Maciej Żenczykowski <maze@google.com> Change-Id: Ie7cf8cd51b4e272fc76a281df6231ed27955ed3f (cherry picked from commit 62315472e581ea119fb8f44d3a03b41a8ca80b3b) Merged-In: Ie7cf8cd51b4e272fc76a281df6231ed27955ed3f
* | cache kernelVersion(), make isAtLeastKernelVersion() cheaperMaciej Żenczykowski2022-06-212-2/+12
|/ | | | | | | | | | | | not perfect due to this being in a header file, so multiple copies potentially exist, but it's really simple, and works nearly as well. Bug: 218408035 Test: TreeHugger Signed-off-by: Maciej Żenczykowski <maze@google.com> Change-Id: Id90c6933d57bc12f4dd640c8918fd0885c7474cf (cherry picked from commit 9d481287aa69200a36c997200e71232b77234b0a) Merged-In: Id90c6933d57bc12f4dd640c8918fd0885c7474cf
* BpfMap: simplify .init() mMapFd assignmentMaciej Żenczykowski2022-06-201-1/+1
| | | | | | | | | | | this way is more obviously not calling dup_with_cloexec Bug: 218408035 Test: TreeHugger Signed-off-by: Maciej Żenczykowski <maze@google.com> Change-Id: I4e1ce3b0a42ccea638332ae451e291e025d57895 (cherry picked from commit 703e4682444dcab121f9657dc5c1605a7bcce65e) Merged-In: I4e1ce3b0a42ccea638332ae451e291e025d57895
* BpfMap: introduce resetMap(type, entries, flags)Maciej Żenczykowski2022-06-081-0/+17
| | | | | | | | | | | | | to replace less safe uses of BpfMap.reset(create(type, keysize, valuesize, entries, flags)) Meant to be used in tests only. Bug: 235286176 Test: TreeHugger Signed-off-by: Maciej Żenczykowski <maze@google.com> Change-Id: I869f1f935bcf5d00702c42bc46d6094ea552addc (cherry picked from commit d2dec08c73b2bc1dd2a3969ccb504a59e9cb223f) Merged-In: I869f1f935bcf5d00702c42bc46d6094ea552addc
* BpfMap: cache bpf map file descriptorsMaciej Żenczykowski2022-05-201-20/+20
| | | | | | | | | | | | | We switch back to int from ParcelFileDescriptor, and eliminate all calls to close(). Bpf Map FDs now live till process exit. Bug: 230880517 Test: TreeHugger, atest com.android.networkstack.tethering.BpfMapTest Signed-off-by: Maciej Żenczykowski <maze@google.com> Change-Id: I89b6dc88ea56cb1e50695f8daf54ed79bce3fba2 (cherry picked from commit 8888c198daa8141988ee806adcf54b43e68b1076) Merged-In: I89b6dc88ea56cb1e50695f8daf54ed79bce3fba2
* BpfMap: wrap native fd with ParcelFileDescriptor to avoid fd leakHungming Chen2022-05-121-11/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | ParcelFileDescriptor has implemented finalize(). Wrap native fd into ParcelFileDescriptor which helps to release fd automatically. Bug: 230880517 Test: manual test Steps: 1. Connect to IPv6 only wifi and clat maps are created $ adb shell cmd wifi set-wifi-enabled enabled 05-12 13:53:41.182 1793 2031 W BpfMap : open /sys/fs/bpf/net_shared/map_clatd_clat_ingress6_map..: 493 05-12 13:53:41.182 1793 2031 W BpfMap : open /sys/fs/bpf/net_shared/map_clatd_clat_egress4_map..: 546 $ adb shell ls -all proc/1793/fd | grep bpf .. system system 64 2022-05-12 13:55:35 .. 493 -> anon_inode:bpf-map .. system system 64 2022-05-12 13:55:35 .. 546 -> anon_inode:bpf-map $ adb shell dumpsys connectivity Forwarding rules: BPF ingress map: iif nat64Prefix v6Addr -> v4Addr oif 47 /64:ff9b::/96 /2a00:79e1:abc:6f02:6efd:1d4b:f05e:25bd -> /192.0.0.4 54 BPF egress map: iif v4Addr -> v6Addr nat64Prefix oif 54 /192.0.0.4 -> /2a00:79e1:abc:6f02:6efd:1d4b:f05e:25bd /64:ff9b::/96 47 ether 2. Disconnect from IPv6 only wifi, force GC and clat map fds are released $ adb shell cmd wifi set-wifi-enabled disabled $ adb shell kill -10 1793 $ adb shell ls -all proc/1793/fd | grep bpf (fd 493 and 546 are removed) Change-Id: I26bbafbd73eccab6f4ae2c71690ecad12bbef7df (cherry picked from commit ef5e791312fbed4ead02809893039d8e21b43a03) Merged-In: I26bbafbd73eccab6f4ae2c71690ecad12bbef7df
* Make libtcutils visible to netd testsPatrick Rohr2022-03-301-1/+1
| | | | | Test: TH Change-Id: I71943cfd2fb72dca8a7ffd5d063860b89be47ca1
* TcUtils: add tcQdiscAddDevClsactHungming Chen2022-03-171-0/+14
| | | | | | | | Support tc command: $ tc qdisc add dev .. clsact Test: TreeHugger Change-Id: I98abcb59418ab12b6e4de0f42a18ded4677ddbfc
* Allow use of shared bpf headers by recoveryStephane Lee2022-03-092-0/+2
| | | | | | | | This will allow healthd to filter uevent packets, if needed Bug: 203462310 Test: Ensure that healthd can build if it uses bpf filters Change-Id: I97bfe9509a6934444f656508176495bba38381be
* Merge "BpfUtils.h - switch to GTEST_SKIP in all 4 SKIP macros"Ken Chen2022-03-021-26/+16
|\
| * BpfUtils.h - switch to GTEST_SKIP in all 4 SKIP macrosKen Chen2022-03-021-26/+16
| | | | | | | | | | | | | | | | | | patch the missing commit I3acb47a432378f257418f81b26516e18d6ff3780. Test: TreeHugger, atest libbpf_android_test netd_unit_test netd_integration_test Change-Id: I6b7114584759c0689e0d6b852387b93a799f663f
* | Bpf Util Lib in Common LocationTyler Wear2022-03-012-0/+176
|/ | | | | | | | | Add bpf lib to load and attach BPF programs in commonly accesible location. Bug: 179733303 Change-Id: I17b68abb14e816e7210bc603ffda44e10fb73d2f
* Merge "Fix wrong nla_type for matchall"Maciej Żenczykowski2022-02-111-1/+1
|\
| * Fix wrong nla_type for matchallPatrick Rohr2022-02-111-1/+1
| | | | | | | | | | | | | | | | | | | | | | TCA_U32_ACT was missed when converting from the u32 filter to matchall. Interestingly, cls_matchall does not seem to validate this type as the kernel happily accepted this configuration (which absolutely should not happen as TCA_U32_ACT is greater than __TCA_MATCHALL_MAX). Bug: 218840346 Test: atest CtsNetTestCases:RateLimitTest Change-Id: Ia24683cbd5fbd10084163db6e6a4415ec03f6f3f
* | Merge "expose bpf_syscall_wrappers to art apex"Maciej Żenczykowski2022-02-101-0/+1
|\ \
| * | expose bpf_syscall_wrappers to art apexMaciej Żenczykowski2022-02-091-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The art apex already has access to bpf_headers which includes bpf_syscall_wrappers, but this extra line is needed to switch it away from needlessly linking libbpf_android. Since these are header files only, this annotation is kind of pointless, but it does turn out to be needed... Test: TreeHugger Signed-off-by: Maciej Żenczykowski <maze@google.com> Change-Id: I9e4d3373cea488080304e31ed7c8708aec988933
* | | Merge "switch from libbpf_android to bpf_headers"Maciej Żenczykowski2022-02-101-1/+1
|\| |
| * | switch from libbpf_android to bpf_headersMaciej Żenczykowski2022-02-091-1/+1
| | | | | | | | | | | | | | | | | | Test: TreeHugger, atest libbpf_android_test Signed-off-by: Maciej Żenczykowski <maze@google.com> Change-Id: I215ac3c5d4820bfef94a48024d511ea86012eb0f
* | | Merge "bpf_headers/bpf_syscall_wrappers - remove visibility restrictions"Maciej Żenczykowski2022-02-102-36/+0
|\| |
| * | bpf_headers/bpf_syscall_wrappers - remove visibility restrictionsMaciej Żenczykowski2022-02-092-36/+0
| |/ | | | | | | | | | | | | | | this doesn't appear to make sense now that it's available to vendors Test: TreeHugger Signed-off-by: Maciej Żenczykowski <maze@google.com> Change-Id: If2d24fa8eccfb5c12832fb191a8560b024751db7
* | Merge "Add attach bpf with flags and detach single bpf"Maciej Żenczykowski2022-02-101-1/+11
|\ \ | |/ |/|
| * Add attach bpf with flags and detach single bpfKaiWen Zheng2022-02-091-1/+11
| | | | | | | | | | | | | | | | | | | | Attach bpf program to cgroup with flags, support 'BPF_F_ALLOW_OVERRIDE' and 'BPF_F_ALLOW_MULTI'; corresponding to detach a single bpf program in a cgroup. Test: m Signed-off-by: KaiWen Zheng <zhengkaiwen5@xiaomi.corp-partner.google.com> Change-Id: I9a4d2dcb249c6c628e3f1287d7d5d1879b722bd6
* | bpf_headers for vendor.Steven Moreland2022-02-083-3/+3
| | | | | | | | | | | | | | | | For waitForProgsLoaded. Bug: 162057235 Test: build, load bpf program from vendor Change-Id: Ib670aada0a98249fed21beb72879326286b2f4c2
* | Include libtcutils inside libnet_utils_device_common_bpfjniPatrick Rohr2022-02-011-1/+1
| | | | | | | | | | | | | | | | This way, users of libnet_utils_device_common_bpfjni do not also have to separately list the required libtcutils. Test: build, boots Change-Id: Id40863de83b6c40b79f38d638299626f7e025810
* | [LSC] Add LOCAL_LICENSE_KINDS to frameworks/libs/netBob Badour2022-01-271-0/+4
| | | | | | | | | | | | | | | | | | | | | | | | Added SPDX-license-identifier-Apache-2.0 to: common/native/nettestutils/Android.bp Bug: 68860345 Bug: 151177513 Bug: 151953481 Test: m all Change-Id: If5fcd4735fe82f336227626a443bba1d74201722
* | libclat: Use space indentation instead of tabHungming Chen2022-01-252-2/+2
| | | | | | | | | | | | | | | | | | Correct the indentation style of libclat in the follows bpf_headers/Android.bp bpf_syscall_wrappers/Android.bp Test: build Change-Id: I7cdd354141124fa8f7b4a864ddd937bef4676302
* | Merge "Add BPF_ANNOTATE_KV_PAIR to BPF map definition macros"Maciej Żenczykowski2022-01-251-0/+10
|\ \
| * | Add BPF_ANNOTATE_KV_PAIR to BPF map definition macrosConnor O'Brien2022-01-201-0/+10
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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
* | | Merge changes from topic "configure_bpf_for_clat"Maciej Żenczykowski2022-01-242-0/+2
|\ \ \ | | | | | | | | | | | | | | | | | | | | * changes: make bpf_headers visible to libclat make bpf_syscall_wrappers visible to libclat
| * | | make bpf_headers visible to libclatHungming Chen2022-01-161-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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
| * | | make bpf_syscall_wrappers visible to libclatHungming Chen2022-01-161-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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
* | | | Merge changes from topic "bpfinterfacemap"Maciej Żenczykowski2022-01-241-0/+2
|\ \ \ \ | | | | | | | | | | | | | | | | | | | | | | | | | * changes: Decouple "net-utils-framework-common" from "net-utils-device-common-bpf" Add visibility for use bpfmap by BpfInterfaceMapUpdater
| * | | | Add visibility for use bpfmap by BpfInterfaceMapUpdatermarkchien2022-01-211-0/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Bug: 215095957 Test: m Change-Id: Idbb8e3cbf520a29444ccdfd2d1c42553c886a7f0
* | | | | Clean up bpf_headers visibilityKen Chen2022-01-231-1/+0
|/ / / / | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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
* | | | Merge changes from topic "tc-police"Maciej Żenczykowski2022-01-217-27/+671
|\ \ \ \ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * 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
| * | | | Move logging helper to own filePatrick Rohr2022-01-192-26/+53
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | And rename to ALOGE to be in line with liblog. Test: builds Change-Id: I6c33f78a0649b273f75ebf05ea5ba3689beabc24
| * | | | Add tc police support to jni libPatrick Rohr2022-01-191-0/+20
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Bug: 157552970 Test: TreeHugger Change-Id: I63b4324bbb8d20b7d401921dad1f8e73ccc26a39
| * | | | Add functionality to attach tc-police action to ingress qdiscPatrick Rohr2022-01-193-0/+392
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This is used for go/bandwidth-limiting. Bug: 157552970 Test: atest LibTcUtilsTest Change-Id: Ic8e4d8dc016b14a6d4fc8ddbb3949941e9ef95af
| * | | | Add tests for adding / deleting bpf filterPatrick Rohr2022-01-191-0/+35
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Bug: 202086915 Bug: 157552970 Test: atest LibTcUtilsTest Change-Id: I8adcb3df29e4b3e0c558714f90b2840698e40cb9
| * | | | Add support to attach / replace / detach clsact qdisc to libtcutilsPatrick Rohr2022-01-193-0/+76
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Bug: 202086915 Bug: 157552970 Test: atest LibTcUtilsTest Change-Id: I2f2e2f66acb7590e8951ac6e178c5893ba635597
| * | | | Add tests for libtcutilsPatrick Rohr2022-01-193-2/+92
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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
| * | | | Fix kernelversion.hPatrick Rohr2022-01-192-3/+7
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Add missing pragma once and static inline all functions. Bug: 202086915 Bug: 157552970 Test: builds Change-Id: I8aca683e9e60c33bf5a5ac45cc20c2e59c8eecde
* | | | | Add libnettestutils as a networking test utilityKen Chen2022-01-203-0/+108
| |/ / / |/| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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
* | | | Add bpf_headers visibility for CtsNativeNetPlatformTestCasesKen Chen2022-01-151-0/+1
|/ / / | | | | | | | | | | | | | | | | | | | | | | | | The CtsNativeNetPlatformTestCases uses BpfUtils.h in bpf_headers. Bug: 29761778 Bug: 202086915 Test: atest CtsNativeNetPlatformTestCases on signed user build Change-Id: Ibbb10392a283b88328ae17d9aa54322f50878e76
* | | Merge "[NETD-TC#12] Fix dependency on libtraffic_controller"Wayne Ma2022-01-142-0/+2
|\ \ \
| * | | [NETD-TC#12] Fix dependency on libtraffic_controllerWayne Ma2022-01-142-0/+2
| |/ / | | | | | | | | | | | | | | | | | | | | | | | | 1. Add visibility for libtraffic_control 2. Add com.android.tethering into apex_available statement Bug: 202086915 Test: m; flash; boot Change-Id: I817e22c24dd205f09ef62a2a7ff85b2a970f6d3a