From: Tom Gundersen Date: Sat, 19 Apr 2014 18:39:17 +0000 (+0200) Subject: networkd: link - track interface renames X-Git-Tag: v213~370 X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?a=commitdiff_plain;h=b8941f74c87b56c341d0f4f14aae8aab268eadc0;p=elogind.git networkd: link - track interface renames --- diff --git a/src/network/networkd-link.c b/src/network/networkd-link.c index 319f2904c..aad72debe 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)