]> git.proxmox.com Git - mirror_frr.git/blobdiff - zebra/zebra_vty.c
*: nuke ^L (page feed)
[mirror_frr.git] / zebra / zebra_vty.c
index 1785fec0a622d650dba5a7abf59c4cf2da6da7ff..baa60db9a71f083dd276aa216266bb23b8e2998a 100644 (file)
@@ -280,9 +280,9 @@ DEFUN (ip_route_mask_flags_distance,
        "IP destination prefix mask\n"
        "IP gateway address\n"
        "IP gateway interface name\n"
-       "Distance value for this route\n"
        "Emit an ICMP unreachable when matched\n"
-       "Silently discard pkts when matched\n")
+       "Silently discard pkts when matched\n"
+       "Distance value for this route\n")
 {
   return zebra_static_ipv4 (vty, 1, argv[0], argv[1], argv[2], argv[3], argv[4]);
 }
@@ -294,9 +294,9 @@ DEFUN (ip_route_mask_flags_distance2,
        "Establish static routes\n"
        "IP destination prefix\n"
        "IP destination prefix mask\n"
-       "Distance value for this route\n"
        "Emit an ICMP unreachable when matched\n"
-       "Silently discard pkts when matched\n")
+       "Silently discard pkts when matched\n"
+       "Distance value for this route\n")
 {
   return zebra_static_ipv4 (vty, 1, argv[0], argv[1], NULL, argv[2], argv[3]);
 }
@@ -533,15 +533,16 @@ static void
 vty_show_ip_route_detail (struct vty *vty, struct route_node *rn)
 {
   struct rib *rib;
-  struct nexthop *nexthop;
+  struct nexthop *nexthop, *tnexthop;
+  int recursing;
 
-  for (rib = rn->info; rib; rib = rib->next)
+  RNODE_FOREACH_RIB (rn, rib)
     {
       vty_out (vty, "Routing entry for %s/%d%s", 
               inet_ntoa (rn->p.u.prefix4), rn->p.prefixlen,
               VTY_NEWLINE);
       vty_out (vty, "  Known via \"%s\"", zebra_route_string (rib->type));
-      vty_out (vty, ", distance %d, metric %d", rib->distance, rib->metric);
+      vty_out (vty, ", distance %u, metric %u", rib->distance, rib->metric);
       if (CHECK_FLAG (rib->flags, ZEBRA_FLAG_SELECTED))
        vty_out (vty, ", best");
       if (rib->refcnt)
@@ -556,6 +557,7 @@ vty_show_ip_route_detail (struct vty *vty, struct route_node *rn)
 #define ONE_WEEK_SECOND 60*60*24*7
       if (rib->type == ZEBRA_ROUTE_RIP
          || rib->type == ZEBRA_ROUTE_OSPF
+         || rib->type == ZEBRA_ROUTE_BABEL
          || rib->type == ZEBRA_ROUTE_ISIS
          || rib->type == ZEBRA_ROUTE_BGP)
        {
@@ -581,12 +583,13 @@ vty_show_ip_route_detail (struct vty *vty, struct route_node *rn)
          vty_out (vty, " ago%s", VTY_NEWLINE);
        }
 
-      for (nexthop = rib->nexthop; nexthop; nexthop = nexthop->next)
+      for (ALL_NEXTHOPS_RO(rib->nexthop, nexthop, tnexthop, recursing))
        {
           char addrstr[32];
 
-         vty_out (vty, "  %c",
-                  CHECK_FLAG (nexthop->flags, NEXTHOP_FLAG_FIB) ? '*' : ' ');
+         vty_out (vty, "  %c%s",
+                  CHECK_FLAG (nexthop->flags, NEXTHOP_FLAG_FIB) ? '*' : ' ',
+                  recursing ? "  " : "");
 
          switch (nexthop->type)
            {
@@ -612,25 +615,12 @@ vty_show_ip_route_detail (struct vty *vty, struct route_node *rn)
          if (! CHECK_FLAG (nexthop->flags, NEXTHOP_FLAG_ACTIVE))
            vty_out (vty, " inactive");
 
+         if (CHECK_FLAG (nexthop->flags, NEXTHOP_FLAG_ONLINK))
+           vty_out (vty, " onlink");
+
          if (CHECK_FLAG (nexthop->flags, NEXTHOP_FLAG_RECURSIVE))
-           {
-             vty_out (vty, " (recursive");
-               
-             switch (nexthop->rtype)
-               {
-               case NEXTHOP_TYPE_IPV4:
-               case NEXTHOP_TYPE_IPV4_IFINDEX:
-                 vty_out (vty, " via %s)", inet_ntoa (nexthop->rgate.ipv4));
-                 break;
-               case NEXTHOP_TYPE_IFINDEX:
-               case NEXTHOP_TYPE_IFNAME:
-                 vty_out (vty, " is directly connected, %s)",
-                          ifindex2ifname (nexthop->rifindex));
-                 break;
-               default:
-                 break;
-               }
-           }
+           vty_out (vty, " (recursive)");
+
          switch (nexthop->type)
             {
             case NEXTHOP_TYPE_IPV4:
@@ -667,12 +657,13 @@ vty_show_ip_route_detail (struct vty *vty, struct route_node *rn)
 static void
 vty_show_ip_route (struct vty *vty, struct route_node *rn, struct rib *rib)
 {
-  struct nexthop *nexthop;
+  struct nexthop *nexthop, *tnexthop;
+  int recursing;
   int len = 0;
   char buf[BUFSIZ];
 
   /* Nexthop information. */
-  for (nexthop = rib->nexthop; nexthop; nexthop = nexthop->next)
+  for (ALL_NEXTHOPS_RO(rib->nexthop, nexthop, tnexthop, recursing))
     {
       if (nexthop == rib->nexthop)
        {
@@ -696,7 +687,7 @@ vty_show_ip_route (struct vty *vty, struct route_node *rn, struct rib *rib)
        vty_out (vty, "  %c%*c",
                 CHECK_FLAG (nexthop->flags, NEXTHOP_FLAG_FIB)
                 ? '*' : ' ',
-                len - 3, ' ');
+                len - 3 + (2 * recursing), ' ');
 
       switch (nexthop->type)
        {
@@ -722,25 +713,12 @@ vty_show_ip_route (struct vty *vty, struct route_node *rn, struct rib *rib)
       if (! CHECK_FLAG (nexthop->flags, NEXTHOP_FLAG_ACTIVE))
        vty_out (vty, " inactive");
 
+      if (CHECK_FLAG (nexthop->flags, NEXTHOP_FLAG_ONLINK))
+       vty_out (vty, " onlink");
+
       if (CHECK_FLAG (nexthop->flags, NEXTHOP_FLAG_RECURSIVE))
-       {
-         vty_out (vty, " (recursive");
-               
-         switch (nexthop->rtype)
-           {
-           case NEXTHOP_TYPE_IPV4:
-           case NEXTHOP_TYPE_IPV4_IFINDEX:
-             vty_out (vty, " via %s)", inet_ntoa (nexthop->rgate.ipv4));
-             break;
-           case NEXTHOP_TYPE_IFINDEX:
-           case NEXTHOP_TYPE_IFNAME:
-             vty_out (vty, " is directly connected, %s)",
-                      ifindex2ifname (nexthop->rifindex));
-             break;
-           default:
-             break;
-           }
-       }
+       vty_out (vty, " (recursive)");
+
       switch (nexthop->type)
         {
           case NEXTHOP_TYPE_IPV4:
@@ -774,6 +752,7 @@ vty_show_ip_route (struct vty *vty, struct route_node *rn, struct rib *rib)
 
       if (rib->type == ZEBRA_ROUTE_RIP
          || rib->type == ZEBRA_ROUTE_OSPF
+         || rib->type == ZEBRA_ROUTE_BABEL
          || rib->type == ZEBRA_ROUTE_ISIS
          || rib->type == ZEBRA_ROUTE_BGP)
        {
@@ -820,7 +799,7 @@ DEFUN (show_ip_route,
 
   /* Show all IPv4 routes. */
   for (rn = route_top (table); rn; rn = route_next (rn))
-    for (rib = rn->info; rib; rib = rib->next)
+    RNODE_FOREACH_RIB (rn, rib)
       {
        if (first)
          {
@@ -861,7 +840,7 @@ DEFUN (show_ip_route_prefix_longer,
 
   /* Show matched type IPv4 routes. */
   for (rn = route_top (table); rn; rn = route_next (rn))
-    for (rib = rn->info; rib; rib = rib->next)
+    RNODE_FOREACH_RIB (rn, rib)
       if (prefix_match (&p, &rn->p))
        {
          if (first)
@@ -894,7 +873,7 @@ DEFUN (show_ip_route_supernets,
 
   /* Show matched type IPv4 routes. */
   for (rn = route_top (table); rn; rn = route_next (rn))
-    for (rib = rn->info; rib; rib = rib->next)
+    RNODE_FOREACH_RIB (rn, rib)
       {
        addr = ntohl (rn->p.u.prefix4.s_addr);
 
@@ -940,7 +919,7 @@ DEFUN (show_ip_route_protocol,
 
   /* Show matched type IPv4 routes. */
   for (rn = route_top (table); rn; rn = route_next (rn))
-    for (rib = rn->info; rib; rib = rib->next)
+    RNODE_FOREACH_RIB (rn, rib)
       if (rib->type == type)
        {
          if (first)
@@ -1044,12 +1023,13 @@ vty_show_ip_route_summary (struct vty *vty, struct route_table *table)
   memset (&rib_cnt, 0, sizeof(rib_cnt));
   memset (&fib_cnt, 0, sizeof(fib_cnt));
   for (rn = route_top (table); rn; rn = route_next (rn))
-    for (rib = rn->info; rib; rib = rib->next)
+    RNODE_FOREACH_RIB (rn, rib)
       for (nexthop = rib->nexthop; nexthop; nexthop = nexthop->next)
         {
          rib_cnt[ZEBRA_ROUTE_TOTAL]++;
          rib_cnt[rib->type]++;
-         if (CHECK_FLAG (nexthop->flags, NEXTHOP_FLAG_FIB)) 
+         if (CHECK_FLAG (nexthop->flags, NEXTHOP_FLAG_FIB)
+             || nexthop_has_fib_child(nexthop))
            {
              fib_cnt[ZEBRA_ROUTE_TOTAL]++;
              fib_cnt[rib->type]++;
@@ -1058,7 +1038,8 @@ vty_show_ip_route_summary (struct vty *vty, struct route_table *table)
              CHECK_FLAG (rib->flags, ZEBRA_FLAG_IBGP)) 
            {
              rib_cnt[ZEBRA_ROUTE_IBGP]++;
-             if (CHECK_FLAG (nexthop->flags, NEXTHOP_FLAG_FIB)) 
+             if (CHECK_FLAG (nexthop->flags, NEXTHOP_FLAG_FIB)
+                 || nexthop_has_fib_child(nexthop))
                fib_cnt[ZEBRA_ROUTE_IBGP]++;
            }
        }
@@ -1195,7 +1176,41 @@ DEFUN (show_ip_protocol,
     return CMD_SUCCESS;
 }
 
-\f
+/*
+ * Show IP mroute command to dump the BGP Multicast
+ * routing table
+ */
+DEFUN (show_ip_mroute,
+       show_ip_mroute_cmd,
+       "show ip mroute",
+       SHOW_STR
+       IP_STR
+       "IP Multicast routing table\n")
+{
+  struct route_table *table;
+  struct route_node *rn;
+  struct rib *rib;
+  int first = 1;
+
+  table = vrf_table (AFI_IP, SAFI_MULTICAST, 0);
+  if (! table)
+    return CMD_SUCCESS;
+
+  /* Show all IPv4 routes. */
+  for (rn = route_top (table); rn; rn = route_next (rn))
+    RNODE_FOREACH_RIB (rn, rib)
+      {
+       if (first)
+         {
+          vty_out (vty, SHOW_ROUTE_V4_HEADER);
+           first = 0;
+         }
+       vty_show_ip_route (vty, rn, rib);
+      }
+  return CMD_SUCCESS;
+}
+
+
 #ifdef HAVE_IPV6
 /* General fucntion for IPv6 static route. */
 static int
@@ -1507,17 +1522,18 @@ static void
 vty_show_ipv6_route_detail (struct vty *vty, struct route_node *rn)
 {
   struct rib *rib;
-  struct nexthop *nexthop;
+  struct nexthop *nexthop, *tnexthop;
+  int recursing;
   char buf[BUFSIZ];
 
-  for (rib = rn->info; rib; rib = rib->next)
+  RNODE_FOREACH_RIB (rn, rib)
     {
       vty_out (vty, "Routing entry for %s/%d%s", 
               inet_ntop (AF_INET6, &rn->p.u.prefix6, buf, BUFSIZ),
               rn->p.prefixlen,
               VTY_NEWLINE);
       vty_out (vty, "  Known via \"%s\"", zebra_route_string (rib->type));
-      vty_out (vty, ", distance %d, metric %d", rib->distance, rib->metric);
+      vty_out (vty, ", distance %u, metric %u", rib->distance, rib->metric);
       if (CHECK_FLAG (rib->flags, ZEBRA_FLAG_SELECTED))
        vty_out (vty, ", best");
       if (rib->refcnt)
@@ -1532,6 +1548,7 @@ vty_show_ipv6_route_detail (struct vty *vty, struct route_node *rn)
 #define ONE_WEEK_SECOND 60*60*24*7
       if (rib->type == ZEBRA_ROUTE_RIPNG
          || rib->type == ZEBRA_ROUTE_OSPF6
+         || rib->type == ZEBRA_ROUTE_BABEL
          || rib->type == ZEBRA_ROUTE_ISIS
          || rib->type == ZEBRA_ROUTE_BGP)
        {
@@ -1557,10 +1574,11 @@ vty_show_ipv6_route_detail (struct vty *vty, struct route_node *rn)
          vty_out (vty, " ago%s", VTY_NEWLINE);
        }
 
-      for (nexthop = rib->nexthop; nexthop; nexthop = nexthop->next)
+      for (ALL_NEXTHOPS_RO(rib->nexthop, nexthop, tnexthop, recursing))
        {
-         vty_out (vty, "  %c",
-                  CHECK_FLAG (nexthop->flags, NEXTHOP_FLAG_FIB) ? '*' : ' ');
+         vty_out (vty, "  %c%s",
+                  CHECK_FLAG (nexthop->flags, NEXTHOP_FLAG_FIB) ? '*' : ' ',
+                  recursing ? "  " : "");
 
          switch (nexthop->type)
            {
@@ -1588,30 +1606,12 @@ vty_show_ipv6_route_detail (struct vty *vty, struct route_node *rn)
          if (! CHECK_FLAG (nexthop->flags, NEXTHOP_FLAG_ACTIVE))
            vty_out (vty, " inactive");
 
+         if (CHECK_FLAG (nexthop->flags, NEXTHOP_FLAG_ONLINK))
+           vty_out (vty, " onlink");
+
          if (CHECK_FLAG (nexthop->flags, NEXTHOP_FLAG_RECURSIVE))
-           {
-             vty_out (vty, " (recursive");
-               
-             switch (nexthop->rtype)
-               {
-               case NEXTHOP_TYPE_IPV6:
-               case NEXTHOP_TYPE_IPV6_IFINDEX:
-               case NEXTHOP_TYPE_IPV6_IFNAME:
-                 vty_out (vty, " via %s)",
-                          inet_ntop (AF_INET6, &nexthop->rgate.ipv6,
-                                     buf, BUFSIZ));
-                 if (nexthop->rifindex)
-                   vty_out (vty, ", %s", ifindex2ifname (nexthop->rifindex));
-                 break;
-               case NEXTHOP_TYPE_IFINDEX:
-               case NEXTHOP_TYPE_IFNAME:
-                 vty_out (vty, " is directly connected, %s)",
-                          ifindex2ifname (nexthop->rifindex));
-                 break;
-               default:
-                 break;
-               }
-           }
+           vty_out (vty, " (recursive)");
+
          vty_out (vty, "%s", VTY_NEWLINE);
        }
       vty_out (vty, "%s", VTY_NEWLINE);
@@ -1622,12 +1622,13 @@ static void
 vty_show_ipv6_route (struct vty *vty, struct route_node *rn,
                     struct rib *rib)
 {
-  struct nexthop *nexthop;
+  struct nexthop *nexthop, *tnexthop;
+  int recursing;
   int len = 0;
   char buf[BUFSIZ];
 
   /* Nexthop information. */
-  for (nexthop = rib->nexthop; nexthop; nexthop = nexthop->next)
+  for (ALL_NEXTHOPS_RO(rib->nexthop, nexthop, tnexthop, recursing))
     {
       if (nexthop == rib->nexthop)
        {
@@ -1651,7 +1652,7 @@ vty_show_ipv6_route (struct vty *vty, struct route_node *rn,
        vty_out (vty, "  %c%*c",
                 CHECK_FLAG (nexthop->flags, NEXTHOP_FLAG_FIB)
                 ? '*' : ' ',
-                len - 3, ' ');
+                len - 3 + (2 * recursing), ' ');
 
       switch (nexthop->type)
        {
@@ -1680,29 +1681,7 @@ vty_show_ipv6_route (struct vty *vty, struct route_node *rn,
        vty_out (vty, " inactive");
 
       if (CHECK_FLAG (nexthop->flags, NEXTHOP_FLAG_RECURSIVE))
-       {
-         vty_out (vty, " (recursive");
-               
-         switch (nexthop->rtype)
-           {
-           case NEXTHOP_TYPE_IPV6:
-           case NEXTHOP_TYPE_IPV6_IFINDEX:
-           case NEXTHOP_TYPE_IPV6_IFNAME:
-             vty_out (vty, " via %s)",
-                      inet_ntop (AF_INET6, &nexthop->rgate.ipv6,
-                                 buf, BUFSIZ));
-             if (nexthop->rifindex)
-               vty_out (vty, ", %s", ifindex2ifname (nexthop->rifindex));
-             break;
-           case NEXTHOP_TYPE_IFINDEX:
-           case NEXTHOP_TYPE_IFNAME:
-             vty_out (vty, " is directly connected, %s)",
-                      ifindex2ifname (nexthop->rifindex));
-             break;
-           default:
-             break;
-           }
-       }
+       vty_out (vty, " (recursive)");
 
       if (CHECK_FLAG (rib->flags, ZEBRA_FLAG_BLACKHOLE))
        vty_out (vty, ", bh");
@@ -1711,6 +1690,7 @@ vty_show_ipv6_route (struct vty *vty, struct route_node *rn,
       
       if (rib->type == ZEBRA_ROUTE_RIPNG
          || rib->type == ZEBRA_ROUTE_OSPF6
+         || rib->type == ZEBRA_ROUTE_BABEL
          || rib->type == ZEBRA_ROUTE_ISIS
          || rib->type == ZEBRA_ROUTE_BGP)
        {
@@ -1757,7 +1737,7 @@ DEFUN (show_ipv6_route,
 
   /* Show all IPv6 route. */
   for (rn = route_top (table); rn; rn = route_next (rn))
-    for (rib = rn->info; rib; rib = rib->next)
+    RNODE_FOREACH_RIB (rn, rib)
       {
        if (first)
          {
@@ -1798,7 +1778,7 @@ DEFUN (show_ipv6_route_prefix_longer,
 
   /* Show matched type IPv6 routes. */
   for (rn = route_top (table); rn; rn = route_next (rn))
-    for (rib = rn->info; rib; rib = rib->next)
+    RNODE_FOREACH_RIB (rn, rib)
       if (prefix_match (&p, &rn->p))
        {
          if (first)
@@ -1838,7 +1818,7 @@ DEFUN (show_ipv6_route_protocol,
 
   /* Show matched type IPv6 routes. */
   for (rn = route_top (table); rn; rn = route_next (rn))
-    for (rib = rn->info; rib; rib = rib->next)
+    RNODE_FOREACH_RIB (rn, rib)
       if (rib->type == type)
        {
          if (first)
@@ -1947,41 +1927,6 @@ DEFUN (show_ipv6_route_summary,
   return CMD_SUCCESS;
 }
 
-/*
- * Show IP mroute command to dump the BGP Multicast 
- * routing table
- */
-DEFUN (show_ip_mroute,
-       show_ip_mroute_cmd,
-       "show ip mroute",
-       SHOW_STR
-       IP_STR
-       "IP Multicast routing table\n")
-{
-  struct route_table *table;
-  struct route_node *rn;
-  struct rib *rib;
-  int first = 1;
-
-  table = vrf_table (AFI_IP, SAFI_MULTICAST, 0);
-  if (! table)
-    return CMD_SUCCESS;
-
-  /* Show all IPv4 routes. */
-  for (rn = route_top (table); rn; rn = route_next (rn))
-    for (rib = rn->info; rib; rib = rib->next)
-      {
-       if (first)
-         {
-           vty_out (vty, SHOW_ROUTE_V4_HEADER, VTY_NEWLINE, VTY_NEWLINE,
-                    VTY_NEWLINE);
-           first = 0;
-         }
-       vty_show_ip_route (vty, rn, rib);
-      }
-  return CMD_SUCCESS;
-}
-
 /*
  * Show IPv6 mroute command.Used to dump
  * the Multicast routing table.
@@ -2005,11 +1950,11 @@ DEFUN (show_ipv6_mroute,
 
   /* Show all IPv6 route. */
   for (rn = route_top (table); rn; rn = route_next (rn))
-    for (rib = rn->info; rib; rib = rib->next)
+    RNODE_FOREACH_RIB (rn, rib)
       {
        if (first)
          {
-           vty_out (vty, SHOW_ROUTE_V6_HEADER, VTY_NEWLINE, VTY_NEWLINE, VTY_NEWLINE);
+          vty_out (vty, SHOW_ROUTE_V6_HEADER);
            first = 0;
          }
        vty_show_ipv6_route (vty, rn, rib);
@@ -2017,11 +1962,6 @@ DEFUN (show_ipv6_mroute,
   return CMD_SUCCESS;
 }
 
-
-
-
-
-
 /* Write IPv6 static route configuration. */
 static int
 static_config_ipv6 (struct vty *vty)