[quagga-dev 8251] Re: [PATCH 4/4] bgpd: fix memory leak when deleting a community

Stephen Hemminger shemminger at vyatta.com
Thu Sep 9 19:29:29 BST 2010


On Mon, 23 Aug 2010 12:54:37 -0400
Michael Lambert <lambert at psc.edu> wrote:

> * bgp_routemap.c: (route_set_community_delete) When deleting a
>   community in a route-map the old community was being orphaned.
> ---
>  bgpd/bgp_routemap.c |    1 +
>  1 files changed, 1 insertions(+), 0 deletions(-)
> 
> diff --git a/bgpd/bgp_routemap.c b/bgpd/bgp_routemap.c
> index aa7dbce..b8da186 100644
> --- a/bgpd/bgp_routemap.c
> +++ b/bgpd/bgp_routemap.c
> @@ -1484,6 +1484,7 @@ route_set_community_delete (void *rule, struct prefix *prefix,
>  	  merge = community_list_match_delete (community_dup (old), list);
>  	  new = community_uniq_sort (merge);
>  	  community_free (merge);
> +	  if (old->refcnt == 0) community_free (old);
>  
>  	  if (new->size == 0)
>  	    {

A couple of comments:
   1. Put statement on second line to be consistent with
      style used in Quagga.

   2. Checking refcount here indicates a bigger problem. Looks like
      routemap should actually be using community_intern/community_unintern
      to manage references.



More information about the Quagga-dev mailing list