diff options
author | Stephen Hemminger <stephen.hemminger@vyatta.com> | 2008-12-12 06:45:00 -0800 |
---|---|---|
committer | Stephen Hemminger <stephen.hemminger@vyatta.com> | 2008-12-12 06:47:48 -0800 |
commit | 219940a5f510270113c7eca0c7b25f6938b7565a (patch) | |
tree | 26a944084d06719765dfcdf80b45ed23aaba00dd /lib/if.c | |
parent | 29d708b0556e8cb01441dab463204280e28d6aa1 (diff) | |
download | quagga-219940a5f510270113c7eca0c7b25f6938b7565a.tar.bz2 quagga-219940a5f510270113c7eca0c7b25f6938b7565a.tar.xz |
Handle interfaces coming back from dead
Need to handle the case where interface comes back after being
deleted. After deletion state is retained but ifindex is set to
IFINDEX_INTERNAL. When new interface arrives with same name, then
update index
Diffstat (limited to 'lib/if.c')
-rw-r--r-- | lib/if.c | 33 |
1 files changed, 18 insertions, 15 deletions
@@ -117,23 +117,26 @@ if_create (const char *name, int namelen) { struct interface *ifp; - ifp = XCALLOC (MTYPE_IF, sizeof (struct interface)); - ifp->ifindex = IFINDEX_INTERNAL; + ifp = if_lookup_by_name(name); + if (ifp) { + if (ifp->ifindex != IFINDEX_INTERNAL) + zlog_err("if_create(%s): corruption detected -- interface with this " + "name exists already!", ifp->name); + } else { + ifp = XCALLOC (MTYPE_IF, sizeof (struct interface)); + ifp->ifindex = IFINDEX_INTERNAL; - assert (name); - assert (namelen <= INTERFACE_NAMSIZ); /* Need space for '\0' at end. */ - strncpy (ifp->name, name, namelen); - ifp->name[namelen] = '\0'; - if (if_lookup_by_name(ifp->name) == NULL) - listnode_add_sort (iflist, ifp); - else - zlog_err("if_create(%s): corruption detected -- interface with this " - "name exists already!", ifp->name); - ifp->connected = list_new (); - ifp->connected->del = (void (*) (void *)) connected_free; + assert (namelen <= INTERFACE_NAMSIZ); /* Need space for '\0' at end. */ + strncpy (ifp->name, name, namelen); + ifp->name[namelen] = '\0'; - if (if_master.if_new_hook) - (*if_master.if_new_hook) (ifp); + listnode_add_sort (iflist, ifp); + ifp->connected = list_new (); + ifp->connected->del = (void (*) (void *)) connected_free; + + if (if_master.if_new_hook) + (*if_master.if_new_hook) (ifp); + } return ifp; } |