diff options
-rw-r--r-- | zebra/interface.c | 28 | ||||
-rw-r--r-- | zebra/rt_netlink.c | 15 |
2 files changed, 25 insertions, 18 deletions
diff --git a/zebra/interface.c b/zebra/interface.c index dec91297..12b2c500 100644 --- a/zebra/interface.c +++ b/zebra/interface.c @@ -483,20 +483,36 @@ if_delete_update (struct interface *ifp) ifp->ifindex = IFINDEX_INTERNAL; } -/* Quagga daemons don't handle rename, so delete then add */ +/* Interfaces can only be renamed when DOWN */ void if_rename (struct interface *ifp, const char *name) { - int ifindex = ifp->ifindex; + struct interface *oifp; - if_delete_update(ifp); + zebra_interface_delete_update (ifp); listnode_delete (iflist, ifp); - strncpy(ifp->name, name, INTERFACE_NAMSIZ); - ifp->ifindex = ifindex; + /* rename overlaps earlier interface */ + oifp = if_lookup_by_name(name); + if (oifp) + { + if (oifp->ifindex != IFINDEX_INTERNAL) + { + zlog_warn ("interface rname %s to %s overlaps earlier interface", + ifp->name, name); + if_delete_update (oifp); + } + if (IS_ZEBRA_DEBUG_KERNEL) + zlog_debug ("interface %s superseded by rename of %s", + oifp->name, ifp->name); + if_delete (oifp); + } + strncpy(ifp->name, name, INTERFACE_NAMSIZ); + ifp->name[INTERFACE_NAMSIZ] = 0; listnode_add_sort (iflist, ifp); - if_add_update (ifp); + + zebra_interface_add_update (ifp); } /* Interface is up. */ diff --git a/zebra/rt_netlink.c b/zebra/rt_netlink.c index e9ddd737..8b65845e 100644 --- a/zebra/rt_netlink.c +++ b/zebra/rt_netlink.c @@ -454,13 +454,8 @@ netlink_interface (struct sockaddr_nl *snl, struct nlmsghdr *h) } /* Add interface. */ - ifp = if_lookup_by_index(ifi->ifi_index); - if (!ifp) - { - ifp = if_create(name, strlen(name)); - ifp->ifindex = ifi->ifi_index; - } - strncpy(ifp->name, name, INTERFACE_NAMSIZ); + ifp = if_get_by_name (name); + ifp->ifindex = ifi->ifi_index; ifp->flags = ifi->ifi_flags & 0x0000fffff; ifp->mtu6 = ifp->mtu = *(uint32_t *) RTA_DATA (tb[IFLA_MTU]); ifp->metric = 1; @@ -968,14 +963,10 @@ netlink_link_change (struct sockaddr_nl *snl, struct nlmsghdr *h) { if (ifp == NULL) { - ifp = if_create(name, strlen(name)); + ifp = if_get_by_name (name); ifp->ifindex = ifi->ifi_index; ifp->metric = 1; } - else if (strcmp(ifp->name, name) != 0) - { - strncpy(ifp->name, name, INTERFACE_NAMSIZ); - } zlog_info ("interface %s index %d %s added.", name, ifi->ifi_index, if_flag_dump(new_flags)); |