summaryrefslogtreecommitdiffstats
path: root/bgpd/bgp_debug.c
diff options
context:
space:
mode:
authorpaul <paul>2007-05-04 20:15:47 +0000
committerpaul <paul>2007-05-04 20:15:47 +0000
commitd8e8016594f87bbdd3bbb1737a95c39c6e951ede (patch)
tree0428400b6e642f23f31e8872ea395fef5474b2f2 /bgpd/bgp_debug.c
parent966ae8fbe216e9bef19f709168638ee3ba735092 (diff)
downloadquagga-d8e8016594f87bbdd3bbb1737a95c39c6e951ede.tar.bz2
quagga-d8e8016594f87bbdd3bbb1737a95c39c6e951ede.tar.xz
[bgpd] Trim memory usage of BGP routes
2007-05-03 Paul Jakma <paul.jakma@sun.com> * bgp_route.h: (struct info) Move less frequently used fields to a lazily allocated struct info_extra. Export bgp_info_extra_get * bgp_route.c: (bgp_info_extra_new) allocate extra (bgp_info_extra_free) Free damp info and the info_extra. (bgp_info_extra_get) Retrieve the info_extra of a struct info, allocating as required. (generally) adjust to use info->extra * bgp_damp.c: (generally) use bgp_info_extra_get to access dampinfo * bgp_attr.h: Move rarely allocated attributes from struct attr to a struct attr_extra, for a substantial saving in size of struct attr. * bgp_attr.c: (bgp_attr_extra_{new,free}), new, self-explanatory. (bgp_attr_extra_get) Get the attr_extra for a given struct attr, allocating it if needs be. (bgp_attr_dup) Shallow copy the struct attr and its attr_extra. (generally) adjust to know about attr->extra. * bgp_debug.c: (bgp_dump_attr) ditto * bgp_vty.c: (show_bgp_memory) print attr and info extra sizes. * bgp_nexthop.c: (generally) adjust to know about attr->extra and info->extra. * bgp_{packet,routemap,snmp,zebra}.c: ditto * lib/memtypes.c: Add MTYPE_ATTR_EXTRA and MTYPE_BGP_ROUTE_EXTRA
Diffstat (limited to 'bgpd/bgp_debug.c')
-rw-r--r--bgpd/bgp_debug.c39
1 files changed, 21 insertions, 18 deletions
diff --git a/bgpd/bgp_debug.c b/bgpd/bgp_debug.c
index 1986b35b..60284a2d 100644
--- a/bgpd/bgp_debug.c
+++ b/bgpd/bgp_debug.c
@@ -176,20 +176,22 @@ bgp_dump_attr (struct peer *peer, struct attr *attr, char *buf, size_t size)
bgp_origin_str[attr->origin]);
#ifdef HAVE_IPV6
- {
- char addrbuf[BUFSIZ];
-
- /* Add MP case. */
- if (attr->mp_nexthop_len == 16 || attr->mp_nexthop_len == 32)
- snprintf (buf + strlen (buf), size - strlen (buf), ", mp_nexthop %s",
- inet_ntop (AF_INET6, &attr->mp_nexthop_global,
- addrbuf, BUFSIZ));
-
- if (attr->mp_nexthop_len == 32)
- snprintf (buf + strlen (buf), size - strlen (buf), "(%s)",
- inet_ntop (AF_INET6, &attr->mp_nexthop_local,
- addrbuf, BUFSIZ));
- }
+ if (attr->extra)
+ {
+ char addrbuf[BUFSIZ];
+
+ /* Add MP case. */
+ if (attr->extra->mp_nexthop_len == 16
+ || attr->extra->mp_nexthop_len == 32)
+ snprintf (buf + strlen (buf), size - strlen (buf), ", mp_nexthop %s",
+ inet_ntop (AF_INET6, &attr->extra->mp_nexthop_global,
+ addrbuf, BUFSIZ));
+
+ if (attr->extra->mp_nexthop_len == 32)
+ snprintf (buf + strlen (buf), size - strlen (buf), "(%s)",
+ inet_ntop (AF_INET6, &attr->extra->mp_nexthop_local,
+ addrbuf, BUFSIZ));
+ }
#endif /* HAVE_IPV6 */
if (CHECK_FLAG (attr->flag, ATTR_FLAG_BIT (BGP_ATTR_LOCAL_PREF)))
@@ -209,20 +211,21 @@ bgp_dump_attr (struct peer *peer, struct attr *attr, char *buf, size_t size)
if (CHECK_FLAG (attr->flag, ATTR_FLAG_BIT (BGP_ATTR_AGGREGATOR)))
snprintf (buf + strlen (buf), size - strlen (buf), ", aggregated by %d %s",
- attr->aggregator_as, inet_ntoa (attr->aggregator_addr));
+ attr->extra->aggregator_as,
+ inet_ntoa (attr->extra->aggregator_addr));
if (CHECK_FLAG (attr->flag, ATTR_FLAG_BIT (BGP_ATTR_ORIGINATOR_ID)))
snprintf (buf + strlen (buf), size - strlen (buf), ", originator %s",
- inet_ntoa (attr->originator_id));
+ inet_ntoa (attr->extra->originator_id));
if (CHECK_FLAG (attr->flag, ATTR_FLAG_BIT (BGP_ATTR_CLUSTER_LIST)))
{
int i;
snprintf (buf + strlen (buf), size - strlen (buf), ", clusterlist");
- for (i = 0; i < attr->cluster->length / 4; i++)
+ for (i = 0; i < attr->extra->cluster->length / 4; i++)
snprintf (buf + strlen (buf), size - strlen (buf), " %s",
- inet_ntoa (attr->cluster->list[i]));
+ inet_ntoa (attr->extra->cluster->list[i]));
}
if (CHECK_FLAG (attr->flag, ATTR_FLAG_BIT (BGP_ATTR_AS_PATH)))