Commit graph

95 commits

Author SHA1 Message Date
Joel Fernandes
b0d0de4f80 Merge "Add support for the bpf_probe_read_str bpf function"
am: fe5e7aa314

Change-Id: Icb6e46c103213c7367103f1dc85a5a46652b0556
2019-04-17 14:08:15 -07:00
Joel Fernandes
fe5e7aa314 Merge "Add support for the bpf_probe_read_str bpf function" 2019-04-17 19:09:32 +00:00
Joel Fernandes
1b8962af4c Add support for the bpf_probe_read_str bpf function
This is needed for the iorapd project (i/o readahead).

Change-Id: If6a3de682296bbce0fc808a0eced6bd778106292
Signed-off-by: Joel Fernandes <joelaf@google.com>
2019-04-17 15:37:18 +00:00
Chenbo Feng
a7aca77297 Add helper function to set rlimit for tests
am: 0a1a9a11d9

Change-Id: I6c71f8a79be2a8bd74405f1c850230e56e7afdfc
2019-04-09 23:08:12 -07:00
Chenbo Feng
0a1a9a11d9 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
2019-04-10 05:54:00 +00:00
Chenbo Feng
3dc9188861 Set bpfloader MEMLOCK rlimit to at least 8MB
am: ee121646cf

Change-Id: Ia8a8e30ac8a07722758e097877b2708896656dac
2019-04-09 13:10:38 -07:00
Chenbo Feng
ee121646cf Set bpfloader MEMLOCK rlimit to at least 8MB
Since bpfloader is only used to create the bpf maps and load bpf
programs on android devices. It is okay to set the MEMLOCK rlimit of
bpfloader to the proper size needed by bpf maps regardless of the global
device values. It helps partner to adopt the bpf feature without
changing the device configuration.

Bug: 119279144
Bug: 129246448
Test: remove device specific rlimit and build and verify bpf maps
created.

Change-Id: Ib97d1d304f4ea9a6215afed76e1c1e28f1415221
2019-04-09 12:04:33 -07:00
Maciej enczykowski
59747b9273 bpf_helpers.h - define more kernel provided functions
am: e1153fd1da

Change-Id: I96e1292bc57f26e92cf6c62967a37e39495aea74
2019-04-02 11:04:05 -07:00
Maciej Żenczykowski
e1153fd1da bpf_helpers.h - define more kernel provided functions
Test: builds
Bug: 65674744
Signed-off-by: Maciej Żenczykowski <maze@google.com>
Change-Id: I88dcaf5edf61b780666f346e963a7417c04c97ec
2019-04-02 04:04:02 -07:00
Maciej enczykowski
bf68b18e07 BpfMap.getOrCreate(size, path, type) -> BpfMap.init(path)
am: 52108bf52c

Change-Id: I13be3fbdf9f0b9602a39d597e6434edea5bc62d3
2019-04-01 19:14:44 -07:00
Maciej enczykowski
9e330265db BpfMap - remove mPinnedPath, getPinnedPath, pinToPath
am: 04d88b7576

Change-Id: Iaf409b7898100d63e0511be264bf83381ff18e21
2019-04-01 19:14:37 -07:00
Maciej Żenczykowski
52108bf52c BpfMap.getOrCreate(size, path, type) -> BpfMap.init(path)
We don't have the appropriate selinux privs to create the maps anyway.

Test: builds (when combined with system/netd change)
      'git grep getOrCreate' in system/{bpf,netd} comes up empty
      atest netd_unit_test netd_integration_test libbpf_android_test
Bug: 65674744
Bug: 129654883
Signed-off-by: Maciej Żenczykowski <maze@google.com>
Change-Id: Idffbce5b28b723943c6495cfafdecddc7a0f4e67
2019-04-01 16:54:08 -07:00
Maciej Żenczykowski
04d88b7576 BpfMap - remove mPinnedPath, getPinnedPath, pinToPath
Test: builds, git grep 'mPinnedPath|getPinnedPath|pinToPath' comes up empty
      atest netd_unit_test netd_integration_test libbpf_android_test
Bug: 65674744
Bug: 129654883
Signed-off-by: Maciej Żenczykowski <maze@google.com>
Change-Id: Iad84ce7c74bef77e63cf63563d67b7501dd0165b
2019-04-01 16:54:08 -07:00
Maciej enczykowski
7885e42926 bpfloader depends on clatd.o
am: 7a3a5ba1ad

Change-Id: I42921c8fde3e75ee7d2ce24121004ae13638556d
2019-03-26 20:36:54 -07:00
Maciej Żenczykowski
7a3a5ba1ad bpfloader depends on clatd.o
Test: builds
Bug: 65674744
Signed-off-by: Maciej Żenczykowski <maze@google.com>
Change-Id: I5c48acc6aed81c38650564d2fb42e6e816b4b726
2019-03-26 18:11:01 -07:00
Lorenzo Colitti
bd7cf3f302 Remove bpfloader dependency on netd.
am: ac600729b8

Change-Id: I9cfc80e863408f385214cff65ef52cc1d3a6d69b
2019-03-26 01:33:00 -07:00
Lorenzo Colitti
ac600729b8 Remove bpfloader dependency on netd.
This was necessary when the netd BPF program lived in system/bpf,
but it's no longer necessary.

Test: m
Bug: 65674744
Change-Id: I1fcf7e41276341b1258adf9d3795e81b6139f84f
2019-03-26 13:52:15 +09:00
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