From 85c675538fd18eefe0bbfd6fc87d9e0f38f3207a Mon Sep 17 00:00:00 2001 From: Daniel Mack Date: Mon, 8 Jun 2015 18:52:25 +0200 Subject: kmod-setup: split warn flags Traditionally, we used to warn about ipv6 being a module or being unavailable. This was changed in b4aa82f16 ("kmod-setup: don't warn when ipv6 can't be loaded") in a way that neither of the two conditions will cause a log message. Now, while running a setup without any IPv6 is completely fine and shouldn't cause any warning, we should still warn about ipv6 being a module instead of built-in. To achieve this, split the boolean warn flag into two: one for a feature not being built-in but shipped as a module, and one to print an error when a module is entirely unavailable. We will, however, still warn if kmod returns anything else than -ENOENT in the attempt of loading the module, and at the very least, turn the message into a debug log. --- src/core/kmod-setup.c | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) (limited to 'src/core/kmod-setup.c') diff --git a/src/core/kmod-setup.c b/src/core/kmod-setup.c index 96379058a1..cf543c81a3 100644 --- a/src/core/kmod-setup.c +++ b/src/core/kmod-setup.c @@ -53,26 +53,27 @@ int kmod_setup(void) { static const struct { const char *module; const char *path; - bool warn; + bool warn_if_unavailable:1; + bool warn_if_module:1; bool (*condition_fn)(void); } kmod_table[] = { /* auto-loading on use doesn't work before udev is up */ - { "autofs4", "/sys/class/misc/autofs", true, NULL }, + { "autofs4", "/sys/class/misc/autofs", true, false, NULL }, /* early configure of ::1 on the loopback device */ - { "ipv6", "/sys/module/ipv6", false, NULL }, + { "ipv6", "/sys/module/ipv6", false, true, NULL }, /* this should never be a module */ - { "unix", "/proc/net/unix", true, NULL }, + { "unix", "/proc/net/unix", true, true, NULL }, #ifdef ENABLE_KDBUS /* IPC is needed before we bring up any other services */ - { "kdbus", "/sys/fs/kdbus", false, is_kdbus_wanted }, + { "kdbus", "/sys/fs/kdbus", false, false, is_kdbus_wanted }, #endif #ifdef HAVE_LIBIPTC /* netfilter is needed by networkd, nspawn among others, and cannot be autoloaded */ - { "ip_tables", "/proc/net/ip_tables_names", false, NULL }, + { "ip_tables", "/proc/net/ip_tables_names", false, false, NULL }, #endif }; struct kmod_ctx *ctx = NULL; @@ -91,7 +92,7 @@ int kmod_setup(void) { if (kmod_table[i].condition_fn && !kmod_table[i].condition_fn()) continue; - if (kmod_table[i].warn) + if (kmod_table[i].warn_if_module) log_debug("Your kernel apparently lacks built-in %s support. Might be " "a good idea to compile it in. We'll now try to work around " "this by loading the module...", kmod_table[i].module); @@ -116,8 +117,9 @@ int kmod_setup(void) { log_info("Inserted module '%s'", kmod_module_get_name(mod)); else if (r == KMOD_PROBE_APPLY_BLACKLIST) log_info("Module '%s' is blacklisted", kmod_module_get_name(mod)); - else if (kmod_table[i].warn) - log_error("Failed to insert module '%s'", kmod_module_get_name(mod)); + else + log_full((kmod_table[i].warn_if_unavailable || (r < 0 && r != -ENOENT)) ? LOG_ERR : LOG_DEBUG, + "Failed to insert module '%s'", kmod_module_get_name(mod)); kmod_module_unref(mod); } -- cgit v1.2.3-54-g00ecf