summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorTom Gundersen <teg@jklm.no>2013-10-30 14:40:10 +0100
committerTom Gundersen <teg@jklm.no>2013-10-30 15:36:04 +0100
commitf61942250a43a123580d7bbe5d7873dc5118ed97 (patch)
treedf32b398902f245f8f23ca4fd69de61c714a52e3 /src
parent3e137a1b9a0eac2bf43d493d3302c3c959b6ccdb (diff)
udev: link-config - less verbose logging
Also reinstate print to kmsg when renaming netif.
Diffstat (limited to 'src')
-rw-r--r--src/udev/net/link-config.c60
-rw-r--r--src/udev/udev-event.c2
2 files changed, 33 insertions, 29 deletions
diff --git a/src/udev/net/link-config.c b/src/udev/net/link-config.c
index 80f8b16f54..b268254276 100644
--- a/src/udev/net/link-config.c
+++ b/src/udev/net/link-config.c
@@ -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++) {
diff --git a/src/udev/udev-event.c b/src/udev/udev-event.c
index 1242db9ef3..0d1049cf1c 100644
--- a/src/udev/udev-event.c
+++ b/src/udev/udev-event.c
@@ -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;
}