]> git.proxmox.com Git - mirror_frr.git/blobdiff - zebra/table_manager.c
isisd: implement the 'lsp-too-large' notification
[mirror_frr.git] / zebra / table_manager.c
index db07f402f304496f3453aea9beabf84449f931ea..7ed673a88f12ee73a5d64f798c2dd7c9518f0410 100644 (file)
  * 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"
 #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"
+#include "zebra/zebra_errors.h"
 
 /* routing table identifiers
  *
@@ -77,6 +79,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(zserv_client_close, release_daemon_table_chunks);
 }
 
 /**
@@ -144,8 +147,8 @@ struct table_manager_chunk *assign_table_chunk(uint8_t proto, uint16_t instance,
 #endif /* SUNOS_5 */
        tmc->start = start;
        if (RT_TABLE_ID_UNRESERVED_MAX - size  + 1 < start) {
-               zlog_err("Reached max table id. Start/Size %u/%u",
-                        start, size);
+               flog_err(EC_ZEBRA_TM_EXHAUSTED_IDS,
+                        "Reached max table id. Start/Size %u/%u", start, size);
                XFREE(MTYPE_TM_CHUNK, tmc);
                return NULL;
        }
@@ -182,7 +185,8 @@ int release_table_chunk(uint8_t proto, uint16_t instance, uint32_t start,
                if (tmc->end != end)
                        continue;
                if (tmc->proto != proto || tmc->instance != instance) {
-                       zlog_err("%s: Daemon mismatch!!", __func__);
+                       flog_err(EC_ZEBRA_TM_DAEMON_MISMATCH,
+                                "%s: Daemon mismatch!!", __func__);
                        continue;
                }
                tmc->proto = NO_PROTO;
@@ -191,7 +195,8 @@ int release_table_chunk(uint8_t proto, uint16_t instance, uint32_t start,
                break;
        }
        if (ret != 0)
-               zlog_err("%s: Table chunk not released!!", __func__);
+               flog_err(EC_ZEBRA_TM_UNRELEASED_CHUNK,
+                        "%s: Table chunk not released!!", __func__);
 
        return ret;
 }
@@ -202,12 +207,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;
@@ -231,5 +237,5 @@ void table_manager_disable(ns_id_t ns_id)
 {
        if (ns_id != NS_DEFAULT)
                return;
-       list_delete_and_null(&tbl_mgr.lc_list);
+       list_delete(&tbl_mgr.lc_list);
 }