summaryrefslogtreecommitdiffstats
path: root/lib/if.c
diff options
context:
space:
mode:
authorStephen Hemminger <stephen.hemminger@vyatta.com>2008-12-12 06:45:00 -0800
committerStephen Hemminger <stephen.hemminger@vyatta.com>2008-12-12 06:47:48 -0800
commit219940a5f510270113c7eca0c7b25f6938b7565a (patch)
tree26a944084d06719765dfcdf80b45ed23aaba00dd /lib/if.c
parent29d708b0556e8cb01441dab463204280e28d6aa1 (diff)
downloadquagga-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.c33
1 files changed, 18 insertions, 15 deletions
diff --git a/lib/if.c b/lib/if.c
index d270c21f..7c4fb1a4 100644
--- a/lib/if.c
+++ b/lib/if.c
@@ -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;
}