Commit graph

78 commits

Author SHA1 Message Date
Connor O'Brien
b827e50926 Merge "Remove time_in_state.o from build"
am: 1dc90cbfd3

Change-Id: Iedff4ef208c386e6cf85e5f0e1986e8771cf18a7
2019-03-22 18:31:54 -07:00
Treehugger Robot
1dc90cbfd3 Merge "Remove time_in_state.o from build" 2019-03-23 01:09:31 +00:00
Connor O'Brien
c551a76f45 Remove time_in_state.o from build
The data collected by this program currently has no consumers, so
there's no need to load it or include it in the bpfloader build yet.

Test: make bpfloader
Change-Id: I206d94e3da34dc3b81bdbfdd4a00b05cfb624f48
Signed-off-by: Connor O'Brien <connoro@google.com>
2019-03-22 16:19:25 -07:00
Chenbo Feng
f8b9dee2d8 Move netd specific program back to netd
am: 47e92158ca

Change-Id: Id77610beb224e678844379acf98557a0026179b7
2019-02-28 17:31:04 -08:00
Chenbo Feng
47e92158ca Move netd specific program back to netd
For the eBPF programs that only related to networking, move them back
to netd so for the future changes in networking eBPF area, there is not
need to make changes in both netd project and bpf project.

Bug: 112334572
Test: mmma -j32 system/bpf
Change-Id: Icd0efd165c60c055a00fe88705a0c8070c0d22f5
2019-02-26 15:41:00 -08:00
Xin Li
c6980d5ab4 DO NOT MERGE - Merge pi-dev@5234907 into stage-aosp-master
Bug: 120848293
Change-Id: I4f96f8351b170c9b438079080c7a3885237f1cf8
2019-02-20 16:20:06 -08:00
Chenbo Feng
d61ee6c7d8 Merge "Add detailed kernel version when checking bpf support"
am: 7dacd1b72a

Change-Id: I0bfbdd9ad561e9e4841d7ea96e1d84fd5f1019ff
2019-02-14 21:29:15 -08:00
Treehugger Robot
7dacd1b72a Merge "Add detailed kernel version when checking bpf support" 2019-02-15 05:26:35 +00:00
Joel Fernandes (Google)
1b9a6c52e1 netd: Use common BPF helper for C program
am: 14ba88881f

Change-Id: I8001088a9d0cc054d7fef2887fc8ef7bbf9e76cc
2019-02-14 13:52:14 -08:00
Chenbo Feng
79b7e61d49 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
2019-02-14 13:39:05 -08:00
Joel Fernandes (Google)
14ba88881f netd: Use common BPF helper for C program
The BPF helper is moved into system/bpf/include/ and is available
to all BPF programs in the include search path. Make use of it.

Only minor refactor, no functional change.

Bug: 122665156
Change-Id: Ib5b495aff83874d39abe3640fb369b2ff92b3239
Signed-off-by: Joel Fernandes <joelaf@google.com>
2019-02-12 17:20:20 -05:00
Joel Fernandes
3365e895ae Add tests for BPF loader
am: 4845288a6e

Change-Id: Ie7149e369c82ad251a6afe4c701c07d9269622d6
2019-02-04 15:05:47 -08:00
Joel Fernandes
4845288a6e Add tests for BPF loader
Bug: 112334572
Change-Id: I4457ee9ea3044c5c9ecb6ebfd5ad4f5a2c11dce5
Signed-off-by: Joel Fernandes <joelaf@google.com>
2019-02-04 15:28:52 -05:00
Suren Baghdasaryan
823ca6fd4e Remove hardcoded cgroup v2 path
am: 9217ccba51

Change-Id: If1a17a86cddee4cf9e35544006900a3584f82fab
2019-02-03 20:12:01 -08:00
Suren Baghdasaryan
9217ccba51 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>
2019-02-02 16:58:40 +00:00
Christopher Ferris
c0402548cd Fix compiler warnings.
am: c151c67412

Change-Id: I5ade2daddc0db4571d2c79ceb085bdf5e5632570
2019-02-01 17:54:15 -08:00
Christopher Ferris
c151c67412 Fix compiler warnings.
Changed finds that use a string with a single character ("X"), to 'X'.

Remove using statements from header file.

Add a couple of missing includes.

Changed a couple of functions that take a string to const string& to
avoid extra copies.

Test: No warnings when compiled, unit tests pass.
Change-Id: I218ee0e6b6c7fb1c79d1337c1ce3d6f1e318a3cd
2019-02-01 15:48:19 -08:00
Chenbo Feng
01806ba3e1 Add bpf program to control socket creation
am: ef6d45e7cf

Change-Id: Id8ccc7d804816d8d445dc510c4768075f7f039b1
2019-01-30 13:01:16 -08:00
Chenbo Feng
f102a5435f Add cgroup socket bpf kernel program support
am: 5aee2f14a5

Change-Id: I3b38a275feb463edf2af4ba64c6b865571ebff51
2019-01-30 13:01:10 -08:00
Chenbo Feng
ef6d45e7cf Add bpf program to control socket creation
For new kernel that support cgroup socket filter, use bpf programs to
control the creation of inet socket.

Bug: 111560570
Bug: 111560739
Test: dumpsys netd trafficcontroller
Change-Id: I94efcdccfcd17f08c731caa700ea5797f2f56e7d
2019-01-29 18:58:03 -08:00
Steven Moreland
74175c244a Merge "Replace clang-format with symlink."
am: b78998c447

Change-Id: I5dcc53e877904ce06835417865d91697628dfd54
2019-01-28 20:07:02 -08:00
Chenbo Feng
5aee2f14a5 Add cgroup socket bpf kernel program support
Add support for cgroup socket filter program loading in bpfloader,
and create a uid permission map to store the uids that have INTERNET
permission.

Bug: 111560570
Bug: 111560739
Test: dumpsys netd trafficcontroller

Change-Id: I658f533d302cb594d7b36d4a3a2a70e394874c33
2019-01-28 15:21:59 -08:00
Treehugger Robot
b78998c447 Merge "Replace clang-format with symlink." 2019-01-28 20:16:54 +00:00
Maciej enczykowski
e5a32ae658 bpf loader - add support for new schedcls type
am: ffa7aadf75

Change-Id: I60395d1d0db2551f704b204fbe166ab1f34a6f8d
2019-01-25 02:12:12 -08:00
Maciej Żenczykowski
ffa7aadf75 bpf loader - add support for new schedcls type
which maps to BPF_PROG_TYPE_SCHED_CLS

Bug: 65674744
Signed-off-by: Maciej Żenczykowski <maze@google.com>
Change-Id: I7ca5912756c575e2c0667b9dae2d24471845e028
2019-01-24 23:16:10 -08:00
Chenbo Feng
c451e95209 Merge "Do not take cumulative network stats anymore"
am: 5b2a4f4159

Change-Id: I189c5a1cfc24585d887d38b94e3a04870e9e2286
2019-01-24 10:55:26 -08:00
Chenbo Feng
5b2a4f4159 Merge "Do not take cumulative network stats anymore" 2019-01-24 18:16:25 +00:00
Connor O'Brien
5dfa15cadb Add time_in_state.o to build
am: c8885ccf3f

Change-Id: Ic46a2f95767377390af60b3209bfe7ec682ca877
2019-01-23 15:44:17 -08:00
Connor O'Brien
c8885ccf3f Add time_in_state.o to build
bpfloader now has CAP_SYS_ADMIN, which allows it to load programs like
time_in_state.o that use eBPF's tracepoint support.

Test: make bpfloader
Test: ls /sys/fs/bpf/ shows time_in_state progs and maps are created
Bug: 112334572
Bug: 78498733
Change-Id: Iedff50381c9ee2b3bdfc6c01b2e2ccaeaf0917d5
Signed-off-by: Connor O'Brien <connoro@google.com>
2019-01-23 12:09:19 -08:00
Chenbo Feng
9cd8f14ed0 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
2019-01-22 18:40:10 -08:00
Steven Moreland
65e2b23220 Replace clang-format with symlink.
Automatic consistency.

Bug: 122835115
Test: manual
Change-Id: I3ca92906c3bde25d3314ea3da91f1c42d09332f4
2019-01-18 14:26:33 -08:00
Joel Fernandes
d3e821739d Set bpf.progs_loaded property when programs finish loading am: d3ec871017
am: b4ea87be03

Change-Id: I01d613fab6393ea54c0cd1508eac3866999e08a8
2019-01-14 15:01:42 -08:00
Joel Fernandes
a95fc2631b bpfloader: Make it an init service am: 6e1341ef20
am: 71ae90e0f2

Change-Id: Ifd0ff0462a86998de551183f96826da5f4e90b9b
2019-01-14 15:01:32 -08:00
Joel Fernandes
b4ea87be03 Set bpf.progs_loaded property when programs finish loading
am: d3ec871017

Change-Id: Ia26b08e968e04085b9e22ef70711f19b4f2843ac
2019-01-14 14:06:42 -08:00
Joel Fernandes
71ae90e0f2 bpfloader: Make it an init service
am: 6e1341ef20

Change-Id: I40258fe60be096d614ecf838f11a2fc2d097e2ae
2019-01-14 14:06:35 -08:00
Joel Fernandes
d3ec871017 Set bpf.progs_loaded property when programs finish loading
The property bpf.progs_loaded will be used by services expecting BPF
programs to be loaded and wait before they are loaded.

Bug: 112334572

Change-Id: I19daa0caa84e2659e8790f0dd551d95ab824e13b
Signed-off-by: Joel Fernandes <joelaf@google.com>
2019-01-11 09:02:11 -05:00
Chenbo Feng
f6c30042b7 New bpfloader netd kernel program am: c1dd7648b1
am: 8a9681b360

Change-Id: I5d686647b75c5ab0beb4ddf6c9327a719ba29e71
2019-01-09 11:15:50 -08:00
Chenbo Feng
8a9681b360 New bpfloader netd kernel program
am: c1dd7648b1

Change-Id: I543955a4d19bc6fd4cd79b6bdd6ea547de217b63
2019-01-09 10:53:27 -08:00
Joel Fernandes
6e1341ef20 bpfloader: Make it an init service
With this, bpfloader does not need to be started by netd and will load
at boot time.

Bug: 112334572
Change-Id: Iad777ed0a5bb5995dbf2fc176a220292a4c5e41f
Signed-off-by: Joel Fernandes <joelaf@google.com>
2019-01-07 20:17:42 -05:00
Chenbo Feng
c1dd7648b1 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
2019-01-07 20:17:42 -05:00
Chih-Hung Hsieh
762b1d1bee Remove unused using decls. am: 18d8bfcfe9
am: df2c186b85

Change-Id: I8e8c528343eaa8bb0277324b519e26f9dcce36a4
2018-12-19 15:57:16 -08:00
Chih-Hung Hsieh
df2c186b85 Remove unused using decls.
am: 18d8bfcfe9

Change-Id: I6d5ac3fabfc687b4aa3b52c4488d68042e9a5955
2018-12-19 15:47:43 -08:00
Chih-Hung Hsieh
18d8bfcfe9 Remove unused using decls.
Bug: 121209395
Test: make with WITH_TIDY=1 DEFAULT_GLOBAL_TIDY_CHECKS=-*,misc-unused-using-decls
Change-Id: I42d89c904c562ea2860510844c139b93ebee4637
2018-12-18 15:02:11 -08:00
Joel Fernandes
50dd665575 Initial checkin for relocatable ELF loader and link with bcc am: d76a2004a6
am: 6ed41e94a5

Change-Id: I10bf1c680fb76544b75c29cdfcfe043ea7ac3a0a
2018-12-17 16:41:50 -08:00
Joel Fernandes
6ed41e94a5 Initial checkin for relocatable ELF loader and link with bcc
am: d76a2004a6

Change-Id: I292123efc24bc6a761353cc829a2e8596c1c4547
2018-12-17 16:32:46 -08:00
Joel Fernandes
d76a2004a6 Initial checkin for relocatable ELF loader and link with bcc
* Wrote a relocatable ELF loader from scratch. The loader library loads
all objects in /system/etc/bpf/, parses and fixes up eBPF instructions
based on relocation information, creates maps and programs and pins
them. A single API call without arguments is made which results in this
operation. The API has all the information it needs from the filesystem
and the ELF objects, so there is no configuration stored in the code
calling the loader API essentially making it zero conf. Initially this
will be used by time_in_state statistics collection using tracepoints.
In the future, netd's eBPF C code should be rewritten to use this
infrastructure and the old ELF loader can be gotten rid off. This is the
first step.

* Link libbpf with libbpf_android which will come from the external/ bcc
project. This will be used for tracepoint and perf eBPF support. In the
future it can be used for other things as kernel eBPF support advances.

This patch will be merged only after bcc is cloned into external/ to
prevent build breakage.

Bug: 112334572
Change-Id: Ic0fd9504e18031132d40bb627c5e44058d59c9f8
Signed-off-by: Joel Fernandes <joelaf@google.com>
2018-12-17 22:27:56 +00:00
Yi Kong
b519321d89 Use size_t instead of unsigned int am: 4a74569453
am: 08333b4f40

Change-Id: I607f36e5b26ee2f29ca14937053c1181ea81761d
2018-12-16 19:39:03 -08:00
Yi Kong
08333b4f40 Use size_t instead of unsigned int
am: 4a74569453

Change-Id: I89fcb241e31734931e0170f5bc4bfdf65fa4da18
2018-12-16 19:33:57 -08:00
Yi Kong
4a74569453 Use size_t instead of unsigned int
Addresses follow-up review on commit fc3c769.

Test: m checkbuild
Change-Id: I79cd341c425ebe27cc66584540398fc98e94be50
2018-12-16 18:23:19 -08:00
Yi Kong
bbf889512c Fix sign-compare warning am: cb8e0a08ea
am: a66d9d59dd

Change-Id: I062ca6e1d4473de18560f8fb93602a429de203af
2018-12-14 18:35:30 -08:00