From a1b11f9bfaa857c0b5d5b69e6db765b2c9c68305 Mon Sep 17 00:00:00 2001 From: Donald Sharp Date: Tue, 19 May 2015 18:03:40 -0700 Subject: [PATCH] Support for 'clear ipv6 ospf6 interface [ifname] --- ospf6d/ospf6_interface.c | 60 ++++++++++++++++++++++++++++++++++++++++ ospf6d/ospf6_interface.h | 2 ++ ospf6d/ospf6d.c | 2 ++ 3 files changed, 64 insertions(+) diff --git a/ospf6d/ospf6_interface.c b/ospf6d/ospf6_interface.c index 59e53aa3d..3d06ce390 100644 --- a/ospf6d/ospf6_interface.c +++ b/ospf6d/ospf6_interface.c @@ -1927,6 +1927,66 @@ ospf6_interface_init (void) install_element (OSPF6_NODE, &no_auto_cost_reference_bandwidth_cmd); } +/* Clear the specified interface structure */ +static void +ospf6_interface_clear (struct vty *vty, struct interface *ifp) +{ + struct ospf6_interface *oi; + + if (!if_is_operative (ifp)) + return; + + if (ifp->info == NULL) + return; + + oi = (struct ospf6_interface *) ifp->info; + + if (IS_OSPF6_DEBUG_INTERFACE) + zlog_debug ("Interface %s: clear by reset", ifp->name); + + /* Reset the interface */ + thread_add_event (master, interface_down, oi, 0); + thread_add_event (master, interface_up, oi, 0); +} + +/* Clear interface */ +DEFUN (clear_ipv6_ospf6_interface, + clear_ipv6_ospf6_interface_cmd, + "clear ipv6 ospf6 interface [IFNAME]", + CLEAR_STR + IP6_STR + OSPF6_STR + INTERFACE_STR + IFNAME_STR + ) +{ + struct interface *ifp; + struct listnode *node; + + if (argc == 0) /* Clear all the ospfv3 interfaces. */ + { + for (ALL_LIST_ELEMENTS_RO (iflist, node, ifp)) + ospf6_interface_clear (vty, ifp); + } + else /* Interface name is specified. */ + { + if ((ifp = if_lookup_by_name (argv[0])) == NULL) + { + vty_out (vty, "No such Interface: %s%s", argv[0], VNL); + return CMD_WARNING; + } + ospf6_interface_clear (vty, ifp); + } + + return CMD_SUCCESS; +} + +void +install_element_ospf6_clear_interface (void) +{ + install_element (ENABLE_NODE, &clear_ipv6_ospf6_interface_cmd); +} + DEFUN (debug_ospf6_interface, debug_ospf6_interface_cmd, "debug ospf6 interface", diff --git a/ospf6d/ospf6_interface.h b/ospf6d/ospf6_interface.h index df892cf16..dde589b8f 100644 --- a/ospf6d/ospf6_interface.h +++ b/ospf6d/ospf6_interface.h @@ -170,6 +170,8 @@ extern int neighbor_change (struct thread *); extern void ospf6_interface_init (void); +extern void install_element_ospf6_clear_interface (void); + extern int config_write_ospf6_debug_interface (struct vty *vty); extern void install_element_ospf6_debug_interface (void); diff --git a/ospf6d/ospf6d.c b/ospf6d/ospf6d.c index 3cdd5c116..f5760b089 100644 --- a/ospf6d/ospf6d.c +++ b/ospf6d/ospf6d.c @@ -1790,6 +1790,8 @@ ospf6_init (void) install_element_ospf6_debug_abr (); install_element_ospf6_debug_flood (); + install_element_ospf6_clear_interface (); + install_element (VIEW_NODE, &show_version_ospf6_cmd); install_element (ENABLE_NODE, &show_version_ospf6_cmd); -- 2.39.2