]> git.puffer.fish Git - matthieu/frr.git/commitdiff
ripngd: move "Vripng_passive_interface" to the ripng structure
authorRenato Westphal <renato@opensourcerouting.org>
Fri, 4 Jan 2019 21:08:10 +0000 (19:08 -0200)
committerRenato Westphal <renato@opensourcerouting.org>
Fri, 18 Jan 2019 18:15:41 +0000 (16:15 -0200)
Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
ripngd/ripng_interface.c
ripngd/ripngd.c
ripngd/ripngd.h

index dbf9a2c3331f846bdad67d027c72560265660326..b0a07ab462f973eb4f7c85613a24eec19d976e29 100644 (file)
@@ -762,17 +762,17 @@ void ripng_clean_network()
                }
 }
 
-/* Vector to store passive-interface name. */
-vector Vripng_passive_interface;
-
 /* Utility function for looking up passive interface settings. */
 static int ripng_passive_interface_lookup(const char *ifname)
 {
        unsigned int i;
        char *str;
 
-       for (i = 0; i < vector_active(Vripng_passive_interface); i++)
-               if ((str = vector_slot(Vripng_passive_interface, i)) != NULL)
+       if (!ripng)
+               return -1;
+
+       for (i = 0; i < vector_active(ripng->passive_interface); i++)
+               if ((str = vector_slot(ripng->passive_interface, i)) != NULL)
                        if (strcmp(str, ifname) == 0)
                                return i;
        return -1;
@@ -807,7 +807,7 @@ int ripng_passive_interface_set(const char *ifname)
        if (ripng_passive_interface_lookup(ifname) >= 0)
                return NB_ERR_INCONSISTENCY;
 
-       vector_set(Vripng_passive_interface, strdup(ifname));
+       vector_set(ripng->passive_interface, strdup(ifname));
 
        ripng_passive_interface_apply_all();
 
@@ -823,9 +823,9 @@ int ripng_passive_interface_unset(const char *ifname)
        if (i < 0)
                return NB_ERR_INCONSISTENCY;
 
-       str = vector_slot(Vripng_passive_interface, i);
+       str = vector_slot(ripng->passive_interface, i);
        free(str);
-       vector_unset(Vripng_passive_interface, i);
+       vector_unset(ripng->passive_interface, i);
 
        ripng_passive_interface_apply_all();
 
@@ -838,10 +838,10 @@ void ripng_passive_interface_clean(void)
        unsigned int i;
        char *str;
 
-       for (i = 0; i < vector_active(Vripng_passive_interface); i++)
-               if ((str = vector_slot(Vripng_passive_interface, i)) != NULL) {
+       for (i = 0; i < vector_active(ripng->passive_interface); i++)
+               if ((str = vector_slot(ripng->passive_interface, i)) != NULL) {
                        free(str);
-                       vector_slot(Vripng_passive_interface, i) = NULL;
+                       vector_slot(ripng->passive_interface, i) = NULL;
                }
        ripng_passive_interface_apply_all();
 }
@@ -937,9 +937,6 @@ void ripng_if_init()
        hook_register_prio(if_add, 0, ripng_if_new_hook);
        hook_register_prio(if_del, 0, ripng_if_delete_hook);
 
-       /* RIPng passive interface. */
-       Vripng_passive_interface = vector_init(1);
-
        /* Install interface node. */
        install_node(&interface_node, interface_config_write);
        if_cmd_init();
index 9158cdcd3f527ef36c397f8a649d4e41370462d5..7db8bafd38d1fff3427344859de165c06b55d5cf 100644 (file)
@@ -1807,6 +1807,7 @@ int ripng_create(int socket)
        ripng->table = agg_table_init();
        ripng->enable_if = vector_init(1);
        ripng->enable_network = agg_table_init();
+       ripng->passive_interface = vector_init(1);
 
        /* Distribute list install. */
        ripng->distribute_ctx = distribute_list_ctx_create(
@@ -2465,6 +2466,7 @@ void ripng_clean()
        ripng_passive_interface_clean();
        vector_free(ripng->enable_if);
        agg_table_finish(ripng->enable_network);
+       vector_free(ripng->passive_interface);
        ripng_offset_clean();
        ripng_interface_clean();
        ripng_redistribute_clean();
index 935a9e8591a2786a771e289b7789564a3e31d655..95b128f4d90bbc00c54881b8cfbb838c4dacd8ae 100644 (file)
@@ -114,6 +114,9 @@ struct ripng {
        /* RIPng enabled networks. */
        struct agg_table *enable_network;
 
+       /* Vector to store passive-interface name. */
+       vector passive_interface;
+
        /* RIPng threads. */
        struct thread *t_read;
        struct thread *t_write;