summaryrefslogtreecommitdiff
path: root/src/core
diff options
context:
space:
mode:
authorDominique Martinet <asmadeus@codewreck.org>2022-09-30 19:25:18 +0900
committerDominique Martinet <asmadeus@codewreck.org>2022-10-06 21:33:55 +0900
commit87e462f71361a47b154865dc14032a27580dd4cb (patch)
tree760dcd2103f2216496d4d442e727306e8418337f /src/core
parent5a967e28873816806a8f1e7c6c7d1ac28369f8b9 (diff)
downloadsystemd-87e462f71361a47b154865dc14032a27580dd4cb.tar.gz
libbpf: add compat helpers for libbpf down to 0.1.0
- new symbols are available from libbpf 0.6.0 so could be used with libbpf.so.0, but we're sure the old symbols will be there and this simplifies code - detection at runtime should always work, regardless of whether systemd has been compiled with older or newer libbpf and runs with older or newer libbpf
Diffstat (limited to 'src/core')
-rw-r--r--src/core/bpf-lsm.c4
-rw-r--r--src/core/bpf-socket-bind.c2
-rw-r--r--src/core/restrict-ifaces.c2
3 files changed, 4 insertions, 4 deletions
diff --git a/src/core/bpf-lsm.c b/src/core/bpf-lsm.c
index 33c9322e7e..173221b9f1 100644
--- a/src/core/bpf-lsm.c
+++ b/src/core/bpf-lsm.c
@@ -72,7 +72,7 @@ static int prepare_restrict_fs_bpf(struct restrict_fs_bpf **ret_obj) {
sym_bpf_map__name(obj->maps.cgroup_hash));
/* Dummy map to satisfy the verifier */
- inner_map_fd = sym_bpf_map_create(BPF_MAP_TYPE_HASH, NULL, sizeof(uint32_t), sizeof(uint32_t), 128U, NULL);
+ inner_map_fd = compat_bpf_map_create(BPF_MAP_TYPE_HASH, NULL, sizeof(uint32_t), sizeof(uint32_t), 128U, NULL);
if (inner_map_fd < 0)
return log_error_errno(errno, "bpf-lsm: Failed to create BPF map: %m");
@@ -202,7 +202,7 @@ int lsm_bpf_unit_restrict_filesystems(Unit *u, const Set *filesystems, bool allo
return log_unit_error_errno(u, SYNTHETIC_ERRNO(EINVAL),
"bpf-lsm: BPF LSM object is not installed, has setup failed?");
- int inner_map_fd = sym_bpf_map_create(
+ int inner_map_fd = compat_bpf_map_create(
BPF_MAP_TYPE_HASH,
NULL,
sizeof(uint32_t),
diff --git a/src/core/bpf-socket-bind.c b/src/core/bpf-socket-bind.c
index 790813bdbe..660ffdb723 100644
--- a/src/core/bpf-socket-bind.c
+++ b/src/core/bpf-socket-bind.c
@@ -120,7 +120,7 @@ int bpf_socket_bind_supported(void) {
if (!cgroup_bpf_supported())
return false;
- if (!sym_libbpf_probe_bpf_prog_type(BPF_PROG_TYPE_CGROUP_SOCK_ADDR, /*opts=*/NULL)) {
+ if (!compat_libbpf_probe_bpf_prog_type(BPF_PROG_TYPE_CGROUP_SOCK_ADDR, /*opts=*/NULL)) {
log_debug("bpf-socket-bind: BPF program type cgroup_sock_addr is not supported");
return false;
}
diff --git a/src/core/restrict-ifaces.c b/src/core/restrict-ifaces.c
index c0daa38a03..134f70a07b 100644
--- a/src/core/restrict-ifaces.c
+++ b/src/core/restrict-ifaces.c
@@ -83,7 +83,7 @@ int restrict_network_interfaces_supported(void) {
if (!cgroup_bpf_supported())
return (supported = false);
- if (!sym_libbpf_probe_bpf_prog_type(BPF_PROG_TYPE_CGROUP_SKB, /*opts=*/NULL)) {
+ if (!compat_libbpf_probe_bpf_prog_type(BPF_PROG_TYPE_CGROUP_SKB, /*opts=*/NULL)) {
log_debug("restrict-interfaces: BPF program type cgroup_skb is not supported");
return (supported = false);
}