diff options
| author | Daniel Borkmann <daniel@iogearbox.net> | 2019-06-18 00:11:14 +0200 |
|---|---|---|
| committer | Daniel Borkmann <daniel@iogearbox.net> | 2019-06-18 00:11:40 +0200 |
| commit | 32b88d3743573222c3ce0165727b6a4c4f7c245b (patch) | |
| tree | d04dba2d6c2e76d1987c71faf627403074c297c4 /tools/testing/selftests/bpf/progs/socket_cookie_prog.c | |
| parent | 7f94208c8f9a0a6d2ff0e0c0858c00ad8e5c8617 (diff) | |
| parent | df0b7792598291128fcca66b039fd027be25c10a (diff) | |
| download | talos-op-linux-32b88d3743573222c3ce0165727b6a4c4f7c245b.tar.gz talos-op-linux-32b88d3743573222c3ce0165727b6a4c4f7c245b.zip | |
Merge branch 'bpf-libbpf-btf-defined-maps'
Andrii Nakryiko says:
====================
This patch set implements initial version (as discussed at LSF/MM2019
conference) of a new way to specify BPF maps, relying on BTF type information,
which allows for easy extensibility, preserving forward and backward
compatibility. See details and examples in description for patch #6.
[0] contains an outline of follow up extensions to be added after this basic
set of features lands. They are useful by itself, but also allows to bring
libbpf to feature-parity with iproute2 BPF loader. That should open a path
forward for BPF loaders unification.
Patch #1 centralizes commonly used min/max macro in libbpf_internal.h.
Patch #2 extracts .BTF and .BTF.ext loading loging from elf_collect().
Patch #3 simplifies elf_collect() error-handling logic.
Patch #4 refactors map initialization logic into user-provided maps and global
data maps, in preparation to adding another way (BTF-defined maps).
Patch #5 adds support for map definitions in multiple ELF sections and
deprecates bpf_object__find_map_by_offset() API which doesn't appear to be
used anymore and makes assumption that all map definitions reside in single
ELF section.
Patch #6 splits BTF intialization from sanitization/loading into kernel to
preserve original BTF at the time of map initialization.
Patch #7 adds support for BTF-defined maps.
Patch #8 adds new test for BTF-defined map definition.
Patches #9-11 convert test BPF map definitions to use BTF way.
[0] https://lore.kernel.org/bpf/CAEf4BzbfdG2ub7gCi0OYqBrUoChVHWsmOntWAkJt47=FE+km+A@mail.gmail.com/
v1->v2:
- more BTF-sanity checks in parsing map definitions (Song);
- removed confusing usage of "attribute", switched to "field;
- split off elf_collect() refactor from btf loading refactor (Song);
- split selftests conversion into 3 patches (Stanislav):
1. test already relying on BTF;
2. tests w/ custom types as key/value (so benefiting from BTF);
3. all the rest tests (integers as key/value, special maps w/o BTF support).
- smaller code improvements (Song);
rfc->v1:
- error out on unknown field by default (Stanislav, Jakub, Lorenz);
====================
Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
Diffstat (limited to 'tools/testing/selftests/bpf/progs/socket_cookie_prog.c')
| -rw-r--r-- | tools/testing/selftests/bpf/progs/socket_cookie_prog.c | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/tools/testing/selftests/bpf/progs/socket_cookie_prog.c b/tools/testing/selftests/bpf/progs/socket_cookie_prog.c index 0db15c3210ad..6aabb681fb9a 100644 --- a/tools/testing/selftests/bpf/progs/socket_cookie_prog.c +++ b/tools/testing/selftests/bpf/progs/socket_cookie_prog.c @@ -12,15 +12,16 @@ struct socket_cookie { __u32 cookie_value; }; -struct bpf_map_def SEC("maps") socket_cookies = { +struct { + __u32 type; + __u32 map_flags; + int *key; + struct socket_cookie *value; +} socket_cookies SEC(".maps") = { .type = BPF_MAP_TYPE_SK_STORAGE, - .key_size = sizeof(int), - .value_size = sizeof(struct socket_cookie), .map_flags = BPF_F_NO_PREALLOC, }; -BPF_ANNOTATE_KV_PAIR(socket_cookies, int, struct socket_cookie); - SEC("cgroup/connect6") int set_cookie(struct bpf_sock_addr *ctx) { |

