summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDonald Sharp <sharpd@nvidia.com>2023-12-11 15:22:07 -0500
committerDonald Sharp <sharpd@nvidia.com>2023-12-11 15:22:07 -0500
commit7cabd9361ca981c9f1becae2505d6fc35e32bd5f (patch)
treeae935d984e58a2717b7bb3d85c770dde675f002b
parentc783d5b698b77dfac44ffbd69ae9160a1723da6a (diff)
zebra: Properly unregister hook on shutdown
the zebra pseudo wire code was registering a callback per vrf. These callbacks are not per vrf based. They are vrf agnostic so this was a mistake. Modify the code to on startup register once and on shutdown unregister once. Finally rename the zebra_pw_init and zebra_pw_exit functions to more properly reflect when they are called. Signed-off-by: Donald Sharp <sharpd@nvidia.com>
-rw-r--r--zebra/main.c2
-rw-r--r--zebra/zebra_pw.c18
-rw-r--r--zebra/zebra_pw.h5
-rw-r--r--zebra/zebra_vrf.c4
4 files changed, 21 insertions, 8 deletions
diff --git a/zebra/main.c b/zebra/main.c
index 1efb27db06..2e5f8c48f4 100644
--- a/zebra/main.c
+++ b/zebra/main.c
@@ -234,6 +234,8 @@ void zebra_finalize(struct event *dummy)
zebra_mpls_terminate();
+ zebra_pw_terminate();
+
ns_terminate();
frr_fini();
exit(0);
diff --git a/zebra/zebra_pw.c b/zebra/zebra_pw.c
index f76bf747d6..deed3b6ad3 100644
--- a/zebra/zebra_pw.c
+++ b/zebra/zebra_pw.c
@@ -377,15 +377,18 @@ static int zebra_pw_client_close(struct zserv *client)
return 0;
}
-void zebra_pw_init(struct zebra_vrf *zvrf)
+static void zebra_pw_init(void)
+{
+ hook_register(zserv_client_close, zebra_pw_client_close);
+}
+
+void zebra_pw_init_vrf(struct zebra_vrf *zvrf)
{
RB_INIT(zebra_pw_head, &zvrf->pseudowires);
RB_INIT(zebra_static_pw_head, &zvrf->static_pseudowires);
-
- hook_register(zserv_client_close, zebra_pw_client_close);
}
-void zebra_pw_exit(struct zebra_vrf *zvrf)
+void zebra_pw_exit_vrf(struct zebra_vrf *zvrf)
{
struct zebra_pw *pw;
@@ -396,6 +399,11 @@ void zebra_pw_exit(struct zebra_vrf *zvrf)
}
}
+void zebra_pw_terminate(void)
+{
+ hook_unregister(zserv_client_close, zebra_pw_client_close);
+}
+
DEFUN_NOSH (pseudowire_if,
pseudowire_if_cmd,
"pseudowire IFNAME",
@@ -837,4 +845,6 @@ void zebra_pw_vty_init(void)
install_element(VIEW_NODE, &show_pseudowires_cmd);
install_element(VIEW_NODE, &show_pseudowires_detail_cmd);
+
+ zebra_pw_init();
}
diff --git a/zebra/zebra_pw.h b/zebra/zebra_pw.h
index a41afc920b..431d663f7c 100644
--- a/zebra/zebra_pw.h
+++ b/zebra/zebra_pw.h
@@ -60,8 +60,9 @@ void zebra_pw_change(struct zebra_pw *, ifindex_t, int, int, union g_addr *,
struct zebra_pw *zebra_pw_find(struct zebra_vrf *, const char *);
void zebra_pw_update(struct zebra_pw *);
void zebra_pw_install_failure(struct zebra_pw *pw, int pwstatus);
-void zebra_pw_init(struct zebra_vrf *);
-void zebra_pw_exit(struct zebra_vrf *);
+void zebra_pw_init_vrf(struct zebra_vrf *);
+void zebra_pw_exit_vrf(struct zebra_vrf *);
+void zebra_pw_terminate(void);
void zebra_pw_vty_init(void);
#ifdef __cplusplus
diff --git a/zebra/zebra_vrf.c b/zebra/zebra_vrf.c
index 2adae61f54..92982f25c8 100644
--- a/zebra/zebra_vrf.c
+++ b/zebra/zebra_vrf.c
@@ -195,7 +195,7 @@ static int zebra_vrf_disable(struct vrf *vrf)
/* Cleanup Vxlan, MPLS and PW tables. */
zebra_vxlan_cleanup_tables(zvrf);
zebra_mpls_cleanup_tables(zvrf);
- zebra_pw_exit(zvrf);
+ zebra_pw_exit_vrf(zvrf);
/* Remove link-local IPv4 addresses created for BGP unnumbered peering.
*/
@@ -376,7 +376,7 @@ struct zebra_vrf *zebra_vrf_alloc(struct vrf *vrf)
zebra_vxlan_init_tables(zvrf);
zebra_mpls_init_tables(zvrf);
- zebra_pw_init(zvrf);
+ zebra_pw_init_vrf(zvrf);
zvrf->table_id = rt_table_main_id;
/* by default table ID is default one */