]> git.puffer.fish Git - mirror/frr.git/commitdiff
isisd: fix dangling instances
authorIgor Ryzhov <iryzhov@nfware.com>
Sun, 9 May 2021 13:43:29 +0000 (16:43 +0300)
committerIgor Ryzhov <iryzhov@nfware.com>
Thu, 27 May 2021 10:18:42 +0000 (13:18 +0300)
We only need an instance when we have at least one area configured in a
VRF. Currently we have the following issues:
- instance for the default VRF is always created
- instance is not removed after the last area config is removed

This commit fixes both issues.

Signed-off-by: Igor Ryzhov <iryzhov@nfware.com>
isisd/isis_main.c
isisd/isis_nb_config.c
isisd/isisd.c
tests/isisd/test_isis_spf.c

index c93bbb83af0c234687b752fa42081302adb304cc..acfa1a29d41ef02da2fbeb8b0eb3923c38a0c803 100644 (file)
@@ -265,9 +265,6 @@ int main(int argc, char **argv, char **envp)
        lsp_init();
        mt_init();
 
-       /* create the global 'isis' instance */
-       isis_global_instance_create(VRF_DEFAULT_NAME);
-
        isis_zebra_init(master, instance);
        isis_bfd_init(master);
        isis_ldp_sync_init();
index 68a4581a46520c3e574ec26a6ad8752c30fb66b2..a00c86eeaf1af5139a8dd4ef57616f4f9b2eff24 100644 (file)
@@ -68,7 +68,7 @@ int isis_instance_create(struct nb_cb_create_args *args)
                return NB_OK;
        vrf_name = yang_dnode_get_string(args->dnode, "./vrf");
        area_tag = yang_dnode_get_string(args->dnode, "./area-tag");
-       isis_global_instance_create(vrf_name);
+
        area = isis_area_lookup_by_vrf(area_tag, vrf_name);
        if (area)
                return NB_ERR_INCONSISTENCY;
index 172d20215031493b3a8fa2cdf771b695a031b101..bda2295ae1bb53d81dc8ffd86454f4abfcbb534a 100644 (file)
@@ -175,15 +175,6 @@ void isis_master_init(struct thread_master *master)
        im->master = master;
 }
 
-void isis_global_instance_create(const char *vrf_name)
-{
-       struct isis *isis;
-
-       isis = isis_lookup_by_vrfname(vrf_name);
-       if (isis == NULL)
-               isis_new(vrf_name);
-}
-
 struct isis *isis_new(const char *vrf_name)
 {
        struct vrf *vrf;
@@ -571,8 +562,7 @@ void isis_area_destroy(struct isis_area *area)
        area_mt_finish(area);
 
        if (listcount(area->isis->area_list) == 0) {
-               memset(area->isis->sysid, 0, ISIS_SYS_ID_LEN);
-               area->isis->sysid_set = 0;
+               isis_finish(area->isis);
        }
 
        XFREE(MTYPE_ISIS_AREA, area);
index 915f849aec51813fb179d3e1198c583eee89f836..b89a5a008ee7cbf1030d7fae3d0389c07bc47e44 100644 (file)
@@ -51,8 +51,6 @@ enum test_type {
 #define F_LEVEL1_ONLY 0x08
 #define F_LEVEL2_ONLY 0x10
 
-static struct isis *isis;
-
 static void test_run_spf(struct vty *vty, const struct isis_topology *topology,
                         const struct isis_test_node *root,
                         struct isis_area *area, struct lspdb_head *lspdb,
@@ -257,8 +255,8 @@ static int test_run(struct vty *vty, const struct isis_topology *topology,
        uint8_t fail_id[ISIS_SYS_ID_LEN] = {};
 
        /* Init topology. */
-       memcpy(isis->sysid, root->sysid, sizeof(isis->sysid));
        area = isis_area_create("1", NULL);
+       memcpy(area->isis->sysid, root->sysid, sizeof(area->isis->sysid));
        area->is_type = IS_LEVEL_1_AND_2;
        area->srdb.enabled = true;
        if (test_topology_load(topology, area, area->lspdb) != 0) {
@@ -470,7 +468,6 @@ static void vty_do_exit(int isexit)
 {
        printf("\nend.\n");
 
-       isis_finish(isis);
        cmd_terminate();
        vty_terminate();
        yang_terminate();
@@ -555,7 +552,6 @@ int main(int argc, char **argv)
 
        /* IS-IS inits. */
        yang_module_load("frr-isisd");
-       isis = isis_new(VRF_DEFAULT_NAME);
        SET_FLAG(im->options, F_ISIS_UNIT_TEST);
        debug_spf_events |= DEBUG_SPF_EVENTS;
        debug_lfa |= DEBUG_LFA;