summaryrefslogtreecommitdiffstats
path: root/src/shared/bpf-link.c
diff options
context:
space:
mode:
authorLuca Boccassi <bluca@debian.org>2024-05-28 19:59:24 +0200
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>2024-05-29 08:29:47 +0200
commit8e495bf0b7c2c6a86ce2af9f49f888c281203eb6 (patch)
tree0f139c6bf14e88e23b385e479bd7fc2897afad19 /src/shared/bpf-link.c
parenttest-network: update comment about status of kernel regression (diff)
downloadsystemd-8e495bf0b7c2c6a86ce2af9f49f888c281203eb6.tar.xz
systemd-8e495bf0b7c2c6a86ce2af9f49f888c281203eb6.zip
bpf: add helper to translate kernel error codes from libbpf
libbpf returns error codes from the kernel unmodified, and we don't understand them so non-fatal ones are handled as hard errors. Add a translation helper, and start by translating 524 to EOPNOTSUPP, which is returned when nsresourced tries to use LSM BPF hooks that are not implemented on a given arch (in this case, arm64 is misssing trampolines). Fixes https://github.com/systemd/systemd/issues/32170
Diffstat (limited to '')
-rw-r--r--src/shared/bpf-link.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/src/shared/bpf-link.c b/src/shared/bpf-link.c
index fea49b2ecb..77f6a4ee9a 100644
--- a/src/shared/bpf-link.c
+++ b/src/shared/bpf-link.c
@@ -16,7 +16,7 @@ bool bpf_can_link_program(struct bpf_program *prog) {
link = sym_bpf_program__attach_cgroup(prog, /*cgroup_fd=*/-1);
/* EBADF indicates that bpf_link is supported by kernel. */
- return sym_libbpf_get_error(link) == -EBADF;
+ return bpf_get_error_translated(link) == -EBADF;
}
int bpf_serialize_link(FILE *f, FDSet *fds, const char *key, struct bpf_link *link) {
@@ -25,7 +25,7 @@ int bpf_serialize_link(FILE *f, FDSet *fds, const char *key, struct bpf_link *li
if (!link)
return -ENOENT;
- if (sym_libbpf_get_error(link) != 0)
+ if (bpf_get_error_translated(link) != 0)
return -EINVAL;
return serialize_fd(f, fds, key, sym_bpf_link__fd(link));