]> git.puffer.fish Git - mirror/frr.git/commitdiff
ospfd: fix GR helper initialization and termination
authorRenato Westphal <renato@opensourcerouting.org>
Mon, 31 May 2021 13:27:51 +0000 (10:27 -0300)
committerIgor Ryzhov <iryzhov@nfware.com>
Wed, 9 Jun 2021 16:26:36 +0000 (19:26 +0300)
Since a single ospfd process can have multiple OSPF interfaces
configured, we need to separate the global GR initialization and
termination from per-instance initialization and termination.

Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
ospfd/ospf_gr_helper.c
ospfd/ospf_gr_helper.h
ospfd/ospf_main.c
ospfd/ospfd.c

index a25057a27f54514ea2a9fc0595d33e045a68bb3e..8ee4207b048b84ed3a7639ed84015bd212afb1d2 100644 (file)
@@ -159,10 +159,8 @@ const char *ospf_rejected_reason2str(unsigned int reason)
  * Returns:
  *    Nothing
  */
-void ospf_gr_helper_init(struct ospf *ospf)
+void ospf_gr_helper_instance_init(struct ospf *ospf)
 {
-       int rc;
-
        if (IS_DEBUG_OSPF_GR_HELPER)
                zlog_debug("%s, GR Helper init.", __func__);
 
@@ -176,6 +174,37 @@ void ospf_gr_helper_init(struct ospf *ospf)
        ospf->enable_rtr_list =
                hash_create(ospf_enable_rtr_hash_key, ospf_enable_rtr_hash_cmp,
                            "OSPF enable router hash");
+}
+
+/*
+ * De-Initialize GR helper config data structures.
+ *
+ * OSPF
+ *    OSPF pointer
+ *
+ * Returns:
+ *    Nothing
+ */
+void ospf_gr_helper_instance_stop(struct ospf *ospf)
+{
+       if (IS_DEBUG_OSPF_GR_HELPER)
+               zlog_debug("%s, GR helper deinit.", __func__);
+
+       ospf_enable_rtr_hash_destroy(ospf);
+}
+
+/*
+ * Initialize GR helper config data structures.
+ *
+ * Returns:
+ *    Nothing
+ */
+void ospf_gr_helper_init(void)
+{
+       int rc;
+
+       if (IS_DEBUG_OSPF_GR_HELPER)
+               zlog_debug("%s, GR Helper init.", __func__);
 
        rc = ospf_register_opaque_functab(
                OSPF_OPAQUE_LINK_LSA, OPAQUE_TYPE_GRACE_LSA, NULL, NULL, NULL,
@@ -191,20 +220,15 @@ void ospf_gr_helper_init(struct ospf *ospf)
 /*
  * De-Initialize GR helper config data structures.
  *
- * OSPF
- *    OSPF pointer
- *
  * Returns:
  *    Nothing
  */
-void ospf_gr_helper_stop(struct ospf *ospf)
+void ospf_gr_helper_stop(void)
 {
 
        if (IS_DEBUG_OSPF_GR_HELPER)
                zlog_debug("%s, GR helper deinit.", __func__);
 
-       ospf_enable_rtr_hash_destroy(ospf);
-
        ospf_delete_opaque_functab(OSPF_OPAQUE_LINK_LSA, OPAQUE_TYPE_GRACE_LSA);
 }
 
index c355bb4f3d65027c4552abc02d3b3359a20b108a..bd6d1d74622e41386ebd4d5ae319a51a24303adb 100644 (file)
@@ -156,8 +156,10 @@ const char *ospf_exit_reason2str(unsigned int reason);
 const char *ospf_restart_reason2str(unsigned int reason);
 const char *ospf_rejected_reason2str(unsigned int reason);
 
-extern void ospf_gr_helper_init(struct ospf *ospf);
-extern void ospf_gr_helper_stop(struct ospf *ospf);
+extern void ospf_gr_helper_instance_init(struct ospf *ospf);
+extern void ospf_gr_helper_instance_stop(struct ospf *ospf);
+extern void ospf_gr_helper_init(void);
+extern void ospf_gr_helper_stop(void);
 extern int ospf_process_grace_lsa(struct ospf *ospf, struct ospf_lsa *lsa,
                                  struct ospf_neighbor *nbr);
 extern void ospf_gr_helper_exit(struct ospf_neighbor *nbr,
index 91ba3044fe5fe018ed9bab7cc1586fbc942b4453..d94de129942f5c870dd9171b3a0fd3450a380fb6 100644 (file)
@@ -225,6 +225,7 @@ int main(int argc, char **argv)
 
        ospf_route_map_init();
        ospf_opaque_init();
+       ospf_gr_helper_init();
 
        /* OSPF errors init */
        ospf_error_init();
index 2f088aa81160c7f6f59888befa243efdac87d864..55beeec9de18954f134e1dbb2241e68d7e42575d 100644 (file)
@@ -386,7 +386,7 @@ struct ospf *ospf_new_alloc(unsigned short instance, const char *name)
 
        new->proactive_arp = OSPF_PROACTIVE_ARP_DEFAULT;
 
-       ospf_gr_helper_init(new);
+       ospf_gr_helper_instance_init(new);
 
        ospf_asbr_external_aggregator_init(new);
 
@@ -651,6 +651,9 @@ void ospf_terminate(void)
        for (ALL_LIST_ELEMENTS(om->ospf, node, nnode, ospf))
                ospf_finish(ospf);
 
+       /* Cleanup GR */
+       ospf_gr_helper_stop();
+
        /* Cleanup route maps */
        route_map_finish();
 
@@ -890,7 +893,7 @@ static void ospf_finish_final(struct ospf *ospf)
        list_delete(&ospf->oi_write_q);
 
        /* Reset GR helper data structers */
-       ospf_gr_helper_stop(ospf);
+       ospf_gr_helper_instance_stop(ospf);
 
        close(ospf->fd);
        stream_free(ospf->ibuf);