summaryrefslogtreecommitdiffstats
path: root/ripngd
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
commita9caf6e9399536bfe0383e9ab0a7b6f83972a2e5 (patch)
treebc01d033c18c7aad5aaf899a4821134328c22075 /ripngd
parentripd: remove the rip global variable (diff)
downloadfrr-a9caf6e9399536bfe0383e9ab0a7b6f83972a2e5.tar.xz
frr-a9caf6e9399536bfe0383e9ab0a7b6f83972a2e5.zip
ripngd: simplify cleaning up of routing instance
* Call ripng_clean() only when RIPng is configured, this way we can remove one indentation level from this function. * ripng_redistribute_clean() is only called on shutdown, so there's no need to call ripng_redistribute_withdraw() there since the RIPng table is already cleaned up elsewhere. * Deallocate the ripng structure only at the end of the function. This prepares the ground for the next commits where all global variables will be moved to the ripng structure. Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
Diffstat (limited to 'ripngd')
-rw-r--r--ripngd/ripng_main.c3
-rw-r--r--ripngd/ripng_zebra.c3
-rw-r--r--ripngd/ripngd.c102
3 files changed, 49 insertions, 59 deletions
diff --git a/ripngd/ripng_main.c b/ripngd/ripng_main.c
index 10e19efe7..b7e5739ed 100644
--- a/ripngd/ripng_main.c
+++ b/ripngd/ripng_main.c
@@ -82,7 +82,8 @@ static void sigint(void)
{
zlog_notice("Terminating on signal");
- ripng_clean();
+ if (ripng)
+ ripng_clean();
ripng_zebra_stop();
frr_fini();
diff --git a/ripngd/ripng_zebra.c b/ripngd/ripng_zebra.c
index e3f42edf5..7b7456197 100644
--- a/ripngd/ripng_zebra.c
+++ b/ripngd/ripng_zebra.c
@@ -173,9 +173,6 @@ void ripng_redistribute_clean()
VRF_DEFAULT);
vrf_bitmap_unset(zclient->redist[AFI_IP6][i], VRF_DEFAULT);
-
- /* Remove the routes from RIP table. */
- ripng_redistribute_withdraw(i);
}
}
diff --git a/ripngd/ripngd.c b/ripngd/ripngd.c
index 03383bc26..13e360694 100644
--- a/ripngd/ripngd.c
+++ b/ripngd/ripngd.c
@@ -1026,9 +1026,6 @@ void ripng_redistribute_withdraw(int type)
struct ripng_info *rinfo = NULL;
struct list *list = NULL;
- if (!ripng)
- return;
-
for (rp = agg_route_top(ripng->table); rp; rp = agg_route_next(rp))
if ((list = rp->info) != NULL) {
rinfo = listgetdata(listhead(list));
@@ -2403,77 +2400,72 @@ static void ripng_distribute_update_all_wrapper(struct access_list *notused)
/* delete all the added ripng routes. */
void ripng_clean()
{
- int i;
struct agg_node *rp;
- struct ripng_info *rinfo;
- struct ripng_aggregate *aggregate;
- struct list *list = NULL;
- struct listnode *listnode = NULL;
- if (ripng) {
- /* Clear RIPng routes */
- for (rp = agg_route_top(ripng->table); rp;
- rp = agg_route_next(rp)) {
- if ((list = rp->info) != NULL) {
- rinfo = listgetdata(listhead(list));
- if (ripng_route_rte(rinfo))
- ripng_zebra_ipv6_delete(rp);
+ /* Clear RIPng routes */
+ for (rp = agg_route_top(ripng->table); rp; rp = agg_route_next(rp)) {
+ struct ripng_aggregate *aggregate;
+ struct list *list;
- for (ALL_LIST_ELEMENTS_RO(list, listnode,
- rinfo)) {
- RIPNG_TIMER_OFF(rinfo->t_timeout);
- RIPNG_TIMER_OFF(
- rinfo->t_garbage_collect);
- ripng_info_free(rinfo);
- }
- list_delete(&list);
- rp->info = NULL;
- agg_unlock_node(rp);
- }
+ if ((list = rp->info) != NULL) {
+ struct ripng_info *rinfo;
+ struct listnode *listnode;
- if ((aggregate = rp->aggregate) != NULL) {
- ripng_aggregate_free(aggregate);
- rp->aggregate = NULL;
- agg_unlock_node(rp);
+ rinfo = listgetdata(listhead(list));
+ if (ripng_route_rte(rinfo))
+ ripng_zebra_ipv6_delete(rp);
+
+ for (ALL_LIST_ELEMENTS_RO(list, listnode, rinfo)) {
+ RIPNG_TIMER_OFF(rinfo->t_timeout);
+ RIPNG_TIMER_OFF(rinfo->t_garbage_collect);
+ ripng_info_free(rinfo);
}
+ list_delete(&list);
+ rp->info = NULL;
+ agg_unlock_node(rp);
}
- /* Cancel the RIPng timers */
- RIPNG_TIMER_OFF(ripng->t_update);
- RIPNG_TIMER_OFF(ripng->t_triggered_update);
- RIPNG_TIMER_OFF(ripng->t_triggered_interval);
-
- /* Cancel the read thread */
- if (ripng->t_read) {
- thread_cancel(ripng->t_read);
- ripng->t_read = NULL;
+ if ((aggregate = rp->aggregate) != NULL) {
+ ripng_aggregate_free(aggregate);
+ rp->aggregate = NULL;
+ agg_unlock_node(rp);
}
+ }
- /* Close the RIPng socket */
- if (ripng->sock >= 0) {
- close(ripng->sock);
- ripng->sock = -1;
- }
+ /* Cancel the RIPng timers */
+ RIPNG_TIMER_OFF(ripng->t_update);
+ RIPNG_TIMER_OFF(ripng->t_triggered_update);
+ RIPNG_TIMER_OFF(ripng->t_triggered_interval);
- for (i = 0; i < ZEBRA_ROUTE_MAX; i++)
- if (ripng->route_map[i].name)
- free(ripng->route_map[i].name);
+ /* Cancel the read thread */
+ if (ripng->t_read) {
+ thread_cancel(ripng->t_read);
+ ripng->t_read = NULL;
+ }
+
+ /* Close the RIPng socket */
+ if (ripng->sock >= 0) {
+ close(ripng->sock);
+ ripng->sock = -1;
+ }
- agg_table_finish(ripng->table);
+ for (int i = 0; i < ZEBRA_ROUTE_MAX; i++)
+ if (ripng->route_map[i].name)
+ free(ripng->route_map[i].name);
- stream_free(ripng->ibuf);
- stream_free(ripng->obuf);
+ agg_table_finish(ripng->table);
+ distribute_list_delete(&ripng->distribute_ctx);
- distribute_list_delete(&ripng->distribute_ctx);
- XFREE(MTYPE_RIPNG, ripng);
- ripng = NULL;
- } /* if (ripng) */
+ stream_free(ripng->ibuf);
+ stream_free(ripng->obuf);
ripng_clean_network();
ripng_passive_interface_clean();
ripng_offset_clean();
ripng_interface_clean();
ripng_redistribute_clean();
+
+ XFREE(MTYPE_RIPNG, ripng);
}
static void ripng_if_rmap_update(struct if_rmap *if_rmap)