From d00061ea32901096fa4c3af6b9e65914dd895031 Mon Sep 17 00:00:00 2001 From: Renato Westphal Date: Sat, 12 Aug 2017 13:03:29 -0300 Subject: [PATCH] *: reduce excessive indentation in a few places Signed-off-by: Renato Westphal --- eigrpd/eigrp_zebra.c | 134 +++++++------- isisd/isis_zebra.c | 130 +++++++------- ospf6d/ospf6_zebra.c | 138 +++++++------- ospfd/ospf_zebra.c | 417 +++++++++++++++++++++---------------------- ripd/rip_zebra.c | 179 +++++++++---------- ripngd/ripng_zebra.c | 181 +++++++++---------- 6 files changed, 587 insertions(+), 592 deletions(-) diff --git a/eigrpd/eigrp_zebra.c b/eigrpd/eigrp_zebra.c index 1ee1237f75..00b269b489 100644 --- a/eigrpd/eigrp_zebra.c +++ b/eigrpd/eigrp_zebra.c @@ -398,81 +398,83 @@ void eigrp_zebra_route_add(struct prefix_ipv4 *p, struct list *successors) 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; diff --git a/isisd/isis_zebra.c b/isisd/isis_zebra.c index 8c6968f8ec..c1d558fc22 100644 --- a/isisd/isis_zebra.c +++ b/isisd/isis_zebra.c @@ -258,63 +258,62 @@ static void isis_zebra_route_add_ipv4(struct prefix *prefix, 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, @@ -323,23 +322,22 @@ 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, @@ -367,8 +365,8 @@ 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); diff --git a/ospf6d/ospf6_zebra.c b/ospf6d/ospf6_zebra.c index d33f41730e..dc97f1ff4b 100644 --- a/ospf6d/ospf6_zebra.c +++ b/ospf6d/ospf6_zebra.c @@ -497,40 +497,42 @@ void ospf6_zebra_add_discard(struct ospf6_route *request) 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); } } @@ -540,39 +542,41 @@ void ospf6_zebra_delete_discard(struct ospf6_route *request) 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); } } diff --git a/ospfd/ospf_zebra.c b/ospfd/ospf_zebra.c index d615afc072..f9668f2495 100644 --- a/ospfd/ospf_zebra.c +++ b/ospfd/ospf_zebra.c @@ -342,118 +342,116 @@ void ospf_zebra_add(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; - - /* 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) @@ -467,78 +465,77 @@ 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) @@ -546,29 +543,30 @@ 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) @@ -576,29 +574,30 @@ 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) diff --git a/ripd/rip_zebra.c b/ripd/rip_zebra.c index 961a846db2..8a166745ec 100644 --- a/ripd/rip_zebra.c +++ b/ripd/rip_zebra.c @@ -48,73 +48,70 @@ static void rip_zebra_ipv4_send(struct route_node *rp, u_char cmd) 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. */ @@ -623,39 +620,39 @@ int config_write_rip_redistribute(struct vty *vty, int config_mode) { 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; } diff --git a/ripngd/ripng_zebra.c b/ripngd/ripng_zebra.c index 386bee43b8..875ec4f225 100644 --- a/ripngd/ripng_zebra.c +++ b/ripngd/ripng_zebra.c @@ -49,71 +49,69 @@ static void ripng_zebra_ipv6_send(struct route_node *rp, u_char cmd) 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); } } @@ -452,41 +450,38 @@ void ripng_redistribute_write(struct vty *vty, int config_mode) { 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. */ -- 2.39.5