On Sun, Oct 25, 2020 at 01:44:43PM +0100, Felix Maurer wrote:
> I noticed that bgpd leaks memory when it parses a roa-set containing
> multiple entries with the same prefix. Such entries are present in the
> output rpki-client generates at the moment. To use rpki-client, one needs to
> reload bgpd regularly, which parses the config file again, which leaks
> memory. This leads to an ever growing bgpd process. With the current
> roa-set, it grows about 1MB per reload. The issue seems to exist in 6.7 and
> 6.8.
> 
> A minimal sample config to reproduce the issue looks like this:
> 
> AS 64500
> router-id 10.0.0.1
> roa-set {
>         172.16.0.0/24 source-as 64510
>         172.16.0.0/24 source-as 64520
> }
> 
> All items in the tree of prefixes are freed at some point of time. But items
> that can not be inserted, because the prefix already exists, are never
> freed. I have included a patch which frees such items when the insertion
> into the tree fails.
> 

Nice find. I committed your diff to -current.

Thanks
-- 
:wq Claudio


> 
> Index: usr.sbin/bgpd/parse.y
> ===================================================================
> RCS file: /cvs/src/usr.sbin/bgpd/parse.y,v
> retrieving revision 1.408
> diff -u -p -u -p -r1.408 parse.y
> --- usr.sbin/bgpd/parse.y     10 May 2020 13:38:46 -0000      1.408
> +++ usr.sbin/bgpd/parse.y     25 Oct 2020 12:23:39 -0000
> @@ -4513,6 +4513,8 @@ add_roa_set(struct prefixset_item *npsi,
>       psi = RB_INSERT(prefixset_tree, curpsitree, npsi);
>       if (psi == NULL)
>               psi = npsi;
> +     else
> +             free(npsi);
> 
>       if (psi->set == NULL)
>               if ((psi->set = set_new(1, sizeof(rs))) == NULL)
> 

Reply via email to