Skip to content

Commit

Permalink
Always rename an interface to its name specified in config if no Name…
Browse files Browse the repository at this point in the history
…Policy= is specified

This is for issue systemd#9006
  • Loading branch information
Mathieu Trudel-Lapierre committed May 30, 2018
1 parent 49805b3 commit 8709eb4
Showing 1 changed file with 2 additions and 37 deletions.
39 changes: 2 additions & 37 deletions src/udev/net/link-config.c
Original file line number Diff line number Diff line change
Expand Up @@ -295,37 +295,6 @@ static bool mac_is_random(struct udev_device *device) {
return type == NET_ADDR_RANDOM;
}

static bool should_rename(struct udev_device *device, bool respect_predictable) {
const char *s;
unsigned type;
int r;

/* if we can't get the assgin type, assume we should rename */
s = udev_device_get_sysattr_value(device, "name_assign_type");
if (!s)
return true;

r = safe_atou(s, &type);
if (r < 0)
return true;

switch (type) {
case NET_NAME_USER:
case NET_NAME_RENAMED:
/* these were already named by userspace, do not touch again */
return false;
case NET_NAME_PREDICTABLE:
/* the kernel claims to have given a predictable name */
if (respect_predictable)
return false;
_fallthrough_;
case NET_NAME_ENUM:
default:
/* the name is known to be bad, or of an unknown type */
return true;
}
}

static int get_mac(struct udev_device *device, bool want_random,
struct ether_addr *mac) {
int r;
Expand Down Expand Up @@ -435,12 +404,8 @@ int link_config_apply(link_config_ctx *ctx, link_config *config,
}
}

if (should_rename(device, respect_predictable)) {
/* if not set by policy, fall back manually set name */
if (!new_name)
new_name = config->name;
} else
new_name = NULL;
if (!new_name)
new_name = config->name;

switch (config->mac_policy) {
case MACPOLICY_PERSISTENT:
Expand Down

0 comments on commit 8709eb4

Please sign in to comment.