Browse Source

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>
Vipin Kumar 4 years ago
parent
commit
a90dc87527
3 changed files with 47 additions and 0 deletions
  1. 1 0
      ospfd/ospf_main.c
  2. 45 0
      ospfd/ospf_vty.c
  3. 1 0
      ospfd/ospf_vty.h

+ 1 - 0
ospfd/ospf_main.c

@@ -303,6 +303,7 @@ main (int argc, char **argv)
   /* OSPF vty inits. */
   ospf_vty_init ();
   ospf_vty_show_init ();
+  ospf_vty_clear_init ();
 
   ospf_route_map_init ();
 #ifdef HAVE_SNMP

+ 45 - 0
ospfd/ospf_vty.c

@@ -7712,6 +7712,51 @@ static struct cmd_node ospf_node =
   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

+ 1 - 0
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 */