[bgpd] rearrange some structs for less padding, stats for table/attrs.
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.
diff --git a/bgpd/bgp_attr.h b/bgpd/bgp_attr.h
index ad0302d..a018256 100644
--- a/bgpd/bgp_attr.h
+++ b/bgpd/bgp_attr.h
@@ -48,30 +48,11 @@
/* 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 @@
/* 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 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);