]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
core/bpf: drop unnecessary check for probing program type
authorYu Watanabe <watanabe.yu+github@gmail.com>
Tue, 29 Apr 2025 20:13:26 +0000 (05:13 +0900)
committerYu Watanabe <watanabe.yu+github@gmail.com>
Fri, 9 May 2025 15:17:52 +0000 (00:17 +0900)
BPF_PROG_TYPE_CGROUP_SKB is supported since kernel v4.10
(0e33661de493db325435d565a4a722120ae4cbf3) and
BPF_PROG_TYPE_CGROUP_SOCK_ADDR is supported since kernel v4.17
(4fbac77d2d092b475dda9eea66da674369665427).

Our baseline on the kernel is v5.4. The check is not necessary.

src/core/bpf-restrict-ifaces.c
src/core/bpf-socket-bind.c

index e5f9a3c53e44de1278174617e736de04b374e78c..e97682a19cd7b8e0c713210eb9f2d0e0047ef4a7 100644 (file)
@@ -83,11 +83,6 @@ int bpf_restrict_ifaces_supported(void) {
         if (dlopen_bpf_full(LOG_WARNING) < 0)
                 return (supported = false);
 
-        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);
-        }
-
         r = prepare_restrict_ifaces_bpf(NULL, true, NULL, &obj);
         if (r < 0) {
                 log_debug_errno(r, "restrict-interfaces: Failed to load BPF object: %m");
index 374e684f04c787f6868c314f65dfa9d779ddef10..ce5f5c2f10772b6bd18ccbc5f50a52d7178a432a 100644 (file)
@@ -129,11 +129,6 @@ int bpf_socket_bind_supported(void) {
         if (dlopen_bpf_full(LOG_WARNING) < 0)
                 return false;
 
-        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;
-        }
-
         r = prepare_socket_bind_bpf(/*unit=*/NULL, /*allow_rules=*/NULL, /*deny_rules=*/NULL, &obj);
         if (r < 0) {
                 log_debug_errno(r, "bpf-socket-bind: socket bind filtering is not supported: %m");