diff options
Diffstat (limited to 'zebra/label_manager.c')
| -rw-r--r-- | zebra/label_manager.c | 33 |
1 files changed, 27 insertions, 6 deletions
diff --git a/zebra/label_manager.c b/zebra/label_manager.c index c77470a701..0be0b4e732 100644 --- a/zebra/label_manager.c +++ b/zebra/label_manager.c @@ -28,6 +28,8 @@ #include "zebra/zapi_msg.h" #include "zebra/debug.h" +#include "zebra/label_manager_clippy.c" + #define CONNECTION_DELAY 5 struct label_manager lbl_mgr; @@ -96,7 +98,7 @@ void delete_label_chunk(void *val) */ int release_daemon_label_chunks(struct zserv *client) { - struct listnode *node; + struct listnode *node, *nnode; struct label_manager_chunk *lmc; int count = 0; int ret; @@ -106,7 +108,7 @@ int release_daemon_label_chunks(struct zserv *client) __func__, zebra_route_string(client->proto), client->instance, client->session_id); - for (ALL_LIST_ELEMENTS_RO(lbl_mgr.lc_list, node, lmc)) { + for (ALL_LIST_ELEMENTS(lbl_mgr.lc_list, node, nnode, lmc)) { if (lmc->proto == client->proto && lmc->instance == client->instance && lmc->session_id == client->session_id && lmc->keep == 0) { @@ -145,6 +147,22 @@ void lm_hooks_unregister(void) hook_unregister(lm_release_chunk, label_manager_release_label_chunk); } +DEFPY(show_label_table, show_label_table_cmd, "show debugging label-table", + SHOW_STR + DEBUG_STR + "Display allocated label chunks\n") +{ + struct label_manager_chunk *lmc; + struct listnode *node; + + for (ALL_LIST_ELEMENTS_RO(lbl_mgr.lc_list, node, lmc)) { + vty_out(vty, "Proto %s: [%u/%u]\n", + zebra_route_string(lmc->proto), lmc->start, lmc->end); + } + + return CMD_SUCCESS; +} + /** * Init label manager (or proxy to an external one) */ @@ -159,6 +177,8 @@ void label_manager_init(void) /* notify any external module that we are done */ hook_call(lm_cbs_inited); + + install_element(VIEW_NODE, &show_label_table_cmd); } /* alloc and fill a label chunk */ @@ -399,13 +419,14 @@ int release_label_chunk(uint8_t proto, unsigned short instance, "%s: Daemon mismatch!!", __func__); continue; } - lmc->proto = NO_PROTO; - lmc->instance = 0; - lmc->session_id = 0; - lmc->keep = 0; ret = 0; break; } + if (lmc) { + list_delete_node(lbl_mgr.lc_list, node); + delete_label_chunk(lmc); + } + if (ret != 0) flog_err(EC_ZEBRA_LM_UNRELEASED_CHUNK, "%s: Label chunk not released!!", __func__); |
