From 8eefe200e02ba99c1c32bf9fd565e0da1dee69cf Mon Sep 17 00:00:00 2001 From: Donald Sharp Date: Thu, 15 Dec 2016 20:39:46 -0500 Subject: [PATCH 1/3] lib: Ensure ptrs are NULL on free There exists a possibility that when we cleanup for shutdown that we may attempt to access them again. Found via valgrind, stopped showing up in there. Signed-off-by: Donald Sharp --- lib/routemap.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/lib/routemap.c b/lib/routemap.c index 7b0749953354..ace4961f72b3 100644 --- a/lib/routemap.c +++ b/lib/routemap.c @@ -1845,9 +1845,13 @@ route_map_finish (void) } for (i = 1; i < ROUTE_MAP_DEP_MAX; i++) - hash_free(route_map_dep_hash[i]); + { + hash_free(route_map_dep_hash[i]); + route_map_dep_hash[i] = NULL; + } hash_free (route_map_master_hash); + route_map_master_hash = NULL; } /* Initialization of route map vector. */ From 26acb92b840a169e52ab8e2fdae2536292e841ee Mon Sep 17 00:00:00 2001 From: Donald Sharp Date: Thu, 15 Dec 2016 20:41:47 -0500 Subject: [PATCH 2/3] bgpd: Cleanup double read of free'd data Valgrind found this issue. This cleans it up from happening. Signed-off-by: Donald Sharp --- bgpd/bgp_updgrp_adv.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/bgpd/bgp_updgrp_adv.c b/bgpd/bgp_updgrp_adv.c index a95a11b620d4..8a3f4567caf3 100644 --- a/bgpd/bgp_updgrp_adv.c +++ b/bgpd/bgp_updgrp_adv.c @@ -573,8 +573,9 @@ subgroup_clear_table (struct update_subgroup *subgrp) SUBGRP_FOREACH_ADJ_SAFE (subgrp, aout, taout) { - bgp_adj_out_remove_subgroup (aout->rn, aout, subgrp); - bgp_unlock_node (aout->rn); + struct bgp_node *rn = aout->rn; + bgp_adj_out_remove_subgroup (rn, aout, subgrp); + bgp_unlock_node (rn); } } From c9d5bd27c10b620571985ffc99e839883f9a7551 Mon Sep 17 00:00:00 2001 From: Donald Sharp Date: Thu, 15 Dec 2016 21:28:51 -0500 Subject: [PATCH 3/3] bgpd: Fix 'show ip bgp summary' variable output being wrong The first time through calling 'show ip bgp summary' we were always calculating the variable hostname field size incorrectly. Signed-off-by: Donald Sharp --- bgpd/bgp_vty.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/bgpd/bgp_vty.c b/bgpd/bgp_vty.c index 5dafac1e0621..b0d96150a8fa 100644 --- a/bgpd/bgp_vty.c +++ b/bgpd/bgp_vty.c @@ -10317,6 +10317,10 @@ bgp_show_summary (struct vty *vty, struct bgp *bgp, int afi, int safi, if (peer->afc[afi][safi]) { + memset(dn_flag, '\0', sizeof(dn_flag)); + if (peer_dynamic_neighbor(peer)) + dn_flag[0] = '*'; + if (peer->hostname && bgp_flag_check(bgp, BGP_FLAG_SHOW_HOSTNAME)) sprintf(neighbor_buf, "%s%s(%s) ", dn_flag, peer->hostname, peer->host); else