]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
bpf-devices: if a device node is referenced which doesn't exist, downgrade log message 31268/head
authorLennart Poettering <lennart@poettering.net>
Fri, 9 Feb 2024 11:28:10 +0000 (12:28 +0100)
committerLennart Poettering <lennart@poettering.net>
Fri, 9 Feb 2024 14:32:10 +0000 (15:32 +0100)
Currently in many of our test cases you'll see a warning about a tun
device not being around. Let's make that quiet, since if there's no such
device there's no point in adding it to a policy anyway, and it makes
useless noise go away.

We keep the warning as a warning if a device node is missing for other
errors than ENOENT.

src/core/bpf-devices.c

index abfe6a85a2de33c49e03eb2d7c6ab9ca709e70c3..8484dbc61909871e5db80943ff2eb015ab367f81 100644 (file)
@@ -372,8 +372,14 @@ int bpf_devices_allow_list_device(
                         return log_warning_errno(r, "Couldn't parse major/minor from device path '%s': %m", node);
 
                 struct stat st;
-                if (stat(node, &st) < 0)
+                if (stat(node, &st) < 0) {
+                        if (errno == ENOENT) {
+                                log_debug_errno(errno, "Device '%s' does not exist, skipping.", node);
+                                return 0; /* returning 0 means → skipped */
+                        }
+
                         return log_warning_errno(errno, "Couldn't stat device %s: %m", node);
+                }
 
                 if (!S_ISCHR(st.st_mode) && !S_ISBLK(st.st_mode))
                         return log_warning_errno(SYNTHETIC_ERRNO(ENODEV), "%s is not a device.", node);