summaryrefslogtreecommitdiff
path: root/src/network
diff options
context:
space:
mode:
authorTom Gundersen <teg@jklm.no>2014-04-19 20:39:17 +0200
committerTom Gundersen <teg@jklm.no>2014-04-19 20:39:29 +0200
commitb8941f74c87b56c341d0f4f14aae8aab268eadc0 (patch)
treecf08f795d7c817ce6a30ff009eedfb73d490de1f /src/network
parentd4ef4f46cfa393f65c7312a18bc798db43018cd0 (diff)
networkd: link - track interface renames
Diffstat (limited to 'src/network')
-rw-r--r--src/network/networkd-link.c12
1 files changed, 12 insertions, 0 deletions
diff --git a/src/network/networkd-link.c b/src/network/networkd-link.c
index 319f2904c0..aad72debeb 100644
--- a/src/network/networkd-link.c
+++ b/src/network/networkd-link.c
@@ -1487,14 +1487,26 @@ int link_add(Manager *m, sd_rtnl_message *message, Link **ret) {
int link_update(Link *link, sd_rtnl_message *m) {
unsigned flags;
struct ether_addr mac;
+ char *ifname;
int r;
assert(link);
+ assert(link->ifname);
assert(m);
if (link->state == LINK_STATE_FAILED)
return 0;
+ r = sd_rtnl_message_read_string(m, IFLA_IFNAME, &ifname);
+ if (r >= 0 && !streq(ifname, link->ifname)) {
+ log_info_link(link, "renamed to %s", ifname);
+
+ free(link->ifname);
+ link->ifname = strdup(ifname);
+ if (!link->ifname)
+ return -ENOMEM;
+ }
+
if (!link->original_mtu) {
r = sd_rtnl_message_read_u16(m, IFLA_MTU, &link->original_mtu);
if (r >= 0)