int psize;
struct stream *s;
- if (zclient->redist[AFI_IP][ZEBRA_ROUTE_EIGRP]) {
- message = 0;
- flags = 0;
-
- /* EIGRP pass nexthop and metric */
- SET_FLAG(message, ZAPI_MESSAGE_NEXTHOP);
-
- /* Make packet. */
- s = zclient->obuf;
- stream_reset(s);
-
- /* Put command, type, flags, message. */
- zclient_create_header(s, ZEBRA_IPV4_ROUTE_ADD, VRF_DEFAULT);
- stream_putc(s, ZEBRA_ROUTE_EIGRP);
- stream_putw(s, 0);
- stream_putl(s, flags);
- stream_putc(s, message);
- stream_putw(s, SAFI_UNICAST);
-
- /* Put prefix information. */
- psize = PSIZE(p->prefixlen);
- stream_putc(s, p->prefixlen);
- stream_write(s, (u_char *)&p->prefix, psize);
-
- /* Nexthop count. */
- stream_putc(s, successors->count);
-
- /* Nexthop, ifindex, distance and metric information. */
- for (ALL_LIST_ELEMENTS_RO(successors, node, te)) {
- if (te->adv_router->src.s_addr) {
- stream_putc(s, NEXTHOP_TYPE_IPV4_IFINDEX);
- stream_put_in_addr(s, &te->adv_router->src);
- } else
- stream_putc(s, NEXTHOP_TYPE_IFINDEX);
- stream_putl(s, te->ei->ifp->ifindex);
- }
+ if (!zclient->redist[AFI_IP][ZEBRA_ROUTE_EIGRP])
+ return;
+
+ message = 0;
+ flags = 0;
+
+ /* EIGRP pass nexthop and metric */
+ SET_FLAG(message, ZAPI_MESSAGE_NEXTHOP);
+
+ /* Make packet. */
+ s = zclient->obuf;
+ stream_reset(s);
+
+ /* Put command, type, flags, message. */
+ zclient_create_header(s, ZEBRA_IPV4_ROUTE_ADD, VRF_DEFAULT);
+ stream_putc(s, ZEBRA_ROUTE_EIGRP);
+ stream_putw(s, 0);
+ stream_putl(s, flags);
+ stream_putc(s, message);
+ stream_putw(s, SAFI_UNICAST);
+
+ /* Put prefix information. */
+ psize = PSIZE(p->prefixlen);
+ stream_putc(s, p->prefixlen);
+ stream_write(s, (u_char *)&p->prefix, psize);
+
+ /* Nexthop count. */
+ stream_putc(s, successors->count);
+
+ /* Nexthop, ifindex, distance and metric information. */
+ for (ALL_LIST_ELEMENTS_RO(successors, node, te)) {
+ if (te->adv_router->src.s_addr) {
+ stream_putc(s, NEXTHOP_TYPE_IPV4_IFINDEX);
+ stream_put_in_addr(s, &te->adv_router->src);
+ } else
+ stream_putc(s, NEXTHOP_TYPE_IFINDEX);
+ stream_putl(s, te->ei->ifp->ifindex);
+ }
- if (IS_DEBUG_EIGRP(zebra, ZEBRA_REDISTRIBUTE)) {
- char buf[2][INET_ADDRSTRLEN];
- zlog_debug("Zebra: Route add %s/%d nexthop %s",
- inet_ntop(AF_INET, &p->prefix, buf[0],
- sizeof(buf[0])),
- p->prefixlen,
- inet_ntop(AF_INET, 0 /*&p->nexthop*/, buf[1],
- sizeof(buf[1])));
- }
+ if (IS_DEBUG_EIGRP(zebra, ZEBRA_REDISTRIBUTE)) {
+ char buf[2][INET_ADDRSTRLEN];
+ zlog_debug("Zebra: Route add %s/%d nexthop %s",
+ inet_ntop(AF_INET, &p->prefix, buf[0],
+ sizeof(buf[0])),
+ p->prefixlen,
+ inet_ntop(AF_INET, 0 /*&p->nexthop*/, buf[1],
+ sizeof(buf[1])));
+ }
- stream_putw_at(s, 0, stream_get_endp(s));
+ stream_putw_at(s, 0, stream_get_endp(s));
- zclient_send_message(zclient);
- }
+ zclient_send_message(zclient);
}
void eigrp_zebra_route_delete(struct prefix_ipv4 *p)
{
struct zapi_ipv4 api;
- if (zclient->redist[AFI_IP][ZEBRA_ROUTE_EIGRP]) {
- api.vrf_id = VRF_DEFAULT;
- api.type = ZEBRA_ROUTE_EIGRP;
- api.instance = 0;
- api.flags = 0;
- api.message = 0;
- api.safi = SAFI_UNICAST;
- zapi_ipv4_route(ZEBRA_IPV4_ROUTE_DELETE, zclient, p, &api);
-
- if (IS_DEBUG_EIGRP(zebra, ZEBRA_REDISTRIBUTE)) {
- char buf[2][INET_ADDRSTRLEN];
- zlog_debug("Zebra: Route del %s/%d nexthop %s",
- inet_ntop(AF_INET, &p->prefix, buf[0],
- sizeof(buf[0])),
- p->prefixlen,
- inet_ntop(AF_INET, 0 /*&p->nexthop*/, buf[1],
- sizeof(buf[1])));
- }
+ if (!zclient->redist[AFI_IP][ZEBRA_ROUTE_EIGRP])
+ return;
+
+ api.vrf_id = VRF_DEFAULT;
+ api.type = ZEBRA_ROUTE_EIGRP;
+ api.instance = 0;
+ api.flags = 0;
+ api.message = 0;
+ api.safi = SAFI_UNICAST;
+ zapi_ipv4_route(ZEBRA_IPV4_ROUTE_DELETE, zclient, p, &api);
+
+ if (IS_DEBUG_EIGRP(zebra, ZEBRA_REDISTRIBUTE)) {
+ char buf[2][INET_ADDRSTRLEN];
+ zlog_debug("Zebra: Route del %s/%d nexthop %s",
+ inet_ntop(AF_INET, &p->prefix, buf[0],
+ sizeof(buf[0])),
+ p->prefixlen,
+ inet_ntop(AF_INET, 0 /*&p->nexthop*/, buf[1],
+ sizeof(buf[1])));
}
return;
if (CHECK_FLAG(route_info->flag, ISIS_ROUTE_FLAG_ZEBRA_SYNCED))
return;
- if (vrf_bitmap_check(zclient->redist[AFI_IP][ZEBRA_ROUTE_ISIS],
- VRF_DEFAULT)) {
- message = 0;
- flags = 0;
+ if (!vrf_bitmap_check(zclient->redist[AFI_IP][ZEBRA_ROUTE_ISIS],
+ VRF_DEFAULT))
+ return;
+
+ message = 0;
+ flags = 0;
- SET_FLAG(message, ZAPI_MESSAGE_NEXTHOP);
- SET_FLAG(message, ZAPI_MESSAGE_METRIC);
+ SET_FLAG(message, ZAPI_MESSAGE_NEXTHOP);
+ SET_FLAG(message, ZAPI_MESSAGE_METRIC);
#if 0
- SET_FLAG (message, ZAPI_MESSAGE_DISTANCE);
+ SET_FLAG (message, ZAPI_MESSAGE_DISTANCE);
#endif
- stream = zclient->obuf;
- stream_reset(stream);
- zclient_create_header(stream, ZEBRA_IPV4_ROUTE_ADD,
- VRF_DEFAULT);
- /* type */
- stream_putc(stream, ZEBRA_ROUTE_ISIS);
- /* instance */
- stream_putw(stream, 0);
- /* flags */
- stream_putl(stream, flags);
- /* message */
- stream_putc(stream, message);
- /* SAFI */
- stream_putw(stream, SAFI_UNICAST);
- /* prefix information */
- psize = PSIZE(prefix->prefixlen);
- stream_putc(stream, prefix->prefixlen);
- stream_write(stream, (u_char *)&prefix->u.prefix4, psize);
-
- stream_putc(stream, listcount(route_info->nexthops));
-
- /* Nexthop, ifindex, distance and metric information */
- for (ALL_LIST_ELEMENTS_RO(route_info->nexthops, node,
- nexthop)) {
- /* FIXME: can it be ? */
- if (nexthop->ip.s_addr != INADDR_ANY) {
- stream_putc(stream, NEXTHOP_TYPE_IPV4_IFINDEX);
- stream_put_in_addr(stream, &nexthop->ip);
- stream_putl(stream, nexthop->ifindex);
- } else {
- stream_putc(stream, NEXTHOP_TYPE_IFINDEX);
- stream_putl(stream, nexthop->ifindex);
- }
+ stream = zclient->obuf;
+ stream_reset(stream);
+ zclient_create_header(stream, ZEBRA_IPV4_ROUTE_ADD, VRF_DEFAULT);
+ /* type */
+ stream_putc(stream, ZEBRA_ROUTE_ISIS);
+ /* instance */
+ stream_putw(stream, 0);
+ /* flags */
+ stream_putl(stream, flags);
+ /* message */
+ stream_putc(stream, message);
+ /* SAFI */
+ stream_putw(stream, SAFI_UNICAST);
+ /* prefix information */
+ psize = PSIZE(prefix->prefixlen);
+ stream_putc(stream, prefix->prefixlen);
+ stream_write(stream, (u_char *)&prefix->u.prefix4, psize);
+
+ stream_putc(stream, listcount(route_info->nexthops));
+
+ /* Nexthop, ifindex, distance and metric information */
+ for (ALL_LIST_ELEMENTS_RO(route_info->nexthops, node, nexthop)) {
+ /* FIXME: can it be ? */
+ if (nexthop->ip.s_addr != INADDR_ANY) {
+ stream_putc(stream, NEXTHOP_TYPE_IPV4_IFINDEX);
+ stream_put_in_addr(stream, &nexthop->ip);
+ stream_putl(stream, nexthop->ifindex);
+ } else {
+ stream_putc(stream, NEXTHOP_TYPE_IFINDEX);
+ stream_putl(stream, nexthop->ifindex);
}
+ }
#if 0
- if (CHECK_FLAG (message, ZAPI_MESSAGE_DISTANCE))
- stream_putc (stream, route_info->depth);
+ if (CHECK_FLAG (message, ZAPI_MESSAGE_DISTANCE))
+ stream_putc (stream, route_info->depth);
#endif
- if (CHECK_FLAG(message, ZAPI_MESSAGE_METRIC))
- stream_putl(stream, route_info->cost);
+ if (CHECK_FLAG(message, ZAPI_MESSAGE_METRIC))
+ stream_putl(stream, route_info->cost);
- stream_putw_at(stream, 0, stream_get_endp(stream));
- zclient_send_message(zclient);
- SET_FLAG(route_info->flag, ISIS_ROUTE_FLAG_ZEBRA_SYNCED);
- UNSET_FLAG(route_info->flag, ISIS_ROUTE_FLAG_ZEBRA_RESYNC);
- }
+ stream_putw_at(stream, 0, stream_get_endp(stream));
+ zclient_send_message(zclient);
+ SET_FLAG(route_info->flag, ISIS_ROUTE_FLAG_ZEBRA_SYNCED);
+ UNSET_FLAG(route_info->flag, ISIS_ROUTE_FLAG_ZEBRA_RESYNC);
}
static void isis_zebra_route_del_ipv4(struct prefix *prefix,
struct zapi_ipv4 api;
struct prefix_ipv4 prefix4;
- if (vrf_bitmap_check(zclient->redist[AFI_IP][ZEBRA_ROUTE_ISIS],
- VRF_DEFAULT)) {
- api.vrf_id = VRF_DEFAULT;
- api.type = ZEBRA_ROUTE_ISIS;
- api.instance = 0;
- api.flags = 0;
- api.message = 0;
- api.safi = SAFI_UNICAST;
- prefix4.family = AF_INET;
- prefix4.prefixlen = prefix->prefixlen;
- prefix4.prefix = prefix->u.prefix4;
- zapi_ipv4_route(ZEBRA_IPV4_ROUTE_DELETE, zclient, &prefix4,
- &api);
- }
UNSET_FLAG(route_info->flag, ISIS_ROUTE_FLAG_ZEBRA_SYNCED);
- return;
+ if (!vrf_bitmap_check(zclient->redist[AFI_IP][ZEBRA_ROUTE_ISIS],
+ VRF_DEFAULT))
+ return;
+
+ api.vrf_id = VRF_DEFAULT;
+ api.type = ZEBRA_ROUTE_ISIS;
+ api.instance = 0;
+ api.flags = 0;
+ api.message = 0;
+ api.safi = SAFI_UNICAST;
+ prefix4.family = AF_INET;
+ prefix4.prefixlen = prefix->prefixlen;
+ prefix4.prefix = prefix->u.prefix4;
+ zapi_ipv4_route(ZEBRA_IPV4_ROUTE_DELETE, zclient, &prefix4, &api);
}
static void isis_zebra_route_add_ipv6(struct prefix *prefix,
SET_FLAG(api.message, ZAPI_MESSAGE_METRIC);
api.metric = route_info->cost;
#if 0
- SET_FLAG (api.message, ZAPI_MESSAGE_DISTANCE);
- api.distance = route_info->depth;
+ SET_FLAG (api.message, ZAPI_MESSAGE_DISTANCE);
+ api.distance = route_info->depth;
#endif
api.nexthop_num = listcount(route_info->nexthops6);
api.ifindex_num = listcount(route_info->nexthops6);
char buf[INET6_ADDRSTRLEN];
struct prefix_ipv6 *dest;
- if (vrf_bitmap_check(zclient->redist[AFI_IP6][ZEBRA_ROUTE_OSPF6],
- VRF_DEFAULT)) {
- if (!CHECK_FLAG(request->flag, OSPF6_ROUTE_BLACKHOLE_ADDED)) {
- api.vrf_id = VRF_DEFAULT;
- api.type = ZEBRA_ROUTE_OSPF6;
- api.flags = ZEBRA_FLAG_BLACKHOLE;
- api.instance = 0;
- api.message = 0;
- api.safi = SAFI_UNICAST;
- SET_FLAG(api.message, ZAPI_MESSAGE_NEXTHOP);
- api.nexthop_num = 0;
- api.ifindex_num = 0;
-
- dest = (struct prefix_ipv6 *)&request->prefix;
-
- zapi_ipv6_route(ZEBRA_IPV6_ROUTE_ADD, zclient, dest,
- NULL, &api);
-
- if (IS_OSPF6_DEBUG_ZEBRA(SEND))
- zlog_debug("Zebra: Route add discard %s/%d",
- inet_ntop(AF_INET6, &dest->prefix,
- buf, INET6_ADDRSTRLEN),
- dest->prefixlen);
- SET_FLAG(request->flag, OSPF6_ROUTE_BLACKHOLE_ADDED);
- } else {
- dest = (struct prefix_ipv6 *)&request->prefix;
-
- if (IS_OSPF6_DEBUG_ZEBRA(SEND))
- zlog_debug(
- "Zebra: Blackhole route present already %s/%d",
- inet_ntop(AF_INET6, &dest->prefix, buf,
- INET6_ADDRSTRLEN),
- dest->prefixlen);
- }
+ if (!vrf_bitmap_check(zclient->redist[AFI_IP6][ZEBRA_ROUTE_OSPF6],
+ VRF_DEFAULT))
+ return;
+
+ if (!CHECK_FLAG(request->flag, OSPF6_ROUTE_BLACKHOLE_ADDED)) {
+ api.vrf_id = VRF_DEFAULT;
+ api.type = ZEBRA_ROUTE_OSPF6;
+ api.flags = ZEBRA_FLAG_BLACKHOLE;
+ api.instance = 0;
+ api.message = 0;
+ api.safi = SAFI_UNICAST;
+ SET_FLAG(api.message, ZAPI_MESSAGE_NEXTHOP);
+ api.nexthop_num = 0;
+ api.ifindex_num = 0;
+
+ dest = (struct prefix_ipv6 *)&request->prefix;
+
+ zapi_ipv6_route(ZEBRA_IPV6_ROUTE_ADD, zclient, dest, NULL,
+ &api);
+
+ if (IS_OSPF6_DEBUG_ZEBRA(SEND))
+ zlog_debug("Zebra: Route add discard %s/%d",
+ inet_ntop(AF_INET6, &dest->prefix, buf,
+ INET6_ADDRSTRLEN),
+ dest->prefixlen);
+
+ SET_FLAG(request->flag, OSPF6_ROUTE_BLACKHOLE_ADDED);
+ } else {
+ dest = (struct prefix_ipv6 *)&request->prefix;
+
+ if (IS_OSPF6_DEBUG_ZEBRA(SEND))
+ zlog_debug(
+ "Zebra: Blackhole route present already %s/%d",
+ inet_ntop(AF_INET6, &dest->prefix, buf,
+ INET6_ADDRSTRLEN),
+ dest->prefixlen);
}
}
char buf[INET6_ADDRSTRLEN];
struct prefix_ipv6 *dest;
- if (vrf_bitmap_check(zclient->redist[AFI_IP6][ZEBRA_ROUTE_OSPF6],
- VRF_DEFAULT)) {
- if (CHECK_FLAG(request->flag, OSPF6_ROUTE_BLACKHOLE_ADDED)) {
- api.vrf_id = VRF_DEFAULT;
- api.type = ZEBRA_ROUTE_OSPF6;
- api.flags = ZEBRA_FLAG_BLACKHOLE;
- api.instance = 0;
- api.message = 0;
- api.safi = SAFI_UNICAST;
- SET_FLAG(api.message, ZAPI_MESSAGE_NEXTHOP);
- api.nexthop_num = 0;
- api.ifindex_num = 0;
-
- dest = (struct prefix_ipv6 *)&request->prefix;
-
- zapi_ipv6_route(ZEBRA_IPV6_ROUTE_DELETE, zclient, dest,
- NULL, &api);
-
- if (IS_OSPF6_DEBUG_ZEBRA(SEND))
- zlog_debug("Zebra: Route delete discard %s/%d",
- inet_ntop(AF_INET6, &dest->prefix,
- buf, INET6_ADDRSTRLEN),
- dest->prefixlen);
- UNSET_FLAG(request->flag, OSPF6_ROUTE_BLACKHOLE_ADDED);
- } else {
- dest = (struct prefix_ipv6 *)&request->prefix;
- if (IS_OSPF6_DEBUG_ZEBRA(SEND))
- zlog_debug(
- "Zebra: Blackhole route already deleted %s/%d",
- inet_ntop(AF_INET6, &dest->prefix, buf,
- INET6_ADDRSTRLEN),
- dest->prefixlen);
- }
+ if (!vrf_bitmap_check(zclient->redist[AFI_IP6][ZEBRA_ROUTE_OSPF6],
+ VRF_DEFAULT))
+ return;
+
+ if (CHECK_FLAG(request->flag, OSPF6_ROUTE_BLACKHOLE_ADDED)) {
+ api.vrf_id = VRF_DEFAULT;
+ api.type = ZEBRA_ROUTE_OSPF6;
+ api.flags = ZEBRA_FLAG_BLACKHOLE;
+ api.instance = 0;
+ api.message = 0;
+ api.safi = SAFI_UNICAST;
+ SET_FLAG(api.message, ZAPI_MESSAGE_NEXTHOP);
+ api.nexthop_num = 0;
+ api.ifindex_num = 0;
+
+ dest = (struct prefix_ipv6 *)&request->prefix;
+
+ zapi_ipv6_route(ZEBRA_IPV6_ROUTE_DELETE, zclient, dest, NULL,
+ &api);
+
+ if (IS_OSPF6_DEBUG_ZEBRA(SEND))
+ zlog_debug("Zebra: Route delete discard %s/%d",
+ inet_ntop(AF_INET6, &dest->prefix, buf,
+ INET6_ADDRSTRLEN),
+ dest->prefixlen);
+
+ UNSET_FLAG(request->flag, OSPF6_ROUTE_BLACKHOLE_ADDED);
+ } else {
+ dest = (struct prefix_ipv6 *)&request->prefix;
+ if (IS_OSPF6_DEBUG_ZEBRA(SEND))
+ zlog_debug(
+ "Zebra: Blackhole route already deleted %s/%d",
+ inet_ntop(AF_INET6, &dest->prefix, buf,
+ INET6_ADDRSTRLEN),
+ dest->prefixlen);
}
}
struct listnode *node;
struct ospf *ospf = ospf_lookup();
- if ((ospf->instance
- && redist_check_instance(
- &zclient->mi_redist[AFI_IP][ZEBRA_ROUTE_OSPF],
- ospf->instance))
- || vrf_bitmap_check(zclient->redist[AFI_IP][ZEBRA_ROUTE_OSPF],
- VRF_DEFAULT)) {
- message = 0;
- flags = 0;
-
- /* OSPF pass nexthop and metric */
- SET_FLAG(message, ZAPI_MESSAGE_NEXTHOP);
- SET_FLAG(message, ZAPI_MESSAGE_METRIC);
-
- /* Distance value. */
- distance = ospf_distance_apply(p, or);
- if (distance)
- SET_FLAG(message, ZAPI_MESSAGE_DISTANCE);
-
- /* Check if path type is ASE */
- if (((or->path_type == OSPF_PATH_TYPE1_EXTERNAL)
- || (or->path_type == OSPF_PATH_TYPE2_EXTERNAL))
- && (or->u.ext.tag > 0) && (or->u.ext.tag <= ROUTE_TAG_MAX))
- SET_FLAG(message, ZAPI_MESSAGE_TAG);
-
- /* Make packet. */
- s = zclient->obuf;
- stream_reset(s);
-
- /* Put command, type, flags, message. */
- zclient_create_header(s, ZEBRA_IPV4_ROUTE_ADD, VRF_DEFAULT);
- stream_putc(s, ZEBRA_ROUTE_OSPF);
- stream_putw(s, ospf->instance);
- stream_putl(s, flags);
- stream_putc(s, message);
- stream_putw(s, SAFI_UNICAST);
-
- /* Put prefix information. */
- psize = PSIZE(p->prefixlen);
- stream_putc(s, p->prefixlen);
- stream_write(s, (u_char *)&p->prefix, psize);
-
- /* Nexthop count. */
- stream_putc(s, or->paths->count);
-
- /* Nexthop, ifindex, distance and metric information. */
- for (ALL_LIST_ELEMENTS_RO(or->paths, node, path)) {
+ if (!(ospf->instance
+ && redist_check_instance(
+ &zclient->mi_redist[AFI_IP][ZEBRA_ROUTE_OSPF],
+ ospf->instance))
+ && !vrf_bitmap_check(zclient->redist[AFI_IP][ZEBRA_ROUTE_OSPF],
+ VRF_DEFAULT))
+ return;
+
+ message = 0;
+ flags = 0;
+
+ /* OSPF pass nexthop and metric */
+ SET_FLAG(message, ZAPI_MESSAGE_NEXTHOP);
+ SET_FLAG(message, ZAPI_MESSAGE_METRIC);
+
+ /* Distance value. */
+ distance = ospf_distance_apply(p, or);
+ if (distance)
+ SET_FLAG(message, ZAPI_MESSAGE_DISTANCE);
+
+ /* Check if path type is ASE */
+ if (((or->path_type == OSPF_PATH_TYPE1_EXTERNAL)
+ || (or->path_type == OSPF_PATH_TYPE2_EXTERNAL))
+ && (or->u.ext.tag > 0) && (or->u.ext.tag <= ROUTE_TAG_MAX))
+ SET_FLAG(message, ZAPI_MESSAGE_TAG);
+
+ /* Make packet. */
+ s = zclient->obuf;
+ stream_reset(s);
+
+ /* Put command, type, flags, message. */
+ zclient_create_header(s, ZEBRA_IPV4_ROUTE_ADD, VRF_DEFAULT);
+ stream_putc(s, ZEBRA_ROUTE_OSPF);
+ stream_putw(s, ospf->instance);
+ stream_putl(s, flags);
+ stream_putc(s, message);
+ stream_putw(s, SAFI_UNICAST);
+
+ /* Put prefix information. */
+ psize = PSIZE(p->prefixlen);
+ stream_putc(s, p->prefixlen);
+ stream_write(s, (u_char *)&p->prefix, psize);
+
+ /* Nexthop count. */
+ stream_putc(s, or->paths->count);
+
+ /* Nexthop, ifindex, distance and metric information. */
+ for (ALL_LIST_ELEMENTS_RO(or->paths, node, path)) {
#ifdef HAVE_NETLINK
- if (path->unnumbered
- || (path->nexthop.s_addr != INADDR_ANY
- && path->ifindex != 0)) {
- stream_putc(s, NEXTHOP_TYPE_IPV4_IFINDEX);
- stream_put_in_addr(s, &path->nexthop);
+ if (path->unnumbered || (path->nexthop.s_addr != INADDR_ANY
+ && path->ifindex != 0)) {
+ stream_putc(s, NEXTHOP_TYPE_IPV4_IFINDEX);
+ stream_put_in_addr(s, &path->nexthop);
+ stream_putl(s, path->ifindex);
+ } else if (path->nexthop.s_addr != INADDR_ANY) {
+ stream_putc(s, NEXTHOP_TYPE_IPV4);
+ stream_put_in_addr(s, &path->nexthop);
+ } else {
+ stream_putc(s, NEXTHOP_TYPE_IFINDEX);
+ if (path->ifindex)
stream_putl(s, path->ifindex);
- } else if (path->nexthop.s_addr != INADDR_ANY) {
- stream_putc(s, NEXTHOP_TYPE_IPV4);
- stream_put_in_addr(s, &path->nexthop);
- } else {
- stream_putc(s, NEXTHOP_TYPE_IFINDEX);
- if (path->ifindex)
- stream_putl(s, path->ifindex);
- else
- stream_putl(s, 0);
- }
+ else
+ stream_putl(s, 0);
+ }
#else /* HAVE_NETLINK */
- if (path->nexthop.s_addr != INADDR_ANY
- && path->ifindex != 0) {
- stream_putc(s, NEXTHOP_TYPE_IPV4_IFINDEX);
- stream_put_in_addr(s, &path->nexthop);
+ if (path->nexthop.s_addr != INADDR_ANY && path->ifindex != 0) {
+ stream_putc(s, NEXTHOP_TYPE_IPV4_IFINDEX);
+ stream_put_in_addr(s, &path->nexthop);
+ stream_putl(s, path->ifindex);
+ } else if (path->nexthop.s_addr != INADDR_ANY) {
+ stream_putc(s, NEXTHOP_TYPE_IPV4);
+ stream_put_in_addr(s, &path->nexthop);
+ } else {
+ stream_putc(s, NEXTHOP_TYPE_IFINDEX);
+ if (path->ifindex)
stream_putl(s, path->ifindex);
- } else if (path->nexthop.s_addr != INADDR_ANY) {
- stream_putc(s, NEXTHOP_TYPE_IPV4);
- stream_put_in_addr(s, &path->nexthop);
- } else {
- stream_putc(s, NEXTHOP_TYPE_IFINDEX);
- if (path->ifindex)
- stream_putl(s, path->ifindex);
- else
- stream_putl(s, 0);
- }
+ else
+ stream_putl(s, 0);
+ }
#endif /* HAVE_NETLINK */
- if (IS_DEBUG_OSPF(zebra, ZEBRA_REDISTRIBUTE)) {
- char buf[2][INET_ADDRSTRLEN];
- zlog_debug(
- "Zebra: Route add %s/%d nexthop %s, ifindex=%d",
- inet_ntop(AF_INET, &p->prefix, buf[0],
- sizeof(buf[0])),
- p->prefixlen,
- inet_ntop(AF_INET, &path->nexthop,
- buf[1], sizeof(buf[1])),
- path->ifindex);
- }
+ if (IS_DEBUG_OSPF(zebra, ZEBRA_REDISTRIBUTE)) {
+ char buf[2][INET_ADDRSTRLEN];
+ zlog_debug(
+ "Zebra: Route add %s/%d nexthop %s, ifindex=%d",
+ inet_ntop(AF_INET, &p->prefix, buf[0],
+ sizeof(buf[0])),
+ p->prefixlen, inet_ntop(AF_INET, &path->nexthop,
+ buf[1], sizeof(buf[1])),
+ path->ifindex);
}
+ }
- if (CHECK_FLAG(message, ZAPI_MESSAGE_DISTANCE))
- stream_putc(s, distance);
- if (CHECK_FLAG(message, ZAPI_MESSAGE_METRIC)) {
- if (or->path_type == OSPF_PATH_TYPE1_EXTERNAL)
- stream_putl(s, or->cost + or->u.ext.type2_cost);
- else if (or->path_type == OSPF_PATH_TYPE2_EXTERNAL)
- stream_putl(s, or->u.ext.type2_cost);
- else
- stream_putl(s, or->cost);
- }
+ if (CHECK_FLAG(message, ZAPI_MESSAGE_DISTANCE))
+ stream_putc(s, distance);
+ if (CHECK_FLAG(message, ZAPI_MESSAGE_METRIC)) {
+ if (or->path_type == OSPF_PATH_TYPE1_EXTERNAL)
+ stream_putl(s, or->cost + or->u.ext.type2_cost);
+ else if (or->path_type == OSPF_PATH_TYPE2_EXTERNAL)
+ stream_putl(s, or->u.ext.type2_cost);
+ else
+ stream_putl(s, or->cost);
+ }
- if (CHECK_FLAG(message, ZAPI_MESSAGE_TAG))
- stream_putl(s, or->u.ext.tag);
+ if (CHECK_FLAG(message, ZAPI_MESSAGE_TAG))
+ stream_putl(s, or->u.ext.tag);
- stream_putw_at(s, 0, stream_get_endp(s));
+ stream_putw_at(s, 0, stream_get_endp(s));
- zclient_send_message(zclient);
- }
+ zclient_send_message(zclient);
}
void ospf_zebra_delete(struct prefix_ipv4 *p, struct ospf_route * or)
struct listnode *node;
struct ospf *ospf = ospf_lookup();
- if ((ospf->instance
- && redist_check_instance(
- &zclient->mi_redist[AFI_IP][ZEBRA_ROUTE_OSPF],
- ospf->instance))
- || vrf_bitmap_check(zclient->redist[AFI_IP][ZEBRA_ROUTE_OSPF],
- VRF_DEFAULT)) {
- message = 0;
- flags = 0;
- /* Distance value. */
- distance = ospf_distance_apply(p, or);
- /* Make packet. */
- s = zclient->obuf;
- stream_reset(s);
-
- /* Put command, type, flags, message. */
- zclient_create_header(s, ZEBRA_IPV4_ROUTE_DELETE, VRF_DEFAULT);
- stream_putc(s, ZEBRA_ROUTE_OSPF);
- stream_putw(s, ospf->instance);
- stream_putl(s, flags);
- stream_putc(s, message);
- stream_putw(s, SAFI_UNICAST);
-
- /* Put prefix information. */
- psize = PSIZE(p->prefixlen);
- stream_putc(s, p->prefixlen);
- stream_write(s, (u_char *)&p->prefix, psize);
-
- /* Nexthop count. */
- stream_putc(s, or->paths->count);
-
- /* Nexthop, ifindex, distance and metric information. */
- for (ALL_LIST_ELEMENTS_RO(or->paths, node, path)) {
- if (path->nexthop.s_addr != INADDR_ANY
- && path->ifindex != 0) {
- stream_putc(s, NEXTHOP_TYPE_IPV4_IFINDEX);
- stream_put_in_addr(s, &path->nexthop);
- stream_putl(s, path->ifindex);
- } else if (path->nexthop.s_addr != INADDR_ANY) {
- stream_putc(s, NEXTHOP_TYPE_IPV4);
- stream_put_in_addr(s, &path->nexthop);
- } else {
- stream_putc(s, NEXTHOP_TYPE_IFINDEX);
- stream_putl(s, path->ifindex);
- }
+ if (!(ospf->instance
+ && redist_check_instance(
+ &zclient->mi_redist[AFI_IP][ZEBRA_ROUTE_OSPF],
+ ospf->instance))
+ && !vrf_bitmap_check(zclient->redist[AFI_IP][ZEBRA_ROUTE_OSPF],
+ VRF_DEFAULT))
+ return;
- if (IS_DEBUG_OSPF(zebra, ZEBRA_REDISTRIBUTE)) {
- char buf[2][INET_ADDRSTRLEN];
- zlog_debug(
- "Zebra: Route delete %s/%d nexthop %s",
- inet_ntop(AF_INET, &p->prefix, buf[0],
- sizeof(buf[0])),
- p->prefixlen,
- inet_ntop(AF_INET, &path->nexthop,
- buf[1], sizeof(buf[1])));
- }
+ message = 0;
+ flags = 0;
+ /* Distance value. */
+ distance = ospf_distance_apply(p, or);
+ /* Make packet. */
+ s = zclient->obuf;
+ stream_reset(s);
+
+ /* Put command, type, flags, message. */
+ zclient_create_header(s, ZEBRA_IPV4_ROUTE_DELETE, VRF_DEFAULT);
+ stream_putc(s, ZEBRA_ROUTE_OSPF);
+ stream_putw(s, ospf->instance);
+ stream_putl(s, flags);
+ stream_putc(s, message);
+ stream_putw(s, SAFI_UNICAST);
+
+ /* Put prefix information. */
+ psize = PSIZE(p->prefixlen);
+ stream_putc(s, p->prefixlen);
+ stream_write(s, (u_char *)&p->prefix, psize);
+
+ /* Nexthop count. */
+ stream_putc(s, or->paths->count);
+
+ /* Nexthop, ifindex, distance and metric information. */
+ for (ALL_LIST_ELEMENTS_RO(or->paths, node, path)) {
+ if (path->nexthop.s_addr != INADDR_ANY && path->ifindex != 0) {
+ stream_putc(s, NEXTHOP_TYPE_IPV4_IFINDEX);
+ stream_put_in_addr(s, &path->nexthop);
+ stream_putl(s, path->ifindex);
+ } else if (path->nexthop.s_addr != INADDR_ANY) {
+ stream_putc(s, NEXTHOP_TYPE_IPV4);
+ stream_put_in_addr(s, &path->nexthop);
+ } else {
+ stream_putc(s, NEXTHOP_TYPE_IFINDEX);
+ stream_putl(s, path->ifindex);
}
- if (CHECK_FLAG(message, ZAPI_MESSAGE_DISTANCE))
- stream_putc(s, distance);
- if (CHECK_FLAG(message, ZAPI_MESSAGE_METRIC)) {
- if (or->path_type == OSPF_PATH_TYPE1_EXTERNAL)
- stream_putl(s, or->cost + or->u.ext.type2_cost);
- else if (or->path_type == OSPF_PATH_TYPE2_EXTERNAL)
- stream_putl(s, or->u.ext.type2_cost);
- else
- stream_putl(s, or->cost);
+ if (IS_DEBUG_OSPF(zebra, ZEBRA_REDISTRIBUTE)) {
+ char buf[2][INET_ADDRSTRLEN];
+ zlog_debug("Zebra: Route delete %s/%d nexthop %s",
+ inet_ntop(AF_INET, &p->prefix, buf[0],
+ sizeof(buf[0])),
+ p->prefixlen,
+ inet_ntop(AF_INET, &path->nexthop, buf[1],
+ sizeof(buf[1])));
}
+ }
- stream_putw_at(s, 0, stream_get_endp(s));
-
- zclient_send_message(zclient);
+ if (CHECK_FLAG(message, ZAPI_MESSAGE_DISTANCE))
+ stream_putc(s, distance);
+ if (CHECK_FLAG(message, ZAPI_MESSAGE_METRIC)) {
+ if (or->path_type == OSPF_PATH_TYPE1_EXTERNAL)
+ stream_putl(s, or->cost + or->u.ext.type2_cost);
+ else if (or->path_type == OSPF_PATH_TYPE2_EXTERNAL)
+ stream_putl(s, or->u.ext.type2_cost);
+ else
+ stream_putl(s, or->cost);
}
+
+ stream_putw_at(s, 0, stream_get_endp(s));
+
+ zclient_send_message(zclient);
}
void ospf_zebra_add_discard(struct prefix_ipv4 *p)
struct zapi_ipv4 api;
struct ospf *ospf = ospf_lookup();
- if ((ospf->instance
- && redist_check_instance(
- &zclient->mi_redist[AFI_IP][ZEBRA_ROUTE_OSPF],
- ospf->instance))
- || vrf_bitmap_check(zclient->redist[AFI_IP][ZEBRA_ROUTE_OSPF],
- VRF_DEFAULT)) {
- api.vrf_id = VRF_DEFAULT;
- api.type = ZEBRA_ROUTE_OSPF;
- api.instance = ospf->instance;
- api.flags = ZEBRA_FLAG_BLACKHOLE;
- api.message = 0;
- api.safi = SAFI_UNICAST;
- SET_FLAG(api.message, ZAPI_MESSAGE_NEXTHOP);
- api.nexthop_num = 0;
- api.ifindex_num = 0;
- api.tag = 0;
+ if (!(ospf->instance
+ && redist_check_instance(
+ &zclient->mi_redist[AFI_IP][ZEBRA_ROUTE_OSPF],
+ ospf->instance))
+ && !vrf_bitmap_check(zclient->redist[AFI_IP][ZEBRA_ROUTE_OSPF],
+ VRF_DEFAULT))
+ return;
- zapi_ipv4_route(ZEBRA_IPV4_ROUTE_ADD, zclient, p, &api);
+ api.vrf_id = VRF_DEFAULT;
+ api.type = ZEBRA_ROUTE_OSPF;
+ api.instance = ospf->instance;
+ api.flags = ZEBRA_FLAG_BLACKHOLE;
+ api.message = 0;
+ api.safi = SAFI_UNICAST;
+ SET_FLAG(api.message, ZAPI_MESSAGE_NEXTHOP);
+ api.nexthop_num = 0;
+ api.ifindex_num = 0;
+ api.tag = 0;
- if (IS_DEBUG_OSPF(zebra, ZEBRA_REDISTRIBUTE))
- zlog_debug("Zebra: Route add discard %s/%d",
- inet_ntoa(p->prefix), p->prefixlen);
- }
+ zapi_ipv4_route(ZEBRA_IPV4_ROUTE_ADD, zclient, p, &api);
+
+ if (IS_DEBUG_OSPF(zebra, ZEBRA_REDISTRIBUTE))
+ zlog_debug("Zebra: Route add discard %s/%d",
+ inet_ntoa(p->prefix), p->prefixlen);
}
void ospf_zebra_delete_discard(struct prefix_ipv4 *p)
struct zapi_ipv4 api;
struct ospf *ospf = ospf_lookup();
- if ((ospf->instance
- && redist_check_instance(
- &zclient->mi_redist[AFI_IP][ZEBRA_ROUTE_OSPF],
- ospf->instance))
- || vrf_bitmap_check(zclient->redist[AFI_IP][ZEBRA_ROUTE_OSPF],
- VRF_DEFAULT)) {
- api.vrf_id = VRF_DEFAULT;
- api.type = ZEBRA_ROUTE_OSPF;
- api.instance = ospf->instance;
- api.flags = ZEBRA_FLAG_BLACKHOLE;
- api.message = 0;
- api.safi = SAFI_UNICAST;
- SET_FLAG(api.message, ZAPI_MESSAGE_NEXTHOP);
- api.nexthop_num = 0;
- api.ifindex_num = 0;
- api.tag = 0;
+ if (!(ospf->instance
+ && redist_check_instance(
+ &zclient->mi_redist[AFI_IP][ZEBRA_ROUTE_OSPF],
+ ospf->instance))
+ && !vrf_bitmap_check(zclient->redist[AFI_IP][ZEBRA_ROUTE_OSPF],
+ VRF_DEFAULT))
+ return;
- zapi_ipv4_route(ZEBRA_IPV4_ROUTE_DELETE, zclient, p, &api);
+ api.vrf_id = VRF_DEFAULT;
+ api.type = ZEBRA_ROUTE_OSPF;
+ api.instance = ospf->instance;
+ api.flags = ZEBRA_FLAG_BLACKHOLE;
+ api.message = 0;
+ api.safi = SAFI_UNICAST;
+ SET_FLAG(api.message, ZAPI_MESSAGE_NEXTHOP);
+ api.nexthop_num = 0;
+ api.ifindex_num = 0;
+ api.tag = 0;
- if (IS_DEBUG_OSPF(zebra, ZEBRA_REDISTRIBUTE))
- zlog_debug("Zebra: Route delete discard %s/%d",
- inet_ntoa(p->prefix), p->prefixlen);
- }
+ zapi_ipv4_route(ZEBRA_IPV4_ROUTE_DELETE, zclient, p, &api);
+
+ if (IS_DEBUG_OSPF(zebra, ZEBRA_REDISTRIBUTE))
+ zlog_debug("Zebra: Route delete discard %s/%d",
+ inet_ntoa(p->prefix), p->prefixlen);
}
struct ospf_external *ospf_external_lookup(u_char type, u_short instance)
struct rip_info *rinfo = NULL;
int count = 0;
- if (vrf_bitmap_check(zclient->redist[AFI_IP][ZEBRA_ROUTE_RIP],
- VRF_DEFAULT)) {
- api.vrf_id = VRF_DEFAULT;
- api.type = ZEBRA_ROUTE_RIP;
- api.instance = 0;
- api.flags = 0;
- api.message = 0;
- api.safi = SAFI_UNICAST;
-
- if (nexthops_len < listcount(list)) {
- nexthops_len = listcount(list);
- nexthops = XREALLOC(MTYPE_TMP, nexthops,
- nexthops_len
- * sizeof(struct in_addr *));
- }
-
- SET_FLAG(api.message, ZAPI_MESSAGE_NEXTHOP);
- for (ALL_LIST_ELEMENTS_RO(list, listnode, rinfo)) {
- nexthops[count++] = &rinfo->nexthop;
- if (cmd == ZEBRA_IPV4_ROUTE_ADD)
- SET_FLAG(rinfo->flags, RIP_RTF_FIB);
- else
- UNSET_FLAG(rinfo->flags, RIP_RTF_FIB);
- }
+ if (!vrf_bitmap_check(zclient->redist[AFI_IP][ZEBRA_ROUTE_RIP],
+ VRF_DEFAULT))
+ return;
+
+ api.vrf_id = VRF_DEFAULT;
+ api.type = ZEBRA_ROUTE_RIP;
+ api.instance = 0;
+ api.flags = 0;
+ api.message = 0;
+ api.safi = SAFI_UNICAST;
+
+ if (nexthops_len < listcount(list)) {
+ nexthops_len = listcount(list);
+ nexthops = XREALLOC(MTYPE_TMP, nexthops,
+ nexthops_len * sizeof(struct in_addr *));
+ }
- api.nexthop = nexthops;
- api.nexthop_num = count;
- api.ifindex_num = 0;
+ SET_FLAG(api.message, ZAPI_MESSAGE_NEXTHOP);
+ for (ALL_LIST_ELEMENTS_RO(list, listnode, rinfo)) {
+ nexthops[count++] = &rinfo->nexthop;
+ if (cmd == ZEBRA_IPV4_ROUTE_ADD)
+ SET_FLAG(rinfo->flags, RIP_RTF_FIB);
+ else
+ UNSET_FLAG(rinfo->flags, RIP_RTF_FIB);
+ }
- rinfo = listgetdata(listhead(list));
+ api.nexthop = nexthops;
+ api.nexthop_num = count;
+ api.ifindex_num = 0;
- SET_FLAG(api.message, ZAPI_MESSAGE_METRIC);
- api.metric = rinfo->metric;
+ rinfo = listgetdata(listhead(list));
- if (rinfo->distance
- && rinfo->distance != ZEBRA_RIP_DISTANCE_DEFAULT) {
- SET_FLAG(api.message, ZAPI_MESSAGE_DISTANCE);
- api.distance = rinfo->distance;
- }
+ SET_FLAG(api.message, ZAPI_MESSAGE_METRIC);
+ api.metric = rinfo->metric;
- if (rinfo->tag) {
- SET_FLAG(api.message, ZAPI_MESSAGE_TAG);
- api.tag = rinfo->tag;
- }
+ if (rinfo->distance && rinfo->distance != ZEBRA_RIP_DISTANCE_DEFAULT) {
+ SET_FLAG(api.message, ZAPI_MESSAGE_DISTANCE);
+ api.distance = rinfo->distance;
+ }
- zapi_ipv4_route(cmd, zclient, (struct prefix_ipv4 *)&rp->p,
- &api);
-
- if (IS_RIP_DEBUG_ZEBRA) {
- if (rip->ecmp)
- zlog_debug("%s: %s/%d nexthops %d",
- (cmd == ZEBRA_IPV4_ROUTE_ADD)
- ? "Install into zebra"
- : "Delete from zebra",
- inet_ntoa(rp->p.u.prefix4),
- rp->p.prefixlen, count);
- else
- zlog_debug("%s: %s/%d",
- (cmd == ZEBRA_IPV4_ROUTE_ADD)
- ? "Install into zebra"
- : "Delete from zebra",
- inet_ntoa(rp->p.u.prefix4),
- rp->p.prefixlen);
- }
+ if (rinfo->tag) {
+ SET_FLAG(api.message, ZAPI_MESSAGE_TAG);
+ api.tag = rinfo->tag;
+ }
- rip_global_route_changes++;
+ zapi_ipv4_route(cmd, zclient, (struct prefix_ipv4 *)&rp->p, &api);
+
+ if (IS_RIP_DEBUG_ZEBRA) {
+ if (rip->ecmp)
+ zlog_debug("%s: %s/%d nexthops %d",
+ (cmd == ZEBRA_IPV4_ROUTE_ADD)
+ ? "Install into zebra"
+ : "Delete from zebra",
+ inet_ntoa(rp->p.u.prefix4), rp->p.prefixlen,
+ count);
+ else
+ zlog_debug("%s: %s/%d",
+ (cmd == ZEBRA_IPV4_ROUTE_ADD)
+ ? "Install into zebra"
+ : "Delete from zebra",
+ inet_ntoa(rp->p.u.prefix4), rp->p.prefixlen);
}
+
+ rip_global_route_changes++;
}
/* Add/update ECMP routes to zebra. */
{
int i;
- for (i = 0; i < ZEBRA_ROUTE_MAX; i++)
- if (i != zclient->redist_default
- && vrf_bitmap_check(zclient->redist[AFI_IP][i],
- VRF_DEFAULT)) {
- if (config_mode) {
- if (rip->route_map[i].metric_config) {
- if (rip->route_map[i].name)
- vty_out(vty,
- " redistribute %s metric %d route-map %s\n",
- zebra_route_string(i),
- rip->route_map[i]
- .metric,
- rip->route_map[i].name);
- else
- vty_out(vty,
- " redistribute %s metric %d\n",
- zebra_route_string(i),
- rip->route_map[i]
- .metric);
- } else {
- if (rip->route_map[i].name)
- vty_out(vty,
- " redistribute %s route-map %s\n",
- zebra_route_string(i),
- rip->route_map[i].name);
- else
- vty_out(vty,
- " redistribute %s\n",
- zebra_route_string(i));
- }
- } else
- vty_out(vty, " %s", zebra_route_string(i));
+ for (i = 0; i < ZEBRA_ROUTE_MAX; i++) {
+ if (i == zclient->redist_default
+ || !vrf_bitmap_check(zclient->redist[AFI_IP][i],
+ VRF_DEFAULT))
+ continue;
+
+ if (!config_mode) {
+ vty_out(vty, " %s", zebra_route_string(i));
+ continue;
+ }
+
+ if (rip->route_map[i].metric_config) {
+ if (rip->route_map[i].name)
+ vty_out(vty,
+ " redistribute %s metric %d route-map %s\n",
+ zebra_route_string(i),
+ rip->route_map[i].metric,
+ rip->route_map[i].name);
+ else
+ vty_out(vty, " redistribute %s metric %d\n",
+ zebra_route_string(i),
+ rip->route_map[i].metric);
+ } else {
+ if (rip->route_map[i].name)
+ vty_out(vty, " redistribute %s route-map %s\n",
+ zebra_route_string(i),
+ rip->route_map[i].name);
+ else
+ vty_out(vty, " redistribute %s\n",
+ zebra_route_string(i));
}
+ }
+
return 0;
}
struct ripng_info *rinfo = NULL;
int count = 0;
- if (vrf_bitmap_check(zclient->redist[AFI_IP6][ZEBRA_ROUTE_RIPNG],
- VRF_DEFAULT)) {
- api.vrf_id = VRF_DEFAULT;
- api.type = ZEBRA_ROUTE_RIPNG;
- api.instance = 0;
- api.flags = 0;
- api.message = 0;
- api.safi = SAFI_UNICAST;
-
- if (nexthops_len < listcount(list)) {
- nexthops_len = listcount(list);
- nexthops = XREALLOC(
- MTYPE_TMP, nexthops,
- nexthops_len * sizeof(struct in6_addr *));
- ifindexes =
- XREALLOC(MTYPE_TMP, ifindexes,
- nexthops_len * sizeof(unsigned int));
- }
+ if (!vrf_bitmap_check(zclient->redist[AFI_IP6][ZEBRA_ROUTE_RIPNG],
+ VRF_DEFAULT))
+ return;
+
+ api.vrf_id = VRF_DEFAULT;
+ api.type = ZEBRA_ROUTE_RIPNG;
+ api.instance = 0;
+ api.flags = 0;
+ api.message = 0;
+ api.safi = SAFI_UNICAST;
+
+ if (nexthops_len < listcount(list)) {
+ nexthops_len = listcount(list);
+ nexthops = XREALLOC(MTYPE_TMP, nexthops,
+ nexthops_len * sizeof(struct in6_addr *));
+ ifindexes = XREALLOC(MTYPE_TMP, ifindexes,
+ nexthops_len * sizeof(unsigned int));
+ }
- SET_FLAG(api.message, ZAPI_MESSAGE_NEXTHOP);
- SET_FLAG(api.message, ZAPI_MESSAGE_IFINDEX);
- for (ALL_LIST_ELEMENTS_RO(list, listnode, rinfo)) {
- nexthops[count] = &rinfo->nexthop;
- ifindexes[count] = rinfo->ifindex;
- count++;
- if (cmd == ZEBRA_IPV6_ROUTE_ADD)
- SET_FLAG(rinfo->flags, RIPNG_RTF_FIB);
- else
- UNSET_FLAG(rinfo->flags, RIPNG_RTF_FIB);
- }
+ SET_FLAG(api.message, ZAPI_MESSAGE_NEXTHOP);
+ SET_FLAG(api.message, ZAPI_MESSAGE_IFINDEX);
+ for (ALL_LIST_ELEMENTS_RO(list, listnode, rinfo)) {
+ nexthops[count] = &rinfo->nexthop;
+ ifindexes[count] = rinfo->ifindex;
+ count++;
+ if (cmd == ZEBRA_IPV6_ROUTE_ADD)
+ SET_FLAG(rinfo->flags, RIPNG_RTF_FIB);
+ else
+ UNSET_FLAG(rinfo->flags, RIPNG_RTF_FIB);
+ }
- api.nexthop = nexthops;
- api.nexthop_num = count;
- api.ifindex = ifindexes;
- api.ifindex_num = count;
+ api.nexthop = nexthops;
+ api.nexthop_num = count;
+ api.ifindex = ifindexes;
+ api.ifindex_num = count;
- rinfo = listgetdata(listhead(list));
+ rinfo = listgetdata(listhead(list));
- SET_FLAG(api.message, ZAPI_MESSAGE_METRIC);
- api.metric = rinfo->metric;
+ SET_FLAG(api.message, ZAPI_MESSAGE_METRIC);
+ api.metric = rinfo->metric;
- if (rinfo->tag) {
- SET_FLAG(api.message, ZAPI_MESSAGE_TAG);
- api.tag = rinfo->tag;
- }
+ if (rinfo->tag) {
+ SET_FLAG(api.message, ZAPI_MESSAGE_TAG);
+ api.tag = rinfo->tag;
+ }
- zapi_ipv6_route(cmd, zclient, (struct prefix_ipv6 *)&rp->p,
- NULL, &api);
-
- if (IS_RIPNG_DEBUG_ZEBRA) {
- if (ripng->ecmp)
- zlog_debug("%s: %s/%d nexthops %d",
- (cmd == ZEBRA_IPV6_ROUTE_ADD)
- ? "Install into zebra"
- : "Delete from zebra",
- inet6_ntoa(rp->p.u.prefix6),
- rp->p.prefixlen, count);
- else
- zlog_debug("%s: %s/%d",
- (cmd == ZEBRA_IPV6_ROUTE_ADD)
- ? "Install into zebra"
- : "Delete from zebra",
- inet6_ntoa(rp->p.u.prefix6),
- rp->p.prefixlen);
- }
+ zapi_ipv6_route(cmd, zclient, (struct prefix_ipv6 *)&rp->p, NULL, &api);
+
+ if (IS_RIPNG_DEBUG_ZEBRA) {
+ if (ripng->ecmp)
+ zlog_debug("%s: %s/%d nexthops %d",
+ (cmd == ZEBRA_IPV6_ROUTE_ADD)
+ ? "Install into zebra"
+ : "Delete from zebra",
+ inet6_ntoa(rp->p.u.prefix6), rp->p.prefixlen,
+ count);
+ else
+ zlog_debug("%s: %s/%d",
+ (cmd == ZEBRA_IPV6_ROUTE_ADD)
+ ? "Install into zebra"
+ : "Delete from zebra",
+ inet6_ntoa(rp->p.u.prefix6),
+ rp->p.prefixlen);
}
}
{
int i;
- for (i = 0; i < ZEBRA_ROUTE_MAX; i++)
- if (i != zclient->redist_default
- && vrf_bitmap_check(zclient->redist[AFI_IP6][i],
- VRF_DEFAULT)) {
- if (config_mode) {
- if (ripng->route_map[i].metric_config) {
- if (ripng->route_map[i].name)
- vty_out(vty,
- " redistribute %s metric %d route-map %s\n",
- zebra_route_string(i),
- ripng->route_map[i]
- .metric,
- ripng->route_map[i]
- .name);
- else
- vty_out(vty,
- " redistribute %s metric %d\n",
- zebra_route_string(i),
- ripng->route_map[i]
- .metric);
- } else {
- if (ripng->route_map[i].name)
- vty_out(vty,
- " redistribute %s route-map %s\n",
- zebra_route_string(i),
- ripng->route_map[i]
- .name);
- else
- vty_out(vty,
- " redistribute %s\n",
- zebra_route_string(i));
- }
- } else
- vty_out(vty, " %s", zebra_route_string(i));
+ for (i = 0; i < ZEBRA_ROUTE_MAX; i++) {
+ if (i == zclient->redist_default
+ || !vrf_bitmap_check(zclient->redist[AFI_IP6][i],
+ VRF_DEFAULT))
+ continue;
+
+ if (!config_mode) {
+ vty_out(vty, " %s", zebra_route_string(i));
+ continue;
}
+
+ if (ripng->route_map[i].metric_config) {
+ if (ripng->route_map[i].name)
+ vty_out(vty,
+ " redistribute %s metric %d route-map %s\n",
+ zebra_route_string(i),
+ ripng->route_map[i].metric,
+ ripng->route_map[i].name);
+ else
+ vty_out(vty, " redistribute %s metric %d\n",
+ zebra_route_string(i),
+ ripng->route_map[i].metric);
+ } else {
+ if (ripng->route_map[i].name)
+ vty_out(vty, " redistribute %s route-map %s\n",
+ zebra_route_string(i),
+ ripng->route_map[i].name);
+ else
+ vty_out(vty, " redistribute %s\n",
+ zebra_route_string(i));
+ }
+ }
}
/* RIPng configuration write function. */