chiark / gitweb /
udev: link-config - less verbose logging
authorTom Gundersen <teg@jklm.no>
Wed, 30 Oct 2013 13:40:10 +0000 (14:40 +0100)
committerTom Gundersen <teg@jklm.no>
Wed, 30 Oct 2013 14:36:04 +0000 (15:36 +0100)
Also reinstate print to kmsg when renaming netif.

src/udev/net/link-config.c
src/udev/udev-event.c

index 80f8b16f54b6c99cb8ddf0ccf4bf12fb7bca6a31..b26825427625e46b9397c2e3e8896edf29fc2fb8 100644 (file)
@@ -44,6 +44,8 @@ struct link_config_ctx {
 
         int ethtool_fd;
 
+        bool enable_name_policy;
+
         sd_rtnl *rtnl;
 
         char **link_dirs;
@@ -67,6 +69,8 @@ int link_config_ctx_new(link_config_ctx **ret) {
 
         ctx->ethtool_fd = -1;
 
+        ctx->enable_name_policy = true;
+
         ctx->link_dirs = strv_new("/etc/systemd/network",
                                   "/run/systemd/network",
                                   "/usr/lib/systemd/network",
@@ -181,12 +185,37 @@ failure:
         return r;
 }
 
+static bool enable_name_policy(void) {
+        _cleanup_free_ char *line;
+        char *w, *state;
+        int r;
+        size_t l;
+
+        r = read_one_line_file("/proc/cmdline", &line);
+        if (r < 0) {
+                log_warning("Failed to read /proc/cmdline, ignoring: %s", strerror(-r));
+                return true; /* something is very wrong, let's not make it worse */
+        }
+
+        FOREACH_WORD_QUOTED(w, l, line, state)
+                if (strneq(w, "net.ifnames=0", l))
+                        return false;
+
+        return true;
+}
+
 int link_config_load(link_config_ctx *ctx) {
         int r;
         char **files, **f;
 
         link_configs_free(ctx);
 
+
+        if (!enable_name_policy()) {
+                ctx->enable_name_policy = false;
+                log_info("Network interface NamePolicy= disabled on kernel commandline, ignoring.");
+        }
+
         /* update timestamp */
         paths_check_timestamp(ctx->link_dirs, &ctx->link_dirs_ts_usec, true);
 
@@ -255,10 +284,8 @@ int link_config_get(link_config_ctx *ctx, struct udev_device *device, link_confi
         link_config *link;
 
         LIST_FOREACH(links, link, ctx->links) {
-                if (!match_config(link, device)) {
-                        log_info("Config file %s does not apply to device %s", link->filename, udev_device_get_sysname(device));
-                } else {
-                        log_info("Config file %s applies to device %s", link->filename, udev_device_get_sysname(device));
+                if (match_config(link, device)) {
+                        log_debug("Config file %s applies to device %s", link->filename, udev_device_get_sysname(device));
                         *ret = link;
                         return 0;
                 }
@@ -267,27 +294,6 @@ int link_config_get(link_config_ctx *ctx, struct udev_device *device, link_confi
         return -ENOENT;
 }
 
-static bool enable_name_policy(void) {
-        _cleanup_free_ char *line;
-        char *w, *state;
-        int r;
-        size_t l;
-
-        r = read_one_line_file("/proc/cmdline", &line);
-        if (r < 0) {
-                log_warning("Failed to read /proc/cmdline, ignoring: %s", strerror(-r));
-                return true; /* something is very wrong, let's not make it worse */
-        }
-
-        FOREACH_WORD_QUOTED(w, l, line, state)
-                if (strneq(w, "net.ifnames=0", l)) {
-                        log_info("Link name policy disabled on kernel commandline, ignoring.");
-                        return false;
-                }
-
-        return true;
-}
-
 static bool mac_is_random(struct udev_device *device) {
         const char *s;
         unsigned type;
@@ -387,8 +393,6 @@ int link_config_apply(link_config_ctx *ctx, link_config *config, struct udev_dev
         if (!old_name)
                 return -EINVAL;
 
-        log_info("Configuring %s", old_name);
-
         if (config->description) {
                 r = udev_device_set_sysattr_value(device, "ifalias",
                                                   config->description);
@@ -413,7 +417,7 @@ int link_config_apply(link_config_ctx *ctx, link_config *config, struct udev_dev
                 return -ENODEV;
         }
 
-        if (config->name_policy && enable_name_policy()) {
+        if (ctx->enable_name_policy && config->name_policy) {
                 NamePolicy *policy;
 
                 for (policy = config->name_policy; !new_name && *policy != _NAMEPOLICY_INVALID; policy++) {
index 1242db9ef3b9a3f39a615b1c2edd085c2ea78591..0d1049cf1cc13ceb725e072a277754bdc8abb88b 100644 (file)
@@ -769,7 +769,7 @@ static int rename_netif(struct udev_event *event)
                 log_error("error changing net interface name %s to %s: %s",
                           oldname, name, strerror(-r));
         else
-                log_info("renamed network interface %s to %s", oldname, name);
+                print_kmsg("renamed network interface %s to %s", oldname, name);
 
         return r;
 }