]> git.puffer.fish Git - mirror/frr.git/commitdiff
bgpd: Fix bgp display of blackhole nexthops 1157/head
authorDonald Sharp <sharpd@cumulusnetworks.com>
Tue, 12 Sep 2017 12:24:27 +0000 (08:24 -0400)
committerDonald Sharp <sharpd@cumulusnetworks.com>
Tue, 12 Sep 2017 12:33:37 +0000 (08:33 -0400)
Allow BGP to tell the user that a particular nexthop
is a blackhole nexthop.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
bgpd/bgp_nexthop.c

index 1200d74d6a59246846d800928bda511c66770993..2b3984d75771dd1f4e67147899bb7595069efdf6 100644 (file)
@@ -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,