ospfd: Support for 'clear ip ospf interface [IFNAME]'
Allow the user to enter the 'clear ip ospf interface [IFNAME]' command
this resets the connection between ospf and any peers out the
specified interface.
Signed-off-by: Vipin Kumar <vipin@cumulusnetworks.com>
diff --git a/ospfd/ospf_main.c b/ospfd/ospf_main.c
index f373650..32b64e2 100644
--- a/ospfd/ospf_main.c
+++ b/ospfd/ospf_main.c
@@ -303,6 +303,7 @@
/* OSPF vty inits. */
ospf_vty_init ();
ospf_vty_show_init ();
+ ospf_vty_clear_init ();
ospf_route_map_init ();
#ifdef HAVE_SNMP
diff --git a/ospfd/ospf_vty.c b/ospfd/ospf_vty.c
index f0b8505..bcc4008 100644
--- a/ospfd/ospf_vty.c
+++ b/ospfd/ospf_vty.c
@@ -7712,6 +7712,51 @@
1
};
+static void
+ospf_interface_clear (struct interface *ifp)
+{
+ if (!if_is_operative (ifp)) return;
+
+ if (IS_DEBUG_OSPF (ism, ISM_EVENTS))
+ zlog (NULL, LOG_DEBUG, "ISM[%s]: clear by reset", ifp->name);
+
+ ospf_if_reset(ifp);
+}
+
+DEFUN (clear_ip_ospf_interface,
+ clear_ip_ospf_interface_cmd,
+ "clear ip ospf interface [IFNAME]",
+ CLEAR_STR
+ IP_STR
+ "OSPF information\n"
+ "Interface information\n"
+ "Interface name\n")
+{
+ struct interface *ifp;
+ struct listnode *node;
+
+ if (argc == 0) /* Clear all the ospfv2 interfaces. */
+ {
+ for (ALL_LIST_ELEMENTS_RO (iflist, node, ifp))
+ ospf_interface_clear(ifp);
+ }
+ else /* Interface name is specified. */
+ {
+ if ((ifp = if_lookup_by_name (argv[0])) == NULL)
+ vty_out (vty, "No such interface name%s", VTY_NEWLINE);
+ else
+ ospf_interface_clear(ifp);
+ }
+
+ return CMD_SUCCESS;
+}
+
+void
+ospf_vty_clear_init (void)
+{
+ install_element (ENABLE_NODE, &clear_ip_ospf_interface_cmd);
+}
+
/* Install OSPF related vty commands. */
void
diff --git a/ospfd/ospf_vty.h b/ospfd/ospf_vty.h
index 0602fec..4610638 100644
--- a/ospfd/ospf_vty.h
+++ b/ospfd/ospf_vty.h
@@ -54,5 +54,6 @@
extern void ospf_vty_init (void);
extern void ospf_vty_show_init (void);
extern int ospf_str2area_id (const char *, struct in_addr *, int *);
+extern void ospf_vty_clear_init (void);
#endif /* _QUAGGA_OSPF_VTY_H */