From: Donald Sharp Date: Tue, 12 Sep 2017 12:24:27 +0000 (-0400) Subject: bgpd: Fix bgp display of blackhole nexthops X-Git-Tag: frr-4.0-dev~287^2 X-Git-Url: https://git.puffer.fish/?a=commitdiff_plain;h=e22ac3eec4f1b2072d169fcc84a16e040e376f74;p=mirror%2Ffrr.git bgpd: Fix bgp display of blackhole nexthops Allow BGP to tell the user that a particular nexthop is a blackhole nexthop. Signed-off-by: Donald Sharp --- diff --git a/bgpd/bgp_nexthop.c b/bgpd/bgp_nexthop.c index 1200d74d6a..2b3984d757 100644 --- a/bgpd/bgp_nexthop.c +++ b/bgpd/bgp_nexthop.c @@ -430,12 +430,59 @@ int bgp_multiaccess_check_v4(struct in_addr nexthop, struct peer *peer) return (ret); } +static void bgp_show_nexthops_detail(struct vty *vty, + struct bgp *bgp, + struct bgp_nexthop_cache *bnc) +{ + char buf[PREFIX2STR_BUFFER]; + struct nexthop *nexthop; + + for (nexthop = bnc->nexthop; nexthop; nexthop = nexthop->next) + switch (nexthop->type) { + case NEXTHOP_TYPE_IPV6: + vty_out(vty, " gate %s\n", + inet_ntop(AF_INET6, &nexthop->gate.ipv6, + buf, sizeof(buf))); + break; + case NEXTHOP_TYPE_IPV6_IFINDEX: + vty_out(vty, " gate %s, if %s\n", + inet_ntop(AF_INET6, &nexthop->gate.ipv6, + buf, sizeof(buf)), + ifindex2ifname(nexthop->ifindex, + bgp->vrf_id)); + break; + case NEXTHOP_TYPE_IPV4: + vty_out(vty, " gate %s\n", + inet_ntop(AF_INET, &nexthop->gate.ipv4, + buf, sizeof(buf))); + break; + case NEXTHOP_TYPE_IFINDEX: + vty_out(vty, " if %s\n", + ifindex2ifname(nexthop->ifindex, + bgp->vrf_id)); + break; + case NEXTHOP_TYPE_IPV4_IFINDEX: + vty_out(vty, " gate %s, if %s\n", + inet_ntop(AF_INET, &nexthop->gate.ipv4, + buf, sizeof(buf)), + ifindex2ifname(nexthop->ifindex, + bgp->vrf_id)); + break; + case NEXTHOP_TYPE_BLACKHOLE: + vty_out(vty, " blackhole\n"); + break; + default: + vty_out(vty, + " invalid nexthop type %u\n", + nexthop->type); + } +} + static void bgp_show_nexthops(struct vty *vty, struct bgp *bgp, int detail) { struct bgp_node *rn; struct bgp_nexthop_cache *bnc; char buf[PREFIX2STR_BUFFER]; - struct nexthop *nexthop; time_t tbuf; afi_t afi; @@ -454,70 +501,13 @@ static void bgp_show_nexthops(struct vty *vty, struct bgp *bgp, int detail) &rn->p.u.prefix, buf, sizeof(buf)), bnc->metric, bnc->path_count); - if (detail) - for (nexthop = bnc->nexthop; - nexthop; - nexthop = nexthop->next) - switch (nexthop->type) { - case NEXTHOP_TYPE_IPV6: - vty_out(vty, - " gate %s\n", - inet_ntop( - AF_INET6, - &nexthop->gate - .ipv6, - buf, - sizeof(buf))); - break; - case NEXTHOP_TYPE_IPV6_IFINDEX: - vty_out(vty, - " gate %s, if %s\n", - inet_ntop( - AF_INET6, - &nexthop->gate - .ipv6, - buf, - sizeof(buf)), - ifindex2ifname( - nexthop->ifindex, - bgp->vrf_id)); - break; - case NEXTHOP_TYPE_IPV4: - vty_out(vty, - " gate %s\n", - inet_ntop( - AF_INET, - &nexthop->gate - .ipv4, - buf, - sizeof(buf))); - break; - case NEXTHOP_TYPE_IFINDEX: - vty_out(vty, - " if %s\n", - ifindex2ifname( - nexthop->ifindex, - bgp->vrf_id)); - break; - case NEXTHOP_TYPE_IPV4_IFINDEX: - vty_out(vty, - " gate %s, if %s\n", - inet_ntop( - AF_INET, - &nexthop->gate - .ipv4, - buf, - sizeof(buf)), - ifindex2ifname( - nexthop->ifindex, - bgp->vrf_id)); - break; - default: - vty_out(vty, - " invalid nexthop type %u\n", - nexthop->type); - } - } else { + + if (!detail) + continue; + + bgp_show_nexthops_detail(vty, bgp, bnc); + + } else{ vty_out(vty, " %s invalid\n", inet_ntop(rn->p.family, &rn->p.u.prefix, buf,