diff options
author | Stephen Hemminger <stephen.hemminger@vyatta.com> | 2008-12-19 08:47:33 -0800 |
---|---|---|
committer | Stephen Hemminger <stephen.hemminger@vyatta.com> | 2008-12-19 08:47:33 -0800 |
commit | 744ffdc3b679b43bb39b10519e9ca76c08fc85f1 (patch) | |
tree | 0c2ce155f187bd79f13a7dc2d2f7f5d2446faf84 /zebra/interface.c | |
parent | 3111ae93268b1af36e469b1f7744e821f27f0a30 (diff) | |
download | quagga-744ffdc3b679b43bb39b10519e9ca76c08fc85f1.tar.bz2 quagga-744ffdc3b679b43bb39b10519e9ca76c08fc85f1.tar.xz |
Interface rename changes
When interface is created, associate it with any pre-existing
configuration. When interface is renamed, notify protocols that
is deleted/added but keep existing address information.
Diffstat (limited to 'zebra/interface.c')
-rw-r--r-- | zebra/interface.c | 28 |
1 files changed, 22 insertions, 6 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. */ |