network: fix build with libbpf < 0.7

bpf_loop() and bpf_strncmp(), used by sysctl-monitor, were introduced
in libbpf 0.7, so skip the module if using an older version

Follow-up for 6d9ef22acd
This commit is contained in:
Luca Boccassi
2025-08-06 12:58:20 +01:00
parent 3ec74b96b7
commit 7108a882b3
7 changed files with 9 additions and 7 deletions

View File

@@ -1958,6 +1958,8 @@ endif
conf.set10('HAVE_VMLINUX_H', use_provided_vmlinux_h or use_generated_vmlinux_h)
conf.set10('ENABLE_SYSCTL_BPF', conf.get('HAVE_VMLINUX_H') == 1 and libbpf.version().version_compare('>= 0.7'))
#####################################################################
check_version_history_py = files('tools/check-version-history.py')

View File

@@ -1,6 +1,6 @@
# SPDX-License-Identifier: LGPL-2.1-or-later
if conf.get('HAVE_VMLINUX_H') != 1
if conf.get('ENABLE_SYSCTL_BPF') != 1
subdir_done()
endif

View File

@@ -140,7 +140,7 @@ networkctl_sources = files(
networkd_network_gperf_gperf = files('networkd-network-gperf.gperf')
networkd_netdev_gperf_gperf = files('netdev/netdev-gperf.gperf')
if conf.get('HAVE_VMLINUX_H') == 1
if conf.get('ENABLE_SYSCTL_BPF') == 1
systemd_networkd_extract_sources += sysctl_monitor_skel_h
endif

View File

@@ -646,7 +646,7 @@ int manager_new(Manager **ret, bool test_mode) {
.dhcp_server_persist_leases = DHCP_SERVER_PERSIST_LEASES_YES,
.serialization_fd = -EBADF,
.ip_forwarding = { -1, -1, },
#if HAVE_VMLINUX_H
#if ENABLE_SYSCTL_BPF
.cgroup_fd = -EBADF,
#endif
};

View File

@@ -117,7 +117,7 @@ typedef struct Manager {
/* sysctl */
int ip_forwarding[2];
#if HAVE_VMLINUX_H
#if ENABLE_SYSCTL_BPF
Hashmap *sysctl_shadow;
sd_event_source *sysctl_event_source;
struct ring_buffer *sysctl_buffer;
@@ -148,7 +148,7 @@ int manager_set_timezone(Manager *m, const char *timezone);
int manager_reload(Manager *m, sd_bus_message *message);
static inline Hashmap** manager_get_sysctl_shadow(Manager *manager) {
#if HAVE_VMLINUX_H
#if ENABLE_SYSCTL_BPF
return &ASSERT_PTR(manager)->sysctl_shadow;
#else
return NULL;

View File

@@ -26,7 +26,7 @@
#include "string-util.h"
#include "sysctl-util.h"
#if HAVE_VMLINUX_H
#if ENABLE_SYSCTL_BPF
#include "bpf-link.h"
#include "bpf/sysctl-monitor/sysctl-monitor-skel.h"

View File

@@ -22,7 +22,7 @@ typedef enum IPReversePathFilter {
_IP_REVERSE_PATH_FILTER_INVALID = -EINVAL,
} IPReversePathFilter;
#if HAVE_VMLINUX_H
#if ENABLE_SYSCTL_BPF
int manager_install_sysctl_monitor(Manager *manager);
void manager_remove_sysctl_monitor(Manager *manager);
int link_clear_sysctl_shadows(Link *link);