Login | Register For Free | Help
Search for: (Advanced)

Mailing List Archive: Quagga: Dev

[PATCH] bgpd: fix for leaked struct bgp_adj_[in|out] on peer shutdown

 

 

Quagga dev RSS feed   Index | Next | Previous | View Threaded


jorge at dti2

May 7, 2012, 9:17 AM

Post #1 of 5 (246 views)
Permalink
[PATCH] bgpd: fix for leaked struct bgp_adj_[in|out] on peer shutdown

From: "Jorge Boncompte [DTI2]" <jorge [at] dti2>

If a peer with soft-reconfiguration configured it's cleared, the
function bgp_clear_route_table() doesn't free the bgp_adj_in and bgp_adj_out
structures of route nodes that for some reason, ej. denied by a filter,
don't have routes attached "rn->info == NULL".

* bgp_route.c: (bgp_clear_route_table) moved the clearing before the
allocation of the work queue items to return memory to the system
allocator before allocating new one to try to avoid heap fragmentation.

Signed-off-by: Jorge Boncompte [DTI2] <jorge [at] dti2>
---
bgpd/bgp_route.c | 33 +++++++++++++++------------------
1 files changed, 15 insertions(+), 18 deletions(-)

diff --git a/bgpd/bgp_route.c b/bgpd/bgp_route.c
index eae13a2..c0255b1 100644
--- a/bgpd/bgp_route.c
+++ b/bgpd/bgp_route.c
@@ -2798,9 +2798,6 @@ bgp_clear_route_table (struct peer *peer, afi_t afi, safi_t safi,
struct bgp_info *ri;
struct bgp_adj_in *ain;
struct bgp_adj_out *aout;
-
- if (rn->info == NULL)
- continue;

/* XXX:TODO: This is suboptimal, every non-empty route_node is
* queued for every clearing peer, regardless of whether it is
@@ -2833,6 +2830,21 @@ bgp_clear_route_table (struct peer *peer, afi_t afi, safi_t safi,
* this may actually be achievable. It doesn't seem to be a huge
* problem at this time,
*/
+ for (ain = rn->adj_in; ain; ain = ain->next)
+ if (ain->peer == peer || purpose == BGP_CLEAR_ROUTE_MY_RSCLIENT)
+ {
+ bgp_adj_in_remove (rn, ain);
+ bgp_unlock_node (rn);
+ break;
+ }
+ for (aout = rn->adj_out; aout; aout = aout->next)
+ if (aout->peer == peer || purpose == BGP_CLEAR_ROUTE_MY_RSCLIENT)
+ {
+ bgp_adj_out_remove (rn, aout, peer, afi, safi);
+ bgp_unlock_node (rn);
+ break;
+ }
+
for (ri = rn->info; ri; ri = ri->next)
if (ri->peer == peer || purpose == BGP_CLEAR_ROUTE_MY_RSCLIENT)
{
@@ -2848,21 +2860,6 @@ bgp_clear_route_table (struct peer *peer, afi_t afi, safi_t safi,
work_queue_add (peer->clear_node_queue, cnq);
break;
}
-
- for (ain = rn->adj_in; ain; ain = ain->next)
- if (ain->peer == peer || purpose == BGP_CLEAR_ROUTE_MY_RSCLIENT)
- {
- bgp_adj_in_remove (rn, ain);
- bgp_unlock_node (rn);
- break;
- }
- for (aout = rn->adj_out; aout; aout = aout->next)
- if (aout->peer == peer || purpose == BGP_CLEAR_ROUTE_MY_RSCLIENT)
- {
- bgp_adj_out_remove (rn, aout, peer, afi, safi);
- bgp_unlock_node (rn);
- break;
- }
}
return;
}
--
1.7.8.3


_______________________________________________
Quagga-dev mailing list
Quagga-dev [at] lists
http://lists.quagga.net/mailman/listinfo/quagga-dev


shemminger at vyatta

May 7, 2012, 9:51 AM

Post #2 of 5 (241 views)
Permalink
Re: [PATCH] bgpd: fix for leaked struct bgp_adj_[in|out] on peer shutdown [In reply to]

On Mon, 7 May 2012 18:17:33 +0200
"Jorge Boncompte [DTI2]" <jorge [at] dti2> wrote:

> From: "Jorge Boncompte [DTI2]" <jorge [at] dti2>
>
> If a peer with soft-reconfiguration configured it's cleared, the
> function bgp_clear_route_table() doesn't free the bgp_adj_in and bgp_adj_out
> structures of route nodes that for some reason, ej. denied by a filter,
> don't have routes attached "rn->info == NULL".
>
> * bgp_route.c: (bgp_clear_route_table) moved the clearing before the
> allocation of the work queue items to return memory to the system
> allocator before allocating new one to try to avoid heap fragmentation.
>
> Signed-off-by: Jorge Boncompte [DTI2] <jorge [at] dti2>


This earlier (now lost) patch might be related.
Stephen Hemminger wrote (2012/01/06 2:32):
>
> When soft-reconfig is used the advertised routes are stored and
> never cleared when session is lost. This means peer still has reference
> and all other memory is held as well.
> ---
> bgpd/bgp_fsm.c | 4 ++++
> 1 files changed, 4 insertions(+), 0 deletions(-)
>
> --- a/bgpd/bgp_fsm.c 2011-10-10 08:32:32.384321044 -0700
> +++ b/bgpd/bgp_fsm.c 2012-01-05 09:30:16.955532576 -0800
> @@ -546,6 +546,10 @@ bgp_stop (struct peer *peer)
> /* ORF received prefix-filter pnt */
> sprintf (orf_name, "%s.%d.%d", peer->host, afi, safi);
> prefix_bgp_orf_remove_all (orf_name);
> +
> + /* Drop soft reconfig info */
> + if (CHECK_FLAG (peer->af_flags[afi][safi], PEER_FLAG_SOFT_RECONFIG))
> + bgp_clear_adj_in (peer, afi, safi);
> }
>
> /* Reset keepalive and holdtime */
> _______________________________________________
> Quagga-dev mailing list
> Quagga-dev [at] lists
_______________________________________________
Quagga-dev mailing list
Quagga-dev [at] lists
http://lists.quagga.net/mailman/listinfo/quagga-dev


equinox at diac24

May 22, 2012, 4:16 PM

Post #3 of 5 (208 views)
Permalink
Re: [PATCH] bgpd: fix for leaked struct bgp_adj_[in|out] on peer shutdown [In reply to]

On Mon, May 07, 2012 at 09:51:51AM -0700, Stephen Hemminger wrote:
> On Mon, 7 May 2012 18:17:33 +0200
> "Jorge Boncompte [DTI2]" <jorge [at] dti2> wrote:
>
> > From: "Jorge Boncompte [DTI2]" <jorge [at] dti2>
> >
> > If a peer with soft-reconfiguration configured it's cleared, the
> > function bgp_clear_route_table() doesn't free the bgp_adj_in and bgp_adj_out
> > structures of route nodes that for some reason, ej. denied by a filter,
> > don't have routes attached "rn->info == NULL".
>
> This earlier (now lost) patch might be related.
> Stephen Hemminger wrote (2012/01/06 2:32):
> >
> > When soft-reconfig is used the advertised routes are stored and
> > never cleared when session is lost. This means peer still has reference
> > and all other memory is held as well.

Hm. It seems to me that Jorge's patch is more complete and fixes the
same issue in a more consistent way in the proper place. Comments? If
I don't hear anything I'll pick up Jorge's patch and consider Stephen's
as superseded.


-David
Attachments: signature.asc (0.22 KB)


equinox at opensourcerouting

Jan 14, 2013, 4:18 AM

Post #4 of 5 (84 views)
Permalink
Re: [PATCH] bgpd: fix for leaked struct bgp_adj_[in|out] on peer shutdown [In reply to]

On Mon, May 07, 2012 at 06:17:33PM +0200, Jorge Boncompte [DTI2] wrote:
> From: "Jorge Boncompte [DTI2]" <jorge [at] dti2>
>
> If a peer with soft-reconfiguration configured it's cleared, the
> function bgp_clear_route_table() doesn't free the bgp_adj_in and bgp_adj_out
> structures of route nodes that for some reason, ej. denied by a filter,
> don't have routes attached "rn->info == NULL".

I've thrown this to Leonid for review, he agrees with the first part and
is neutral on the second part. (By the way, this should really have
been two patches, I'll split it up on import.)

Reviewed-by: Leonid Rosenboim <Leonid.Rosenboim [at] windriver>

So I'm picking this up for 0.99.22.
(Now going through the backlog on bgpd, starting on this.)


-David
Attachments: signature.asc (0.22 KB)


equinox at opensourcerouting

Jan 14, 2013, 6:19 AM

Post #5 of 5 (84 views)
Permalink
Re: [PATCH] bgpd: fix for leaked struct bgp_adj_[in|out] on peer shutdown [In reply to]

On Mon, Jan 14, 2013 at 01:18:01PM +0100, David Lamparter wrote:
> On Mon, May 07, 2012 at 06:17:33PM +0200, Jorge Boncompte [DTI2] wrote:
> > From: "Jorge Boncompte [DTI2]" <jorge [at] dti2>
> >
> > If a peer with soft-reconfiguration configured it's cleared, the
> > function bgp_clear_route_table() doesn't free the bgp_adj_in and bgp_adj_out
> > structures of route nodes that for some reason, ej. denied by a filter,
> > don't have routes attached "rn->info == NULL".
>
> I've thrown this to Leonid for review, he agrees with the first part and
> is neutral on the second part. (By the way, this should really have
> been two patches, I'll split it up on import.)
>
> Reviewed-by: Leonid Rosenboim <Leonid.Rosenboim [at] windriver>
>
> So I'm picking this up for 0.99.22.
> (Now going through the backlog on bgpd, starting on this.)

Split in 2 and both applied. Thanks Jorge & Leonid!

-David
Attachments: signature.asc (0.22 KB)

Quagga dev RSS feed   Index | Next | Previous | View Threaded
 
 


Interested in having your list archived? Contact Gossamer Threads
 
  Web Applications & Managed Hosting Powered by Gossamer Threads Inc.