ripd: move "Vrip_passive_nondefault" to the rip structure

Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
This commit is contained in:
Renato Westphal 2019-01-04 19:08:10 -02:00
parent 1205fdc482
commit 5a29c0d5c4
3 changed files with 13 additions and 15 deletions

View File

@ -60,9 +60,6 @@ const struct message ri_version_msg[] = {{RI_RIP_VERSION_1, "1"},
{RI_RIP_VERSION_NONE, "none"},
{0}};
/* Vector to store passive-interface name. */
vector Vrip_passive_nondefault;
/* Join to the RIP version 2 multicast group. */
static int ipv4_multicast_join(int sock, struct in_addr group,
struct in_addr ifa, ifindex_t ifindex)
@ -1056,8 +1053,8 @@ static int rip_passive_nondefault_lookup(const char *ifname)
unsigned int i;
char *str;
for (i = 0; i < vector_active(Vrip_passive_nondefault); i++)
if ((str = vector_slot(Vrip_passive_nondefault, i)) != NULL)
for (i = 0; i < vector_active(rip->passive_nondefault); i++)
if ((str = vector_slot(rip->passive_nondefault, i)) != NULL)
if (strcmp(str, ifname) == 0)
return i;
return -1;
@ -1100,7 +1097,7 @@ int rip_passive_nondefault_set(const char *ifname)
*/
return NB_OK;
vector_set(Vrip_passive_nondefault,
vector_set(rip->passive_nondefault,
XSTRDUP(MTYPE_RIP_INTERFACE_STRING, ifname));
rip_passive_interface_apply_all();
@ -1121,9 +1118,9 @@ int rip_passive_nondefault_unset(const char *ifname)
*/
return NB_OK;
str = vector_slot(Vrip_passive_nondefault, i);
str = vector_slot(rip->passive_nondefault, i);
XFREE(MTYPE_RIP_INTERFACE_STRING, str);
vector_unset(Vrip_passive_nondefault, i);
vector_unset(rip->passive_nondefault, i);
rip_passive_interface_apply_all();
@ -1136,10 +1133,10 @@ void rip_passive_nondefault_clean(void)
unsigned int i;
char *str;
for (i = 0; i < vector_active(Vrip_passive_nondefault); i++)
if ((str = vector_slot(Vrip_passive_nondefault, i)) != NULL) {
for (i = 0; i < vector_active(rip->passive_nondefault); i++)
if ((str = vector_slot(rip->passive_nondefault, i)) != NULL) {
XFREE(MTYPE_RIP_INTERFACE_STRING, str);
vector_slot(Vrip_passive_nondefault, i) = NULL;
vector_slot(rip->passive_nondefault, i) = NULL;
}
rip_passive_interface_apply_all();
}
@ -1222,9 +1219,6 @@ void rip_if_init(void)
hook_register_prio(if_add, 0, rip_interface_new_hook);
hook_register_prio(if_del, 0, rip_interface_delete_hook);
/* RIP passive interface. */
Vrip_passive_nondefault = vector_init(1);
/* Install interface node. */
install_node(&interface_node, rip_interface_config_write);
if_cmd_init();

View File

@ -2694,6 +2694,7 @@ int rip_create(int socket)
rip->neighbor = route_table_init();
rip->enable_interface = vector_init(1);
rip->enable_network = route_table_init();
rip->passive_nondefault = vector_init(1);
/* Distribute list install. */
rip->distribute_ctx =
@ -3377,6 +3378,7 @@ void rip_clean(void)
rip_passive_nondefault_clean();
vector_free(rip->enable_interface);
route_table_finish(rip->enable_network);
vector_free(rip->passive_nondefault);
rip_offset_clean();
rip_interfaces_clean();
rip_distance_reset();

View File

@ -150,6 +150,9 @@ struct rip {
/* RIP enabled networks. */
struct route_table *enable_network;
/* Vector to store passive-interface name. */
vector passive_nondefault;
/* For redistribute route map. */
struct {
char *name;
@ -480,7 +483,6 @@ DECLARE_HOOK(rip_ifaddr_del, (struct connected * ifc), (ifc))
extern struct list *peer_list;
extern struct route_table *rip_distance_table;
extern vector Vrip_passive_nondefault;
/* Northbound. */
extern void rip_cli_init(void);