From 97a69b318c3057e1535a53fe3cf7b893cf837a81 Mon Sep 17 00:00:00 2001 From: Chirag Shah Date: Thu, 22 Jun 2017 17:19:00 -0700 Subject: [PATCH] ospfd: Fix conflict router-id, memory leaks Remove assert in path of router_id_update: Upon configuring same router-id as neighbor's assert would cause a crash. Log a warning message and neighborship would not come up. Address memory leaks Signed-off-by: Chirag Shah --- ospfd/ospf_neighbor.c | 3 ++- ospfd/ospf_spf.c | 2 ++ ospfd/ospf_zebra.c | 1 + ospfd/ospfd.c | 2 +- 4 files changed, 6 insertions(+), 2 deletions(-) diff --git a/ospfd/ospf_neighbor.c b/ospfd/ospf_neighbor.c index 33492cf7c9..a7aac26b3b 100644 --- a/ospfd/ospf_neighbor.c +++ b/ospfd/ospf_neighbor.c @@ -269,7 +269,8 @@ void ospf_nbr_add_self(struct ospf_interface *oi, struct in_addr router_id) rn = route_node_get(oi->nbrs, &p); if (rn->info) { /* There is already pseudo neighbor. */ - assert(oi->nbr_self == rn->info); + zlog_warn("router_id %s already present in neighbor table. node refcount %u", + inet_ntoa(router_id), rn->lock); route_unlock_node(rn); } else rn->info = oi->nbr_self; diff --git a/ospfd/ospf_spf.c b/ospfd/ospf_spf.c index c520a31266..7437d26da3 100644 --- a/ospfd/ospf_spf.c +++ b/ospfd/ospf_spf.c @@ -401,6 +401,8 @@ static void ospf_spf_flush_parents(struct vertex *w) /* delete the existing nexthops */ for (ALL_LIST_ELEMENTS(w->parents, ln, nn, vp)) { list_delete_node(w->parents, ln); + if (vp->nexthop) + vertex_nexthop_free(vp->nexthop); vertex_parent_free(vp); } } diff --git a/ospfd/ospf_zebra.c b/ospfd/ospf_zebra.c index ec8f1ee852..d615afc072 100644 --- a/ospfd/ospf_zebra.c +++ b/ospfd/ospf_zebra.c @@ -715,6 +715,7 @@ void ospf_redist_del(struct ospf *ospf, u_char type, u_short instance) list_free(ospf->redist[type]); ospf->redist[type] = NULL; } + ospf_routemap_unset(red); XFREE(MTYPE_OSPF_REDISTRIBUTE, red); } } diff --git a/ospfd/ospfd.c b/ospfd/ospfd.c index b3553238ef..20cee713bd 100644 --- a/ospfd/ospfd.c +++ b/ospfd/ospfd.c @@ -1187,7 +1187,7 @@ void ospf_ls_upd_queue_empty(struct ospf_interface *oi) if ((lst = (struct list *)rn->info)) { for (ALL_LIST_ELEMENTS(lst, node, nnode, lsa)) ospf_lsa_unlock(&lsa); /* oi->ls_upd_queue */ - list_free(lst); + list_delete(lst); rn->info = NULL; } -- 2.39.5