forked from Mirror/frr
[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.
This commit is contained in:
parent
478ccfd61b
commit
cbdfbaa51b
|
@ -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>
|
2006-03-03 Paul Jakma <paul.jakma@sun.com>
|
||||||
|
|
||||||
* bgp_route.c: (bgp_clear_node_complete) Doh. When clearing
|
* bgp_route.c: (bgp_clear_node_complete) Doh. When clearing
|
||||||
|
|
|
@ -274,6 +274,18 @@ transit_init ()
|
||||||
|
|
||||||
struct hash *attrhash;
|
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
|
unsigned int
|
||||||
attrhash_key_make (struct attr *attr)
|
attrhash_key_make (struct attr *attr)
|
||||||
{
|
{
|
||||||
|
|
|
@ -48,30 +48,11 @@ Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
|
||||||
/* BGP attribute structure. */
|
/* BGP attribute structure. */
|
||||||
struct attr
|
struct attr
|
||||||
{
|
{
|
||||||
/* Reference count of this attribute. */
|
|
||||||
unsigned long refcnt;
|
|
||||||
|
|
||||||
/* Flag of attribute is set or not. */
|
|
||||||
u_int32_t flag;
|
|
||||||
|
|
||||||
/* Attributes. */
|
/* 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
|
#ifdef HAVE_IPV6
|
||||||
struct in6_addr mp_nexthop_global;
|
struct in6_addr mp_nexthop_global;
|
||||||
struct in6_addr mp_nexthop_local;
|
struct in6_addr mp_nexthop_local;
|
||||||
#endif /* HAVE_IPV6 */
|
#endif /* HAVE_IPV6 */
|
||||||
struct in_addr mp_nexthop_global_in;
|
|
||||||
struct in_addr mp_nexthop_local_in;
|
|
||||||
|
|
||||||
/* AS Path structure */
|
/* AS Path structure */
|
||||||
struct aspath *aspath;
|
struct aspath *aspath;
|
||||||
|
@ -82,8 +63,30 @@ struct attr
|
||||||
/* Extended Communities attribute. */
|
/* Extended Communities attribute. */
|
||||||
struct ecommunity *ecommunity;
|
struct ecommunity *ecommunity;
|
||||||
|
|
||||||
|
/* Route-Reflector Cluster attribute */
|
||||||
|
struct cluster_list *cluster;
|
||||||
|
|
||||||
/* Unknown transitive attribute. */
|
/* Unknown transitive attribute. */
|
||||||
struct transit *transit;
|
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. */
|
/* 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 unsigned int attrhash_key_make (struct attr *);
|
||||||
extern int attrhash_cmp (struct attr *, struct attr *);
|
extern int attrhash_cmp (struct attr *, struct attr *);
|
||||||
extern void attr_show_all (struct vty *);
|
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. */
|
/* Cluster list prototypes. */
|
||||||
extern int cluster_loop_check (struct cluster_list *, struct in_addr);
|
extern int cluster_loop_check (struct cluster_list *, struct in_addr);
|
||||||
|
|
|
@ -29,20 +29,27 @@ struct bgp_info
|
||||||
struct bgp_info *next;
|
struct bgp_info *next;
|
||||||
struct bgp_info *prev;
|
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 */
|
/* reference count */
|
||||||
unsigned int lock;
|
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. */
|
/* BGP information status. */
|
||||||
u_int16_t flags;
|
u_int16_t flags;
|
||||||
#define BGP_INFO_IGP_CHANGED (1 << 0)
|
#define BGP_INFO_IGP_CHANGED (1 << 0)
|
||||||
|
@ -57,26 +64,19 @@ struct bgp_info
|
||||||
#define BGP_INFO_REMOVED (1 << 9)
|
#define BGP_INFO_REMOVED (1 << 9)
|
||||||
#define BGP_INFO_COUNTED (1 << 10)
|
#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. */
|
/* MPLS label. */
|
||||||
u_char tag[3];
|
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. */
|
/* BGP static route configuration. */
|
||||||
|
|
|
@ -350,8 +350,10 @@ bgp_node_get (struct bgp_table *table, struct prefix *p)
|
||||||
match = new;
|
match = new;
|
||||||
new = bgp_node_set (table, p);
|
new = bgp_node_set (table, p);
|
||||||
set_link (match, new);
|
set_link (match, new);
|
||||||
|
table->count++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
table->count++;
|
||||||
bgp_lock_node (new);
|
bgp_lock_node (new);
|
||||||
|
|
||||||
return new;
|
return new;
|
||||||
|
@ -390,6 +392,8 @@ bgp_node_delete (struct bgp_node *node)
|
||||||
else
|
else
|
||||||
node->table->top = child;
|
node->table->top = child;
|
||||||
|
|
||||||
|
node->table->count--;
|
||||||
|
|
||||||
bgp_node_free (node);
|
bgp_node_free (node);
|
||||||
|
|
||||||
/* If parent node is stub then delete it also. */
|
/* 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);
|
bgp_unlock_node (start);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
unsigned long
|
||||||
|
bgp_table_count (struct bgp_table *table)
|
||||||
|
{
|
||||||
|
return table->count;
|
||||||
|
}
|
||||||
|
|
|
@ -39,6 +39,8 @@ struct bgp_table
|
||||||
void *owner;
|
void *owner;
|
||||||
|
|
||||||
struct bgp_node *top;
|
struct bgp_node *top;
|
||||||
|
|
||||||
|
unsigned long count;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct bgp_node
|
struct bgp_node
|
||||||
|
@ -51,18 +53,16 @@ struct bgp_node
|
||||||
#define l_left link[0]
|
#define l_left link[0]
|
||||||
#define l_right link[1]
|
#define l_right link[1]
|
||||||
|
|
||||||
unsigned int lock;
|
|
||||||
|
|
||||||
void *info;
|
void *info;
|
||||||
|
|
||||||
struct bgp_adj_out *adj_out;
|
struct bgp_adj_out *adj_out;
|
||||||
|
|
||||||
struct bgp_adj_in *adj_in;
|
struct bgp_adj_in *adj_in;
|
||||||
|
|
||||||
void *aggregate;
|
|
||||||
|
|
||||||
struct bgp_node *prn;
|
struct bgp_node *prn;
|
||||||
|
|
||||||
|
unsigned int lock;
|
||||||
|
|
||||||
u_char flags;
|
u_char flags;
|
||||||
#define BGP_NODE_PROCESS_SCHEDULED (1 << 0)
|
#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 *,
|
extern struct bgp_node *bgp_node_match_ipv6 (struct bgp_table *,
|
||||||
struct in6_addr *);
|
struct in6_addr *);
|
||||||
#endif /* HAVE_IPV6 */
|
#endif /* HAVE_IPV6 */
|
||||||
|
extern unsigned long bgp_table_count (struct bgp_table *);
|
||||||
#endif /* _QUAGGA_BGP_TABLE_H */
|
#endif /* _QUAGGA_BGP_TABLE_H */
|
||||||
|
|
Loading…
Reference in a new issue