summaryrefslogtreecommitdiff
path: root/bgpd/bgp_packet.c
diff options
context:
space:
mode:
authorPaul Jakma <paul.jakma@sun.com>2007-05-04 20:15:47 +0000
committerPaul Jakma <paul.jakma@sun.com>2007-05-04 20:15:47 +0000
commitfb982c25aa771b7c7425a3c3cce0a2cda0a715de (patch)
tree74aa4dc86b04365d90a1030682796421b0eff011 /bgpd/bgp_packet.c
parent5921ef9aae3b5d6ff8663298f649fb9d76594acd (diff)
[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_packet.c')
-rw-r--r--bgpd/bgp_packet.c20
1 files changed, 12 insertions, 8 deletions
diff --git a/bgpd/bgp_packet.c b/bgpd/bgp_packet.c
index 9859e50b..26532011 100644
--- a/bgpd/bgp_packet.c
+++ b/bgpd/bgp_packet.c
@@ -177,9 +177,9 @@ bgp_update_packet (struct peer *peer, afi_t afi, safi_t safi)
if (rn->prn)
prd = (struct prefix_rd *) &rn->prn->p;
- if (binfo)
+ if (binfo && binfo->extra)
{
- tag = binfo->tag;
+ tag = binfo->extra->tag;
from = binfo->peer;
}
@@ -1706,12 +1706,16 @@ bgp_update_receive (struct peer *peer, bgp_size_t size)
aspath_unintern (attr.aspath);
if (attr.community)
community_unintern (attr.community);
- if (attr.ecommunity)
- ecommunity_unintern (attr.ecommunity);
- if (attr.cluster)
- cluster_unintern (attr.cluster);
- if (attr.transit)
- transit_unintern (attr.transit);
+ if (attr.extra)
+ {
+ if (attr.extra->ecommunity)
+ ecommunity_unintern (attr.extra->ecommunity);
+ if (attr.extra->cluster)
+ cluster_unintern (attr.extra->cluster);
+ if (attr.extra->transit)
+ transit_unintern (attr.extra->transit);
+ bgp_attr_extra_free (&attr);
+ }
/* If peering is stopped due to some reason, do not generate BGP
event. */