diff --git a/bgpd/bgp_nexthop.c b/bgpd/bgp_nexthop.c index c4b832ee59..1c79d7d03b 100644 --- a/bgpd/bgp_nexthop.c +++ b/bgpd/bgp_nexthop.c @@ -908,17 +908,34 @@ static void bgp_show_nexthops_detail(struct vty *vty, struct bgp *bgp, } switch (nexthop->type) { case NEXTHOP_TYPE_IPV6: - vty_out(vty, " gate %pI6\n", &nexthop->gate.ipv6); - break; case NEXTHOP_TYPE_IPV6_IFINDEX: - vty_out(vty, " gate %pI6, if %s\n", - &nexthop->gate.ipv6, - ifindex2ifname(bnc->ifindex ? bnc->ifindex - : nexthop->ifindex, - bgp->vrf_id)); + vty_out(vty, " gate %pI6", &nexthop->gate.ipv6); + if (nexthop->type == NEXTHOP_TYPE_IPV6_IFINDEX && + bnc->ifindex) + vty_out(vty, ", if %s\n", + ifindex2ifname(bnc->ifindex, + bgp->vrf_id)); + else if (nexthop->ifindex) + vty_out(vty, ", if %s\n", + ifindex2ifname(nexthop->ifindex, + bgp->vrf_id)); + else + vty_out(vty, "\n"); break; case NEXTHOP_TYPE_IPV4: - vty_out(vty, " gate %pI4\n", &nexthop->gate.ipv4); + case NEXTHOP_TYPE_IPV4_IFINDEX: + vty_out(vty, " gate %pI4", &nexthop->gate.ipv4); + if (nexthop->type == NEXTHOP_TYPE_IPV4_IFINDEX && + bnc->ifindex) + vty_out(vty, ", if %s\n", + ifindex2ifname(bnc->ifindex, + bgp->vrf_id)); + else if (nexthop->ifindex) + vty_out(vty, ", if %s\n", + ifindex2ifname(nexthop->ifindex, + bgp->vrf_id)); + else + vty_out(vty, "\n"); break; case NEXTHOP_TYPE_IFINDEX: vty_out(vty, " if %s\n", @@ -926,13 +943,6 @@ static void bgp_show_nexthops_detail(struct vty *vty, struct bgp *bgp, : nexthop->ifindex, bgp->vrf_id)); break; - case NEXTHOP_TYPE_IPV4_IFINDEX: - vty_out(vty, " gate %pI4, if %s\n", - &nexthop->gate.ipv4, - ifindex2ifname(bnc->ifindex ? bnc->ifindex - : nexthop->ifindex, - bgp->vrf_id)); - break; case NEXTHOP_TYPE_BLACKHOLE: vty_out(vty, " blackhole\n"); break;