summaryrefslogtreecommitdiff
path: root/zebra/zserv.c
diff options
context:
space:
mode:
authorKaren Schoener <karen@voltanet.io>2020-12-07 18:01:01 -0500
committerKaren Schoener <karen@volta.io>2020-12-07 18:22:36 -0500
commit581e797e02d91cb1c5a7acfd9b2f8c8feb1cde56 (patch)
treed1ec08584f36686aa19986093d1d06b91687f102 /zebra/zserv.c
parent6a684109aea0e8b314340a00d9c353df0b3daab4 (diff)
zebra: Adding zapi client close notification
When zebra detects a client close, send a zapi client close notification. Signed-off-by: Karen Schoener <karen@voltanet.io>
Diffstat (limited to 'zebra/zserv.c')
-rw-r--r--zebra/zserv.c17
1 files changed, 17 insertions, 0 deletions
diff --git a/zebra/zserv.c b/zebra/zserv.c
index 4b5791530d..c7b9433257 100644
--- a/zebra/zserv.c
+++ b/zebra/zserv.c
@@ -1300,6 +1300,21 @@ DEFUN (show_zebra_client_summary,
return CMD_SUCCESS;
}
+static int zserv_client_close_cb(struct zserv *closed_client)
+{
+ struct listnode *node, *nnode;
+ struct zserv *client = NULL;
+
+ for (ALL_LIST_ELEMENTS(zrouter.client_list, node, nnode, client)) {
+ if (client->proto == closed_client->proto)
+ continue;
+
+ zsend_client_close_notify(client, closed_client);
+ }
+
+ return 0;
+}
+
void zserv_init(void)
{
/* Client list init. */
@@ -1312,4 +1327,6 @@ void zserv_init(void)
install_element(ENABLE_NODE, &show_zebra_client_cmd);
install_element(ENABLE_NODE, &show_zebra_client_summary_cmd);
+
+ hook_register(zserv_client_close, zserv_client_close_cb);
}