diff options
| author | Paul Jakma <paul.jakma@sun.com> | 2007-05-04 20:15:47 +0000 | 
|---|---|---|
| committer | Paul Jakma <paul.jakma@sun.com> | 2007-05-04 20:15:47 +0000 | 
| commit | fb982c25aa771b7c7425a3c3cce0a2cda0a715de (patch) | |
| tree | 74aa4dc86b04365d90a1030682796421b0eff011 /bgpd/bgp_zebra.c | |
| parent | 5921ef9aae3b5d6ff8663298f649fb9d76594acd (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_zebra.c')
| -rw-r--r-- | bgpd/bgp_zebra.c | 26 | 
1 files changed, 15 insertions, 11 deletions
| diff --git a/bgpd/bgp_zebra.c b/bgpd/bgp_zebra.c index 301c15b0..0b6ab45a 100644 --- a/bgpd/bgp_zebra.c +++ b/bgpd/bgp_zebra.c @@ -746,20 +746,22 @@ bgp_zebra_announce (struct prefix *p, struct bgp_info *info, struct bgp *bgp)        ifindex = 0;        nexthop = NULL; - +       +      assert (info->attr->extra); +              /* Only global address nexthop exists. */ -      if (info->attr->mp_nexthop_len == 16) -	nexthop = &info->attr->mp_nexthop_global; +      if (info->attr->extra->mp_nexthop_len == 16) +	nexthop = &info->attr->extra->mp_nexthop_global;        /* If both global and link-local address present. */ -      if (info->attr->mp_nexthop_len == 32) +      if (info->attr->extra->mp_nexthop_len == 32)  	{  	  /* Workaround for Cisco's nexthop bug.  */ -	  if (IN6_IS_ADDR_UNSPECIFIED (&info->attr->mp_nexthop_global) +	  if (IN6_IS_ADDR_UNSPECIFIED (&info->attr->extra->mp_nexthop_global)  	      && peer->su_remote->sa.sa_family == AF_INET6)  	    nexthop = &peer->su_remote->sin6.sin6_addr;  	  else -	    nexthop = &info->attr->mp_nexthop_local; +	    nexthop = &info->attr->extra->mp_nexthop_local;  	  if (info->peer->nexthop.ifp)  	    ifindex = info->peer->nexthop.ifp->ifindex; @@ -867,18 +869,20 @@ bgp_zebra_withdraw (struct prefix *p, struct bgp_info *info)        struct zapi_ipv6 api;        unsigned int ifindex;        struct in6_addr *nexthop; - +       +      assert (info->attr->extra); +              ifindex = 0;        nexthop = NULL;        /* Only global address nexthop exists. */ -      if (info->attr->mp_nexthop_len == 16) -	nexthop = &info->attr->mp_nexthop_global; +      if (info->attr->extra->mp_nexthop_len == 16) +	nexthop = &info->attr->extra->mp_nexthop_global;        /* If both global and link-local address present. */ -      if (info->attr->mp_nexthop_len == 32) +      if (info->attr->extra->mp_nexthop_len == 32)  	{ -	  nexthop = &info->attr->mp_nexthop_local; +	  nexthop = &info->attr->extra->mp_nexthop_local;  	  if (info->peer->nexthop.ifp)  	    ifindex = info->peer->nexthop.ifp->ifindex;  	} | 
