]> git.puffer.fish Git - matthieu/frr.git/commitdiff
[bgpd] rearrange some structs for less padding, stats for table/attrs.
authorPaul Jakma <paul.jakma@sun.com>
Thu, 30 Mar 2006 13:20:48 +0000 (13:20 +0000)
committerPaul Jakma <paul.jakma@sun.com>
Thu, 30 Mar 2006 13:20:48 +0000 (13:20 +0000)
2006-03-12 Paul Jakma <paul.jakma@sun.com>

* bgp_attr.h: (struct attr) rearrange fields to avoid
  wasted padding between them as much as possible.
  (attr_count,attr_unknown_count) export new functions to
  return number of counts of cached attributes.
* bgp_attr.c: (attr_count,attr_unknown_count) new functions to
  return number of counts of cached attributes.
* bgp_route.h: (struct bgp_info) rearrange fields to avoid
  wasted padding.
* bgp_table.h: (struct bgp_table) Add a count field, of number
  of nodes in the table.
  (struct bgp_node)  rearrange fields to avoid
  wasted padding between them, though I don't think there
  was any in this case.
* bgp_table.c: (bgp_node_{delete,get}) Maintain the table node count.
  (bgp_table_count) new function to access the table count.

bgpd/ChangeLog
bgpd/bgp_attr.c
bgpd/bgp_attr.h
bgpd/bgp_route.h
bgpd/bgp_table.c
bgpd/bgp_table.h

index 0c8c9d6eae63deb66c58e5bf8c5ddb3e4a7af79f..51f2e133408161f2eb4117ce048a71c0c9d2906d 100644 (file)
@@ -1,3 +1,21 @@
+2006-03-12 Paul Jakma <paul.jakma@sun.com>
+
+       * bgp_attr.h: (struct attr) rearrange fields to avoid
+         wasted padding between them as much as possible.
+         (attr_count,attr_unknown_count) export new functions to
+         return number of counts of cached attributes.
+       * bgp_attr.c: (attr_count,attr_unknown_count) new functions to
+         return number of counts of cached attributes.
+       * bgp_route.h: (struct bgp_info) rearrange fields to avoid
+         wasted padding.
+       * bgp_table.h: (struct bgp_table) Add a count field, of number
+         of nodes in the table.
+         (struct bgp_node)  rearrange fields to avoid
+         wasted padding between them, though I don't think there
+         was any in this case. 
+       * bgp_table.c: (bgp_node_{delete,get}) Maintain the table node count.
+         (bgp_table_count) new function to access the table count.
+
 2006-03-03 Paul Jakma <paul.jakma@sun.com>
 
        * bgp_route.c: (bgp_clear_node_complete) Doh. When clearing
index 3b27517d7b48d7ca789ffa33699b413cb472eece..27ddab11186f4fcda323a01c4ca3ed252d88cdbe 100644 (file)
@@ -274,6 +274,18 @@ transit_init ()
 
 struct hash *attrhash;
 
+unsigned long int
+attr_count (void)
+{
+  return attrhash->count;
+}
+
+unsigned long int
+attr_unknown_count (void)
+{
+  return transit_hash->count;
+}
+
 unsigned int
 attrhash_key_make (struct attr *attr)
 {
index ad0302d86b8b39c8c2e12708b85a8e3645589f63..a018256fd18806c65e35cd485e7f180a1b94682b 100644 (file)
@@ -48,30 +48,11 @@ Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
 /* BGP attribute structure. */
 struct attr
 {
-  /* Reference count of this attribute. */
-  unsigned long refcnt;
-
-  /* Flag of attribute is set or not. */
-  u_int32_t flag;
-
   /* Attributes. */
-  u_char origin;
-  struct in_addr nexthop;
-  u_int32_t med;
-  u_int32_t local_pref;
-  as_t aggregator_as;
-  struct in_addr aggregator_addr;
-  u_int32_t weight;
-  struct in_addr originator_id;
-  struct cluster_list *cluster;
-
-  u_char mp_nexthop_len;
 #ifdef HAVE_IPV6
   struct in6_addr mp_nexthop_global;
   struct in6_addr mp_nexthop_local;
 #endif /* HAVE_IPV6 */
-  struct in_addr mp_nexthop_global_in;
-  struct in_addr mp_nexthop_local_in;
 
   /* AS Path structure */
   struct aspath *aspath;
@@ -81,9 +62,31 @@ struct attr
 
   /* Extended Communities attribute. */
   struct ecommunity *ecommunity;
-
+  
+  /* Route-Reflector Cluster attribute */
+  struct cluster_list *cluster;
+  
   /* Unknown transitive attribute. */
   struct transit *transit;
+
+  /* Reference count of this attribute. */
+  unsigned long refcnt;
+
+  /* Flag of attribute is set or not. */
+  u_int32_t flag;
+  
+  /* Apart from in6_addr, the remaining static attributes */
+  struct in_addr nexthop;
+  u_int32_t med;
+  u_int32_t local_pref;
+  struct in_addr aggregator_addr;
+  struct in_addr originator_id;
+  struct in_addr mp_nexthop_global_in;
+  struct in_addr mp_nexthop_local_in;
+  u_int32_t weight;
+  as_t aggregator_as;
+  u_char origin;
+  u_char mp_nexthop_len;
 };
 
 /* Router Reflector related structure. */
@@ -129,6 +132,8 @@ extern void bgp_dump_routes_attr (struct stream *, struct attr *,
 extern unsigned int attrhash_key_make (struct attr *);
 extern int attrhash_cmp (struct attr *, struct attr *);
 extern void attr_show_all (struct vty *);
+extern unsigned long int attr_count (void);
+extern unsigned long int attr_unknown_count (void);
 
 /* Cluster list prototypes. */
 extern int cluster_loop_check (struct cluster_list *, struct in_addr);
index 24be30ff2d0c1b053c8fe782060d187222cb9f70..e5f3ae59920d34924b326a370f14896d90aa8c17 100644 (file)
@@ -29,20 +29,27 @@ struct bgp_info
   struct bgp_info *next;
   struct bgp_info *prev;
   
+  /* Peer structure.  */
+  struct peer *peer;
+
+  /* Attribute structure.  */
+  struct attr *attr;
+
+  /* Pointer to dampening structure.  */
+  struct bgp_damp_info *damp_info;
+
+  /* Uptime.  */
+  time_t uptime;
+
+  /* This route is suppressed with aggregation.  */
+  int suppress;
+  
+  /* Nexthop reachability check.  */
+  u_int32_t igpmetric;
+
   /* reference count */
   unsigned int lock;
   
-  /* BGP route type.  This can be static, RIP, OSPF, BGP etc.  */
-  u_char type;
-
-  /* When above type is BGP.  This sub type specify BGP sub type
-     information.  */
-  u_char sub_type;
-#define BGP_ROUTE_NORMAL       0
-#define BGP_ROUTE_STATIC       1
-#define BGP_ROUTE_AGGREGATE    2
-#define BGP_ROUTE_REDISTRIBUTE 3 
-
   /* BGP information status.  */
   u_int16_t flags;
 #define BGP_INFO_IGP_CHANGED    (1 << 0)
@@ -57,26 +64,19 @@ struct bgp_info
 #define BGP_INFO_REMOVED        (1 << 9)
 #define BGP_INFO_COUNTED       (1 << 10)
 
-  /* Peer structure.  */
-  struct peer *peer;
-
-  /* Attribute structure.  */
-  struct attr *attr;
-
-  /* This route is suppressed with aggregation.  */
-  int suppress;
-  
-  /* Nexthop reachability check.  */
-  u_int32_t igpmetric;
-
-  /* Uptime.  */
-  time_t uptime;
-
-  /* Pointer to dampening structure.  */
-  struct bgp_damp_info *damp_info;
-
   /* MPLS label.  */
   u_char tag[3];
+
+  /* BGP route type.  This can be static, RIP, OSPF, BGP etc.  */
+  u_char type;
+
+  /* When above type is BGP.  This sub type specify BGP sub type
+     information.  */
+  u_char sub_type;
+#define BGP_ROUTE_NORMAL       0
+#define BGP_ROUTE_STATIC       1
+#define BGP_ROUTE_AGGREGATE    2
+#define BGP_ROUTE_REDISTRIBUTE 3 
 };
 
 /* BGP static route configuration. */
index a3b489d5f28b19d0d55411e128d0576cff3a5d7c..810dab54e8b007362ae9289f15b63c444240e7f4 100644 (file)
@@ -350,8 +350,10 @@ bgp_node_get (struct bgp_table *table, struct prefix *p)
          match = new;
          new = bgp_node_set (table, p);
          set_link (match, new);
+         table->count++;
        }
     }
+  table->count++;
   bgp_lock_node (new);
   
   return new;
@@ -389,7 +391,9 @@ bgp_node_delete (struct bgp_node *node)
     }
   else
     node->table->top = child;
-
+  
+  node->table->count--;
+  
   bgp_node_free (node);
 
   /* If parent node is stub then delete it also. */
@@ -492,3 +496,9 @@ bgp_route_next_until (struct bgp_node *node, struct bgp_node *limit)
   bgp_unlock_node (start);
   return NULL;
 }
+
+unsigned long
+bgp_table_count (struct bgp_table *table)
+{
+  return table->count;
+}
index e13022bb9e595958ce8f0032551c10aca6437a45..62421e716fd070e5659ab4e2a26d5f9e9d944457 100644 (file)
@@ -39,6 +39,8 @@ struct bgp_table
   void *owner;
 
   struct bgp_node *top;
+  
+  unsigned long count;
 };
 
 struct bgp_node
@@ -51,18 +53,16 @@ struct bgp_node
 #define l_left   link[0]
 #define l_right  link[1]
 
-  unsigned int lock;
-
   void *info;
 
   struct bgp_adj_out *adj_out;
 
   struct bgp_adj_in *adj_in;
 
-  void *aggregate;
-
   struct bgp_node *prn;
 
+  unsigned int lock;
+
   u_char flags;
 #define BGP_NODE_PROCESS_SCHEDULED     (1 << 0)
 };
@@ -84,5 +84,5 @@ extern struct bgp_node *bgp_node_match_ipv4 (struct bgp_table *,
 extern struct bgp_node *bgp_node_match_ipv6 (struct bgp_table *,
                                          struct in6_addr *);
 #endif /* HAVE_IPV6 */
-
+extern unsigned long bgp_table_count (struct bgp_table *);
 #endif /* _QUAGGA_BGP_TABLE_H */