summaryrefslogtreecommitdiffstats
path: root/ripd
diff options
context:
space:
mode:
authorRenato Westphal <renato@opensourcerouting.org>2019-01-04 22:08:10 +0100
committerRenato Westphal <renato@opensourcerouting.org>2019-01-18 19:15:41 +0100
commitca04690261bda71898ce34ee719df4f5161ea145 (patch)
tree22fa58e582a091d470446533ac228d653145ea65 /ripd
parentripd: simplify cleaning up of routing instance (diff)
downloadfrr-ca04690261bda71898ce34ee719df4f5161ea145.tar.xz
frr-ca04690261bda71898ce34ee719df4f5161ea145.zip
ripd: move "rip_enable_interface" to the rip structure
Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
Diffstat (limited to 'ripd')
-rw-r--r--ripd/rip_interface.c29
-rw-r--r--ripd/ripd.c4
-rw-r--r--ripd/ripd.h3
3 files changed, 20 insertions, 16 deletions
diff --git a/ripd/rip_interface.c b/ripd/rip_interface.c
index 96b1cd893..7b7faacc2 100644
--- a/ripd/rip_interface.c
+++ b/ripd/rip_interface.c
@@ -60,9 +60,6 @@ const struct message ri_version_msg[] = {{RI_RIP_VERSION_1, "1"},
{RI_RIP_VERSION_NONE, "none"},
{0}};
-/* RIP enabled network vector. */
-vector rip_enable_interface;
-
/* RIP enabled interface table. */
struct route_table *rip_enable_network;
@@ -794,8 +791,11 @@ static int rip_enable_if_lookup(const char *ifname)
unsigned int i;
char *str;
- for (i = 0; i < vector_active(rip_enable_interface); i++)
- if ((str = vector_slot(rip_enable_interface, i)) != NULL)
+ if (!rip)
+ return -1;
+
+ for (i = 0; i < vector_active(rip->enable_interface); i++)
+ if ((str = vector_slot(rip->enable_interface, i)) != NULL)
if (strcmp(str, ifname) == 0)
return i;
return -1;
@@ -810,7 +810,7 @@ int rip_enable_if_add(const char *ifname)
if (ret >= 0)
return NB_ERR_INCONSISTENCY;
- vector_set(rip_enable_interface,
+ vector_set(rip->enable_interface,
XSTRDUP(MTYPE_RIP_INTERFACE_STRING, ifname));
rip_enable_apply_all(); /* TODOVJ */
@@ -828,9 +828,9 @@ int rip_enable_if_delete(const char *ifname)
if (index < 0)
return NB_ERR_INCONSISTENCY;
- str = vector_slot(rip_enable_interface, index);
+ str = vector_slot(rip->enable_interface, index);
XFREE(MTYPE_RIP_INTERFACE_STRING, str);
- vector_unset(rip_enable_interface, index);
+ vector_unset(rip->enable_interface, index);
rip_enable_apply_all(); /* TODOVJ */
@@ -1042,11 +1042,11 @@ void rip_clean_network()
route_unlock_node(rn);
}
- /* rip_enable_interface. */
- for (i = 0; i < vector_active(rip_enable_interface); i++)
- if ((str = vector_slot(rip_enable_interface, i)) != NULL) {
+ /* rip->enable_interface. */
+ for (i = 0; i < vector_active(rip->enable_interface); i++)
+ if ((str = vector_slot(rip->enable_interface, i)) != NULL) {
XFREE(MTYPE_RIP_INTERFACE_STRING, str);
- vector_slot(rip_enable_interface, i) = NULL;
+ vector_slot(rip->enable_interface, i) = NULL;
}
}
@@ -1183,8 +1183,8 @@ int rip_show_network_config(struct vty *vty)
node->p.prefixlen);
/* Interface name RIP enable statement. */
- for (i = 0; i < vector_active(rip_enable_interface); i++)
- if ((ifname = vector_slot(rip_enable_interface, i)) != NULL)
+ for (i = 0; i < vector_active(rip->enable_interface); i++)
+ if ((ifname = vector_slot(rip->enable_interface, i)) != NULL)
vty_out(vty, " %s\n", ifname);
/* RIP neighbors listing. */
@@ -1223,7 +1223,6 @@ void rip_if_init(void)
hook_register_prio(if_del, 0, rip_interface_delete_hook);
/* RIP network init. */
- rip_enable_interface = vector_init(1);
rip_enable_network = route_table_init();
/* RIP passive interface. */
diff --git a/ripd/ripd.c b/ripd/ripd.c
index f1c92ac7b..752328888 100644
--- a/ripd/ripd.c
+++ b/ripd/ripd.c
@@ -2689,9 +2689,10 @@ int rip_create(int socket)
rip->version_recv =
yang_get_default_enum("%s/version/receive", RIP_INSTANCE);
- /* Initialize RIP routig table. */
+ /* Initialize RIP data structures. */
rip->table = route_table_init();
rip->neighbor = route_table_init();
+ rip->enable_interface = vector_init(1);
/* Distribute list install. */
rip->distribute_ctx =
@@ -3373,6 +3374,7 @@ void rip_clean(void)
rip_clean_network();
rip_passive_nondefault_clean();
+ vector_free(rip->enable_interface);
rip_offset_clean();
rip_interfaces_clean();
rip_distance_reset();
diff --git a/ripd/ripd.h b/ripd/ripd.h
index 7b8fe3a90..a1edbed5e 100644
--- a/ripd/ripd.h
+++ b/ripd/ripd.h
@@ -144,6 +144,9 @@ struct rip {
/* Are we in passive-interface default mode? */
bool passive_default;
+ /* RIP enabled interfaces. */
+ vector enable_interface;
+
/* For redistribute route map. */
struct {
char *name;