Commit graph android_system_bpf/libbpf_android/BpfUtils.cpp
Message SHA1
BpfUtils - move trivial functions from .cpp to static inline's in .h
Test: builds, atest
Signed-off-by: Maciej Żenczykowski <maze@google.com>
Change-Id: I49d1ac6e196c5b1afbe460a7247d2ad38f571958

Maciej Żenczykowski   commited 2020-01-17 09:07:15 +00:00
b479fd6a9f
BpfUtils - use aggregate initializers for bpf()
Test: builds, atest
Signed-off-by: Maciej Żenczykowski <maze@google.com>
Change-Id: Ic8383e92973ff68a1b54299949121a31fb5c66d1

Maciej Żenczykowski   commited 2020-01-16 02:19:22 -08:00
2a1be9c22e
BpfUtils - replace memset() with = {}
We can't specify which union member we want to initialize
or the compiler will be too smart and do a partial init,
but a = {} will still zero the entire struct.

Test: builds, atest
Signed-off-by: Maciej Żenczykowski <maze@google.com>
Change-Id: I0f9208be1be65cec35d848d37a0142d03e0919bf

Maciej Żenczykowski   commited 2020-01-15 07:08:21 +00:00
bc32ac641d
get rid of netdutils::Slice in BpfUtils.cpp
Test: build, atest
Signed-off-by: Maciej Żenczykowski <maze@google.com>
Change-Id: Ic17181be20480c6db0806cc8dafef97d61736ec3

Maciej Żenczykowski   commited 2020-01-15 04:17:45 +00:00
c827aaa235
libbpf_android/BpfUtils - remove unused bpfProgLoad
(due to switch to bpfloader from loading via netd)

Test: build, atest
Signed-off-by: Maciej Żenczykowski <maze@google.com>
Change-Id: Ic95cdfde26b8e7b905551a7fd2b465e0cf99bbce

Maciej Żenczykowski   authored and   Steven Moreland   commited 2020-01-14 09:10:32 -08:00
c66f5c6bc1
remove spurious equals comparators
These are unused by virtue of the code continuing to build.

C++20 has https://en.cppreference.com/w/cpp/language/default_comparisons
but still requires explicit declaration of them with '=default' annotation.

Test: builds
Bug: 146787904
Signed-off-by: Maciej Żenczykowski <maze@google.com>
Change-Id: I751ad5592acc1ed4cf763d1ca82c301f2e233e56

Maciej Żenczykowski   commited 2020-01-06 13:57:05 +00:00
be15fa1edd
Revert "bpf: change how we detect device bpf support level"
This reverts commit 8daa0b6070.

Reason for revert: Not clear if O -> R will be supported or not.

Change-Id: I02818f35b4468cb3676a02951876c7768bb0451f

Maciej Żenczykowski   commited 2019-11-15 00:54:05 +00:00
1b5491d758
bpf: change how we detect device bpf support level
Now that we're developing Android R and we know upgrades
will only be supported from Android P & Q, we no longer
need to check for Android pre-P (ie. O) - so we can remove
that check.

We also take the opportunity to slightly refactor the code
to make it more readable.

Note: it's not appropriate to backport this into any 'normal'
Q branch, since it *will* break 4.9-O devices upgrading to Q
userspace without upgrading the kernel to at least 4.9-P.

Test: builds, atest
Bug: 139501958
Signed-off-by: Maciej Żenczykowski <maze@google.com>
Change-Id: Iacb3c2db489061b3f278d8e971e44dd1a5c4c1e6

Maciej Żenczykowski   commited 2019-10-23 07:31:24 +00:00
8daa0b6070
Clean up the legacy loader
delete the loader code that is no longer used by any bpf programs.

Bug: 130206035
Test: build all the bpf related target.
Change-Id: I3ea4e40cb986b380f3b79a7685c3c09633e4d199

Chenbo Feng   commited 2019-04-19 19:51:30 +00:00
097205c8e1
Add helper function to set rlimit for tests
Add a helper function to set sufficient MEMLOCK rlimit
for bpf related unit tests.

Bug: 119279144
Bug: 129246448
Test: libbpf_android_test
Change-Id: I5390f4d3b21436abff69a661d1c6e6a6749542ed

Chenbo Feng   authored and   Maciej Żenczykowski   commited 2019-04-10 05:54:00 +00:00
0a1a9a11d9
Add detailed kernel version when checking bpf support
For devices with 4.14 kernel shipping with bpf feature, they support more
functionality compared to 4.9 kernels. So when checking if the device
supports a given bpf feature, return a bpf level dependent on the detailed
kernel version instead of a simple boolean. This information would be
useful when we support new features such as map_in_map and cgroup socket
filters.

Bug: 111441138
Test: libnetdbpf_test, netd_integration_test
Change-Id: Ib51a56a35643ad76b58987ba1938c69905d28141

Chenbo Feng   commited 2019-02-14 13:39:05 -08:00
79b7e61d49
Remove hardcoded cgroup v2 path
Replace hardcoded cgroup v2 root path with new libprocessgroup API calls.

Bug: 111307099
Test: builds, boots

Change-Id: Ic9c47b52702767f9934f65d04bb91ab303b1d06e
Merged-In: Ic9c47b52702767f9934f65d04bb91ab303b1d06e
Signed-off-by: Suren Baghdasaryan <surenb@google.com>

Suren Baghdasaryan   commited 2019-02-02 16:58:40 +00:00
9217ccba51
Do not take cumulative network stats anymore
Use two maps to record the details of network stats and swap and clean
up after system server pulls the stats. The kernel program checks the
bpf map currently enabled before updating the stats and updates on the
corresponding map. Remove the TAG_STATS_MAP since we don't need to worry
about uid stats overflow problem. All the stats can be stored in the
same map until system server scrapes the stats and clean it up.

Bug: 79171384
Test: dumpsys netd trafficcontroller
      CtsUsageStatsTestCases

Change-Id: Ic79e382f51bf21eee78c4cac5a8a97edaf3654cd

Chenbo Feng   commited 2019-01-22 18:40:10 -08:00
9cd8f14ed0
New bpfloader netd kernel program
Change the netd bpf program to the new format. Adding map definition and
necessary helper functions to the kernel program code. Move the netd bpf
programs out of bpfloader to a new directory.

Test: dumpsys netd trafficcontroller
Bug: 112334572
Change-Id: I9287285d188e966193532b1522b5d3e67e32e930

Chenbo Feng   authored and   Joel Fernandes   commited 2019-01-07 20:17:42 -05:00
c1dd7648b1
Remove unused using decls.
Bug: 121209395
Test: make with WITH_TIDY=1 DEFAULT_GLOBAL_TIDY_CHECKS=-*,misc-unused-using-decls
Change-Id: I42d89c904c562ea2860510844c139b93ebee4637

Chih-Hung Hsieh   commited 2018-12-18 15:02:11 -08:00
18d8bfcfe9
Code style clean up
Apply the git clang format on the bpf project to make sure the existing
code compliance with the standard.

Test: project compiles and bpfMapTest pass.
Bug: 112334572
Change-Id: I4774aa2a197be2c671f6fb307c1fc9b71edfeeec

Chenbo Feng   commited 2018-11-28 11:31:36 -08:00
1f20ad3d78
Rename libbpf to libbpf_android
Rename the bpf support library in android to libbpf_android to make
it compatible with external bcc project. Fix the Android.bp file to
prevent build break.

Bug: 112334572
Test: No build breakage.
Change-Id: I24ae8aaf8ca8afdded5e46d21f0deec68d6030da

Chenbo Feng   commited 2018-11-08 11:32:31 -08:00
79a4da2d1e
Renamed from libbpf/BpfUtils.cpp (Browse further)