summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--bgpd/bgp_main.c6
-rw-r--r--bgpd/bgp_zebra.c94
-rw-r--r--bgpd/bgp_zebra.h8
3 files changed, 14 insertions, 94 deletions
diff --git a/bgpd/bgp_main.c b/bgpd/bgp_main.c
index 9fcbff0f53..b4d71f78d2 100644
--- a/bgpd/bgp_main.c
+++ b/bgpd/bgp_main.c
@@ -232,12 +232,6 @@ bgp_exit (int status)
vnc_zebra_destroy();
#endif
bgp_zebra_destroy();
- if (bgp_nexthop_buf)
- stream_free (bgp_nexthop_buf);
- if (bgp_ifindices_buf)
- stream_free (bgp_ifindices_buf);
- if (bgp_label_buf)
- stream_free (bgp_label_buf);
/* reverse bgp_master_init */
if (bm->master)
diff --git a/bgpd/bgp_zebra.c b/bgpd/bgp_zebra.c
index 4fff339b85..adf6f89aac 100644
--- a/bgpd/bgp_zebra.c
+++ b/bgpd/bgp_zebra.c
@@ -1222,8 +1222,7 @@ bgp_zebra_announce (struct bgp_node *rn, struct prefix *p, struct bgp_info *info
u_char distance;
struct peer *peer;
struct bgp_info *mpinfo;
- size_t oldsize, newsize;
- u_int32_t nhcount, metric;
+ u_int32_t metric;
struct bgp_info local_info;
struct bgp_info *info_cp = &local_info;
route_tag_t tag;
@@ -1270,8 +1269,6 @@ bgp_zebra_announce (struct bgp_node *rn, struct prefix *p, struct bgp_info *info
SET_FLAG (flags, ZEBRA_FLAG_INTERNAL);
- nhcount = 1 + bgp_info_mpath_count (info);
-
if (p->family == AF_INET && !BGP_ATTR_NEXTHOP_AFI_IP6(info->attr))
{
struct zapi_ipv4 api;
@@ -1280,38 +1277,10 @@ bgp_zebra_announce (struct bgp_node *rn, struct prefix *p, struct bgp_info *info
int valid_nh_count = 0;
/* resize nexthop buffer size if necessary */
- if ((oldsize = stream_get_size (bgp_nexthop_buf)) <
- (sizeof (struct in_addr *) * nhcount))
- {
- newsize = sizeof (struct in_addr *) * nhcount;
- newsize = stream_resize (bgp_nexthop_buf, newsize);
- if (newsize == oldsize)
- {
- zlog_err ("can't resize nexthop buffer");
- return;
- }
- }
stream_reset (bgp_nexthop_buf);
nexthop = NULL;
- /* For labeled unicast, each nexthop has a label too. Resize label
- * buffer, if required.
- */
- if (safi == SAFI_LABELED_UNICAST)
- {
- if ((oldsize = stream_get_size (bgp_label_buf)) <
- (sizeof (unsigned int) * nhcount))
- {
- newsize = (sizeof (unsigned int) * nhcount);
- newsize = stream_resize (bgp_label_buf, newsize);
- if (newsize == oldsize)
- {
- zlog_err ("can't resize label buffer");
- return;
- }
- }
- stream_reset (bgp_label_buf);
- }
+ stream_reset (bgp_label_buf);
/* Metric is currently based on the best-path only. */
metric = info->attr->med;
@@ -1464,52 +1433,9 @@ bgp_zebra_announce (struct bgp_node *rn, struct prefix *p, struct bgp_info *info
int valid_nh_count = 0;
char buf[2][INET6_ADDRSTRLEN];
- /* resize nexthop buffer size if necessary */
- if ((oldsize = stream_get_size (bgp_nexthop_buf)) <
- (sizeof (struct in6_addr *) * nhcount))
- {
- newsize = (sizeof (struct in6_addr *) * nhcount);
- newsize = stream_resize (bgp_nexthop_buf, newsize);
- if (newsize == oldsize)
- {
- zlog_err ("can't resize nexthop buffer");
- return;
- }
- }
stream_reset (bgp_nexthop_buf);
-
- /* resize ifindices buffer size if necessary */
- if ((oldsize = stream_get_size (bgp_ifindices_buf)) <
- (sizeof (unsigned int) * nhcount))
- {
- newsize = (sizeof (unsigned int) * nhcount);
- newsize = stream_resize (bgp_ifindices_buf, newsize);
- if (newsize == oldsize)
- {
- zlog_err ("can't resize nexthop buffer");
- return;
- }
- }
stream_reset (bgp_ifindices_buf);
-
- /* For labeled unicast, each nexthop has a label too. Resize label
- * buffer, if required.
- */
- if (safi == SAFI_LABELED_UNICAST)
- {
- if ((oldsize = stream_get_size (bgp_label_buf)) <
- (sizeof (unsigned int) * nhcount))
- {
- newsize = (sizeof (unsigned int) * nhcount);
- newsize = stream_resize (bgp_label_buf, newsize);
- if (newsize == oldsize)
- {
- zlog_err ("can't resize label buffer");
- return;
- }
- }
- stream_reset (bgp_label_buf);
- }
+ stream_reset (bgp_label_buf);
ifindex = 0;
nexthop = NULL;
@@ -2270,14 +2196,22 @@ bgp_zebra_init (struct thread_master *master)
zclient->import_check_update = bgp_read_import_check_update;
zclient->fec_update = bgp_read_fec_update;
- bgp_nexthop_buf = stream_new(BGP_NEXTHOP_BUF_SIZE);
- bgp_ifindices_buf = stream_new(BGP_IFINDICES_BUF_SIZE);
- bgp_label_buf = stream_new(BGP_LABEL_BUF_SIZE);
+ bgp_nexthop_buf = stream_new(multipath_num * sizeof (struct in6_addr));
+ bgp_ifindices_buf = stream_new(multipath_num * sizeof (unsigned int));
+ bgp_label_buf = stream_new(multipath_num * sizeof (unsigned int));
}
void
bgp_zebra_destroy(void)
{
+
+ if (bgp_nexthop_buf)
+ stream_free (bgp_nexthop_buf);
+ if (bgp_ifindices_buf)
+ stream_free (bgp_ifindices_buf);
+ if (bgp_label_buf)
+ stream_free (bgp_label_buf);
+
if (zclient == NULL)
return;
zclient_stop(zclient);
diff --git a/bgpd/bgp_zebra.h b/bgpd/bgp_zebra.h
index 6a36fb84f7..3d634ed695 100644
--- a/bgpd/bgp_zebra.h
+++ b/bgpd/bgp_zebra.h
@@ -21,14 +21,6 @@
#ifndef _QUAGGA_BGP_ZEBRA_H
#define _QUAGGA_BGP_ZEBRA_H
-#define BGP_NEXTHOP_BUF_SIZE (8 * sizeof (struct in_addr *))
-#define BGP_IFINDICES_BUF_SIZE (8 * sizeof (unsigned int))
-#define BGP_LABEL_BUF_SIZE (8 * sizeof (unsigned int))
-
-extern struct stream *bgp_nexthop_buf;
-extern struct stream *bgp_ifindices_buf;
-extern struct stream *bgp_label_buf;
-
extern void bgp_zebra_init (struct thread_master *master);
extern void bgp_zebra_destroy (void);
extern int bgp_if_update_all (void);