[quagga-dev 8961] bgpd: extra attribute memory leak

Stephen Hemminger shemminger at vyatta.com
Sat Dec 3 01:47:23 GMT 2011

For the simple case of:
   * setup BGP peer connection
   * close connection
   * lather, rinse, repeat

I see that BGP extra attributes are building up, in fact on close
the extra attributes grow (not shrink). The problem looks like this

bgp_attr_unintern (struct attr **attr)
  struct attr *ret;
  struct attr tmp;
  /* Decrement attribute reference. */
  tmp = *(*attr);
  if ((*attr)->extra)
      tmp.extra = bgp_attr_extra_new ();
      memcpy (tmp.extra, (*attr)->extra, sizeof (struct attr_extra));

Which actually creates new copy of extra attribute rather than cleaning
up the attributes. Basically, it alloc's when it should be freeing.

The problem was introduced by the massive BGP commit fix for error
handling. (Yet another plea for only allowing small incremental patches
that can actually be reviewed!)

commit b881c7074bb698aeb1b099175b325734fc6e44d2
Author: Paul Jakma <paul at quagga.net>
Date:   Tue Nov 23 16:35:42 2010 +0000

    bgpd: Implement revised error handling for partial optional/trans. attributes

More information about the Quagga-dev mailing list