Martin KaFai Lau
95b9afd398
bpf: Test for bpf ID
...
Add test to exercise the bpf_prog/map id generation,
bpf_(prog|map)_get_next_id(), bpf_(prog|map)_get_fd_by_id() and
bpf_get_obj_info_by_fd().
Signed-off-by: Martin KaFai Lau <[email protected] >
Acked-by: Alexei Starovoitov <[email protected] >
Acked-by: Daniel Borkmann <[email protected] >
Signed-off-by: David S. Miller <[email protected] >
2017-06-06 15:41:24 -04:00
David S. Miller
91045f5e52
bpf: Add bpf_verify_program() to the library.
...
This allows a test case to load a BPF program and unconditionally
acquire the verifier log.
It also allows specification of the strict alignment flag.
Signed-off-by: David S. Miller <[email protected] >
Acked-by: Daniel Borkmann <[email protected] >
2017-05-11 14:19:00 -04:00
David S. Miller
b0c47807d3
bpf: Add sparc support to tools and samples.
...
Signed-off-by: David S. Miller <[email protected] >
Acked-by: Daniel Borkmann <[email protected] >
2017-04-22 13:01:52 -07:00
Alexei Starovoitov
3084887378
tools/lib/bpf: add support for BPF_PROG_TEST_RUN command
...
add support for BPF_PROG_TEST_RUN command to libbpf.a
Signed-off-by: Alexei Starovoitov <[email protected] >
Acked-by: Daniel Borkmann <[email protected] >
Acked-by: Martin KaFai Lau <[email protected] >
Acked-by: Wang Nan <[email protected] >
Signed-off-by: David S. Miller <[email protected] >
2017-04-01 12:45:57 -07:00
Martin KaFai Lau
fb30d4b712
bpf: Add tests for map-in-map
...
Test cases for array of maps and hash of maps.
Signed-off-by: Martin KaFai Lau <[email protected] >
Acked-by: Alexei Starovoitov <[email protected] >
Signed-off-by: David S. Miller <[email protected] >
2017-03-22 15:45:45 -07:00
Masahiro Yamada
03671057c3
scripts/spelling.txt: add "overrided" pattern and fix typo instances
...
Fix typos and add the following to the scripts/spelling.txt:
overrided||overridden
Link: http://lkml.kernel.org/r/[email protected]
Signed-off-by: Masahiro Yamada <[email protected] >
Signed-off-by: Andrew Morton <[email protected] >
Signed-off-by: Linus Torvalds <[email protected] >
2017-02-27 18:43:47 -08:00
David S. Miller
3f64116a83
Merge git://git.kernel.org/pub/scm/linux/kernel/git/davem/net
2017-02-16 19:34:01 -05:00
Mickaël Salaün
cdc6a4ba88
bpf: Remove redundant ifdef
...
Remove a useless ifdef __NR_bpf as requested by Wang Nan.
Inline one-line static functions as it was in the bpf_sys.h file.
Signed-off-by: Mickaël Salaün <[email protected] >
Cc: Alexei Starovoitov <[email protected] >
Cc: Daniel Borkmann <[email protected] >
Cc: David S. Miller <[email protected] >
Cc: Wang Nan <[email protected] >
Link: https://lkml.kernel.org/r/[email protected]
Acked-by: Wang Nan <[email protected] >
Signed-off-by: David S. Miller <[email protected] >
2017-02-15 12:14:54 -05:00
Alexei Starovoitov
7f67763337
bpf: introduce BPF_F_ALLOW_OVERRIDE flag
...
If BPF_F_ALLOW_OVERRIDE flag is used in BPF_PROG_ATTACH command
to the given cgroup the descendent cgroup will be able to override
effective bpf program that was inherited from this cgroup.
By default it's not passed, therefore override is disallowed.
Examples:
1.
prog X attached to /A with default
prog Y fails to attach to /A/B and /A/B/C
Everything under /A runs prog X
2.
prog X attached to /A with allow_override.
prog Y fails to attach to /A/B with default (non-override)
prog M attached to /A/B with allow_override.
Everything under /A/B runs prog M only.
3.
prog X attached to /A with allow_override.
prog Y fails to attach to /A with default.
The user has to detach first to switch the mode.
In the future this behavior may be extended with a chain of
non-overridable programs.
Also fix the bug where detach from cgroup where nothing is attached
was not throwing error. Return ENOENT in such case.
Add several testcases and adjust libbpf.
Fixes: 3007098494 ("cgroup: add support for eBPF programs")
Signed-off-by: Alexei Starovoitov <[email protected] >
Acked-by: Daniel Borkmann <[email protected] >
Acked-by: Tejun Heo <[email protected] >
Acked-by: Daniel Mack <[email protected] >
Signed-off-by: David S. Miller <[email protected] >
2017-02-12 21:52:19 -05:00
Mickaël Salaün
702498a142
bpf: Remove bpf_sys.h from selftests
...
Add require dependency headers.
Signed-off-by: Mickaël Salaün <[email protected] >
Cc: Alexei Starovoitov <[email protected] >
Cc: Daniel Borkmann <[email protected] >
Cc: Shuah Khan <[email protected] >
Signed-off-by: David S. Miller <[email protected] >
2017-02-10 15:56:08 -05:00
Mickaël Salaün
5f155c2563
bpf: Use bpf_map_get_next_key() from the library
...
Replace bpf_map_next_key() with bpf_map_get_next_key() calls.
Signed-off-by: Mickaël Salaün <[email protected] >
Cc: Alexei Starovoitov <[email protected] >
Cc: Daniel Borkmann <[email protected] >
Cc: Shuah Khan <[email protected] >
Signed-off-by: David S. Miller <[email protected] >
2017-02-10 15:56:07 -05:00
Mickaël Salaün
e58383b803
bpf: Use bpf_map_delete_elem() from the library
...
Replace bpf_map_delete() with bpf_map_delete_elem() calls.
Signed-off-by: Mickaël Salaün <[email protected] >
Cc: Alexei Starovoitov <[email protected] >
Cc: Daniel Borkmann <[email protected] >
Cc: Shuah Khan <[email protected] >
Signed-off-by: David S. Miller <[email protected] >
2017-02-10 15:56:07 -05:00
Mickaël Salaün
e5ff7c4019
bpf: Use bpf_map_lookup_elem() from the library
...
Replace bpf_map_lookup() with bpf_map_lookup_elem() calls.
Signed-off-by: Mickaël Salaün <[email protected] >
Cc: Alexei Starovoitov <[email protected] >
Cc: Daniel Borkmann <[email protected] >
Cc: Shuah Khan <[email protected] >
Signed-off-by: David S. Miller <[email protected] >
2017-02-10 15:56:07 -05:00
Mickaël Salaün
10ecc728fe
bpf: Use bpf_map_update_elem() from the library
...
Replace bpf_map_update() with bpf_map_update_elem() calls.
Signed-off-by: Mickaël Salaün <[email protected] >
Cc: Alexei Starovoitov <[email protected] >
Cc: Daniel Borkmann <[email protected] >
Cc: Shuah Khan <[email protected] >
Signed-off-by: David S. Miller <[email protected] >
2017-02-10 15:56:07 -05:00
Mickaël Salaün
2ee89fb9a9
bpf: Use bpf_load_program() from the library
...
Replace bpf_prog_load() with bpf_load_program() calls.
Signed-off-by: Mickaël Salaün <[email protected] >
Cc: Alexei Starovoitov <[email protected] >
Cc: Daniel Borkmann <[email protected] >
Cc: Shuah Khan <[email protected] >
Signed-off-by: David S. Miller <[email protected] >
2017-02-10 15:56:06 -05:00
Joe Stringer
5dc880de6e
tools lib bpf: Add bpf_prog_{attach,detach}
...
Commit d8c5b17f2b ("samples: bpf: add userspace example for attaching
eBPF programs to cgroups") added these functions to samples/libbpf, but
during this merge all of the samples libbpf functionality is shifting to
tools/lib/bpf. Shift these functions there.
Committer notes:
Use bzero + attr.FIELD = value instead of 'attr = { .FIELD = value, just
like the other wrapper calls to sys_bpf with bpf_attr to make this build
in older toolchais, such as the ones in CentOS 5 and 6.
Signed-off-by: Joe Stringer <[email protected] >
Cc: Alexei Starovoitov <[email protected] >
Cc: Daniel Borkmann <[email protected] >
Cc: Wang Nan <[email protected] >
Link: http://lkml.kernel.org/n/[email protected]
Link: https://github.com/joestringer/linux/commit/353e6f298c3d0a92fa8bfa61ff898c5050261a12.patch
Signed-off-by: Arnaldo Carvalho de Melo <[email protected] >
2016-12-20 12:00:39 -03:00
Joe Stringer
a5580c7f7a
tools lib bpf: Add flags to bpf_create_map()
...
Commit 6c90598174 ("bpf: pre-allocate hash map elements") introduces
map_flags to bpf_attr for BPF_MAP_CREATE command. Expose this new
parameter in libbpf.
By exposing it, users can access flags such as whether or not to
preallocate the map.
Signed-off-by: Joe Stringer <[email protected] >
Acked-by: Wang Nan <[email protected] >
Cc: Alexei Starovoitov <[email protected] >
Cc: Daniel Borkmann <[email protected] >
Link: http://lkml.kernel.org/r/[email protected]
[ Added clarifying comment made by Wang Nan ]
Signed-off-by: Arnaldo Carvalho de Melo <[email protected] >
2016-12-15 16:25:47 -03:00
Joe Stringer
83d994d02b
tools lib bpf: use __u32 from linux/types.h
...
Fixes the following issue when building without access to 'u32' type:
./tools/lib/bpf/bpf.h:27:23: error: unknown type name ‘u32’
Signed-off-by: Joe Stringer <[email protected] >
Acked-by: Wang Nan <[email protected] >
Cc: Alexei Starovoitov <[email protected] >
Cc: Daniel Borkmann <[email protected] >
Link: http://lkml.kernel.org/r/[email protected]
Signed-off-by: Arnaldo Carvalho de Melo <[email protected] >
2016-12-15 16:25:46 -03:00
Wang Nan
9742da0150
tools lib bpf: Add missing BPF functions
...
Add more BPF map operations to libbpf. Also add bpf_obj_{pin,get}(). They
can be used on not only BPF maps but also BPF programs.
Signed-off-by: Wang Nan <[email protected] >
Acked-by: Alexei Starovoitov <[email protected] >
Cc: He Kuang <[email protected] >
Cc: Joe Stringer <[email protected] >
Cc: Zefan Li <[email protected] >
Cc: [email protected]
Link: http://lkml.kernel.org/r/[email protected]
Signed-off-by: Arnaldo Carvalho de Melo <[email protected] >
2016-11-29 12:09:36 -03:00
Wang Nan
203d1cacad
tools lib bpf: Add license header
...
Adding a missing license descriptopn header to files in libbpf, make it
LGPL-2.1.
Signed-off-by: Wang Nan <[email protected] >
Cc: Alexei Starovoitov <[email protected] >
Cc: Daniel Borkmann <[email protected] >
Cc: Eric Leblond <[email protected] >
Cc: Zefan Li <[email protected] >
Cc: [email protected]
Link: http://lkml.kernel.org/r/[email protected]
Signed-off-by: Arnaldo Carvalho de Melo <[email protected] >
2016-07-04 20:27:25 -03:00
Wang Nan
8f9e05fb29
perf tools: Fix PowerPC native building
...
Checks BPF syscall number, turn off libbpf building on platform doesn't
correctly support sys_bpf instead of blocking compiling.
Reported-and-Tested-by: Naveen N. Rao <[email protected] >
Signed-off-by: Wang Nan <[email protected] >
Acked-by: Jiri Olsa <[email protected] >
Cc: Sukadev Bhattiprolu <[email protected] >
Cc: Zefan Li <[email protected] >
Cc: [email protected]
Link: http://lkml.kernel.org/r/[email protected]
Signed-off-by: Arnaldo Carvalho de Melo <[email protected] >
2016-01-11 19:22:20 -03:00
He Kuang
43798bf372
bpf tools: Add helper function for updating bpf maps elements
...
Add bpf_map_update_elem() helper function which calls the sys_bpf
syscall to update elements in bpf maps. Upcoming patches will use it to
adjust data in map through the perf command line.
Signed-off-by: He Kuang <[email protected] >
Cc: Alexei Starovoitov <[email protected] >
Cc: Masami Hiramatsu <[email protected] >
Cc: Namhyung Kim <[email protected] >
Cc: Wang Nan <[email protected] >
Cc: Zefan Li <[email protected] >
Cc: [email protected]
Link: http://lkml.kernel.org/r/[email protected]
Signed-off-by: Wang Nan <[email protected] >
Signed-off-by: Arnaldo Carvalho de Melo <[email protected] >
2015-11-26 17:21:24 -03:00
Wang Nan
7bf98369a7
bpf tools: Introduce bpf_load_program() to bpf.c
...
bpf_load_program() can be used to load bpf program into kernel. To make
loading faster, first try to load without logbuf. Try again with logbuf
if the first try failed.
Signed-off-by: Wang Nan <[email protected] >
Acked-by: Alexei Starovoitov <[email protected] >
Cc: Brendan Gregg <[email protected] >
Cc: Daniel Borkmann <[email protected] >
Cc: David Ahern <[email protected] >
Cc: He Kuang <[email protected] >
Cc: Jiri Olsa <[email protected] >
Cc: Kaixu Xia <[email protected] >
Cc: Masami Hiramatsu <[email protected] >
Cc: Namhyung Kim <[email protected] >
Cc: Peter Zijlstra <[email protected] >
Cc: Zefan Li <[email protected] >
Cc: [email protected]
Link: http://lkml.kernel.org/r/[email protected]
Signed-off-by: Arnaldo Carvalho de Melo <[email protected] >
2015-08-07 10:16:58 -03:00
Wang Nan
e3ed2fef22
bpf tools: Add bpf.c/h for common bpf operations
...
This patch introduces bpf.c and bpf.h, which hold common functions
issuing bpf syscall. The goal of these two files is to hide syscall
completely from user. Note that bpf.c and bpf.h deal with kernel
interface only. Things like structure of 'map' section in the ELF object
is not cared by of bpf.[ch].
We first introduce bpf_create_map().
Note that, since functions in bpf.[ch] are wrapper of sys_bpf, they
don't use OO style naming.
Signed-off-by: Wang Nan <[email protected] >
Acked-by: Alexei Starovoitov <[email protected] >
Cc: Brendan Gregg <[email protected] >
Cc: Daniel Borkmann <[email protected] >
Cc: David Ahern <[email protected] >
Cc: He Kuang <[email protected] >
Cc: Jiri Olsa <[email protected] >
Cc: Kaixu Xia <[email protected] >
Cc: Masami Hiramatsu <[email protected] >
Cc: Namhyung Kim <[email protected] >
Cc: Peter Zijlstra <[email protected] >
Cc: Zefan Li <[email protected] >
Cc: [email protected]
Link: http://lkml.kernel.org/r/[email protected]
Signed-off-by: Arnaldo Carvalho de Melo <[email protected] >
2015-08-07 10:16:58 -03:00