From 56bf1cb2c3236429ff77e5dd19b04a8d1ff5d158 Mon Sep 17 00:00:00 2001 From: Renato Westphal Date: Fri, 4 Jan 2019 19:08:10 -0200 Subject: [PATCH] ripdng: clear list of peers when RIPng is deconfigured This is an old standing bug where the list of RIPng peers wasn't cleared after deconfiguring RIPng, which caused the existing peers to still be present on a newly configured RIPng instance (except when the timed out after ~3 minutes). Fix this. Signed-off-by: Renato Westphal --- ripngd/ripng_peer.c | 6 ++++++ ripngd/ripngd.c | 2 ++ ripngd/ripngd.h | 1 + 3 files changed, 9 insertions(+) diff --git a/ripngd/ripng_peer.c b/ripngd/ripng_peer.c index f5590cf823..36c701b86b 100644 --- a/ripngd/ripng_peer.c +++ b/ripngd/ripng_peer.c @@ -41,6 +41,7 @@ static struct ripng_peer *ripng_peer_new(void) static void ripng_peer_free(struct ripng_peer *peer) { + RIPNG_TIMER_OFF(peer->t_timeout); XFREE(MTYPE_RIPNG_PEER, peer); } @@ -178,3 +179,8 @@ int ripng_peer_list_cmp(struct ripng_peer *p1, struct ripng_peer *p2) { return memcmp(&p1->addr, &p2->addr, sizeof(struct in6_addr)); } + +void ripng_peer_list_del(void *arg) +{ + ripng_peer_free(arg); +} diff --git a/ripngd/ripngd.c b/ripngd/ripngd.c index 2cc3bd7f1e..9456980e87 100644 --- a/ripngd/ripngd.c +++ b/ripngd/ripngd.c @@ -1807,6 +1807,7 @@ int ripng_create(int socket) ripng->table = agg_table_init(); ripng->peer_list = list_new(); ripng->peer_list->cmp = (int (*)(void *, void *))ripng_peer_list_cmp; + ripng->peer_list->del = ripng_peer_list_del; ripng->enable_if = vector_init(1); ripng->enable_network = agg_table_init(); ripng->passive_interface = vector_init(1); @@ -2459,6 +2460,7 @@ void ripng_clean() free(ripng->route_map[i].name); agg_table_finish(ripng->table); + list_delete(&ripng->peer_list); distribute_list_delete(&ripng->distribute_ctx); stream_free(ripng->ibuf); diff --git a/ripngd/ripngd.h b/ripngd/ripngd.h index 3e5ca18ed2..26b6c0bb12 100644 --- a/ripngd/ripngd.h +++ b/ripngd/ripngd.h @@ -377,6 +377,7 @@ extern void ripng_peer_display(struct vty *); extern struct ripng_peer *ripng_peer_lookup(struct in6_addr *); extern struct ripng_peer *ripng_peer_lookup_next(struct in6_addr *); extern int ripng_peer_list_cmp(struct ripng_peer *p1, struct ripng_peer *p2); +extern void ripng_peer_list_del(void *arg); extern struct ripng_offset_list *ripng_offset_list_new(const char *ifname); extern void ripng_offset_list_del(struct ripng_offset_list *offset); -- 2.39.5