]> git.puffer.fish Git - mirror/frr.git/commitdiff
ospf6d: Add config callbacks to suppress hellos during config load. Add bgpd/isisd... 13804/head
authorAcee <aceelindem@gmail.com>
Sun, 18 Jun 2023 11:22:45 +0000 (07:22 -0400)
committerAcee <aceelindem@gmail.com>
Fri, 23 Jun 2023 11:48:02 +0000 (07:48 -0400)
Signed-off-by: Acee <aceelindem@gmail.com>
ospf6d/ospf6_main.c
ospf6d/ospf6_message.c
ospf6d/ospf6d.c
ospf6d/ospf6d.h
ospf6d/subdir.am

index fdb93475d487bc727db206b42133607af88fd360..932304578af1c502a1c691360957e74c7543797f 100644 (file)
@@ -173,6 +173,32 @@ FRR_DAEMON_INFO(ospf6d, OSPF6, .vty_port = OSPF6_VTY_PORT,
                .n_yang_modules = array_size(ospf6d_yang_modules),
 );
 
+/* Max wait time for config to load before accepting hellos */
+#define OSPF6_PRE_CONFIG_MAX_WAIT_SECONDS 600
+
+static void ospf6_config_finish(struct event *t)
+{
+       zlog_err("OSPF6 configuration end timer expired after %d seconds.",
+                OSPF6_PRE_CONFIG_MAX_WAIT_SECONDS);
+}
+
+static void ospf6_config_start(void)
+{
+       if (IS_OSPF6_DEBUG_EVENT)
+               zlog_debug("ospf6d config start received");
+       EVENT_OFF(t_ospf6_cfg);
+       event_add_timer(master, ospf6_config_finish, NULL,
+                       OSPF6_PRE_CONFIG_MAX_WAIT_SECONDS, &t_ospf6_cfg);
+}
+
+static void ospf6_config_end(void)
+{
+       if (IS_OSPF6_DEBUG_EVENT)
+               zlog_debug("ospf6d config end received");
+
+       EVENT_OFF(t_ospf6_cfg);
+}
+
 /* Main routine of ospf6d. Treatment of argument and starting ospf finite
    state machine is handled here. */
 int main(int argc, char *argv[], char *envp[])
@@ -217,6 +243,9 @@ int main(int argc, char *argv[], char *envp[])
        /* initialize ospf6 */
        ospf6_init(master);
 
+       /* Configuration processing callback initialization. */
+       cmd_init_config_callbacks(ospf6_config_start, ospf6_config_end);
+
        frr_config_fork();
        frr_run(master);
 
index 032988a91f36c48c61db565686d58b1f57faeb58..29a68c5c3d9ea5a317facf09173fcea0652fa5c3 100644 (file)
@@ -2248,6 +2248,17 @@ void ospf6_hello_send(struct event *thread)
        if (oi->gr.hello_delay.t_grace_send)
                return;
 
+       /* Check if config is still being processed */
+       if (event_is_scheduled(t_ospf6_cfg)) {
+               if (IS_OSPF6_DEBUG_MESSAGE(OSPF6_MESSAGE_TYPE_HELLO, SEND))
+                       zlog_debug(
+                               "Suppressing Hello on interface %s during config load",
+                               oi->interface->name);
+               event_add_timer(master, ospf6_hello_send, oi,
+                               oi->hello_interval, &oi->thread_send_hello);
+               return;
+       }
+
        if (oi->state <= OSPF6_INTERFACE_DOWN) {
                if (IS_OSPF6_DEBUG_MESSAGE(OSPF6_MESSAGE_TYPE_HELLO, SEND_HDR))
                        zlog_debug("Unable to send Hello on down interface %s",
index 214007d041e788b051037f6828d8c784ef8b9e14..d90a950d79f558556fe1d27ad481f3e788a6fabd 100644 (file)
 #include "lib/json.h"
 #include "ospf6_nssa.h"
 #include "ospf6_auth_trailer.h"
+#include "ospf6d/ospf6d_clippy.c"
 
 DEFINE_MGROUP(OSPF6D, "ospf6d");
 
+/* OSPF6 config processing timer thread */
+struct event *t_ospf6_cfg;
+
+/* OSPF6 debug event state */
+unsigned char conf_debug_ospf6_event;
+
 struct route_node *route_prev(struct route_node *node)
 {
        struct route_node *end;
@@ -62,6 +69,7 @@ struct route_node *route_prev(struct route_node *node)
 }
 
 static int config_write_ospf6_debug(struct vty *vty);
+static int config_write_ospf6_debug_event(struct vty *vty);
 static struct cmd_node debug_node = {
        .name = "debug",
        .node = DEBUG_NODE,
@@ -85,6 +93,7 @@ static int config_write_ospf6_debug(struct vty *vty)
        config_write_ospf6_debug_nssa(vty);
        config_write_ospf6_debug_gr_helper(vty);
        config_write_ospf6_debug_auth(vty);
+       config_write_ospf6_debug_event(vty);
 
        return 0;
 }
@@ -1374,6 +1383,29 @@ DEFUN(show_ipv6_ospf6_linkstate_detail, show_ipv6_ospf6_linkstate_detail_cmd,
        return CMD_SUCCESS;
 }
 
+DEFPY(debug_ospf6_event, debug_ospf6_event_cmd, "[no] debug ospf6 event",
+      NO_STR DEBUG_STR OSPF6_STR "Debug OSPFv3 event function\n")
+{
+       if (!no)
+               OSPF6_DEBUG_EVENT_ON();
+       else
+               OSPF6_DEBUG_EVENT_OFF();
+       return CMD_SUCCESS;
+}
+
+static int config_write_ospf6_debug_event(struct vty *vty)
+{
+       if (IS_OSPF6_DEBUG_EVENT)
+               vty_out(vty, "debug ospf6 event\n");
+       return 0;
+}
+
+static void install_element_ospf6_debug_event(void)
+{
+       install_element(ENABLE_NODE, &debug_ospf6_event_cmd);
+       install_element(CONFIG_NODE, &debug_ospf6_event_cmd);
+}
+
 /* Install ospf related commands. */
 void ospf6_init(struct event_loop *master)
 {
@@ -1447,6 +1479,7 @@ void ospf6_init(struct event_loop *master)
                VIEW_NODE,
                &show_ipv6_ospf6_database_type_self_originated_linkstate_id_cmd);
        install_element(VIEW_NODE, &show_ipv6_ospf6_database_aggr_router_cmd);
+       install_element_ospf6_debug_event();
        install_element_ospf6_debug_auth();
        ospf6_interface_auth_trailer_cmd_init();
        install_element_ospf6_clear_intf_auth();
index 980a365265a05a2b3bce1f38df5791185043a6d3..c927ee7566f1d9b688c4d00f67d96d3872f284a7 100644 (file)
@@ -15,6 +15,9 @@ DECLARE_MGROUP(OSPF6D);
 /* global variables */
 extern struct event_loop *master;
 
+/* OSPF config processing timer thread */
+extern struct event *t_ospf6_cfg;
+
 /* Historical for KAME.  */
 #ifndef IPV6_JOIN_GROUP
 #ifdef IPV6_ADD_MEMBERSHIP
@@ -105,6 +108,12 @@ extern struct event_loop *master;
 
 extern struct zebra_privs_t ospf6d_privs;
 
+/* Event Debug option */
+extern unsigned char conf_debug_ospf6_event;
+#define OSPF6_DEBUG_EVENT_ON() (conf_debug_ospf6_event = 1)
+#define OSPF6_DEBUG_EVENT_OFF() (conf_debug_ospf6_event = 0)
+#define IS_OSPF6_DEBUG_EVENT (conf_debug_ospf6_event)
+
 /* Function Prototypes */
 extern struct route_node *route_prev(struct route_node *node);
 
index c34db3012da5d9bfec2fb1d98955979f0976c1fe..f6d27c84cd5f306f7e53920aca9fce7d0f267201 100644 (file)
@@ -75,6 +75,7 @@ ospf6d_ospf6d_snmp_la_LDFLAGS = $(MODULE_LDFLAGS)
 ospf6d_ospf6d_snmp_la_LIBADD = lib/libfrrsnmp.la
 
 clippy_scan += \
+       ospf6d/ospf6d.c \
        ospf6d/ospf6_top.c \
        ospf6d/ospf6_area.c \
        ospf6d/ospf6_asbr.c \