summaryrefslogtreecommitdiff
path: root/src/udev
diff options
context:
space:
mode:
authorTom Gundersen <teg@jklm.no>2014-12-05 15:56:10 +0100
committerTom Gundersen <teg@jklm.no>2014-12-05 16:01:18 +0100
commit32bc8adcd836baff68e4d0f53b9a382f358cccf8 (patch)
treeb5db45cc55b761fbfa7921b8b97f21495703633b /src/udev
parent2a441c8afe7c81f74cc2ceccdf9a71301cd39d4d (diff)
net_setup/networkd: warn if matching is done on possibly unstable ifname
Diffstat (limited to 'src/udev')
-rw-r--r--src/udev/net/link-config.c45
1 files changed, 33 insertions, 12 deletions
diff --git a/src/udev/net/link-config.c b/src/udev/net/link-config.c
index dc218eb79c..812325000d 100644
--- a/src/udev/net/link-config.c
+++ b/src/udev/net/link-config.c
@@ -226,11 +226,6 @@ int link_config_get(link_config_ctx *ctx, struct udev_device *device,
LIST_FOREACH(links, link, ctx->links) {
const char* attr_value;
- unsigned char name_assign_type = NET_NAME_UNKNOWN;
-
- attr_value = udev_device_get_sysattr_value(device, "name_assign_type");
- if (attr_value)
- (void)safe_atou8(attr_value, &name_assign_type);
attr_value = udev_device_get_sysattr_value(device, "address");
@@ -242,13 +237,39 @@ int link_config_get(link_config_ctx *ctx, struct udev_device *device,
udev_device_get_driver(udev_device_get_parent(device)),
udev_device_get_property_value(device, "ID_NET_DRIVER"),
udev_device_get_devtype(device),
- udev_device_get_sysname(device),
- name_assign_type == NET_NAME_RENAMED)) {
- log_debug("Config file %s applies to device %s",
- link->filename,
- udev_device_get_sysname(device));
- *ret = link;
- return 0;
+ udev_device_get_sysname(device))) {
+ if (link->match_name) {
+ unsigned char name_assign_type = NET_NAME_UNKNOWN;
+
+ attr_value = udev_device_get_sysattr_value(device, "name_assign_type");
+ if (attr_value)
+ (void)safe_atou8(attr_value, &name_assign_type);
+
+ if (name_assign_type == NET_NAME_ENUM) {
+ log_warning("Config file %s applies to device based on potentially unstable interface name '%s'",
+ link->filename, udev_device_get_sysname(device));
+ *ret = link;
+
+ return 0;
+ } else if (name_assign_type == NET_NAME_RENAMED) {
+ log_warning("Config file %s matches device based on renamed interface name '%s', ignoring",
+ link->filename, udev_device_get_sysname(device));
+ } else {
+ log_debug("Config file %s applies to device %s",
+ link->filename, udev_device_get_sysname(device));
+
+ *ret = link;
+
+ return 0;
+ }
+ } else {
+ log_debug("Config file %s applies to device %s",
+ link->filename, udev_device_get_sysname(device));
+
+ *ret = link;
+
+ return 0;
+ }
}
}