]> git.puffer.fish Git - mirror/frr.git/commitdiff
bgpd: optimize bgp_aggregate_[increment|decrement]()
authorJorge Boncompte [DTI2] <jorge@dti2.net>
Mon, 7 May 2012 16:53:10 +0000 (16:53 +0000)
committerDavid Lamparter <equinox@opensourcerouting.org>
Tue, 22 May 2012 18:35:50 +0000 (20:35 +0200)
  If there were no aggregates configured this functions were allocating
and freeing a struct bgp_node for every call, and it's called for every
prefix received.

* bgp_route.c: Bail out early if the there are no aggregates configured.
  Change from bgp_node_get() to bgp_node_lookup() that does not allocate
  a new struct bgp_node if not found.

Signed-off-by: Jorge Boncompte [DTI2] <jorge@dti2.net>
Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
bgpd/bgp_route.c

index ce0b57b91eb6a7cfdb8c7ea688d374fbba283e2c..cd8f3fea98c3a9dff1de9576cb408bcd6bce641f 100644 (file)
@@ -4660,18 +4660,27 @@ bgp_aggregate_increment (struct bgp *bgp, struct prefix *p,
   struct bgp_node *child;
   struct bgp_node *rn;
   struct bgp_aggregate *aggregate;
+  struct bgp_table *table;
 
   /* MPLS-VPN aggregation is not yet supported. */
   if (safi == SAFI_MPLS_VPN)
     return;
 
+  table = bgp->aggregate[afi][safi];
+
+  /* No aggregates configured. */
+  if (table->top == NULL)
+    return;
+
   if (p->prefixlen == 0)
     return;
 
   if (BGP_INFO_HOLDDOWN (ri))
     return;
 
-  child = bgp_node_get (bgp->aggregate[afi][safi], p);
+  child = bgp_node_lookup (table, p);
+  if (! child)
+    return;
 
   /* Aggregate address configuration check. */
   for (rn = child; rn; rn = rn->parent)
@@ -4690,15 +4699,24 @@ bgp_aggregate_decrement (struct bgp *bgp, struct prefix *p,
   struct bgp_node *child;
   struct bgp_node *rn;
   struct bgp_aggregate *aggregate;
+  struct bgp_table *table;
 
   /* MPLS-VPN aggregation is not yet supported. */
   if (safi == SAFI_MPLS_VPN)
     return;
 
+  table = bgp->aggregate[afi][safi];
+
+  /* No aggregates configured. */
+  if (table->top == NULL)
+    return;
+
   if (p->prefixlen == 0)
     return;
 
-  child = bgp_node_get (bgp->aggregate[afi][safi], p);
+  child = bgp_node_lookup (table, p);
+  if (! child)
+    return;
 
   /* Aggregate address configuration check. */
   for (rn = child; rn; rn = rn->parent)