diff options
author | Andrii Nakryiko <andriin@fb.com> | 2020-04-14 11:26:45 -0700 |
---|---|---|
committer | Daniel Borkmann <daniel@iogearbox.net> | 2020-04-15 13:22:43 +0200 |
commit | 25498a1969bf3687c29c29bbac92821d7a0f8b4a (patch) | |
tree | cc579427faea0bdaa8d7b4087eb048c863ac7906 /tools/lib/bpf/libbpf.h | |
parent | 99e3a236dd43d06c65af0a2ef9cb44306aef6e02 (diff) | |
download | linux-25498a1969bf3687c29c29bbac92821d7a0f8b4a.tar.bz2 |
libbpf: Always specify expected_attach_type on program load if supported
For some types of BPF programs that utilize expected_attach_type, libbpf won't
set load_attr.expected_attach_type, even if expected_attach_type is known from
section definition. This was done to preserve backwards compatibility with old
kernels that didn't recognize expected_attach_type attribute yet (which was
added in 5e43f899b03a ("bpf: Check attach type at prog load time"). But this
is problematic for some BPF programs that utilize newer features that require
kernel to know specific expected_attach_type (e.g., extended set of return
codes for cgroup_skb/egress programs).
This patch makes libbpf specify expected_attach_type by default, but also
detect support for this field in kernel and not set it during program load.
This allows to have a good metadata for bpf_program
(e.g., bpf_program__get_extected_attach_type()), but still work with old
kernels (for cases where it can work at all).
Additionally, due to expected_attach_type being always set for recognized
program types, bpf_program__attach_cgroup doesn't have to do extra checks to
determine correct attach type, so remove that additional logic.
Also adjust section_names selftest to account for this change.
More detailed discussion can be found in [0].
[0] https://lore.kernel.org/bpf/20200412003604.GA15986@rdna-mbp.dhcp.thefacebook.com/
Fixes: 5cf1e9145630 ("bpf: cgroup inet skb programs can return 0 to 3")
Fixes: 5e43f899b03a ("bpf: Check attach type at prog load time")
Reported-by: Andrey Ignatov <rdna@fb.com>
Signed-off-by: Andrii Nakryiko <andriin@fb.com>
Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
Acked-by: Song Liu <songliubraving@fb.com>
Acked-by: Andrey Ignatov <rdna@fb.com>
Link: https://lore.kernel.org/bpf/20200414182645.1368174-1-andriin@fb.com
Diffstat (limited to 'tools/lib/bpf/libbpf.h')
0 files changed, 0 insertions, 0 deletions