diff --git a/zebra/zapi_msg.c b/zebra/zapi_msg.c index e9d554ba3d30..89eab4135c9a 100644 --- a/zebra/zapi_msg.c +++ b/zebra/zapi_msg.c @@ -509,7 +509,8 @@ int zsend_interface_update(int cmd, struct zserv *client, struct interface *ifp) return zserv_send_message(client, s); } -int zsend_redistribute_route(int cmd, struct zserv *client, const struct route_node *rn, +int zsend_redistribute_route(int cmd, struct zserv *client, + const struct route_node *rn, const struct route_entry *re, vrf_id_t *to_vrf) { struct zapi_route api; @@ -518,20 +519,24 @@ int zsend_redistribute_route(int cmd, struct zserv *client, const struct route_n const struct prefix *p, *src_p; uint16_t count = 0; afi_t afi; - size_t stream_size = - MAX(ZEBRA_MAX_PACKET_SIZ, sizeof(struct zapi_route)); + size_t stream_size = 0; srcdest_rnode_prefixes(rn, &p, &src_p); memset(&api, 0, sizeof(api)); + /* stream_size += 10; header */ api.vrf_id = re->vrf_id; + /* stream_size += 2; */ api.type = re->type; + /* stream_size += 1; */ api.safi = SAFI_UNICAST; + /* stream_size += 2; */ if (to_vrf != NULL) { api.instance = re->table; api.type = ZEBRA_ROUTE_TABLE_DIRECT; api.vrf_id = *to_vrf; } else api.instance = re->instance; + /* stream_size += 4; */ api.flags = re->flags; afi = family2afi(p->family); @@ -555,6 +560,7 @@ int zsend_redistribute_route(int cmd, struct zserv *client, const struct route_n } /* Prefix. */ + /* stream_size += 18 + 17; */ api.prefix = *p; if (src_p) { SET_FLAG(api.message, ZAPI_MESSAGE_SRCPFX); @@ -567,9 +573,13 @@ int zsend_redistribute_route(int cmd, struct zserv *client, const struct route_n continue; api_nh = &api.nexthops[count]; + /* stream_size += 4; */ api_nh->vrf_id = nexthop->vrf_id; + /* stream_size += 2; */ api_nh->type = nexthop->type; + /* stream_size += 1 + 4; */ api_nh->weight = nexthop->weight; + /* stream_size += 18; */ switch (nexthop->type) { case NEXTHOP_TYPE_BLACKHOLE: api_nh->bh_type = nexthop->bh_type; @@ -591,26 +601,32 @@ int zsend_redistribute_route(int cmd, struct zserv *client, const struct route_n } /* Nexthops. */ + /* stream_size += 2; */ if (count) { SET_FLAG(api.message, ZAPI_MESSAGE_NEXTHOP); api.nexthop_num = count; } /* Attributes. */ + /* stream_size += 1; */ SET_FLAG(api.message, ZAPI_MESSAGE_DISTANCE); if (to_vrf != NULL) api.distance = ZEBRA_TABLEDIRECT_DISTANCE_DEFAULT; else api.distance = re->distance; + /* stream_size += 4; */ SET_FLAG(api.message, ZAPI_MESSAGE_METRIC); api.metric = re->metric; + /* stream_size += 4; */ if (re->tag) { SET_FLAG(api.message, ZAPI_MESSAGE_TAG); api.tag = re->tag; } + /* stream_size += 4; */ SET_FLAG(api.message, ZAPI_MESSAGE_MTU); api.mtu = re->mtu; + stream_size = (69 + (count * 29)); struct stream *s = stream_new(stream_size); /* Encode route and send. */ @@ -1526,6 +1542,7 @@ static void zread_interface_add(ZAPI_HANDLER_ARGS) struct interface *ifp; vrf_id_t vrf_id = zvrf_id(zvrf); + if (vrf_id != VRF_DEFAULT && vrf_id != VRF_UNKNOWN) { FOR_ALL_INTERFACES (zvrf->vrf, ifp) { /* Skip pseudo interface. */