summaryrefslogtreecommitdiff
path: root/zebra/table_manager.c
diff options
context:
space:
mode:
authorQuentin Young <qlyoung@cumulusnetworks.com>2018-04-22 17:03:52 -0400
committerQuentin Young <qlyoung@cumulusnetworks.com>2018-04-22 22:50:24 -0400
commit453844abd7bce28479d10490de513ca59cd0d490 (patch)
tree7396f2ff275f5e8186975d819b3cc75a4b3b34bc /zebra/table_manager.c
parentbf094f69758888e3bd555a24e91f3768bffbf31a (diff)
zebra: use hooks for client lifecycle callbacks
zserv.c was using hardcoded callbacks to clean up various components when a client disconnected. Ergo zserv.c had to know about all these unrelated components that it should not care about. We have hooks now, let's use the proper thing instead. Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
Diffstat (limited to 'zebra/table_manager.c')
-rw-r--r--zebra/table_manager.c19
1 files changed, 11 insertions, 8 deletions
diff --git a/zebra/table_manager.c b/zebra/table_manager.c
index db07f402f3..4c5c16c88a 100644
--- a/zebra/table_manager.c
+++ b/zebra/table_manager.c
@@ -16,12 +16,12 @@
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
+#include "zebra.h"
+
#include <stdio.h>
#include <string.h>
#include <sys/types.h>
-#include "zebra.h"
-#include "zserv.h"
#include "lib/log.h"
#include "lib/memory.h"
#include "lib/table.h"
@@ -31,9 +31,10 @@
#include "lib/libfrr.h"
#include "lib/vrf.h"
-#include "zebra_vrf.h"
-#include "label_manager.h" /* for NO_PROTO */
-#include "table_manager.h"
+#include "zebra/zserv.h"
+#include "zebra/zebra_vrf.h"
+#include "zebra/label_manager.h" /* for NO_PROTO */
+#include "zebra/table_manager.h"
/* routing table identifiers
*
@@ -77,6 +78,7 @@ void table_manager_enable(ns_id_t ns_id)
return;
tbl_mgr.lc_list = list_new();
tbl_mgr.lc_list->del = delete_table_chunk;
+ hook_register(client_close, release_daemon_table_chunks);
}
/**
@@ -202,12 +204,13 @@ int release_table_chunk(uint8_t proto, uint16_t instance, uint32_t start,
* Called on client disconnection or reconnection. It only releases chunks
* with empty keep value.
*
- * @param proto Daemon protocol of client, to identify the owner
- * @param instance Instance, to identify the owner
+ * @param client the client to release chunks from
* @return Number of chunks released
*/
-int release_daemon_table_chunks(uint8_t proto, uint16_t instance)
+int release_daemon_table_chunks(struct zserv *client)
{
+ uint8_t proto = client->proto;
+ uint16_t instance = client->instance;
struct listnode *node;
struct table_manager_chunk *tmc;
int count = 0;