summaryrefslogtreecommitdiff
path: root/lib/if.c
diff options
context:
space:
mode:
authorTom Goff <thomas.goff@boeing.com>2010-11-10 13:00:54 -0800
committerDenis Ovsienko <infrastation@yandex.ru>2012-01-02 19:50:32 +0400
commita809d1cc54a621f4b31397ee5b8b79151baa4bf2 (patch)
tree2e8badac33516de66c4a0cdff9d3c7812ff65fa4 /lib/if.c
parent13351032d1d1632dbaf540cf33b7bebbc748c415 (diff)
lib: Add a function to delete all interfaces
if.c: (if_terminate) This adds a cleanup function that can be called when a daemon exits, similar to vty_terminate().
Diffstat (limited to 'lib/if.c')
-rw-r--r--lib/if.c18
1 files changed, 18 insertions, 0 deletions
diff --git a/lib/if.c b/lib/if.c
index 41115b0f..31c60e3f 100644
--- a/lib/if.c
+++ b/lib/if.c
@@ -872,3 +872,21 @@ if_init (void)
memset (&if_master, 0, sizeof if_master);
}
+
+void
+if_terminate (void)
+{
+ for (;;)
+ {
+ struct interface *ifp;
+
+ ifp = listnode_head (iflist);
+ if (ifp == NULL)
+ break;
+
+ if_delete (ifp);
+ }
+
+ list_delete (iflist);
+ iflist = NULL;
+}