diff options
author | Stephen Hemminger <stephen.hemminger@vyatta.com> | 2008-12-12 16:39:23 -0800 |
---|---|---|
committer | Stephen Hemminger <stephen.hemminger@vyatta.com> | 2008-12-12 18:31:53 -0800 |
commit | a4657249446a96933f0c2928f8a1f87b1929c245 (patch) | |
tree | 1afef1cbf73d7a7bc3816416ea50f9cd893508a6 | |
parent | 219940a5f510270113c7eca0c7b25f6938b7565a (diff) | |
download | quagga-a4657249446a96933f0c2928f8a1f87b1929c245.tar.bz2 quagga-a4657249446a96933f0c2928f8a1f87b1929c245.tar.xz |
Fix management of interface renames
Need to delete then add since zebra has no clean way to pass around
rename, and the configuration is based on name not ifindex.
-rw-r--r-- | zebra/interface.c | 16 | ||||
-rw-r--r-- | zebra/interface.h | 1 | ||||
-rw-r--r-- | zebra/rt_netlink.c | 5 |
3 files changed, 19 insertions, 3 deletions
diff --git a/zebra/interface.c b/zebra/interface.c index 74c977a9..dec91297 100644 --- a/zebra/interface.c +++ b/zebra/interface.c @@ -483,6 +483,22 @@ if_delete_update (struct interface *ifp) ifp->ifindex = IFINDEX_INTERNAL; } +/* Quagga daemons don't handle rename, so delete then add */ +void +if_rename (struct interface *ifp, const char *name) +{ + int ifindex = ifp->ifindex; + + if_delete_update(ifp); + listnode_delete (iflist, ifp); + + strncpy(ifp->name, name, INTERFACE_NAMSIZ); + ifp->ifindex = ifindex; + + listnode_add_sort (iflist, ifp); + if_add_update (ifp); +} + /* Interface is up. */ void if_up (struct interface *ifp) diff --git a/zebra/interface.h b/zebra/interface.h index 0a6b0365..fe44c501 100644 --- a/zebra/interface.h +++ b/zebra/interface.h @@ -215,6 +215,7 @@ extern void if_delete_update (struct interface *ifp); extern void if_add_update (struct interface *ifp); extern void if_up (struct interface *); extern void if_down (struct interface *); +extern void if_rename (struct interface *, const char *); extern void if_refresh (struct interface *); extern void if_flags_update (struct interface *, uint64_t); extern int if_subnet_add (struct interface *, struct connected *); diff --git a/zebra/rt_netlink.c b/zebra/rt_netlink.c index 49101714..17b14fb4 100644 --- a/zebra/rt_netlink.c +++ b/zebra/rt_netlink.c @@ -1014,9 +1014,8 @@ netlink_link_change (struct sockaddr_nl *snl, struct nlmsghdr *h) ifp->mtu = ifp->mtu6 = mtu; zlog_info("interface index %d was renamed from %s to %s", ifi->ifi_index, ifp->name, name); - - strncpy(ifp->name, name, INTERFACE_NAMSIZ); - rib_update(); + + if_rename (ifp, name); } /* Interface mtu change */ else if (mtu != ifp->mtu) |