summaryrefslogtreecommitdiff
path: root/bgpd
diff options
context:
space:
mode:
authorJorge Boncompte [DTI2] <jorge@dti2.net>2012-05-07 15:17:33 +0000
committerDavid Lamparter <equinox@opensourcerouting.org>2013-01-14 14:43:51 +0100
commit24e50f2013e64a73b1f7ecdbd5688360002d09f7 (patch)
tree3c53b418e2f91f703ee79fd4b224e157b25218b3 /bgpd
parentebbb5fca5ca899a9a125aa2770d3fdf857186bac (diff)
bgpd: avoid heap fragmentation in bgp_clear_route_table
In bgp_clear_route_table, moved cleanup code before the allocation of the work queue items. This returns the memory to the system allocator before allocating new and might therefore help avoiding heap fragmentation. * bgp_route.c: (bgp_clear_route_table) moved code blocks. Signed-off-by: Jorge Boncompte [DTI2] <jorge@dti2.net> Reviewed-by: Leonid Rosenboim <Leonid.Rosenboim@windriver.com> Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
Diffstat (limited to 'bgpd')
-rw-r--r--bgpd/bgp_route.c30
1 files changed, 15 insertions, 15 deletions
diff --git a/bgpd/bgp_route.c b/bgpd/bgp_route.c
index 9251d2c2..6155bc16 100644
--- a/bgpd/bgp_route.c
+++ b/bgpd/bgp_route.c
@@ -2842,6 +2842,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)
{
@@ -2857,21 +2872,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;
}