struct zapi_route api;
struct zapi_nexthop *api_nh;
int nh_family;
- int valid_nh_count = 0;
+ unsigned int valid_nh_count = 0;
int has_valid_label = 0;
u_char distance;
struct peer *peer;
/* Metric is currently based on the best-path only */
metric = info->attr->med;
for (mpinfo = info; mpinfo; mpinfo = bgp_info_mpath_next(mpinfo)) {
+ if (valid_nh_count >= multipath_num)
+ break;
+
*mpinfo_cp = *mpinfo;
/* Get nexthop address-family */
/*
* low-level message builder
*/
-static void vnc_zebra_route_msg(struct prefix *p, int nhp_count, void *nhp_ary,
- int add) /* 1 = add, 0 = del */
+static void vnc_zebra_route_msg(struct prefix *p, unsigned int nhp_count,
+ void *nhp_ary, int add) /* 1 = add, 0 = del */
{
struct zapi_route api;
struct zapi_nexthop *api_nh;
/* Nexthops */
SET_FLAG(api.message, ZAPI_MESSAGE_NEXTHOP);
- api.nexthop_num = nhp_count;
- for (i = 0; i < nhp_count; i++) {
+ api.nexthop_num = MIN(nhp_count, multipath_num);
+ for (i = 0; i < api.nexthop_num; i++) {
struct in_addr *nhp_ary4;
struct in6_addr *nhp_ary6;
static void
-nve_list_to_nh_array(u_char family, struct list *nve_list, int *nh_count_ret,
+nve_list_to_nh_array(u_char family, struct list *nve_list,
+ unsigned int *nh_count_ret,
void **nh_ary_ret, /* returned address array */
void **nhp_ary_ret) /* returned pointer array */
{
{
struct list *nves;
- int nexthop_count = 0;
+ unsigned int nexthop_count = 0;
void *nh_ary = NULL;
void *nhp_ary = NULL;
uint8_t family = afi2family(afi);
struct list *nves = NULL;
- int nexthop_count = 0;
+ unsigned int nexthop_count = 0;
void *nh_ary = NULL;
void *nhp_ary = NULL;
memcpy(&api.prefix, p, sizeof(*p));
SET_FLAG(api.message, ZAPI_MESSAGE_NEXTHOP);
- api.nexthop_num = successors->count;
/* Nexthop, ifindex, distance and metric information. */
for (ALL_LIST_ELEMENTS_RO(successors, node, te)) {
+ if (count >= MULTIPATH_NUM)
+ break;
api_nh = &api.nexthops[count];
if (te->adv_router->src.s_addr) {
api_nh->gate.ipv4 = te->adv_router->src;
count++;
}
+ api.nexthop_num = count;
if (IS_DEBUG_EIGRP(zebra, ZEBRA_REDISTRIBUTE)) {
char buf[2][PREFIX_STRLEN];
case AF_INET:
for (ALL_LIST_ELEMENTS_RO(route_info->nexthops, node,
nexthop)) {
+ if (count >= MULTIPATH_NUM)
+ break;
api_nh = &api.nexthops[count];
/* FIXME: can it be ? */
if (nexthop->ip.s_addr != INADDR_ANY) {
case AF_INET6:
for (ALL_LIST_ELEMENTS_RO(route_info->nexthops6, node,
nexthop6)) {
+ if (count >= MULTIPATH_NUM)
+ break;
if (!IN6_IS_ADDR_LINKLOCAL(&nexthop6->ip6)
&& !IN6_IS_ADDR_UNSPECIFIED(&nexthop6->ip6)) {
continue;
prefix2str(&api->prefix, buf, sizeof(buf));
zlog_warn(
- "%s: prefix %s: encoding %u nexthops out of %u",
- __func__, buf, MULTIPATH_NUM, api->nexthop_num);
- api->nexthop_num = MULTIPATH_NUM;
+ "%s: prefix %s: can't encode %u nexthops "
+ "(maximum is %u)",
+ __func__, buf, api->nexthop_num, MULTIPATH_NUM);
+ return -1;
}
stream_putw(s, api->nexthop_num);
api.safi = SAFI_UNICAST;
api.prefix = *dest;
SET_FLAG(api.message, ZAPI_MESSAGE_NEXTHOP);
- api.nexthop_num = nhcount;
- ospf6_route_zebra_copy_nexthops(request, api.nexthops, nhcount);
+ api.nexthop_num = MIN(nhcount, MULTIPATH_NUM);
+ ospf6_route_zebra_copy_nexthops(request, api.nexthops, api.nexthop_num);
SET_FLAG(api.message, ZAPI_MESSAGE_METRIC);
api.metric = (request->path.metric_type == 2 ? request->path.u.cost_e2
: request->path.cost);
memcpy(&api.prefix, p, sizeof(*p));
SET_FLAG(api.message, ZAPI_MESSAGE_NEXTHOP);
- api.nexthop_num = or->paths->count;
/* Metric value. */
SET_FLAG(api.message, ZAPI_MESSAGE_METRIC);
/* Nexthop, ifindex, distance and metric information. */
for (ALL_LIST_ELEMENTS_RO(or->paths, node, path)) {
+ if (count >= MULTIPATH_NUM)
+ break;
api_nh = &api.nexthops[count];
#ifdef HAVE_NETLINK
if (path->unnumbered || (path->nexthop.s_addr != INADDR_ANY
path->ifindex);
}
}
+ api.nexthop_num = count;
zclient_route_send(ZEBRA_ROUTE_ADD, zclient, &api);
}
SET_FLAG(api.message, ZAPI_MESSAGE_NEXTHOP);
for (ALL_LIST_ELEMENTS_RO(list, listnode, rinfo)) {
+ if (count >= MULTIPATH_NUM)
+ break;
api_nh = &api.nexthops[count];
api_nh->gate.ipv4 = rinfo->nexthop;
api_nh->type = NEXTHOP_TYPE_IPV4;
SET_FLAG(api.message, ZAPI_MESSAGE_NEXTHOP);
for (ALL_LIST_ELEMENTS_RO(list, listnode, rinfo)) {
+ if (count >= MULTIPATH_NUM)
+ break;
api_nh = &api.nexthops[count];
api_nh->gate.ipv6 = rinfo->nexthop;
api_nh->ifindex = rinfo->ifindex;