summaryrefslogtreecommitdiffstats
path: root/ospfd
diff options
context:
space:
mode:
authorRenato Westphal <renato@opensourcerouting.org>2021-05-31 15:27:51 +0200
committerRenato Westphal <renato@opensourcerouting.org>2021-06-08 16:41:33 +0200
commit51f8588eb999429eb2181f1897742fa503c17a51 (patch)
treefe9a63e81bc64dbac4cf9add48a11942076a538f /ospfd
parentMerge pull request #8727 from opensourcerouting/ospfv3-nssa (diff)
downloadfrr-51f8588eb999429eb2181f1897742fa503c17a51.tar.xz
frr-51f8588eb999429eb2181f1897742fa503c17a51.zip
ospfd: fix GR helper initialization and termination
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>
Diffstat (limited to 'ospfd')
-rw-r--r--ospfd/ospf_gr_helper.c42
-rw-r--r--ospfd/ospf_gr_helper.h6
-rw-r--r--ospfd/ospf_main.c1
-rw-r--r--ospfd/ospfd.c7
4 files changed, 43 insertions, 13 deletions
diff --git a/ospfd/ospf_gr_helper.c b/ospfd/ospf_gr_helper.c
index a25057a27..8ee4207b0 100644
--- a/ospfd/ospf_gr_helper.c
+++ b/ospfd/ospf_gr_helper.c
@@ -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);
}
diff --git a/ospfd/ospf_gr_helper.h b/ospfd/ospf_gr_helper.h
index c355bb4f3..bd6d1d746 100644
--- a/ospfd/ospf_gr_helper.h
+++ b/ospfd/ospf_gr_helper.h
@@ -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,
diff --git a/ospfd/ospf_main.c b/ospfd/ospf_main.c
index 91ba3044f..d94de1299 100644
--- a/ospfd/ospf_main.c
+++ b/ospfd/ospf_main.c
@@ -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();
diff --git a/ospfd/ospfd.c b/ospfd/ospfd.c
index 38c0ca2b6..106ce3bd7 100644
--- a/ospfd/ospfd.c
+++ b/ospfd/ospfd.c
@@ -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();
@@ -900,7 +903,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);