From: Lennart Poettering Date: Fri, 9 Feb 2024 11:28:10 +0000 (+0100) Subject: bpf-devices: if a device node is referenced which doesn't exist, downgrade log message X-Git-Tag: v256-rc1~915^2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=3a51cf673fd40a06828fd50ada33614441fe639e;p=thirdparty%2Fsystemd.git bpf-devices: if a device node is referenced which doesn't exist, downgrade log message 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. --- diff --git a/src/core/bpf-devices.c b/src/core/bpf-devices.c index abfe6a85a2d..8484dbc6190 100644 --- a/src/core/bpf-devices.c +++ b/src/core/bpf-devices.c @@ -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);