diff options
author | Donald Sharp <sharpd@cumulusnetworks.com> | 2017-09-12 14:24:27 +0200 |
---|---|---|
committer | Donald Sharp <sharpd@cumulusnetworks.com> | 2017-09-12 14:33:37 +0200 |
commit | e22ac3eec4f1b2072d169fcc84a16e040e376f74 (patch) | |
tree | e64d47b7cecd62b6e9fdcc6bc43deec52c511b59 /bgpd/bgp_nexthop.c | |
parent | zebra: Allow recursive nexthop resolution to consider blackholes (diff) | |
download | frr-e22ac3eec4f1b2072d169fcc84a16e040e376f74.tar.xz frr-e22ac3eec4f1b2072d169fcc84a16e040e376f74.zip |
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 <sharpd@cumulusnetworks.com>
Diffstat (limited to 'bgpd/bgp_nexthop.c')
-rw-r--r-- | bgpd/bgp_nexthop.c | 120 |
1 files changed, 55 insertions, 65 deletions
diff --git a/bgpd/bgp_nexthop.c b/bgpd/bgp_nexthop.c index 1200d74d6..2b3984d75 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, |