core/bpf-firewall: make bpf_firewall_supported() always set unsupported reason when...
authorYu Watanabe <watanabe.yu+github@gmail.com>
Wed, 1 Dec 2021 12:07:22 +0000 (21:07 +0900)
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Thu, 13 Jan 2022 09:59:42 +0000 (10:59 +0100)
Otherwise, log_unit_full_errno() in emit_bpf_firewall_warning() will
trigger an assertion.

(cherry picked from commit 8751bb6f5e89562d438566c374b9c3a1059c9211)
(cherry picked from commit 27028ef0f0bc128d14f41e233ad256687fd7e379)

src/core/bpf-firewall.c

index 02e33399c3e36615f9b0932bfbdd0e7363608221..a87ca82424f871a6e9374db4bdfde6e4300d7ef6 100644 (file)
@@ -855,7 +855,10 @@ int bpf_firewall_supported(void) {
 
                 /* YAY! */
         } else {
-                log_debug("Wut? Kernel accepted our invalid BPF_PROG_DETACH call? Something is weird, assuming BPF firewalling is broken and hence not supported.");
+                bpf_firewall_unsupported_reason =
+                        log_debug_errno(SYNTHETIC_ERRNO(EBADE),
+                                        "Wut? Kernel accepted our invalid BPF_PROG_DETACH call? "
+                                        "Something is weird, assuming BPF firewalling is broken and hence not supported.");
                 return supported = BPF_FIREWALL_UNSUPPORTED;
         }
 
@@ -883,7 +886,10 @@ int bpf_firewall_supported(void) {
 
                 return supported = BPF_FIREWALL_SUPPORTED;
         } else {
-                log_debug("Wut? Kernel accepted our invalid BPF_PROG_ATTACH+BPF_F_ALLOW_MULTI call? Something is weird, assuming BPF firewalling is broken and hence not supported.");
+                bpf_firewall_unsupported_reason =
+                        log_debug_errno(SYNTHETIC_ERRNO(EBADE),
+                                        "Wut? Kernel accepted our invalid BPF_PROG_ATTACH+BPF_F_ALLOW_MULTI call? "
+                                        "Something is weird, assuming BPF firewalling is broken and hence not supported.");
                 return supported = BPF_FIREWALL_UNSUPPORTED;
         }
 }