[quagga-dev 8342] [PATCH 1/7] lib: Add a function to delete all interfaces

Tom Goff thomas.goff at boeing.com
Wed Nov 10 21:00:54 GMT 2010


if.c: (if_terminate) This adds a cleanup function that can be called
    when a daemon exits, similar to vty_terminate().

Signed-off-by: Tom Goff <thomas.goff at boeing.com>
---
 lib/if.c |   18 ++++++++++++++++++
 lib/if.h |    1 +
 2 files changed, 19 insertions(+), 0 deletions(-)

diff --git a/lib/if.c b/lib/if.c
index e310711..b61bdbf 100644
--- a/lib/if.c
+++ b/lib/if.c
@@ -878,3 +878,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;
+}
diff --git a/lib/if.h b/lib/if.h
index c99ab81..841ce51 100644
--- a/lib/if.h
+++ b/lib/if.h
@@ -266,6 +266,7 @@ extern int if_is_pointopoint (struct interface *);
 extern int if_is_multicast (struct interface *);
 extern void if_add_hook (int, int (*)(struct interface *));
 extern void if_init (void);
+extern void if_terminate (void);
 extern void if_dump_all (void);
 extern const char *if_flag_dump(unsigned long);
 
-- 
1.7.0.4




More information about the Quagga-dev mailing list