]> git.proxmox.com Git - mirror_frr.git/blobdiff - zebra/zebra_vty.c
vtysh: return non-zero for configuration failures
[mirror_frr.git] / zebra / zebra_vty.c
index 6329722b18157fdc29eaf0455fd1e6d4745a73d1..1b393830825392d9d5f19ddaaf4cf9a292460c94 100644 (file)
@@ -45,7 +45,9 @@
 extern int allow_delete;
 
 static int do_show_ip_route(struct vty *vty, const char *vrf_name,
-                            safi_t safi, bool use_fib, u_char use_json);
+                            afi_t afi, safi_t safi, bool use_fib, u_char use_json,
+                            route_tag_t tag, struct prefix *longer_prefix_p,
+                            bool supernets_only, int type, u_short ospf_instance_id);
 static void vty_show_ip_route_detail (struct vty *vty, struct route_node *rn,
                                       int mcast);
 
@@ -77,8 +79,8 @@ zebra_static_ipv4 (struct vty *vty, safi_t safi, int add_cmd,
   ret = str2prefix (dest_str, &p);
   if (ret <= 0)
     {
-      vty_out (vty, "%% Malformed address%s", VTY_NEWLINE);
-      return CMD_WARNING;
+      vty_outln (vty, "%% Malformed address");
+      return CMD_WARNING_CONFIG_FAILED;
     }
 
   /* Cisco like mask notation. */
@@ -87,8 +89,8 @@ zebra_static_ipv4 (struct vty *vty, safi_t safi, int add_cmd,
       ret = inet_aton (mask_str, &mask);
       if (ret == 0)
         {
-          vty_out (vty, "%% Malformed address%s", VTY_NEWLINE);
-          return CMD_WARNING;
+          vty_outln (vty, "%% Malformed address");
+          return CMD_WARNING_CONFIG_FAILED;
         }
       p.prefixlen = ip_masklen (mask);
     }
@@ -104,15 +106,15 @@ zebra_static_ipv4 (struct vty *vty, safi_t safi, int add_cmd,
 
   /* tag */
   if (tag_str)
-    VTY_GET_INTEGER_RANGE("tag", tag, tag_str, 0, 4294967295);
+    tag = strtoul(tag_str, NULL, 10);
 
   /* VRF id */
   zvrf = zebra_vrf_lookup_by_name (vrf_id_str);
 
   if (!zvrf)
     {
-      vty_out (vty, "%% vrf %s is not defined%s", vrf_id_str, VTY_NEWLINE);
-      return CMD_WARNING;
+      vty_outln (vty, "%% vrf %s is not defined", vrf_id_str);
+      return CMD_WARNING_CONFIG_FAILED;
     }
 
   /* Labels */
@@ -120,15 +122,28 @@ zebra_static_ipv4 (struct vty *vty, safi_t safi, int add_cmd,
     {
       if (!mpls_enabled)
        {
-         vty_out (vty, "%% MPLS not turned on in kernel, ignoring command%s",
-                  VTY_NEWLINE);
-         return CMD_WARNING;
+         vty_outln (vty,
+                     "%% MPLS not turned on in kernel, ignoring command");
+          return CMD_WARNING_CONFIG_FAILED;
        }
-      if (mpls_str2label (label_str, &snh_label.num_labels,
-                          snh_label.label))
+      int rc = mpls_str2label (label_str, &snh_label.num_labels,
+                               snh_label.label);
+      if (rc < 0)
         {
-          vty_out (vty, "%% Malformed label(s)%s", VTY_NEWLINE);
-          return CMD_WARNING;
+          switch (rc) {
+          case -1:
+            vty_outln (vty, "%% Malformed label(s)");
+            break;
+          case -2:
+            vty_outln (vty, "%% Cannot use reserved label(s) (%d-%d)",
+                     MPLS_MIN_RESERVED_LABEL,MPLS_MAX_RESERVED_LABEL);
+            break;
+          case -3:
+            vty_outln (vty, "%% Too many labels. Enter %d or fewer",
+                     MPLS_MAX_LABELS);
+            break;
+          }
+          return CMD_WARNING_CONFIG_FAILED;
         }
     }
 
@@ -137,8 +152,8 @@ zebra_static_ipv4 (struct vty *vty, safi_t safi, int add_cmd,
     {
       if (flag_str)
         {
-          vty_out (vty, "%% can not have flag %s with Null0%s", flag_str, VTY_NEWLINE);
-          return CMD_WARNING;
+          vty_outln (vty, "%% can not have flag %s with Null0", flag_str);
+          return CMD_WARNING_CONFIG_FAILED;
         }
       if (add_cmd)
         static_add_route (AFI_IP, safi, type, &p, NULL, NULL, ifindex, ifname,
@@ -161,8 +176,8 @@ zebra_static_ipv4 (struct vty *vty, safi_t safi, int add_cmd,
         SET_FLAG (flag, ZEBRA_FLAG_BLACKHOLE);
         break;
       default:
-        vty_out (vty, "%% Malformed flag %s %s", flag_str, VTY_NEWLINE);
-        return CMD_WARNING;
+        vty_outln (vty, "%% Malformed flag %s ", flag_str);
+        return CMD_WARNING_CONFIG_FAILED;
     }
   }
 
@@ -186,7 +201,7 @@ zebra_static_ipv4 (struct vty *vty, safi_t safi, int add_cmd,
       struct interface *ifp = if_lookup_by_name (gate_str, zvrf_id (zvrf));
       if (!ifp)
         {
-         vty_out (vty, "%% Unknown interface: %s%s", gate_str, VTY_NEWLINE);
+         vty_outln (vty, "%% Unknown interface: %s", gate_str);
           ifindex = IFINDEX_DELETED;
         }
       else
@@ -271,8 +286,8 @@ DEFUN (ip_multicast_mode,
     multicast_mode_ipv4_set (MCAST_MIX_PFXLEN);
   else
     {
-      vty_out (vty, "Invalid mode specified%s", VTY_NEWLINE);
-      return CMD_WARNING;
+      vty_outln (vty, "Invalid mode specified");
+      return CMD_WARNING_CONFIG_FAILED;
     }
 
   return CMD_SUCCESS;
@@ -298,12 +313,14 @@ DEFUN (no_ip_multicast_mode,
 
 DEFUN (show_ip_rpf,
        show_ip_rpf_cmd,
-       "show ip rpf",
+       "show ip rpf [json]",
        SHOW_STR
        IP_STR
-       "Display RPF information for multicast source\n")
+       "Display RPF information for multicast source\n"
+       JSON_STR)
 {
-  return do_show_ip_route(vty, VRF_DEFAULT_NAME, SAFI_MULTICAST, false, 0);
+  int uj = use_json(argc, argv);
+  return do_show_ip_route (vty, VRF_DEFAULT_NAME, AFI_IP, SAFI_MULTICAST, false, uj, 0, NULL, false, -1, 0);
 }
 
 DEFUN (show_ip_rpf_addr,
@@ -317,22 +334,22 @@ DEFUN (show_ip_rpf_addr,
   int idx_ipv4 = 3;
   struct in_addr addr;
   struct route_node *rn;
-  struct rib *rib;
+  struct route_entry *re;
   int ret;
 
   ret = inet_aton (argv[idx_ipv4]->arg, &addr);
   if (ret == 0)
     {
-      vty_out (vty, "%% Malformed address%s", VTY_NEWLINE);
+      vty_outln (vty, "%% Malformed address");
       return CMD_WARNING;
     }
 
-  rib = rib_match_ipv4_multicast (VRF_DEFAULT, addr, &rn);
+  re = rib_match_ipv4_multicast (VRF_DEFAULT, addr, &rn);
 
-  if (rib)
+  if (re)
     vty_show_ip_route_detail (vty, rn, 1);
   else
-    vty_out (vty, "%% No match for RPF lookup%s", VTY_NEWLINE);
+    vty_outln (vty, "%% No match for RPF lookup");
 
   return CMD_SUCCESS;
 }
@@ -416,9 +433,7 @@ DEFUN (ip_route_flags,
        "Set tag for this route\n"
        "Tag value\n"
        "Distance value for this route\n"
-       VRF_CMD_HELP_STR
-       "Specify labels for this route\n"
-       "One or more labels separated by '/'\n")
+       VRF_CMD_HELP_STR)
 {
   int idx_ipv4_prefixlen = 2;
   int idx_reject_blackhole = 3;
@@ -450,9 +465,7 @@ DEFUN (ip_route_mask,
        "Set tag for this route\n"
        "Tag value\n"
        "Distance value for this route\n"
-       VRF_CMD_HELP_STR
-       "Specify labels for this route\n"
-       "One or more labels separated by '/'\n")
+       VRF_CMD_HELP_STR)
 {
   int idx_ipv4 = 2;
   int idx_ipv4_2 = 3;
@@ -482,9 +495,7 @@ DEFUN (ip_route_mask_flags,
        "Set tag for this route\n"
        "Tag value\n"
        "Distance value for this route\n"
-       VRF_CMD_HELP_STR
-       "Specify labels for this route\n"
-       "One or more labels separated by '/'\n")
+       VRF_CMD_HELP_STR)
 {
   int idx_ipv4 = 2;
   int idx_ipv4_2 = 3;
@@ -516,9 +527,7 @@ DEFUN (no_ip_route,
        "Tag of this route\n"
        "Tag value\n"
        "Distance value for this route\n"
-       VRF_CMD_HELP_STR
-       "Specify labels for this route\n"
-       "One or more labels separated by '/'\n")
+       VRF_CMD_HELP_STR)
 {
   int idx_ipv4_prefixlen = 3;
   int idx_ipv4_ifname_null = 4;
@@ -548,9 +557,7 @@ DEFUN (no_ip_route_flags,
        "Tag of this route\n"
        "Tag value\n"
        "Distance value for this route\n"
-       VRF_CMD_HELP_STR
-       "Specify labels for this route\n"
-       "One or more labels separated by '/'\n")
+       VRF_CMD_HELP_STR)
 {
   int idx_ipv4_prefixlen = 3;
   int idx_curr = 5;
@@ -579,9 +586,7 @@ DEFUN (no_ip_route_mask,
        "Tag of this route\n"
        "Tag value\n"
        "Distance value for this route\n"
-       VRF_CMD_HELP_STR
-       "Specify labels for this route\n"
-       "One or more labels separated by '/'\n")
+       VRF_CMD_HELP_STR)
 {
   int idx_ipv4 = 3;
   int idx_ipv4_2 = 4;
@@ -613,9 +618,7 @@ DEFUN (no_ip_route_mask_flags,
        "Tag of this route\n"
        "Tag value\n"
        "Distance value for this route\n"
-       VRF_CMD_HELP_STR
-       "Specify labels for this route\n"
-       "One or more labels separated by '/'\n")
+       VRF_CMD_HELP_STR)
 {
   int idx_ipv4 = 3;
   int idx_ipv4_2 = 4;
@@ -636,13 +639,13 @@ DEFUN (no_ip_route_mask_flags,
 static void
 vty_show_ip_route_detail (struct vty *vty, struct route_node *rn, int mcast)
 {
-  struct rib *rib;
+  struct route_entry *re;
   struct nexthop *nexthop, *tnexthop;
   int recursing;
   char buf[SRCDEST2STR_BUFFER];
   struct zebra_vrf *zvrf;
 
-  RNODE_FOREACH_RIB (rn, rib)
+  RNODE_FOREACH_RE (rn, re)
     {
       const char *mcast_info = "";
       if (mcast)
@@ -655,43 +658,43 @@ vty_show_ip_route_detail (struct vty *vty, struct route_node *rn, int mcast)
 
       vty_out (vty, "Routing entry for %s%s%s",
               srcdest_rnode2str(rn, buf, sizeof(buf)), mcast_info,
-              VTY_NEWLINE);
-      vty_out (vty, "  Known via \"%s", zebra_route_string (rib->type));
-      if (rib->instance)
-        vty_out (vty, "[%d]", rib->instance);
+              VTYNL);
+      vty_out (vty, "  Known via \"%s", zebra_route_string (re->type));
+      if (re->instance)
+        vty_out (vty, "[%d]", re->instance);
       vty_out (vty, "\"");
-      vty_out (vty, ", distance %u, metric %u", rib->distance, rib->metric);
-      if (rib->tag)
-       vty_out (vty, ", tag %d", rib->tag);
-       if (rib->mtu)
-        vty_out (vty, ", mtu %u", rib->mtu);
-      if (rib->vrf_id != VRF_DEFAULT)
+      vty_out (vty, ", distance %u, metric %u", re->distance, re->metric);
+      if (re->tag)
+       vty_out (vty, ", tag %d", re->tag);
+       if (re->mtu)
+        vty_out (vty, ", mtu %u", re->mtu);
+      if (re->vrf_id != VRF_DEFAULT)
         {
-          zvrf = vrf_info_lookup(rib->vrf_id);
+          zvrf = vrf_info_lookup(re->vrf_id);
           vty_out (vty, ", vrf %s", zvrf_name (zvrf));
         }
-      if (CHECK_FLAG (rib->flags, ZEBRA_FLAG_SELECTED))
+      if (CHECK_FLAG (re->flags, ZEBRA_FLAG_SELECTED))
        vty_out (vty, ", best");
-      if (rib->refcnt)
-       vty_out (vty, ", refcnt %ld", rib->refcnt);
-      if (CHECK_FLAG (rib->flags, ZEBRA_FLAG_BLACKHOLE))
+      if (re->refcnt)
+       vty_out (vty, ", refcnt %ld", re->refcnt);
+      if (CHECK_FLAG (re->flags, ZEBRA_FLAG_BLACKHOLE))
        vty_out (vty, ", blackhole");
-      if (CHECK_FLAG (rib->flags, ZEBRA_FLAG_REJECT))
+      if (CHECK_FLAG (re->flags, ZEBRA_FLAG_REJECT))
        vty_out (vty, ", reject");
-      vty_out (vty, "%s", VTY_NEWLINE);
-
-      if (rib->type == ZEBRA_ROUTE_RIP
-         || rib->type == ZEBRA_ROUTE_OSPF
-         || rib->type == ZEBRA_ROUTE_ISIS
-         || rib->type == ZEBRA_ROUTE_NHRP
-         || rib->type == ZEBRA_ROUTE_TABLE
-         || rib->type == ZEBRA_ROUTE_BGP)
+      vty_out (vty, "%s", VTYNL);
+
+      if (re->type == ZEBRA_ROUTE_RIP
+         || re->type == ZEBRA_ROUTE_OSPF
+         || re->type == ZEBRA_ROUTE_ISIS
+         || re->type == ZEBRA_ROUTE_NHRP
+         || re->type == ZEBRA_ROUTE_TABLE
+         || re->type == ZEBRA_ROUTE_BGP)
        {
          time_t uptime;
          struct tm *tm;
 
          uptime = time (NULL);
-         uptime -= rib->uptime;
+         uptime -= re->uptime;
          tm = gmtime (&uptime);
 
          vty_out (vty, "  Last update ");
@@ -706,10 +709,10 @@ vty_show_ip_route_detail (struct vty *vty, struct route_node *rn, int mcast)
            vty_out (vty, "%02dw%dd%02dh",
                     tm->tm_yday/7,
                     tm->tm_yday - ((tm->tm_yday/7) * 7), tm->tm_hour);
-         vty_out (vty, " ago%s", VTY_NEWLINE);
+         vty_out (vty, " ago%s", VTYNL);
        }
 
-      for (ALL_NEXTHOPS_RO(rib->nexthop, nexthop, tnexthop, recursing))
+      for (ALL_NEXTHOPS_RO(re->nexthop, nexthop, tnexthop, recursing))
        {
           char addrstr[32];
 
@@ -724,19 +727,19 @@ vty_show_ip_route_detail (struct vty *vty, struct route_node *rn, int mcast)
              vty_out (vty, " %s", inet_ntoa (nexthop->gate.ipv4));
              if (nexthop->ifindex)
                vty_out (vty, ", via %s",
-                         ifindex2ifname (nexthop->ifindex, rib->vrf_id));
+                         ifindex2ifname (nexthop->ifindex, re->vrf_id));
              break;
            case NEXTHOP_TYPE_IPV6:
            case NEXTHOP_TYPE_IPV6_IFINDEX:
              vty_out (vty, " %s",
-                      inet_ntop (AF_INET6, &nexthop->gate.ipv6, buf, BUFSIZ));
+                      inet_ntop (AF_INET6, &nexthop->gate.ipv6, buf, sizeof buf));
              if (nexthop->ifindex)
                vty_out (vty, ", via %s",
-                         ifindex2ifname (nexthop->ifindex, rib->vrf_id));
+                         ifindex2ifname (nexthop->ifindex, re->vrf_id));
              break;
            case NEXTHOP_TYPE_IFINDEX:
              vty_out (vty, " directly connected, %s",
-                      ifindex2ifname (nexthop->ifindex, rib->vrf_id));
+                      ifindex2ifname (nexthop->ifindex, re->vrf_id));
              break;
            case NEXTHOP_TYPE_BLACKHOLE:
              vty_out (vty, " directly connected, Null0");
@@ -782,17 +785,17 @@ vty_show_ip_route_detail (struct vty *vty, struct route_node *rn, int mcast)
            {
              vty_out (vty, ", label %s",
                       mpls_label2str (nexthop->nh_label->num_labels,
-                                      nexthop->nh_label->label, buf, BUFSIZ, 1));
+                                      nexthop->nh_label->label, buf, sizeof buf, 1));
            }
 
-         vty_out (vty, "%s", VTY_NEWLINE);
+         vty_out (vty, "%s", VTYNL);
        }
-      vty_out (vty, "%s", VTY_NEWLINE);
+      vty_out (vty, "%s", VTYNL);
     }
 }
 
 static void
-vty_show_ip_route (struct vty *vty, struct route_node *rn, struct rib *rib,
+vty_show_ip_route (struct vty *vty, struct route_node *rn, struct route_entry *re,
                    json_object *json)
 {
   struct nexthop *nexthop, *tnexthop;
@@ -810,41 +813,41 @@ vty_show_ip_route (struct vty *vty, struct route_node *rn, struct rib *rib,
       json_nexthops = json_object_new_array();
 
       json_object_string_add(json_route, "prefix", srcdest_rnode2str (rn, buf, sizeof buf));
-      json_object_string_add(json_route, "protocol", zebra_route_string(rib->type));
+      json_object_string_add(json_route, "protocol", zebra_route_string(re->type));
 
-      if (rib->instance)
-        json_object_int_add(json_route, "instance", rib->instance);
+      if (re->instance)
+        json_object_int_add(json_route, "instance", re->instance);
 
-      if (rib->vrf_id)
-        json_object_int_add(json_route, "vrfId", rib->vrf_id);
+      if (re->vrf_id)
+        json_object_int_add(json_route, "vrfId", re->vrf_id);
 
-      if (CHECK_FLAG (rib->flags, ZEBRA_FLAG_SELECTED))
+      if (CHECK_FLAG (re->flags, ZEBRA_FLAG_SELECTED))
         json_object_boolean_true_add(json_route, "selected");
 
-      if (rib->type != ZEBRA_ROUTE_CONNECT && rib->type != ZEBRA_ROUTE_KERNEL)
+      if (re->type != ZEBRA_ROUTE_CONNECT && re->type != ZEBRA_ROUTE_KERNEL)
         {
-          json_object_int_add(json_route, "distance", rib->distance);
-          json_object_int_add(json_route, "metric", rib->metric);
+          json_object_int_add(json_route, "distance", re->distance);
+          json_object_int_add(json_route, "metric", re->metric);
         }
 
-      if (CHECK_FLAG (rib->flags, ZEBRA_FLAG_BLACKHOLE))
+      if (CHECK_FLAG (re->flags, ZEBRA_FLAG_BLACKHOLE))
         json_object_boolean_true_add(json_route, "blackhole");
 
-      if (CHECK_FLAG (rib->flags, ZEBRA_FLAG_REJECT))
+      if (CHECK_FLAG (re->flags, ZEBRA_FLAG_REJECT))
         json_object_boolean_true_add(json_route, "reject");
 
-      if (rib->type == ZEBRA_ROUTE_RIP
-          || rib->type == ZEBRA_ROUTE_OSPF
-          || rib->type == ZEBRA_ROUTE_ISIS
-         || rib->type == ZEBRA_ROUTE_NHRP
-          || rib->type == ZEBRA_ROUTE_TABLE
-          || rib->type == ZEBRA_ROUTE_BGP)
+      if (re->type == ZEBRA_ROUTE_RIP
+          || re->type == ZEBRA_ROUTE_OSPF
+          || re->type == ZEBRA_ROUTE_ISIS
+         || re->type == ZEBRA_ROUTE_NHRP
+          || re->type == ZEBRA_ROUTE_TABLE
+          || re->type == ZEBRA_ROUTE_BGP)
         {
           time_t uptime;
           struct tm *tm;
 
           uptime = time (NULL);
-          uptime -= rib->uptime;
+          uptime -= re->uptime;
           tm = gmtime (&uptime);
 
           if (uptime < ONE_DAY_SECOND)
@@ -857,7 +860,7 @@ vty_show_ip_route (struct vty *vty, struct route_node *rn, struct rib *rib,
           json_object_string_add(json_route, "uptime", buf);
         }
 
-      for (ALL_NEXTHOPS_RO(rib->nexthop, nexthop, tnexthop, recursing))
+      for (ALL_NEXTHOPS_RO(re->nexthop, nexthop, tnexthop, recursing))
         {
           json_nexthop = json_object_new_object();
 
@@ -874,25 +877,25 @@ vty_show_ip_route (struct vty *vty, struct route_node *rn, struct rib *rib,
               if (nexthop->ifindex)
                 {
                   json_object_int_add(json_nexthop, "interfaceIndex", nexthop->ifindex);
-                  json_object_string_add(json_nexthop, "interfaceName", ifindex2ifname (nexthop->ifindex, rib->vrf_id));
+                  json_object_string_add(json_nexthop, "interfaceName", ifindex2ifname (nexthop->ifindex, re->vrf_id));
                 }
               break;
             case NEXTHOP_TYPE_IPV6:
             case NEXTHOP_TYPE_IPV6_IFINDEX:
-              json_object_string_add(json_nexthop, "ip", inet_ntop (AF_INET6, &nexthop->gate.ipv6, buf, BUFSIZ));
+              json_object_string_add(json_nexthop, "ip", inet_ntop (AF_INET6, &nexthop->gate.ipv6, buf, sizeof buf));
               json_object_string_add(json_nexthop, "afi", "ipv6");
 
               if (nexthop->ifindex)
                 {
                   json_object_int_add(json_nexthop, "interfaceIndex", nexthop->ifindex);
-                  json_object_string_add(json_nexthop, "interfaceName", ifindex2ifname (nexthop->ifindex, rib->vrf_id));
+                  json_object_string_add(json_nexthop, "interfaceName", ifindex2ifname (nexthop->ifindex, re->vrf_id));
                 }
               break;
 
             case NEXTHOP_TYPE_IFINDEX:
               json_object_boolean_true_add(json_nexthop, "directlyConnected");
               json_object_int_add(json_nexthop, "interfaceIndex", nexthop->ifindex);
-              json_object_string_add(json_nexthop, "interfaceName", ifindex2ifname (nexthop->ifindex, rib->vrf_id));
+              json_object_string_add(json_nexthop, "interfaceName", ifindex2ifname (nexthop->ifindex, re->vrf_id));
               break;
             case NEXTHOP_TYPE_BLACKHOLE:
               json_object_boolean_true_add(json_nexthop, "blackhole");
@@ -951,26 +954,26 @@ vty_show_ip_route (struct vty *vty, struct route_node *rn, struct rib *rib,
     }
 
   /* Nexthop information. */
-  for (ALL_NEXTHOPS_RO(rib->nexthop, nexthop, tnexthop, recursing))
+  for (ALL_NEXTHOPS_RO(re->nexthop, nexthop, tnexthop, recursing))
     {
-      if (nexthop == rib->nexthop)
+      if (nexthop == re->nexthop)
        {
          /* Prefix information. */
-         len = vty_out (vty, "%c", zebra_route_char (rib->type));
-          if (rib->instance)
-           len += vty_out (vty, "[%d]", rib->instance);
+         len = vty_out (vty, "%c", zebra_route_char (re->type));
+          if (re->instance)
+           len += vty_out (vty, "[%d]", re->instance);
           len += vty_out (vty, "%c%c %s",
-                         CHECK_FLAG (rib->flags, ZEBRA_FLAG_SELECTED)
+                         CHECK_FLAG (re->flags, ZEBRA_FLAG_SELECTED)
                          ? '>' : ' ',
                          CHECK_FLAG (nexthop->flags, NEXTHOP_FLAG_FIB)
                          ? '*' : ' ',
                          srcdest_rnode2str (rn, buf, sizeof buf));
 
          /* Distance and metric display. */
-         if (rib->type != ZEBRA_ROUTE_CONNECT
-             && rib->type != ZEBRA_ROUTE_KERNEL)
-           len += vty_out (vty, " [%d/%d]", rib->distance,
-                           rib->metric);
+         if (re->type != ZEBRA_ROUTE_CONNECT
+             && re->type != ZEBRA_ROUTE_KERNEL)
+           len += vty_out (vty, " [%d/%d]", re->distance,
+                           re->metric);
        }
       else
        vty_out (vty, "  %c%*c",
@@ -985,20 +988,20 @@ vty_show_ip_route (struct vty *vty, struct route_node *rn, struct rib *rib,
          vty_out (vty, " via %s", inet_ntoa (nexthop->gate.ipv4));
          if (nexthop->ifindex)
            vty_out (vty, ", %s",
-                     ifindex2ifname (nexthop->ifindex, rib->vrf_id));
+                     ifindex2ifname (nexthop->ifindex, re->vrf_id));
          break;
         case NEXTHOP_TYPE_IPV6:
        case NEXTHOP_TYPE_IPV6_IFINDEX:
          vty_out (vty, " via %s",
-                  inet_ntop (AF_INET6, &nexthop->gate.ipv6, buf, BUFSIZ));
+                  inet_ntop (AF_INET6, &nexthop->gate.ipv6, buf, sizeof buf));
          if (nexthop->ifindex)
            vty_out (vty, ", %s",
-                     ifindex2ifname (nexthop->ifindex, rib->vrf_id));
+                     ifindex2ifname (nexthop->ifindex, re->vrf_id));
          break;
 
        case NEXTHOP_TYPE_IFINDEX:
          vty_out (vty, " is directly connected, %s",
-                  ifindex2ifname (nexthop->ifindex, rib->vrf_id));
+                  ifindex2ifname (nexthop->ifindex, re->vrf_id));
          break;
        case NEXTHOP_TYPE_BLACKHOLE:
          vty_out (vty, " is directly connected, Null0");
@@ -1042,26 +1045,26 @@ vty_show_ip_route (struct vty *vty, struct route_node *rn, struct rib *rib,
        {
          vty_out (vty, ", label %s",
                   mpls_label2str (nexthop->nh_label->num_labels,
-                                  nexthop->nh_label->label, buf, BUFSIZ, 1));
+                                  nexthop->nh_label->label, buf, sizeof buf, 1));
        }
 
-      if (CHECK_FLAG (rib->flags, ZEBRA_FLAG_BLACKHOLE))
+      if (CHECK_FLAG (re->flags, ZEBRA_FLAG_BLACKHOLE))
                vty_out (vty, ", bh");
-      if (CHECK_FLAG (rib->flags, ZEBRA_FLAG_REJECT))
+      if (CHECK_FLAG (re->flags, ZEBRA_FLAG_REJECT))
                vty_out (vty, ", rej");
 
-      if (rib->type == ZEBRA_ROUTE_RIP
-         || rib->type == ZEBRA_ROUTE_OSPF
-         || rib->type == ZEBRA_ROUTE_ISIS
-         || rib->type == ZEBRA_ROUTE_NHRP
-         || rib->type == ZEBRA_ROUTE_TABLE
-         || rib->type == ZEBRA_ROUTE_BGP)
+      if (re->type == ZEBRA_ROUTE_RIP
+         || re->type == ZEBRA_ROUTE_OSPF
+         || re->type == ZEBRA_ROUTE_ISIS
+         || re->type == ZEBRA_ROUTE_NHRP
+         || re->type == ZEBRA_ROUTE_TABLE
+         || re->type == ZEBRA_ROUTE_BGP)
        {
          time_t uptime;
          struct tm *tm;
 
          uptime = time (NULL);
-         uptime -= rib->uptime;
+         uptime -= re->uptime;
          tm = gmtime (&uptime);
 
          if (uptime < ONE_DAY_SECOND)
@@ -1075,7 +1078,7 @@ vty_show_ip_route (struct vty *vty, struct route_node *rn, struct rib *rib,
                     tm->tm_yday/7,
                     tm->tm_yday - ((tm->tm_yday/7) * 7), tm->tm_hour);
        }
-      vty_out (vty, "%s", VTY_NEWLINE);
+      vty_out (vty, "%s", VTYNL);
     }
 }
 
@@ -1085,122 +1088,127 @@ use_fib (struct cmd_token *token)
   return strncmp(token->arg, "route", strlen(token->arg));
 }
 
-DEFUN (show_ip_route,
-       show_ip_route_cmd,
-       "show ip <fib|route> [json]",
-       SHOW_STR
-       IP_STR
-       "IP forwarding table\n"
-       "IP routing table\n"
-       JSON_STR)
-{
-  return do_show_ip_route (vty, VRF_DEFAULT_NAME, SAFI_UNICAST,
-                           use_fib(argv[2]), use_json(argc, argv));
-}
-
 static int
-do_show_ip_route (struct vty *vty, const char *vrf_name, safi_t safi,
-                  bool use_fib, u_char use_json)
+do_show_ip_route (struct vty *vty, const char *vrf_name, afi_t afi, safi_t safi,
+                  bool use_fib, u_char use_json, route_tag_t tag,
+                  struct prefix *longer_prefix_p, bool supernets_only,
+                  int type, u_short ospf_instance_id)
 {
   struct route_table *table;
   struct route_node *rn;
-  struct rib *rib;
+  struct route_entry *re;
   int first = 1;
   struct zebra_vrf *zvrf = NULL;
   char buf[BUFSIZ];
   json_object *json = NULL;
   json_object *json_prefix = NULL;
+  u_int32_t addr;
 
   if (!(zvrf = zebra_vrf_lookup_by_name (vrf_name)))
     {
       if (use_json)
-        vty_out (vty, "{}%s", VTY_NEWLINE);
+        vty_outln (vty, "{}");
       else
-        vty_out (vty, "vrf %s not defined%s", vrf_name, VTY_NEWLINE);
+        vty_outln (vty, "vrf %s not defined", vrf_name);
       return CMD_SUCCESS;
     }
 
   if (zvrf_id (zvrf) == VRF_UNKNOWN)
     {
       if (use_json)
-        vty_out (vty, "{}%s", VTY_NEWLINE);
+        vty_outln (vty, "{}");
       else
-        vty_out (vty, "vrf %s inactive%s", vrf_name, VTY_NEWLINE);
+        vty_outln (vty, "vrf %s inactive", vrf_name);
       return CMD_SUCCESS;
     }
 
-  table = zebra_vrf_table (AFI_IP, safi, zvrf_id (zvrf));
+  table = zebra_vrf_table (afi, safi, zvrf_id (zvrf));
   if (! table)
     {
       if (use_json)
-        vty_out (vty, "{}%s", VTY_NEWLINE);
+        vty_outln (vty, "{}");
       return CMD_SUCCESS;
     }
 
   if (use_json)
-    {
       json = json_object_new_object();
 
-      /* Show all IPv4 routes. */
-      for (rn = route_top (table); rn; rn = route_next (rn))
+  /* Show all routes. */
+  for (rn = route_top (table); rn; rn = route_next (rn))
+    {
+      RNODE_FOREACH_RE (rn, re)
         {
-          RNODE_FOREACH_RIB (rn, rib)
+          if (use_fib && !CHECK_FLAG(re->status, ROUTE_ENTRY_SELECTED_FIB))
+            continue;
+
+          if (tag && re->tag != tag)
+            continue;
+
+          if (longer_prefix_p && ! prefix_match (longer_prefix_p, &rn->p))
+            continue;
+
+          /* This can only be true when the afi is IPv4 */
+          if (supernets_only)
             {
-              if (use_fib && !CHECK_FLAG(rib->status, RIB_ENTRY_SELECTED_FIB))
+              addr = ntohl (rn->p.u.prefix4.s_addr);
+
+              if (IN_CLASSC (addr) && rn->p.prefixlen >= 24)
+                continue;
+
+              if (IN_CLASSB (addr) && rn->p.prefixlen >= 16)
+                continue;
+
+              if (IN_CLASSA (addr) && rn->p.prefixlen >= 8)
                 continue;
-              if (!json_prefix)
-                json_prefix = json_object_new_array();
-              vty_show_ip_route (vty, rn, rib, json_prefix);
             }
 
-          if (json_prefix)
+          if (type && re->type != type)
+            continue;
+
+          if (ospf_instance_id && (re->type != ZEBRA_ROUTE_OSPF || re->instance != ospf_instance_id))
+            continue;
+
+          if (use_json)
             {
-              prefix2str (&rn->p, buf, sizeof buf);
-              json_object_object_add(json, buf, json_prefix);
-              json_prefix = NULL;
+              if (!json_prefix)
+                json_prefix = json_object_new_array();
             }
-        }
-
-      vty_out (vty, "%s%s", json_object_to_json_string_ext(json, JSON_C_TO_STRING_PRETTY), VTY_NEWLINE);
-      json_object_free(json);
-    }
-  else
-    {
-      /* Show all IPv4 routes. */
-      for (rn = route_top (table); rn; rn = route_next (rn))
-        {
-          RNODE_FOREACH_RIB (rn, rib)
+          else
             {
-              if (use_fib && !CHECK_FLAG(rib->status, RIB_ENTRY_SELECTED_FIB))
-                continue;
               if (first)
                 {
-                  vty_out (vty, SHOW_ROUTE_V4_HEADER);
+                  if (afi == AFI_IP)
+                    vty_out (vty, SHOW_ROUTE_V4_HEADER);
+                  else
+                    vty_out (vty, SHOW_ROUTE_V6_HEADER);
+
+                  if (zvrf_id (zvrf) != VRF_DEFAULT)
+                    vty_outln (vty, "%sVRF %s:", VTYNL,
+                               zvrf_name(zvrf));
+
                   first = 0;
                 }
-              vty_show_ip_route (vty, rn, rib, NULL);
             }
+
+          vty_show_ip_route (vty, rn, re, json_prefix);
         }
-    }
 
-  return CMD_SUCCESS;
-}
+      if (json_prefix)
+        {
+          prefix2str (&rn->p, buf, sizeof buf);
+          json_object_object_add(json, buf, json_prefix);
+          json_prefix = NULL;
+        }
+    }
 
-DEFUN (show_ip_route_vrf,
-       show_ip_route_vrf_cmd,
-       "show ip <fib|route> vrf NAME [json]",
-       SHOW_STR
-       IP_STR
-       "IP forwarding table\n"
-       "IP routing table\n"
-       VRF_CMD_HELP_STR
-       JSON_STR)
-{
-  int idx_vrf = 4;
-  bool uf = use_fib(argv[2]);
-  u_char uj = use_json(argc, argv);
+  if (use_json)
+    {
+      vty_outln (vty, "%s",
+                 json_object_to_json_string_ext(json, JSON_C_TO_STRING_PRETTY));
+      json_object_free(json);
+    }
 
-  return do_show_ip_route (vty, argv[idx_vrf]->arg, SAFI_UNICAST, uf, uj);
+  return CMD_SUCCESS;
 }
 
 DEFUN (show_ip_nht,
@@ -1236,7 +1244,7 @@ DEFUN (show_ip_nht_vrf_all,
   RB_FOREACH (vrf, vrf_name_head, &vrfs_by_name)
     if ((zvrf = vrf->info) != NULL)
       {
-        vty_out (vty, "%sVRF %s:%s", VTY_NEWLINE, zvrf_name (zvrf), VTY_NEWLINE);
+        vty_outln (vty, "%sVRF %s:", VTYNL, zvrf_name(zvrf));
         zebra_print_rnh_table(zvrf_id (zvrf), AF_INET, vty, RNH_NEXTHOP_TYPE);
       }
 
@@ -1276,7 +1284,7 @@ DEFUN (show_ipv6_nht_vrf_all,
   RB_FOREACH (vrf, vrf_name_head, &vrfs_by_name)
     if ((zvrf = vrf->info) != NULL)
       {
-        vty_out (vty, "%sVRF %s:%s", VTY_NEWLINE, zvrf_name (zvrf), VTY_NEWLINE);
+        vty_outln (vty, "%sVRF %s:", VTYNL, zvrf_name(zvrf));
         zebra_print_rnh_table(zvrf_id (zvrf), AF_INET6, vty, RNH_NEXTHOP_TYPE);
       }
 
@@ -1345,258 +1353,116 @@ DEFUN (no_ipv6_nht_default_route,
   return CMD_SUCCESS;
 }
 
-DEFUN (show_ip_route_tag,
-       show_ip_route_tag_cmd,
-       "show ip <fib|route> [vrf NAME] tag (1-4294967295)",
+DEFUN (show_ip_route,
+       show_ip_route_cmd,
+       "show ip <fib|route> [vrf NAME] [tag (1-4294967295)|A.B.C.D/M longer-prefixes|supernets-only|" FRR_IP_REDIST_STR_ZEBRA "|ospf (1-65535)] [json]",
        SHOW_STR
        IP_STR
        "IP forwarding table\n"
        "IP routing table\n"
        VRF_CMD_HELP_STR
        "Show only routes with tag\n"
-       "Tag value\n")
+       "Tag value\n"
+       "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
+       "Show route matching the specified Network/Mask pair only\n"
+       "Show supernet entries only\n"
+       FRR_IP_REDIST_HELP_STR_ZEBRA
+       "Open Shortest Path First (OSPFv2)\n"
+       "Instance ID\n"
+       JSON_STR)
 {
   bool uf = use_fib(argv[2]);
-  int idx_vrf = 3;
-  int idx_name = 4;
-  int idx_tag = 6;
   struct route_table *table;
-  struct route_node *rn;
-  struct rib *rib;
-  int first = 1;
+  int vrf_all = 0;
   route_tag_t tag = 0;
   vrf_id_t vrf_id = VRF_DEFAULT;
+  struct vrf *vrf;
+  struct zebra_vrf *zvrf;
+  int uj = use_json(argc, argv);
+  int idx = 0;
+  struct prefix p;
+  bool longer_prefixes = false;
+  bool supernets_only = false;
+  int type = 0;
+  u_short ospf_instance_id = 0;
 
-  if (strmatch(argv[idx_vrf]->text, "vrf"))
+  if (argv_find (argv, argc, "vrf", &idx))
     {
-      VRF_GET_ID (vrf_id, argv[idx_name]->arg);
-      VTY_GET_INTEGER_RANGE("tag", tag, argv[idx_tag]->arg, 0, 4294967295);
-    }
-  else
-    {
-      idx_tag -= 2;
-      VTY_GET_INTEGER_RANGE("tag", tag, argv[idx_tag]->arg, 0, 4294967295);
+      if (strmatch(argv[idx+1]->arg, "all"))
+        vrf_all = 1;
+      else
+        VRF_GET_ID (vrf_id, argv[idx+1]->arg);
     }
 
-  table = zebra_vrf_table (AFI_IP, SAFI_UNICAST, vrf_id);
-  if (! table)
-    return CMD_SUCCESS;
-
-  /* Show all IPv4 routes with matching tag value. */
-  for (rn = route_top (table); rn; rn = route_next (rn))
-    RNODE_FOREACH_RIB (rn, rib)
-      {
-        if (uf && !CHECK_FLAG(rib->status, RIB_ENTRY_SELECTED_FIB))
-          continue;
-        if (rib->tag != tag)
-          continue;
-
-        if (first)
-          {
-            vty_out (vty, SHOW_ROUTE_V4_HEADER);
-            first = 0;
-          }
-        vty_show_ip_route (vty, rn, rib, NULL);
-      }
-  return CMD_SUCCESS;
-}
-
-DEFUN (show_ip_route_prefix_longer,
-       show_ip_route_prefix_longer_cmd,
-       "show ip <fib|route> [vrf NAME] A.B.C.D/M longer-prefixes",
-       SHOW_STR
-       IP_STR
-       "IP forwarding table\n"
-       "IP routing table\n"
-       VRF_CMD_HELP_STR
-       "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
-       "Show route matching the specified Network/Mask pair only\n")
-{
-  struct route_table *table;
-  struct route_node *rn;
-  struct rib *rib;
-  struct prefix p;
-  int ret;
-  int first = 1;
-  bool uf = use_fib(argv[2]);
-  vrf_id_t vrf_id = VRF_DEFAULT;
+  if (argv_find (argv, argc, "tag", &idx))
+    tag = strtoul(argv[idx + 1]->arg, NULL, 10);
 
-  if (strmatch(argv[3]->text, "vrf"))
+  else if (argv_find (argv, argc, "A.B.C.D/M", &idx))
     {
-      VRF_GET_ID (vrf_id, argv[4]->arg);
-      ret = str2prefix (argv[5]->arg, &p);
+      str2prefix (argv[idx]->arg, &p);
+      longer_prefixes = true;
     }
+
+  else if (argv_find (argv, argc, "supernets_only", &idx))
+    supernets_only = true;
+
   else
     {
-      ret = str2prefix (argv[3]->arg, &p);
+      if (argv_find (argv, argc, "kernel", &idx))
+        type = proto_redistnum (AFI_IP, argv[idx]->text);
+      else if (argv_find (argv, argc, "babel", &idx))
+        type = proto_redistnum (AFI_IP, argv[idx]->text);
+      else if (argv_find (argv, argc, "connected", &idx))
+        type = proto_redistnum (AFI_IP, argv[idx]->text);
+      else if (argv_find (argv, argc, "static", &idx))
+        type = proto_redistnum (AFI_IP, argv[idx]->text);
+      else if (argv_find (argv, argc, "rip", &idx))
+        type = proto_redistnum (AFI_IP, argv[idx]->text);
+      else if (argv_find (argv, argc, "ospf", &idx))
+        type = proto_redistnum (AFI_IP, argv[idx]->text);
+      else if (argv_find (argv, argc, "isis", &idx))
+        type = proto_redistnum (AFI_IP, argv[idx]->text);
+      else if (argv_find (argv, argc, "bgp", &idx))
+        type = proto_redistnum (AFI_IP, argv[idx]->text);
+      else if (argv_find (argv, argc, "pim", &idx))
+        type = proto_redistnum (AFI_IP, argv[idx]->text);
+      else if (argv_find (argv, argc, "eigrp", &idx))
+        type = proto_redistnum (AFI_IP, argv[idx]->text);
+      else if (argv_find (argv, argc, "nhrp", &idx))
+        type = proto_redistnum (AFI_IP, argv[idx]->text);
+      else if (argv_find (argv, argc, "table", &idx))
+        type = proto_redistnum (AFI_IP, argv[idx]->text);
+      else if (argv_find (argv, argc, "vnc", &idx))
+        type = proto_redistnum (AFI_IP, argv[idx]->text);
+
+      if (argv_find (argv, argc, "(1-65535)", &idx))
+        ospf_instance_id = strtoul(argv[idx]->arg, NULL, 10);
+
+      if (type < 0)
+        {
+          vty_outln (vty, "Unknown route type");
+          return CMD_WARNING;
+        }
     }
 
-  if (! ret)
+  if (vrf_all)
     {
-      vty_out (vty, "%% Malformed Prefix%s", VTY_NEWLINE);
-      return CMD_WARNING;
-    }
-
-  table = zebra_vrf_table (AFI_IP, SAFI_UNICAST, vrf_id);
-  if (! table)
-    return CMD_SUCCESS;
-
-  /* Show matched type IPv4 routes. */
-  for (rn = route_top (table); rn; rn = route_next (rn))
-    RNODE_FOREACH_RIB (rn, rib)
-      if (prefix_match (&p, &rn->p))
-       {
-         if (uf && !CHECK_FLAG(rib->status, RIB_ENTRY_SELECTED_FIB))
-           continue;
-         if (first)
-           {
-             vty_out (vty, SHOW_ROUTE_V4_HEADER);
-             first = 0;
-           }
-         vty_show_ip_route (vty, rn, rib, NULL);
-       }
-  return CMD_SUCCESS;
-}
-
-DEFUN (show_ip_route_supernets,
-       show_ip_route_supernets_cmd,
-       "show ip <fib|route> [vrf NAME] supernets-only",
-       SHOW_STR
-       IP_STR
-       "IP forwarding table\n"
-       "IP routing table\n"
-       VRF_CMD_HELP_STR
-       "Show supernet entries only\n")
-{
-  struct route_table *table;
-  struct route_node *rn;
-  struct rib *rib;
-  u_int32_t addr;
-  int first = 1;
-  vrf_id_t vrf_id = VRF_DEFAULT;
-  bool uf = use_fib(argv[2]);
-
-  if (strmatch(argv[3]->text, "vrf"))
-    VRF_GET_ID (vrf_id, argv[4]->arg);
-
-  table = zebra_vrf_table (AFI_IP, SAFI_UNICAST, vrf_id);
-  if (! table)
-    return CMD_SUCCESS;
-
-  /* Show matched type IPv4 routes. */
-  for (rn = route_top (table); rn; rn = route_next (rn))
-    RNODE_FOREACH_RIB (rn, rib)
-      {
-       if (uf && !CHECK_FLAG(rib->status, RIB_ENTRY_SELECTED_FIB))
-         continue;
-       addr = ntohl (rn->p.u.prefix4.s_addr);
-
-       if ((IN_CLASSC (addr) && rn->p.prefixlen < 24)
-          || (IN_CLASSB (addr) && rn->p.prefixlen < 16)
-          || (IN_CLASSA (addr) && rn->p.prefixlen < 8))
-         {
-           if (first)
-             {
-               vty_out (vty, SHOW_ROUTE_V4_HEADER);
-               first = 0;
-             }
-           vty_show_ip_route (vty, rn, rib, NULL);
-         }
-      }
-  return CMD_SUCCESS;
-}
-
-DEFUN (show_ip_route_protocol,
-       show_ip_route_protocol_cmd,
-       "show ip <fib|route> [vrf NAME] " FRR_IP_REDIST_STR_ZEBRA,
-       SHOW_STR
-       IP_STR
-       "IP forwarding table\n"
-       "IP routing table\n"
-       VRF_CMD_HELP_STR
-       FRR_IP_REDIST_HELP_STR_ZEBRA)
-{
-  int type;
-  struct route_table *table;
-  struct route_node *rn;
-  struct rib *rib;
-  int first = 1;
-  vrf_id_t vrf_id = VRF_DEFAULT;
-  bool uf = use_fib(argv[2]);
-
-  int idx = 0;
-  if (argv_find (argv, argc, "NAME", &idx))
-    VRF_GET_ID (vrf_id, argv[idx]->arg);
-
-  char *proto = argv[argc - 1]->text;
-  type = proto_redistnum (AFI_IP, proto);
+      RB_FOREACH (vrf, vrf_name_head, &vrfs_by_name)
+        {
+          if ((zvrf = vrf->info) == NULL ||
+              (table = zvrf->table[AFI_IP][SAFI_UNICAST]) == NULL)
+            continue;
 
-  if (type < 0)
+          do_show_ip_route (vty, zvrf_name (zvrf), AFI_IP, SAFI_UNICAST, uf, uj, tag,
+                            longer_prefixes ? &p : NULL, supernets_only, type, ospf_instance_id);
+        }
+    }
+  else
     {
-      vty_out (vty, "Unknown route type%s", VTY_NEWLINE);
-      return CMD_WARNING;
+      vrf = vrf_lookup_by_id (vrf_id);
+      do_show_ip_route (vty, vrf->name, AFI_IP, SAFI_UNICAST, uf, uj, tag,
+                        longer_prefixes ? &p : NULL, supernets_only, type, ospf_instance_id);
     }
-
-  table = zebra_vrf_table (AFI_IP, SAFI_UNICAST, vrf_id);
-  if (! table)
-    return CMD_SUCCESS;
-
-  /* Show matched type IPv4 routes. */
-  for (rn = route_top (table); rn; rn = route_next (rn))
-    RNODE_FOREACH_RIB (rn, rib)
-      if (rib->type == type)
-       {
-         if (uf && !CHECK_FLAG(rib->status, RIB_ENTRY_SELECTED_FIB))
-           continue;
-         if (first)
-           {
-             vty_out (vty, SHOW_ROUTE_V4_HEADER);
-             first = 0;
-           }
-         vty_show_ip_route (vty, rn, rib, NULL);
-       }
-  return CMD_SUCCESS;
-}
-
-
-DEFUN (show_ip_route_ospf_instance,
-       show_ip_route_ospf_instance_cmd,
-       "show ip <fib|route> ospf (1-65535)",
-       SHOW_STR
-       IP_STR
-       "IP forwarding table\n"
-       "IP routing table\n"
-       "Open Shortest Path First (OSPFv2)\n"
-       "Instance ID\n")
-{
-  int idx_number = 4;
-  struct route_table *table;
-  struct route_node *rn;
-  struct rib *rib;
-  int first = 1;
-  u_short instance = 0;
-  bool uf = use_fib(argv[2]);
-
-  VTY_GET_INTEGER ("Instance", instance, argv[idx_number]->arg);
-
-  table = zebra_vrf_table (AFI_IP, SAFI_UNICAST, VRF_DEFAULT);
-  if (! table)
-    return CMD_SUCCESS;
-
-  /* Show matched type IPv4 routes. */
-  for (rn = route_top (table); rn; rn = route_next (rn))
-    RNODE_FOREACH_RIB (rn, rib)
-      if (rib->type == ZEBRA_ROUTE_OSPF && rib->instance == instance)
-       {
-         if (uf && !CHECK_FLAG(rib->status, RIB_ENTRY_SELECTED_FIB))
-           continue;
-         if (first)
-           {
-             vty_out (vty, SHOW_ROUTE_V4_HEADER);
-             first = 0;
-           }
-         vty_show_ip_route (vty, rn, rib, NULL);
-       }
   return CMD_SUCCESS;
 }
 
@@ -1627,7 +1493,7 @@ DEFUN (show_ip_route_addr,
 
   if (ret <= 0)
     {
-      vty_out (vty, "%% Malformed IPv4 address%s", VTY_NEWLINE);
+      vty_outln (vty, "%% Malformed IPv4 address");
       return CMD_WARNING;
     }
 
@@ -1638,7 +1504,7 @@ DEFUN (show_ip_route_addr,
   rn = route_node_match (table, (struct prefix *) &p);
   if (! rn)
     {
-      vty_out (vty, "%% Network not in table%s", VTY_NEWLINE);
+      vty_outln (vty, "%% Network not in table");
       return CMD_WARNING;
     }
 
@@ -1676,7 +1542,7 @@ DEFUN (show_ip_route_prefix,
 
   if (ret <= 0)
     {
-      vty_out (vty, "%% Malformed IPv4 address%s", VTY_NEWLINE);
+      vty_outln (vty, "%% Malformed IPv4 address");
       return CMD_WARNING;
     }
 
@@ -1687,7 +1553,7 @@ DEFUN (show_ip_route_prefix,
   rn = route_node_match (table, (struct prefix *) &p);
   if (! rn || rn->p.prefixlen != p.prefixlen)
     {
-      vty_out (vty, "%% Network not in table%s", VTY_NEWLINE);
+      vty_outln (vty, "%% Network not in table");
       return CMD_WARNING;
     }
 
@@ -1703,7 +1569,7 @@ static void
 vty_show_ip_route_summary (struct vty *vty, struct route_table *table)
 {
   struct route_node *rn;
-  struct rib *rib;
+  struct route_entry *re;
 #define ZEBRA_ROUTE_IBGP  ZEBRA_ROUTE_MAX
 #define ZEBRA_ROUTE_TOTAL (ZEBRA_ROUTE_IBGP + 1)
   u_int32_t rib_cnt[ZEBRA_ROUTE_TOTAL + 1];
@@ -1714,32 +1580,31 @@ 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 = srcdest_route_next (rn))
-    RNODE_FOREACH_RIB (rn, rib)
+    RNODE_FOREACH_RE (rn, re)
       {
-        is_ibgp = (rib->type == ZEBRA_ROUTE_BGP &&
-                   CHECK_FLAG (rib->flags, ZEBRA_FLAG_IBGP));
+        is_ibgp = (re->type == ZEBRA_ROUTE_BGP &&
+                   CHECK_FLAG (re->flags, ZEBRA_FLAG_IBGP));
 
         rib_cnt[ZEBRA_ROUTE_TOTAL]++;
         if (is_ibgp)
           rib_cnt[ZEBRA_ROUTE_IBGP]++;
         else
-          rib_cnt[rib->type]++;
+          rib_cnt[re->type]++;
 
-        if (CHECK_FLAG (rib->flags, ZEBRA_FLAG_SELECTED))
+        if (CHECK_FLAG (re->flags, ZEBRA_FLAG_SELECTED))
           {
             fib_cnt[ZEBRA_ROUTE_TOTAL]++;
 
             if (is_ibgp)
               fib_cnt[ZEBRA_ROUTE_IBGP]++;
             else
-              fib_cnt[rib->type]++;
+              fib_cnt[re->type]++;
           }
       }
 
-  vty_out (vty, "%-20s %-20s %s  (vrf %s)%s",
+  vty_outln (vty, "%-20s %-20s %s  (vrf %s)",
            "Route Source", "Routes", "FIB",
-           zvrf_name (((rib_table_info_t *)table->info)->zvrf),
-           VTY_NEWLINE);
+           zvrf_name(((rib_table_info_t *)table->info)->zvrf));
 
   for (i = 0; i < ZEBRA_ROUTE_MAX; i++)
     {
@@ -1748,23 +1613,21 @@ vty_show_ip_route_summary (struct vty *vty, struct route_table *table)
         {
           if (i == ZEBRA_ROUTE_BGP)
             {
-              vty_out (vty, "%-20s %-20d %-20d %s", "ebgp",
-                       rib_cnt[ZEBRA_ROUTE_BGP], fib_cnt[ZEBRA_ROUTE_BGP],
-                       VTY_NEWLINE);
-              vty_out (vty, "%-20s %-20d %-20d %s", "ibgp",
-                       rib_cnt[ZEBRA_ROUTE_IBGP], fib_cnt[ZEBRA_ROUTE_IBGP],
-                       VTY_NEWLINE);
+              vty_outln (vty, "%-20s %-20d %-20d ", "ebgp",
+                       rib_cnt[ZEBRA_ROUTE_BGP],fib_cnt[ZEBRA_ROUTE_BGP]);
+              vty_outln (vty, "%-20s %-20d %-20d ", "ibgp",
+                       rib_cnt[ZEBRA_ROUTE_IBGP],fib_cnt[ZEBRA_ROUTE_IBGP]);
             }
           else
-            vty_out (vty, "%-20s %-20d %-20d %s", zebra_route_string(i),
-                     rib_cnt[i], fib_cnt[i], VTY_NEWLINE);
+            vty_outln (vty, "%-20s %-20d %-20d ", zebra_route_string(i),
+                     rib_cnt[i], fib_cnt[i]);
         }
     }
 
-  vty_out (vty, "------%s", VTY_NEWLINE);
-  vty_out (vty, "%-20s %-20d %-20d %s", "Totals", rib_cnt[ZEBRA_ROUTE_TOTAL],
-           fib_cnt[ZEBRA_ROUTE_TOTAL], VTY_NEWLINE);
-  vty_out (vty, "%s", VTY_NEWLINE);
+  vty_outln (vty, "------");
+  vty_outln (vty, "%-20s %-20d %-20d ", "Totals", rib_cnt[ZEBRA_ROUTE_TOTAL],
+           fib_cnt[ZEBRA_ROUTE_TOTAL]);
+  vty_out (vty, VTYNL);
 }
 
 /*
@@ -1778,7 +1641,7 @@ static void
 vty_show_ip_route_summary_prefix (struct vty *vty, struct route_table *table)
 {
   struct route_node *rn;
-  struct rib *rib;
+  struct route_entry *re;
   struct nexthop *nexthop;
 #define ZEBRA_ROUTE_IBGP  ZEBRA_ROUTE_MAX
 #define ZEBRA_ROUTE_TOTAL (ZEBRA_ROUTE_IBGP + 1)
@@ -1790,25 +1653,25 @@ vty_show_ip_route_summary_prefix (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 = srcdest_route_next (rn))
-    RNODE_FOREACH_RIB (rn, rib)
+    RNODE_FOREACH_RE (rn, re)
       {
 
        /*
         * In case of ECMP, count only once.
         */
        cnt = 0;
-       for (nexthop = rib->nexthop; (!cnt && nexthop); nexthop = nexthop->next)
+       for (nexthop = re->nexthop; (!cnt && nexthop); nexthop = nexthop->next)
          {
           cnt++;
           rib_cnt[ZEBRA_ROUTE_TOTAL]++;
-          rib_cnt[rib->type]++;
+          rib_cnt[re->type]++;
           if (CHECK_FLAG (nexthop->flags, NEXTHOP_FLAG_FIB))
                {
                 fib_cnt[ZEBRA_ROUTE_TOTAL]++;
-             fib_cnt[rib->type]++;
+             fib_cnt[re->type]++;
             }
-             if (rib->type == ZEBRA_ROUTE_BGP &&
-                 CHECK_FLAG (rib->flags, ZEBRA_FLAG_IBGP))
+             if (re->type == ZEBRA_ROUTE_BGP &&
+                 CHECK_FLAG (re->flags, ZEBRA_FLAG_IBGP))
             {
                 rib_cnt[ZEBRA_ROUTE_IBGP]++;
                     if (CHECK_FLAG (nexthop->flags, NEXTHOP_FLAG_FIB))
@@ -1817,10 +1680,9 @@ vty_show_ip_route_summary_prefix (struct vty *vty, struct route_table *table)
             }
       }
 
-  vty_out (vty, "%-20s %-20s %s  (vrf %s)%s",
+  vty_outln (vty, "%-20s %-20s %s  (vrf %s)",
            "Route Source", "Prefix Routes", "FIB",
-           zvrf_name (((rib_table_info_t *)table->info)->zvrf),
-           VTY_NEWLINE);
+           zvrf_name(((rib_table_info_t *)table->info)->zvrf));
 
   for (i = 0; i < ZEBRA_ROUTE_MAX; i++)
     {
@@ -1828,24 +1690,22 @@ vty_show_ip_route_summary_prefix (struct vty *vty, struct route_table *table)
        {
          if (i == ZEBRA_ROUTE_BGP)
            {
-             vty_out (vty, "%-20s %-20d %-20d %s", "ebgp",
+             vty_outln (vty, "%-20s %-20d %-20d ", "ebgp",
                       rib_cnt[ZEBRA_ROUTE_BGP] - rib_cnt[ZEBRA_ROUTE_IBGP],
-                      fib_cnt[ZEBRA_ROUTE_BGP] - fib_cnt[ZEBRA_ROUTE_IBGP],
-                      VTY_NEWLINE);
-             vty_out (vty, "%-20s %-20d %-20d %s", "ibgp",
-                      rib_cnt[ZEBRA_ROUTE_IBGP], fib_cnt[ZEBRA_ROUTE_IBGP],
-                      VTY_NEWLINE);
+                      fib_cnt[ZEBRA_ROUTE_BGP] - fib_cnt[ZEBRA_ROUTE_IBGP]);
+             vty_outln (vty, "%-20s %-20d %-20d ", "ibgp",
+                      rib_cnt[ZEBRA_ROUTE_IBGP],fib_cnt[ZEBRA_ROUTE_IBGP]);
            }
          else
-           vty_out (vty, "%-20s %-20d %-20d %s", zebra_route_string(i),
-                    rib_cnt[i], fib_cnt[i], VTY_NEWLINE);
+           vty_outln (vty, "%-20s %-20d %-20d ", zebra_route_string(i),
+                    rib_cnt[i], fib_cnt[i]);
        }
     }
 
-  vty_out (vty, "------%s", VTY_NEWLINE);
-  vty_out (vty, "%-20s %-20d %-20d %s", "Totals", rib_cnt[ZEBRA_ROUTE_TOTAL],
-          fib_cnt[ZEBRA_ROUTE_TOTAL], VTY_NEWLINE);
-  vty_out (vty, "%s", VTY_NEWLINE);
+  vty_outln (vty, "------");
+  vty_outln (vty, "%-20s %-20d %-20d ", "Totals", rib_cnt[ZEBRA_ROUTE_TOTAL],
+          fib_cnt[ZEBRA_ROUTE_TOTAL]);
+  vty_out (vty, VTYNL);
 }
 
 /* Show route summary.  */
@@ -1900,317 +1760,29 @@ DEFUN (show_ip_route_summary_prefix,
 }
 
 
-DEFUN (show_ip_route_vrf_all,
-       show_ip_route_vrf_all_cmd,
-       "show ip <fib|route> vrf all",
+DEFUN (show_ip_route_vrf_all_addr,
+       show_ip_route_vrf_all_addr_cmd,
+       "show ip route vrf all A.B.C.D",
        SHOW_STR
        IP_STR
-       "IP forwarding table\n"
        "IP routing table\n"
-       VRF_ALL_CMD_HELP_STR)
+       VRF_ALL_CMD_HELP_STR
+       "Network in the IP routing table to display\n")
 {
+  int idx_ipv4 = 5;
+  int ret;
+  struct prefix_ipv4 p;
   struct route_table *table;
   struct route_node *rn;
-  struct rib *rib;
   struct vrf *vrf;
   struct zebra_vrf *zvrf;
-  int first = 1;
-  int vrf_header = 1;
-  bool uf = use_fib(argv[2]);
-
-  RB_FOREACH (vrf, vrf_name_head, &vrfs_by_name)
-    {
-      if ((zvrf = vrf->info) == NULL ||
-          (table = zvrf->table[AFI_IP][SAFI_UNICAST]) == NULL)
-        continue;
-
-      /* Show all IPv4 routes. */
-      for (rn = route_top (table); rn; rn = route_next (rn))
-        RNODE_FOREACH_RIB (rn, rib)
-          {
-            if (uf && !CHECK_FLAG(rib->status, RIB_ENTRY_SELECTED_FIB))
-              continue;
-            if (first)
-              {
-                vty_out (vty, SHOW_ROUTE_V4_HEADER);
-                first = 0;
-              }
-
-            if (vrf_header)
-              {
-                vty_out (vty, "%sVRF %s:%s", VTY_NEWLINE, zvrf_name (zvrf), VTY_NEWLINE);
-                vrf_header = 0;
-              }
-            vty_show_ip_route (vty, rn, rib, NULL);
-          }
-      vrf_header  = 1;
-    }
-
-  return CMD_SUCCESS;
-}
-
-DEFUN (show_ip_route_vrf_all_tag,
-       show_ip_route_vrf_all_tag_cmd,
-       "show ip <fib|route> vrf all tag (1-4294967295)",
-       SHOW_STR
-       IP_STR
-       "IP forwarding table\n"
-       "IP routing table\n"
-       VRF_ALL_CMD_HELP_STR
-       "Show only routes with tag\n"
-       "Tag value\n")
-{
-  int idx_number = 6;
-  struct route_table *table;
-  struct route_node *rn;
-  struct rib *rib;
-  struct vrf *vrf;
-  struct zebra_vrf *zvrf;
-  int first = 1;
-  int vrf_header = 1;
-  route_tag_t tag = 0;
-  bool uf = use_fib(argv[2]);
-
-  if (argv[idx_number]->arg)
-    VTY_GET_INTEGER_RANGE("tag", tag, argv[idx_number]->arg, 0, 4294967295);
-
-  RB_FOREACH (vrf, vrf_name_head, &vrfs_by_name)
-    {
-      if ((zvrf = vrf->info) == NULL ||
-          (table = zvrf->table[AFI_IP][SAFI_UNICAST]) == NULL)
-        continue;
-
-      /* Show all IPv4 routes with matching tag value. */
-      for (rn = route_top (table); rn; rn = route_next (rn))
-        RNODE_FOREACH_RIB (rn, rib)
-          {
-            if (uf && !CHECK_FLAG(rib->status, RIB_ENTRY_SELECTED_FIB))
-              continue;
-            if (rib->tag != tag)
-              continue;
-
-            if (first)
-              {
-                vty_out (vty, SHOW_ROUTE_V4_HEADER);
-                first = 0;
-              }
-
-            if (vrf_header)
-              {
-                vty_out (vty, "%sVRF %s:%s", VTY_NEWLINE, zvrf_name (zvrf), VTY_NEWLINE);
-                vrf_header = 0;
-              }
-            vty_show_ip_route (vty, rn, rib, NULL);
-          }
-      vrf_header = 1;
-    }
-  return CMD_SUCCESS;
-}
-
-DEFUN (show_ip_route_vrf_all_prefix_longer,
-       show_ip_route_vrf_all_prefix_longer_cmd,
-       "show ip <fib|route> vrf all A.B.C.D/M longer-prefixes",
-       SHOW_STR
-       IP_STR
-       "IP forwarding table\n"
-       "IP routing table\n"
-       VRF_ALL_CMD_HELP_STR
-       "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
-       "Show route matching the specified Network/Mask pair only\n")
-{
-  int idx_ipv4_prefixlen = 5;
-  struct route_table *table;
-  struct route_node *rn;
-  struct rib *rib;
-  struct prefix p;
-  struct vrf *vrf;
-  struct zebra_vrf *zvrf;
-  int ret;
-  int first = 1;
-  int vrf_header = 1;
-  bool uf = use_fib(argv[2]);
-
-  ret = str2prefix (argv[idx_ipv4_prefixlen]->arg, &p);
-  if (! ret)
-    {
-      vty_out (vty, "%% Malformed Prefix%s", VTY_NEWLINE);
-      return CMD_WARNING;
-    }
-
-  RB_FOREACH (vrf, vrf_name_head, &vrfs_by_name)
-    {
-      if ((zvrf = vrf->info) == NULL ||
-          (table = zvrf->table[AFI_IP][SAFI_UNICAST]) == NULL)
-        continue;
-
-      /* Show matched type IPv4 routes. */
-      for (rn = route_top (table); rn; rn = route_next (rn))
-        RNODE_FOREACH_RIB (rn, rib)
-          if (prefix_match (&p, &rn->p))
-            {
-              if (uf && !CHECK_FLAG(rib->status, RIB_ENTRY_SELECTED_FIB))
-                continue;
-              if (first)
-                {
-                  vty_out (vty, SHOW_ROUTE_V4_HEADER);
-                  first = 0;
-                }
-
-              if (vrf_header)
-                {
-                  vty_out (vty, "%sVRF %s:%s", VTY_NEWLINE, zvrf_name (zvrf), VTY_NEWLINE);
-                  vrf_header = 0;
-                }
-              vty_show_ip_route (vty, rn, rib, NULL);
-            }
-      vrf_header = 1;
-    }
-
-  return CMD_SUCCESS;
-}
-
-DEFUN (show_ip_route_vrf_all_supernets,
-       show_ip_route_vrf_all_supernets_cmd,
-       "show ip <fib|route> vrf all supernets-only",
-       SHOW_STR
-       IP_STR
-       "IP forwarding table\n"
-       "IP routing table\n"
-       VRF_ALL_CMD_HELP_STR
-       "Show supernet entries only\n")
-{
-  struct route_table *table;
-  struct route_node *rn;
-  struct rib *rib;
-  struct vrf *vrf;
-  struct zebra_vrf *zvrf;
-  u_int32_t addr;
-  int first = 1;
-  int vrf_header = 1;
-  bool uf = use_fib(argv[2]);
-
-  RB_FOREACH (vrf, vrf_name_head, &vrfs_by_name)
-    {
-      if ((zvrf = vrf->info) == NULL ||
-          (table = zvrf->table[AFI_IP][SAFI_UNICAST]) == NULL)
-        continue;
-
-      /* Show matched type IPv4 routes. */
-      for (rn = route_top (table); rn; rn = route_next (rn))
-        RNODE_FOREACH_RIB (rn, rib)
-          {
-            if (uf && !CHECK_FLAG(rib->status, RIB_ENTRY_SELECTED_FIB))
-              continue;
-
-            addr = ntohl (rn->p.u.prefix4.s_addr);
-
-            if ((IN_CLASSC (addr) && rn->p.prefixlen < 24)
-               || (IN_CLASSB (addr) && rn->p.prefixlen < 16)
-               || (IN_CLASSA (addr) && rn->p.prefixlen < 8))
-              {
-                if (first)
-                  {
-                    vty_out (vty, SHOW_ROUTE_V4_HEADER);
-                    first = 0;
-                  }
-                if (vrf_header)
-                  {
-                    vty_out (vty, "%sVRF %s:%s", VTY_NEWLINE, zvrf_name (zvrf), VTY_NEWLINE);
-                    vrf_header = 0;
-                  }
-                vty_show_ip_route (vty, rn, rib, NULL);
-              }
-          }
-      vrf_header = 1;
-    }
-
-  return CMD_SUCCESS;
-}
-
-DEFUN (show_ip_route_vrf_all_protocol,
-       show_ip_route_vrf_all_protocol_cmd,
-       "show ip <fib|route> vrf all " FRR_IP_REDIST_STR_ZEBRA,
-       SHOW_STR
-       IP_STR
-       "IP forwarding table\n"
-       "IP routing table\n"
-       VRF_ALL_CMD_HELP_STR
-       FRR_IP_REDIST_HELP_STR_ZEBRA"\n")
-{
-  int type;
-  struct route_table *table;
-  struct route_node *rn;
-  struct rib *rib;
-  struct vrf *vrf;
-  struct zebra_vrf *zvrf;
-  int first = 1;
-  int vrf_header = 1;
-  bool uf = use_fib(argv[2]);
-
-  char *proto = argv[argc - 1]->text;
-  type = proto_redistnum (AFI_IP, proto);
-
-  if (type < 0)
-    {
-      vty_out (vty, "Unknown route type%s", VTY_NEWLINE);
-      return CMD_WARNING;
-    }
-
-  RB_FOREACH (vrf, vrf_name_head, &vrfs_by_name)
-    {
-      if ((zvrf = vrf->info) == NULL ||
-          (table = zvrf->table[AFI_IP][SAFI_UNICAST]) == NULL)
-        continue;
-
-      /* Show matched type IPv4 routes. */
-      for (rn = route_top (table); rn; rn = route_next (rn))
-        RNODE_FOREACH_RIB (rn, rib)
-          if (rib->type == type)
-            {
-              if (uf && !CHECK_FLAG(rib->status, RIB_ENTRY_SELECTED_FIB))
-                continue;
-              if (first)
-                {
-                  vty_out (vty, SHOW_ROUTE_V4_HEADER);
-                  first = 0;
-                }
-
-              if (vrf_header)
-                {
-                  vty_out (vty, "%sVRF %s:%s", VTY_NEWLINE, zvrf_name (zvrf), VTY_NEWLINE);
-                  vrf_header = 0;
-                }
-              vty_show_ip_route (vty, rn, rib, NULL);
-            }
-      vrf_header = 1;
-    }
-
-  return CMD_SUCCESS;
-}
-
-DEFUN (show_ip_route_vrf_all_addr,
-       show_ip_route_vrf_all_addr_cmd,
-       "show ip route vrf all A.B.C.D",
-       SHOW_STR
-       IP_STR
-       "IP routing table\n"
-       VRF_ALL_CMD_HELP_STR
-       "Network in the IP routing table to display\n")
-{
-  int idx_ipv4 = 5;
-  int ret;
-  struct prefix_ipv4 p;
-  struct route_table *table;
-  struct route_node *rn;
-  struct vrf *vrf;
-  struct zebra_vrf *zvrf;
-
-  ret = str2prefix_ipv4 (argv[idx_ipv4]->arg, &p);
-  if (ret <= 0)
-    {
-      vty_out (vty, "%% Malformed IPv4 address%s", VTY_NEWLINE);
-      return CMD_WARNING;
-    }
+
+  ret = str2prefix_ipv4 (argv[idx_ipv4]->arg, &p);
+  if (ret <= 0)
+    {
+      vty_outln (vty, "%% Malformed IPv4 address");
+      return CMD_WARNING;
+    }
 
   RB_FOREACH (vrf, vrf_name_head, &vrfs_by_name)
     {
@@ -2250,7 +1822,7 @@ DEFUN (show_ip_route_vrf_all_prefix,
   ret = str2prefix_ipv4 (argv[idx_ipv4_prefixlen]->arg, &p);
   if (ret <= 0)
     {
-      vty_out (vty, "%% Malformed IPv4 address%s", VTY_NEWLINE);
+      vty_outln (vty, "%% Malformed IPv4 address");
       return CMD_WARNING;
     }
 
@@ -2316,49 +1888,49 @@ DEFUN (show_ip_route_vrf_all_summary_prefix,
   return CMD_SUCCESS;
 }
 
-/* Write IPv4 static route configuration. */
+/* Write static route configuration. */
 static int
-static_config_ipv4 (struct vty *vty, safi_t safi, const char *cmd)
+static_config (struct vty *vty, afi_t afi, safi_t safi, const char *cmd)
 {
   struct route_node *rn;
   struct static_route *si;
   struct route_table *stable;
   struct vrf *vrf;
   struct zebra_vrf *zvrf;
-  char buf[BUFSIZ];
+  char buf[SRCDEST2STR_BUFFER];
   int write =0;
 
   RB_FOREACH (vrf, vrf_name_head, &vrfs_by_name)
     {
       if (!(zvrf = vrf->info))
         continue;
-      if ((stable = zvrf->stable[AFI_IP][safi]) == NULL)
+      if ((stable = zvrf->stable[afi][safi]) == NULL)
         continue;
 
-      for (rn = route_top (stable); rn; rn = route_next (rn))
+      for (rn = route_top (stable); rn; rn = srcdest_route_next (rn))
         for (si = rn->info; si; si = si->next)
           {
-            vty_out (vty, "%s %s", cmd, prefix2str (&rn->p, buf, sizeof buf));
+            vty_out (vty, "%s %s", cmd, srcdest_rnode2str (rn, buf, sizeof buf));
 
             switch (si->type)
               {
               case STATIC_IPV4_GATEWAY:
                 vty_out (vty, " %s", inet_ntoa (si->addr.ipv4));
                 break;
+              case STATIC_IPV6_GATEWAY:
+                vty_out (vty, " %s", inet_ntop (AF_INET6, &si->addr.ipv6, buf, sizeof buf));
+                break;
               case STATIC_IFINDEX:
                 vty_out (vty, " %s", si->ifname);
                 break;
               case STATIC_BLACKHOLE:
                 vty_out (vty, " Null0");
                 break;
-             case STATIC_IPV6_GATEWAY:
-               vty_out (vty, " %s", inet_ntop (AF_INET6, &si->addr.ipv6, buf, BUFSIZ));
-               break;
-             case STATIC_IPV6_GATEWAY_IFINDEX:
-               vty_out (vty, " %s %s",
-                        inet_ntop (AF_INET6, &si->addr.ipv6, buf, BUFSIZ),
-                        ifindex2ifname (si->ifindex, si->vrf_id));
-               break;
+              case STATIC_IPV6_GATEWAY_IFINDEX:
+                vty_out (vty, " %s %s",
+                         inet_ntop (AF_INET6, &si->addr.ipv6, buf, sizeof buf),
+                         ifindex2ifname (si->ifindex, si->vrf_id));
+                break;
               }
 
             /* flags are incompatible with STATIC_BLACKHOLE */
@@ -2378,7 +1950,7 @@ static_config_ipv4 (struct vty *vty, safi_t safi, const char *cmd)
               vty_out (vty, " %d", si->distance);
 
             if (si->vrf_id != VRF_DEFAULT)
-                vty_out (vty, " vrf %s", zvrf ? zvrf_name (zvrf) : "");
+                vty_out (vty, " vrf %s", zvrf_name (zvrf));
 
             /* Label information */
             if (si->snh_label.num_labels)
@@ -2386,7 +1958,7 @@ static_config_ipv4 (struct vty *vty, safi_t safi, const char *cmd)
                        mpls_label2str (si->snh_label.num_labels,
                                        si->snh_label.label, buf, sizeof buf, 0));
 
-            vty_out (vty, "%s", VTY_NEWLINE);
+            vty_out (vty, VTYNL);
 
             write = 1;
           }
@@ -2420,8 +1992,8 @@ static_ipv6_func (struct vty *vty, int add_cmd, const char *dest_str,
   ret = str2prefix (dest_str, &p);
   if (ret <= 0)
     {
-      vty_out (vty, "%% Malformed address%s", VTY_NEWLINE);
-      return CMD_WARNING;
+      vty_outln (vty, "%% Malformed address");
+      return CMD_WARNING_CONFIG_FAILED;
     }
 
   if (src_str)
@@ -2429,8 +2001,8 @@ static_ipv6_func (struct vty *vty, int add_cmd, const char *dest_str,
       ret = str2prefix (src_str, &src);
       if (ret <= 0 || src.family != AF_INET6)
         {
-          vty_out (vty, "%% Malformed source address%s", VTY_NEWLINE);
-          return CMD_WARNING;
+          vty_outln (vty, "%% Malformed source address");
+          return CMD_WARNING_CONFIG_FAILED;
         }
       src_p = (struct prefix_ipv6*)&src;
     }
@@ -2446,7 +2018,7 @@ static_ipv6_func (struct vty *vty, int add_cmd, const char *dest_str,
 
   /* tag */
   if (tag_str)
-    VTY_GET_INTEGER_RANGE("tag", tag, tag_str, 0, 4294967295);
+    tag = strtoul(tag_str, NULL, 10);
 
   /* When gateway is valid IPv6 addrees, then gate is treated as
      nexthop address other case gate is treated as interface name. */
@@ -2457,8 +2029,8 @@ static_ipv6_func (struct vty *vty, int add_cmd, const char *dest_str,
 
   if (!zvrf)
     {
-      vty_out (vty, "%% vrf %s is not defined%s", vrf_id_str, VTY_NEWLINE);
-      return CMD_WARNING;
+      vty_outln (vty, "%% vrf %s is not defined", vrf_id_str);
+      return CMD_WARNING_CONFIG_FAILED;
     }
 
   /* Labels */
@@ -2467,15 +2039,28 @@ static_ipv6_func (struct vty *vty, int add_cmd, const char *dest_str,
     {
       if (!mpls_enabled)
         {
-          vty_out (vty, "%% MPLS not turned on in kernel, ignoring command%s",
-                   VTY_NEWLINE);
-          return CMD_WARNING;
+          vty_outln (vty,
+                     "%% MPLS not turned on in kernel, ignoring command");
+          return CMD_WARNING_CONFIG_FAILED;
         }
-      if (mpls_str2label (label_str, &snh_label.num_labels,
-                          snh_label.label))
+      int rc = mpls_str2label (label_str, &snh_label.num_labels,
+                               snh_label.label);
+      if (rc < 0)
         {
-          vty_out (vty, "%% Malformed label(s)%s", VTY_NEWLINE);
-          return CMD_WARNING;
+          switch (rc) {
+          case -1:
+            vty_outln (vty, "%% Malformed label(s)");
+            break;
+          case -2:
+            vty_outln (vty, "%% Cannot use reserved label(s) (%d-%d)",
+                     MPLS_MIN_RESERVED_LABEL,MPLS_MAX_RESERVED_LABEL);
+            break;
+          case -3:
+            vty_outln (vty, "%% Too many labels. Enter %d or fewer",
+                     MPLS_MAX_LABELS);
+            break;
+          }
+          return CMD_WARNING_CONFIG_FAILED;
         }
     }
 
@@ -2484,14 +2069,14 @@ static_ipv6_func (struct vty *vty, int add_cmd, const char *dest_str,
     {
       if (flag_str)
         {
-          vty_out (vty, "%% can not have flag %s with Null0%s", flag_str, VTY_NEWLINE);
-          return CMD_WARNING;
+          vty_outln (vty, "%% can not have flag %s with Null0", flag_str);
+          return CMD_WARNING_CONFIG_FAILED;
         }
       if (add_cmd)
-        static_add_route (AFI_IP6, SAFI_UNICAST, type, &p, NULL, NULL, ifindex, ifname,
+        static_add_route (AFI_IP6, SAFI_UNICAST, type, &p, src_p, NULL, ifindex, ifname,
                           ZEBRA_FLAG_BLACKHOLE, tag, distance, zvrf, &snh_label);
       else
-        static_delete_route (AFI_IP6, SAFI_UNICAST, type, &p, NULL, NULL, ifindex, tag,
+        static_delete_route (AFI_IP6, SAFI_UNICAST, type, &p, src_p, NULL, ifindex, tag,
                              distance, zvrf, &snh_label);
       return CMD_SUCCESS;
     }
@@ -2508,8 +2093,8 @@ static_ipv6_func (struct vty *vty, int add_cmd, const char *dest_str,
         SET_FLAG (flag, ZEBRA_FLAG_BLACKHOLE);
         break;
       default:
-        vty_out (vty, "%% Malformed flag %s %s", flag_str, VTY_NEWLINE);
-        return CMD_WARNING;
+        vty_outln (vty, "%% Malformed flag %s ", flag_str);
+        return CMD_WARNING_CONFIG_FAILED;
     }
   }
 
@@ -2519,16 +2104,16 @@ static_ipv6_func (struct vty *vty, int add_cmd, const char *dest_str,
          address. */
       if (ret != 1)
         {
-          vty_out (vty, "%% Malformed address%s", VTY_NEWLINE);
-          return CMD_WARNING;
+          vty_outln (vty, "%% Malformed address");
+          return CMD_WARNING_CONFIG_FAILED;
         }
       type = STATIC_IPV6_GATEWAY_IFINDEX;
       gate = &gate_addr;
       ifp = if_lookup_by_name (ifname, zvrf_id (zvrf));
       if (!ifp)
         {
-          vty_out (vty, "%% Malformed Interface name %s%s", ifname, VTY_NEWLINE);
-          return CMD_WARNING;
+          vty_outln (vty, "%% Malformed Interface name %s", ifname);
+          return CMD_WARNING_CONFIG_FAILED;
         }
       ifindex = ifp->ifindex;
     }
@@ -2545,7 +2130,7 @@ static_ipv6_func (struct vty *vty, int add_cmd, const char *dest_str,
           ifp = if_lookup_by_name (gate_str, zvrf_id (zvrf));
           if (!ifp)
             {
-              vty_out (vty, "%% Malformed Interface name %s%s", gate_str, VTY_NEWLINE);
+              vty_outln (vty, "%% Malformed Interface name %s", gate_str);
               ifindex = IFINDEX_DELETED;
             }
           else
@@ -2575,20 +2160,17 @@ DEFUN (ipv6_route,
        "IPv6 gateway address\n"
        "IPv6 gateway interface name\n"
        "Null interface\n"
-       "Null interface\n"
        "Set tag for this route\n"
        "Tag value\n"
        "Distance value for this prefix\n"
-       VRF_CMD_HELP_STR
-       "Specify labels for this route\n"
-       "One or more labels separated by '/'\n")
+       VRF_CMD_HELP_STR)
 {
   int idx_ipv6_prefixlen = 2;
   int idx_ipv6_ifname;
   int idx_curr;
   char *src, *tag, *distance, *vrf;
 
-  if (!strcmp(argv[3]->text, "from"))
+  if (strmatch(argv[3]->text, "from"))
     {
       src = argv[4]->arg;
       idx_ipv6_ifname = 5;
@@ -2624,13 +2206,10 @@ DEFUN (ipv6_route_flags,
        "IPv6 gateway interface name\n"
        "Emit an ICMP unreachable when matched\n"
        "Silently discard pkts when matched\n"
-       "Silently discard pkts when matched\n"
        "Set tag for this route\n"
        "Tag value\n"
        "Distance value for this prefix\n"
-       VRF_CMD_HELP_STR
-       "Specify labels for this route\n"
-       "One or more labels separated by '/'\n")
+       VRF_CMD_HELP_STR)
 {
   int idx_ipv6_prefixlen = 2;
   int idx_ipv6_ifname;
@@ -2638,7 +2217,7 @@ DEFUN (ipv6_route_flags,
   int idx_curr;
   char *src, *tag, *distance, *vrf;
 
-  if (!strcmp(argv[3]->text, "from"))
+  if (strmatch(argv[3]->text, "from"))
     {
       src = argv[4]->arg;
       idx_ipv6_ifname = 5;
@@ -2678,9 +2257,7 @@ DEFUN (ipv6_route_ifname,
        "Set tag for this route\n"
        "Tag value\n"
        "Distance value for this prefix\n"
-       VRF_CMD_HELP_STR
-       "Specify labels for this route\n"
-       "One or more labels separated by '/'\n")
+       VRF_CMD_HELP_STR)
 {
   int idx_ipv6_prefixlen = 2;
   int idx_ipv6 = 3;
@@ -2688,7 +2265,7 @@ DEFUN (ipv6_route_ifname,
   int idx_curr = 5;
   char *src, *tag, *distance, *vrf;
 
-  if (!strcmp(argv[3]->text, "from"))
+  if (strmatch(argv[3]->text, "from"))
     {
       src = argv[4]->arg;
       idx_ipv6 = 5;
@@ -2730,9 +2307,7 @@ DEFUN (ipv6_route_ifname_flags,
        "Set tag for this route\n"
        "Tag value\n"
        "Distance value for this prefix\n"
-       VRF_CMD_HELP_STR
-       "Specify labels for this route\n"
-       "One or more labels separated by '/'\n")
+       VRF_CMD_HELP_STR)
 {
   int idx_ipv6_prefixlen = 2;
   int idx_ipv6;
@@ -2741,7 +2316,7 @@ DEFUN (ipv6_route_ifname_flags,
   int idx_curr;
   char *src, *tag, *distance, *vrf;
 
-  if (!strcmp(argv[3]->text, "from"))
+  if (strmatch(argv[3]->text, "from"))
     {
       src = argv[4]->arg;
       idx_ipv6 = 5;
@@ -2785,16 +2360,14 @@ DEFUN (no_ipv6_route,
        "Set tag for this route\n"
        "Tag value\n"
        "Distance value for this prefix\n"
-       VRF_CMD_HELP_STR
-       "Specify labels for this route\n"
-       "One or more labels separated by '/'\n")
+       VRF_CMD_HELP_STR)
 {
   int idx_ipv6_prefixlen = 3;
   int idx_ipv6_ifname;
   int idx_curr;
   char *src, *tag, *distance, *vrf;
 
-  if (!strcmp(argv[4]->text, "from"))
+  if (strmatch(argv[4]->text, "from"))
     {
       src = argv[5]->arg;
       idx_ipv6_ifname = 6;
@@ -2834,9 +2407,7 @@ DEFUN (no_ipv6_route_flags,
        "Set tag for this route\n"
        "Tag value\n"
        "Distance value for this prefix\n"
-       VRF_CMD_HELP_STR
-       "Specify labels for this route\n"
-       "One or more labels separated by '/'\n")
+       VRF_CMD_HELP_STR)
 {
   int idx_ipv6_prefixlen = 3;
   int idx_ipv6_ifname;
@@ -2844,7 +2415,7 @@ DEFUN (no_ipv6_route_flags,
   int idx_curr;
   char *src, *tag, *distance, *vrf;
 
-  if (!strcmp(argv[4]->text, "from"))
+  if (strmatch(argv[4]->text, "from"))
     {
       src = argv[5]->arg;
       idx_ipv6_ifname = 6;
@@ -2885,9 +2456,7 @@ DEFUN (no_ipv6_route_ifname,
        "Set tag for this route\n"
        "Tag value\n"
        "Distance value for this prefix\n"
-       VRF_CMD_HELP_STR
-       "Specify labels for this route\n"
-       "One or more labels separated by '/'\n")
+       VRF_CMD_HELP_STR)
 {
   int idx_ipv6_prefixlen = 3;
   int idx_ipv6;
@@ -2895,7 +2464,7 @@ DEFUN (no_ipv6_route_ifname,
   int idx_curr;
   char *src, *tag, *distance, *vrf;
 
-  if (!strcmp(argv[4]->text, "from"))
+  if (strmatch(argv[4]->text, "from"))
     {
       src = argv[5]->arg;
       idx_ipv6 = 6;
@@ -2938,9 +2507,7 @@ DEFUN (no_ipv6_route_ifname_flags,
        "Set tag for this route\n"
        "Tag value\n"
        "Distance value for this prefix\n"
-       VRF_CMD_HELP_STR
-       "Specify labels for this route\n"
-       "One or more labels separated by '/'\n")
+       VRF_CMD_HELP_STR)
 {
   int idx_ipv6_prefixlen = 3;
   int idx_ipv6;
@@ -2949,7 +2516,7 @@ DEFUN (no_ipv6_route_ifname_flags,
   int idx_curr;
   char *src, *tag, *distance, *vrf;
 
-  if (!strcmp(argv[4]->text, "from"))
+  if (strmatch(argv[4]->text, "from"))
     {
       src = argv[5]->arg;
       idx_ipv6 = 6;
@@ -2980,276 +2547,100 @@ DEFUN (no_ipv6_route_ifname_flags,
 
 DEFUN (show_ipv6_route,
        show_ipv6_route_cmd,
-       "show ipv6 <fib|route> [vrf NAME] [json]",
+       "show ipv6 <fib|route> [vrf NAME] [tag (1-4294967295)|X:X::X:X/M longer-prefixes|" FRR_IP6_REDIST_STR_ZEBRA "] [json]",
        SHOW_STR
        IP_STR
-       "IPv6 forwarding table\n"
-       "IPv6 routing table\n"
+       "IP forwarding table\n"
+       "IP routing table\n"
        VRF_CMD_HELP_STR
-       "Output JSON\n")
+       "Show only routes with tag\n"
+       "Tag value\n"
+       "IPv6 prefix\n"
+       "Show route matching the specified Network/Mask pair only\n"
+       FRR_IP6_REDIST_HELP_STR_ZEBRA
+       JSON_STR)
 {
+  bool uf = use_fib(argv[2]);
   struct route_table *table;
-  struct route_node *rn;
-  struct rib *rib;
-  int first = 1;
+  int vrf_all = 0;
+  route_tag_t tag = 0;
   vrf_id_t vrf_id = VRF_DEFAULT;
-  struct zebra_vrf *zvrf = NULL;
-  char buf[SRCDEST2STR_BUFFER];
-  json_object *json = NULL;
-  json_object *json_prefix = NULL;
-  bool uf = use_fib(argv[2]);
-
-  int vrf = (argc > 3 && strmatch (argv[3]->text, "vrf"));
-  int uj = vrf ? argc == 6 : argc == 4;
-  char *vrfname = vrf ? argv[4]->arg : NULL;
+  struct vrf *vrf;
+  struct zebra_vrf *zvrf;
+  int uj = use_json(argc, argv);
+  int idx = 0;
+  struct prefix p;
+  bool longer_prefixes = false;
+  bool supernets_only = false;
+  int type = 0;
 
-  if (vrf)
-  {
-    if (!(zvrf = zebra_vrf_lookup_by_name (vrfname)))
-       {
-         if (uj)
-           vty_out (vty, "{}%s", VTY_NEWLINE);
-         else
-           vty_out (vty, "vrf %s not defined%s", vrfname, VTY_NEWLINE);
-         return CMD_SUCCESS;
-       }
+  if (argv_find (argv, argc, "vrf", &idx))
+    {
+      if (strmatch(argv[idx+1]->arg, "all"))
+        vrf_all = 1;
+      else
+        VRF_GET_ID (vrf_id, argv[idx+1]->arg);
+    }
 
-     if (zvrf_id (zvrf) == VRF_UNKNOWN)
-       {
-         if (uj)
-           vty_out (vty, "{}%s", VTY_NEWLINE);
-         else
-           vty_out (vty, "vrf %s inactive%s", vrfname, VTY_NEWLINE);
-         return CMD_SUCCESS;
-       }
-     else
-       vrf_id = zvrf_id (zvrf);
-  }
+  if (argv_find (argv, argc, "tag", &idx))
+    tag = strtoul(argv[idx + 1]->arg, NULL, 10);
 
-  table = zebra_vrf_table (AFI_IP6, SAFI_UNICAST, vrf_id);
-  if (!table)
+  else if (argv_find (argv, argc, "X:X::X:X/M", &idx))
     {
-      if (uj)
-        vty_out (vty, "{}%s", VTY_NEWLINE);
-      return CMD_SUCCESS;
+      str2prefix (argv[idx]->arg, &p);
+      longer_prefixes = true;
     }
 
-  if (uj)
-    {
-      json = json_object_new_object();
-
-      /* Show all IPv6 route. */
-      for (rn = route_top (table); rn; rn = srcdest_route_next (rn))
-        {
-          RNODE_FOREACH_RIB (rn, rib)
-            {
-              if (uf && !CHECK_FLAG(rib->status, RIB_ENTRY_SELECTED_FIB))
-                continue;
-              if (!json_prefix)
-                json_prefix = json_object_new_array();
-              vty_show_ip_route (vty, rn, rib, json_prefix);
-            }
-
-          if (json_prefix)
-            {
-              srcdest_rnode2str (rn, buf, sizeof buf);
-              json_object_object_add(json, buf, json_prefix);
-              json_prefix = NULL;
-            }
-        }
-
-      vty_out (vty, "%s%s", json_object_to_json_string_ext(json, JSON_C_TO_STRING_PRETTY), VTY_NEWLINE);
-      json_object_free(json);
-    }
   else
     {
-      /* Show all IPv6 route. */
-      for (rn = route_top (table); rn; rn = srcdest_route_next (rn))
+      if (argv_find (argv, argc, "kernel", &idx))
+        type = proto_redistnum (AFI_IP6, argv[idx]->text);
+      else if (argv_find (argv, argc, "babel", &idx))
+        type = proto_redistnum (AFI_IP6, argv[idx]->text);
+      else if (argv_find (argv, argc, "connected", &idx))
+        type = proto_redistnum (AFI_IP6, argv[idx]->text);
+      else if (argv_find (argv, argc, "static", &idx))
+        type = proto_redistnum (AFI_IP6, argv[idx]->text);
+      else if (argv_find (argv, argc, "ripng", &idx))
+        type = proto_redistnum (AFI_IP6, argv[idx]->text);
+      else if (argv_find (argv, argc, "ospf6", &idx))
+        type = proto_redistnum (AFI_IP6, argv[idx]->text);
+      else if (argv_find (argv, argc, "isis", &idx))
+        type = proto_redistnum (AFI_IP6, argv[idx]->text);
+      else if (argv_find (argv, argc, "bgp", &idx))
+        type = proto_redistnum (AFI_IP6, argv[idx]->text);
+      else if (argv_find (argv, argc, "nhrp", &idx))
+        type = proto_redistnum (AFI_IP6, argv[idx]->text);
+      else if (argv_find (argv, argc, "table", &idx))
+        type = proto_redistnum (AFI_IP6, argv[idx]->text);
+      else if (argv_find (argv, argc, "vnc", &idx))
+        type = proto_redistnum (AFI_IP6, argv[idx]->text);
+
+      if (type < 0)
         {
-          RNODE_FOREACH_RIB (rn, rib)
-            {
-              if (uf && !CHECK_FLAG(rib->status, RIB_ENTRY_SELECTED_FIB))
-                continue;
-              if (first)
-                {
-                  vty_out (vty, SHOW_ROUTE_V6_HEADER);
-                  first = 0;
-                }
-              vty_show_ip_route (vty, rn, rib, NULL);
-            }
+          vty_outln (vty, "Unknown route type");
+          return CMD_WARNING;
         }
     }
 
-  return CMD_SUCCESS;
-}
-
-DEFUN (show_ipv6_route_tag,
-       show_ipv6_route_tag_cmd,
-       "show ipv6 <fib|route> [vrf NAME] tag (1-4294967295)",
-       SHOW_STR
-       IP_STR
-       "IPv6 forwarding table\n"
-       "IPv6 routing table\n"
-       VRF_CMD_HELP_STR
-       "Show only routes with tag\n"
-       "Tag value\n")
-{
-  int idx_vrf = 3;
-  int idx_name = 4;
-  int idx_tag = 6;
-  struct route_table *table;
-  struct route_node *rn;
-  struct rib *rib;
-  int first = 1;
-  route_tag_t tag = 0;
-  vrf_id_t vrf_id = VRF_DEFAULT;
-  bool uf = use_fib(argv[2]);
-
-  if (strmatch(argv[idx_vrf]->text, "vrf"))
-    {
-      VRF_GET_ID (vrf_id, argv[idx_name]->arg);
-      VTY_GET_INTEGER_RANGE("tag", tag, argv[idx_tag]->arg, 0, 4294967295);
-    }
-  else
+  if (vrf_all)
     {
-      idx_tag -= 2;
-      VTY_GET_INTEGER_RANGE("tag", tag, argv[idx_tag]->arg, 0, 4294967295);
-    }
-
-  table = zebra_vrf_table (AFI_IP6, SAFI_UNICAST, vrf_id);
-  if (! table)
-    return CMD_SUCCESS;
-
-  /* Show all IPv6 routes with matching tag value. */
-  for (rn = route_top (table); rn; rn = srcdest_route_next (rn))
-    RNODE_FOREACH_RIB (rn, rib)
-      {
-        if (uf && !CHECK_FLAG(rib->status, RIB_ENTRY_SELECTED_FIB))
-         continue;
-        if (rib->tag != tag)
-          continue;
-
-       if (first)
-         {
-           vty_out (vty, SHOW_ROUTE_V6_HEADER);
-           first = 0;
-         }
-       vty_show_ip_route (vty, rn, rib, NULL);
-      }
-  return CMD_SUCCESS;
-}
-
-DEFUN (show_ipv6_route_prefix_longer,
-       show_ipv6_route_prefix_longer_cmd,
-       "show ipv6 <fib|route> [vrf NAME] X:X::X:X/M longer-prefixes",
-       SHOW_STR
-       IP_STR
-       "IPv6 forwarding table\n"
-       "IPv6 routing table\n"
-       VRF_CMD_HELP_STR
-       "IPv6 prefix\n"
-       "Show route matching the specified Network/Mask pair only\n")
-{
-  struct route_table *table;
-  struct route_node *rn;
-  struct rib *rib;
-  struct prefix p;
-  int ret;
-  int first = 1;
-  vrf_id_t vrf_id = VRF_DEFAULT;
-  bool uf = use_fib(argv[2]);
+      RB_FOREACH (vrf, vrf_name_head, &vrfs_by_name)
+        {
+          if ((zvrf = vrf->info) == NULL ||
+              (table = zvrf->table[AFI_IP6][SAFI_UNICAST]) == NULL)
+            continue;
 
-  if (strmatch(argv[3]->text, "vrf"))
-    {
-      VRF_GET_ID (vrf_id, argv[4]->arg);
-      ret = str2prefix (argv[5]->arg, &p);
+          do_show_ip_route (vty, zvrf_name (zvrf), AFI_IP6, SAFI_UNICAST, uf, uj, tag,
+                            longer_prefixes ? &p : NULL, supernets_only, type, 0);
+        }
     }
   else
     {
-      ret = str2prefix (argv[3]->arg, &p);
-    }
-
-  if (! ret)
-    {
-      vty_out (vty, "%% Malformed Prefix%s", VTY_NEWLINE);
-      return CMD_WARNING;
+      vrf = vrf_lookup_by_id (vrf_id);
+      do_show_ip_route (vty, vrf->name, AFI_IP6, SAFI_UNICAST, uf, uj, tag,
+                        longer_prefixes ? &p : NULL, supernets_only, type, 0);
     }
-
-  table = zebra_vrf_table (AFI_IP6, SAFI_UNICAST, vrf_id);
-  if (! table)
-    return CMD_SUCCESS;
-
-  /* Show matched type IPv6 routes. */
-  for (rn = route_top (table); rn; rn = srcdest_route_next (rn))
-    RNODE_FOREACH_RIB (rn, rib)
-      {
-        struct prefix *p, *src_p;
-        srcdest_rnode_prefixes(rn, &p, &src_p);
-
-        if (uf && !CHECK_FLAG(rib->status, RIB_ENTRY_SELECTED_FIB))
-         continue;
-        if (prefix_match (p, &rn->p))
-          {
-            if (first)
-              {
-                vty_out (vty, SHOW_ROUTE_V6_HEADER);
-                first = 0;
-              }
-            vty_show_ip_route (vty, rn, rib, NULL);
-          }
-      }
-  return CMD_SUCCESS;
-}
-
-DEFUN (show_ipv6_route_protocol,
-       show_ipv6_route_protocol_cmd,
-       "show ipv6 <fib|route> [vrf NAME] " FRR_IP6_REDIST_STR_ZEBRA,
-       SHOW_STR
-       IP_STR
-       "IPv6 forwarding table\n"
-       "IPv6 routing table\n"
-       VRF_CMD_HELP_STR
-       FRR_IP6_REDIST_HELP_STR_ZEBRA)
-{
-  int type;
-  struct route_table *table;
-  struct route_node *rn;
-  struct rib *rib;
-  int first = 1;
-  vrf_id_t vrf_id = VRF_DEFAULT;
-  bool uf = use_fib(argv[2]);
-
-  int idx = 0;
-  if (argv_find (argv, argc, "NAME", &idx))
-    VRF_GET_ID (vrf_id, argv[idx]->arg);
-
-  char *proto = argv[argc - 1]->text;
-  type = proto_redistnum (AFI_IP6, proto);
-
-  if (type < 0)
-    {
-      vty_out (vty, "Unknown route type%s", VTY_NEWLINE);
-      return CMD_WARNING;
-    }
-
-  table = zebra_vrf_table (AFI_IP6, SAFI_UNICAST, vrf_id);
-  if (! table)
-    return CMD_SUCCESS;
-
-  /* Show matched type IPv6 routes. */
-  for (rn = route_top (table); rn; rn = srcdest_route_next (rn))
-    RNODE_FOREACH_RIB (rn, rib)
-      if (rib->type == type)
-       {
-         if (uf && !CHECK_FLAG(rib->status, RIB_ENTRY_SELECTED_FIB))
-           continue;
-         if (first)
-           {
-             vty_out (vty, SHOW_ROUTE_V6_HEADER);
-             first = 0;
-           }
-         vty_show_ip_route (vty, rn, rib, NULL);
-       }
   return CMD_SUCCESS;
 }
 
@@ -3280,7 +2671,7 @@ DEFUN (show_ipv6_route_addr,
 
   if (ret <= 0)
     {
-      vty_out (vty, "Malformed IPv6 address%s", VTY_NEWLINE);
+      vty_outln (vty, "Malformed IPv6 address");
       return CMD_WARNING;
     }
 
@@ -3291,7 +2682,7 @@ DEFUN (show_ipv6_route_addr,
   rn = route_node_match (table, (struct prefix *) &p);
   if (! rn)
     {
-      vty_out (vty, "%% Network not in table%s", VTY_NEWLINE);
+      vty_outln (vty, "%% Network not in table");
       return CMD_WARNING;
     }
 
@@ -3327,7 +2718,7 @@ DEFUN (show_ipv6_route_prefix,
 
   if (ret <= 0)
     {
-      vty_out (vty, "Malformed IPv6 prefix%s", VTY_NEWLINE);
+      vty_outln (vty, "Malformed IPv6 prefix");
       return CMD_WARNING;
     }
 
@@ -3338,7 +2729,7 @@ DEFUN (show_ipv6_route_prefix,
   rn = route_node_match (table, (struct prefix *) &p);
   if (! rn || rn->p.prefixlen != p.prefixlen)
     {
-      vty_out (vty, "%% Network not in table%s", VTY_NEWLINE);
+      vty_outln (vty, "%% Network not in table");
       return CMD_WARNING;
     }
 
@@ -3417,7 +2808,7 @@ DEFUN (show_ipv6_mroute,
 {
   struct route_table *table;
   struct route_node *rn;
-  struct rib *rib;
+  struct route_entry *re;
   int first = 1;
   vrf_id_t vrf_id = VRF_DEFAULT;
 
@@ -3430,254 +2821,18 @@ DEFUN (show_ipv6_mroute,
 
   /* Show all IPv6 route. */
   for (rn = route_top (table); rn; rn = srcdest_route_next (rn))
-    RNODE_FOREACH_RIB (rn, rib)
+    RNODE_FOREACH_RE (rn, re)
       {
        if (first)
          {
           vty_out (vty, SHOW_ROUTE_V6_HEADER);
            first = 0;
          }
-       vty_show_ip_route (vty, rn, rib, NULL);
+       vty_show_ip_route (vty, rn, re, NULL);
       }
   return CMD_SUCCESS;
 }
 
-
-DEFUN (show_ipv6_route_vrf_all,
-       show_ipv6_route_vrf_all_cmd,
-       "show ipv6 <fib|route> vrf all",
-       SHOW_STR
-       IP_STR
-       "IPv6 forwarding table\n"
-       "IPv6 routing table\n"
-       VRF_ALL_CMD_HELP_STR)
-{
-  struct route_table *table;
-  struct route_node *rn;
-  struct rib *rib;
-  struct vrf *vrf;
-  struct zebra_vrf *zvrf;
-  int first = 1;
-  int vrf_header = 1;
-  bool uf = use_fib(argv[2]);
-
-  RB_FOREACH (vrf, vrf_name_head, &vrfs_by_name)
-    {
-      if ((zvrf = vrf->info) == NULL ||
-          (table = zvrf->table[AFI_IP6][SAFI_UNICAST]) == NULL)
-        continue;
-
-      /* Show all IPv6 route. */
-      for (rn = route_top (table); rn; rn = srcdest_route_next (rn))
-        RNODE_FOREACH_RIB (rn, rib)
-          {
-            if (uf && !CHECK_FLAG(rib->status, RIB_ENTRY_SELECTED_FIB))
-              continue;
-            if (first)
-              {
-                vty_out (vty, SHOW_ROUTE_V6_HEADER);
-                first = 0;
-              }
-
-            if (vrf_header)
-              {
-                vty_out (vty, "%sVRF %s:%s", VTY_NEWLINE, zvrf_name (zvrf), VTY_NEWLINE);
-                vrf_header = 0;
-              }
-            vty_show_ip_route (vty, rn, rib, NULL);
-          }
-      vrf_header = 1;
-    }
-
-  return CMD_SUCCESS;
-}
-
-DEFUN (show_ipv6_route_vrf_all_tag,
-       show_ipv6_route_vrf_all_tag_cmd,
-       "show ipv6 <fib|route> vrf all tag (1-4294967295)",
-       SHOW_STR
-       IP_STR
-       "IPv6 forwarding table\n"
-       "IPv6 routing table\n"
-       VRF_ALL_CMD_HELP_STR
-       "Show only routes with tag\n"
-       "Tag value\n")
-{
-  int idx_number = 6;
-  struct route_table *table;
-  struct route_node *rn;
-  struct rib *rib;
-  struct vrf *vrf;
-  struct zebra_vrf *zvrf;
-  int first = 1;
-  int vrf_header = 1;
-  route_tag_t tag = 0;
-  bool uf = use_fib(argv[2]);
-
-  if (argv[idx_number]->arg)
-    VTY_GET_INTEGER_RANGE("tag", tag, argv[idx_number]->arg, 0, 4294967295);
-
-  RB_FOREACH (vrf, vrf_name_head, &vrfs_by_name)
-    {
-      if ((zvrf = vrf->info) == NULL ||
-          (table = zvrf->table[AFI_IP6][SAFI_UNICAST]) == NULL)
-        continue;
-
-      /* Show all IPv6 routes with matching tag value. */
-      for (rn = route_top (table); rn; rn = srcdest_route_next (rn))
-        RNODE_FOREACH_RIB (rn, rib)
-          {
-            if (uf && !CHECK_FLAG(rib->status, RIB_ENTRY_SELECTED_FIB))
-              continue;
-            if (rib->tag != tag)
-              continue;
-
-            if (first)
-              {
-                vty_out (vty, SHOW_ROUTE_V6_HEADER);
-                first = 0;
-              }
-
-            if (vrf_header)
-              {
-                vty_out (vty, "%sVRF %s:%s", VTY_NEWLINE, zvrf_name (zvrf), VTY_NEWLINE);
-                vrf_header = 0;
-              }
-            vty_show_ip_route (vty, rn, rib, NULL);
-          }
-      vrf_header = 1;
-    }
-
-  return CMD_SUCCESS;
-}
-
-DEFUN (show_ipv6_route_vrf_all_prefix_longer,
-       show_ipv6_route_vrf_all_prefix_longer_cmd,
-       "show ipv6 <fib|route> vrf all X:X::X:X/M longer-prefixes",
-       SHOW_STR
-       IP_STR
-       "IPv6 forwarding table\n"
-       "IPv6 routing table\n"
-       VRF_ALL_CMD_HELP_STR
-       "IPv6 prefix\n"
-       "Show route matching the specified Network/Mask pair only\n")
-{
-  int idx_ipv6_prefixlen = 5;
-  struct route_table *table;
-  struct route_node *rn;
-  struct rib *rib;
-  struct prefix p;
-  struct vrf *vrf;
-  struct zebra_vrf *zvrf;
-  int ret;
-  int first = 1;
-  int vrf_header = 1;
-  bool uf = use_fib(argv[2]);
-
-  ret = str2prefix (argv[idx_ipv6_prefixlen]->arg, &p);
-  if (! ret)
-    {
-      vty_out (vty, "%% Malformed Prefix%s", VTY_NEWLINE);
-      return CMD_WARNING;
-    }
-
-  RB_FOREACH (vrf, vrf_name_head, &vrfs_by_name)
-    {
-      if ((zvrf = vrf->info) == NULL ||
-          (table = zvrf->table[AFI_IP6][SAFI_UNICAST]) == NULL)
-        continue;
-
-      /* Show matched type IPv6 routes. */
-      for (rn = route_top (table); rn; rn = srcdest_route_next (rn))
-        RNODE_FOREACH_RIB (rn, rib)
-          {
-            struct prefix *p, *src_p;
-            srcdest_rnode_prefixes(rn, &p, &src_p);
-            if (uf && !CHECK_FLAG(rib->status, RIB_ENTRY_SELECTED_FIB))
-              continue;
-            if (prefix_match (p, &rn->p))
-              {
-                if (first)
-                  {
-                    vty_out (vty, SHOW_ROUTE_V6_HEADER);
-                    first = 0;
-                  }
-
-                if (vrf_header)
-                  {
-                    vty_out (vty, "%sVRF %s:%s", VTY_NEWLINE, zvrf_name (zvrf), VTY_NEWLINE);
-                    vrf_header = 0;
-                  }
-                vty_show_ip_route (vty, rn, rib, NULL);
-              }
-          }
-      vrf_header = 1;
-    }
-
-  return CMD_SUCCESS;
-}
-
-DEFUN (show_ipv6_route_vrf_all_protocol,
-       show_ipv6_route_vrf_all_protocol_cmd,
-       "show ipv6 <fib|route> vrf all " FRR_IP6_REDIST_STR_ZEBRA,
-       SHOW_STR
-       IP_STR
-       "IPv6 forwarding table\n"
-       "IPv6 routing table\n"
-       VRF_ALL_CMD_HELP_STR
-       FRR_IP6_REDIST_HELP_STR_ZEBRA)
-{
-  int type;
-  struct route_table *table;
-  struct route_node *rn;
-  struct rib *rib;
-  struct vrf *vrf;
-  struct zebra_vrf *zvrf;
-  int first = 1;
-  int vrf_header = 1;
-  bool uf = use_fib(argv[2]);
-
-  char *proto = argv[argc - 1]->text;
-  type = proto_redistnum (AFI_IP6, proto);
-
-  if (type < 0)
-    {
-      vty_out (vty, "Unknown route type%s", VTY_NEWLINE);
-      return CMD_WARNING;
-    }
-
-  RB_FOREACH (vrf, vrf_name_head, &vrfs_by_name)
-    {
-      if ((zvrf = vrf->info) == NULL ||
-          (table = zvrf->table[AFI_IP6][SAFI_UNICAST]) == NULL)
-        continue;
-
-      /* Show matched type IPv6 routes. */
-      for (rn = route_top (table); rn; rn = srcdest_route_next (rn))
-        RNODE_FOREACH_RIB (rn, rib)
-          if (rib->type == type)
-            {
-              if (uf && !CHECK_FLAG(rib->status, RIB_ENTRY_SELECTED_FIB))
-                continue;
-              if (first)
-                {
-                  vty_out (vty, SHOW_ROUTE_V6_HEADER);
-                  first = 0;
-                }
-
-            if (vrf_header)
-              {
-                vty_out (vty, "%sVRF %s:%s", VTY_NEWLINE, zvrf_name (zvrf), VTY_NEWLINE);
-                vrf_header = 0;
-              }
-              vty_show_ip_route (vty, rn, rib, NULL);
-            }
-      vrf_header = 1;
-    }
-
-  return CMD_SUCCESS;
-}
-
 DEFUN (show_ipv6_route_vrf_all_addr,
        show_ipv6_route_vrf_all_addr_cmd,
        "show ipv6 route vrf all X:X::X:X",
@@ -3698,7 +2853,7 @@ DEFUN (show_ipv6_route_vrf_all_addr,
   ret = str2prefix_ipv6 (argv[idx_ipv6]->arg, &p);
   if (ret <= 0)
     {
-      vty_out (vty, "Malformed IPv6 address%s", VTY_NEWLINE);
+      vty_outln (vty, "Malformed IPv6 address");
       return CMD_WARNING;
     }
 
@@ -3740,7 +2895,7 @@ DEFUN (show_ipv6_route_vrf_all_prefix,
   ret = str2prefix_ipv6 (argv[idx_ipv6_prefixlen]->arg, &p);
   if (ret <= 0)
     {
-      vty_out (vty, "Malformed IPv6 prefix%s", VTY_NEWLINE);
+      vty_outln (vty, "Malformed IPv6 prefix");
       return CMD_WARNING;
     }
 
@@ -3796,7 +2951,7 @@ DEFUN (show_ipv6_mroute_vrf_all,
 {
   struct route_table *table;
   struct route_node *rn;
-  struct rib *rib;
+  struct route_entry *re;
   struct vrf *vrf;
   struct zebra_vrf *zvrf;
   int first = 1;
@@ -3809,14 +2964,14 @@ DEFUN (show_ipv6_mroute_vrf_all,
 
       /* Show all IPv6 route. */
       for (rn = route_top (table); rn; rn = srcdest_route_next (rn))
-        RNODE_FOREACH_RIB (rn, rib)
+        RNODE_FOREACH_RE (rn, re)
           {
            if (first)
              {
                vty_out (vty, SHOW_ROUTE_V6_HEADER);
                first = 0;
              }
-           vty_show_ip_route (vty, rn, rib, NULL);
+           vty_show_ip_route (vty, rn, re, NULL);
           }
     }
   return CMD_SUCCESS;
@@ -3842,85 +2997,6 @@ DEFUN (show_ipv6_route_vrf_all_summary_prefix,
   return CMD_SUCCESS;
 }
 
-/* Write IPv6 static route configuration. */
-static int
-static_config_ipv6 (struct vty *vty)
-{
-  struct route_node *rn;
-  struct static_route *si;
-  int write = 0;
-  char buf[SRCDEST2STR_BUFFER];
-  struct route_table *stable;
-  struct vrf *vrf;
-  struct zebra_vrf *zvrf;
-
-  RB_FOREACH (vrf, vrf_name_head, &vrfs_by_name)
-    {
-      if (!(zvrf = vrf->info))
-        continue;
-      if ((stable = zvrf->stable[AFI_IP6][SAFI_UNICAST]) == NULL)
-        continue;
-
-      for (rn = route_top (stable); rn; rn = srcdest_route_next (rn))
-        for (si = rn->info; si; si = si->next)
-          {
-            vty_out (vty, "ipv6 route %s", srcdest_rnode2str (rn, buf, sizeof buf));
-
-           switch (si->type)
-             {
-             case STATIC_IPV4_GATEWAY:
-                vty_out (vty, " %s", inet_ntoa (si->addr.ipv4));
-                break;
-             case STATIC_IPV6_GATEWAY:
-               vty_out (vty, " %s", inet_ntop (AF_INET6, &si->addr.ipv6, buf, BUFSIZ));
-               break;
-             case STATIC_IFINDEX:
-               vty_out (vty, " %s", si->ifname);
-               break;
-             case STATIC_BLACKHOLE:
-               vty_out (vty, " Null0" );
-               break;
-             case STATIC_IPV6_GATEWAY_IFINDEX:
-               vty_out (vty, " %s %s",
-                        inet_ntop (AF_INET6, &si->addr.ipv6, buf, BUFSIZ),
-                        ifindex2ifname (si->ifindex, si->vrf_id));
-               break;
-             }
-
-            /* flags are incompatible with STATIC_BLACKHOLE */
-            if (si->type != STATIC_BLACKHOLE)
-              {
-                if (CHECK_FLAG(si->flags, ZEBRA_FLAG_REJECT))
-                  vty_out (vty, " %s", "reject");
-                if (CHECK_FLAG(si->flags, ZEBRA_FLAG_BLACKHOLE))
-                  vty_out (vty, " %s", "blackhole");
-              }
-
-            if (si->tag)
-              vty_out (vty, " tag %"ROUTE_TAG_PRI, si->tag);
-
-            if (si->distance != ZEBRA_STATIC_DISTANCE_DEFAULT)
-              vty_out (vty, " %d", si->distance);
-
-            if (si->vrf_id != VRF_DEFAULT)
-              {
-                vty_out (vty, " vrf %s", zvrf_name (zvrf));
-              }
-
-            /* Label information */
-            if (si->snh_label.num_labels)
-              vty_out (vty, " label %s",
-                       mpls_label2str (si->snh_label.num_labels,
-                                       si->snh_label.label, buf, sizeof buf, 0));
-
-            vty_out (vty, "%s", VTY_NEWLINE);
-
-            write = 1;
-          }
-    }
-  return write;
-}
-
 DEFUN (allow_external_route_update,
        allow_external_route_update_cmd,
        "allow-external-route-update",
@@ -3964,7 +3040,7 @@ DEFUN (show_vrf,
        vty_out (vty, "inactive");
      else
        vty_out (vty, "id %u table %u", zvrf_id (zvrf), zvrf->table_id);
-     vty_out (vty, "%s", VTY_NEWLINE);
+     vty_out (vty, VTYNL);
 
     }
 
@@ -3977,9 +3053,9 @@ zebra_ip_config (struct vty *vty)
 {
   int write = 0;
 
-  write += static_config_ipv4 (vty, SAFI_UNICAST, "ip route");
-  write += static_config_ipv4 (vty, SAFI_MULTICAST, "ip mroute");
-  write += static_config_ipv6 (vty);
+  write += static_config (vty, AFI_IP, SAFI_UNICAST, "ip route");
+  write += static_config (vty, AFI_IP, SAFI_MULTICAST, "ip mroute");
+  write += static_config (vty, AFI_IP6, SAFI_UNICAST, "ipv6 route");
 
   write += zebra_import_table_config (vty);
   return write;
@@ -3998,28 +3074,34 @@ DEFUN (ip_zebra_import_table_distance,
 {
   u_int32_t table_id = 0;
 
-  VTY_GET_INTEGER("table", table_id, argv[2]->arg);
+  table_id = strtoul(argv[2]->arg, NULL, 10);
   int distance = ZEBRA_TABLE_DISTANCE_DEFAULT;
   char *rmap = strmatch (argv[argc - 2]->text, "route-map") ?
                XSTRDUP(MTYPE_ROUTE_MAP_NAME, argv[argc - 1]->arg) : NULL;
+  int ret;
+
   if (argc == 7 || (argc == 5 && !rmap))
-    VTY_GET_INTEGER_RANGE("distance", distance, argv[4]->arg, 1, 255);
+    distance = strtoul(argv[4]->arg, NULL, 10);
 
   if (!is_zebra_valid_kernel_table(table_id))
     {
-      vty_out(vty, "Invalid routing table ID, %d. Must be in range 1-252%s",
-             table_id, VTY_NEWLINE);
+      vty_outln (vty, "Invalid routing table ID, %d. Must be in range 1-252",
+             table_id);
       return CMD_WARNING;
     }
 
   if (is_zebra_main_routing_table(table_id))
     {
-      vty_out(vty, "Invalid routing table ID, %d. Must be non-default table%s",
-              table_id, VTY_NEWLINE);
+      vty_outln (vty, "Invalid routing table ID, %d. Must be non-default table",
+              table_id);
       return CMD_WARNING;
     }
 
-  return (zebra_import_table(AFI_IP, table_id, distance, rmap, 1));
+  ret = zebra_import_table(AFI_IP, table_id, distance, rmap, 1);
+  if (rmap)
+    XFREE(MTYPE_ROUTE_MAP_NAME, rmap);
+
+  return ret;
 }
 
 DEFUN (no_ip_zebra_import_table,
@@ -4035,19 +3117,18 @@ DEFUN (no_ip_zebra_import_table,
        "route-map name\n")
 {
   u_int32_t table_id = 0;
-  VTY_GET_INTEGER("table", table_id, argv[3]->arg);
+  table_id = strtoul(argv[3]->arg, NULL, 10);
 
   if (!is_zebra_valid_kernel_table(table_id))
     {
-      vty_out(vty, "Invalid routing table ID. Must be in range 1-252%s",
-             VTY_NEWLINE);
+      vty_outln (vty,"Invalid routing table ID. Must be in range 1-252");
       return CMD_WARNING;
     }
 
   if (is_zebra_main_routing_table(table_id))
     {
-      vty_out(vty, "Invalid routing table ID, %d. Must be non-default table%s",
-             table_id, VTY_NEWLINE);
+      vty_outln (vty, "Invalid routing table ID, %d. Must be non-default table",
+             table_id);
       return CMD_WARNING;
     }
 
@@ -4061,24 +3142,19 @@ static int
 config_write_protocol (struct vty *vty)
 {
   if (allow_delete)
-    vty_out(vty, "allow-external-route-update%s", VTY_NEWLINE);
+    vty_outln (vty, "allow-external-route-update");
 
   if (zebra_rnh_ip_default_route)
-    vty_out(vty, "ip nht resolve-via-default%s", VTY_NEWLINE);
+    vty_outln (vty, "ip nht resolve-via-default");
 
   if (zebra_rnh_ipv6_default_route)
-    vty_out(vty, "ipv6 nht resolve-via-default%s", VTY_NEWLINE);
+    vty_outln (vty, "ipv6 nht resolve-via-default");
 
   enum multicast_mode ipv4_multicast_mode = multicast_mode_ipv4_get ();
 
   if (ipv4_multicast_mode != MCAST_NO_CONFIG)
-    vty_out (vty, "ip multicast rpf-lookup-mode %s%s",
-             ipv4_multicast_mode == MCAST_URIB_ONLY ? "urib-only" :
-             ipv4_multicast_mode == MCAST_MRIB_ONLY ? "mrib-only" :
-             ipv4_multicast_mode == MCAST_MIX_MRIB_FIRST ? "mrib-then-urib" :
-             ipv4_multicast_mode == MCAST_MIX_DISTANCE ? "lower-distance" :
-             "longer-prefix",
-             VTY_NEWLINE);
+    vty_outln (vty, "ip multicast rpf-lookup-mode %s",
+             ipv4_multicast_mode == MCAST_URIB_ONLY ? "urib-only" : ipv4_multicast_mode == MCAST_MRIB_ONLY ? "mrib-only" : ipv4_multicast_mode == MCAST_MIX_MRIB_FIRST ? "mrib-then-urib" : ipv4_multicast_mode == MCAST_MIX_DISTANCE ? "lower-distance" : "longer-prefix");
 
   zebra_routemap_config_write_protocol(vty);
 
@@ -4113,17 +3189,12 @@ zebra_vty_init (void)
 
   install_element (VIEW_NODE, &show_vrf_cmd);
   install_element (VIEW_NODE, &show_ip_route_cmd);
-  install_element (VIEW_NODE, &show_ip_route_ospf_instance_cmd);
-  install_element (VIEW_NODE, &show_ip_route_tag_cmd);
   install_element (VIEW_NODE, &show_ip_nht_cmd);
   install_element (VIEW_NODE, &show_ip_nht_vrf_all_cmd);
   install_element (VIEW_NODE, &show_ipv6_nht_cmd);
   install_element (VIEW_NODE, &show_ipv6_nht_vrf_all_cmd);
   install_element (VIEW_NODE, &show_ip_route_addr_cmd);
   install_element (VIEW_NODE, &show_ip_route_prefix_cmd);
-  install_element (VIEW_NODE, &show_ip_route_prefix_longer_cmd);
-  install_element (VIEW_NODE, &show_ip_route_protocol_cmd);
-  install_element (VIEW_NODE, &show_ip_route_supernets_cmd);
   install_element (VIEW_NODE, &show_ip_route_summary_cmd);
   install_element (VIEW_NODE, &show_ip_route_summary_prefix_cmd);
 
@@ -4135,15 +3206,8 @@ zebra_vty_init (void)
   install_element (CONFIG_NODE, &no_ip_route_flags_cmd);
   install_element (CONFIG_NODE, &no_ip_route_mask_flags_cmd);
 
-  install_element (VIEW_NODE, &show_ip_route_vrf_cmd);
-
-  install_element (VIEW_NODE, &show_ip_route_vrf_all_cmd);
-  install_element (VIEW_NODE, &show_ip_route_vrf_all_tag_cmd);
   install_element (VIEW_NODE, &show_ip_route_vrf_all_addr_cmd);
   install_element (VIEW_NODE, &show_ip_route_vrf_all_prefix_cmd);
-  install_element (VIEW_NODE, &show_ip_route_vrf_all_prefix_longer_cmd);
-  install_element (VIEW_NODE, &show_ip_route_vrf_all_protocol_cmd);
-  install_element (VIEW_NODE, &show_ip_route_vrf_all_supernets_cmd);
   install_element (VIEW_NODE, &show_ip_route_vrf_all_summary_cmd);
   install_element (VIEW_NODE, &show_ip_route_vrf_all_summary_prefix_cmd);
 
@@ -4160,25 +3224,17 @@ zebra_vty_init (void)
   install_element (CONFIG_NODE, &ipv6_nht_default_route_cmd);
   install_element (CONFIG_NODE, &no_ipv6_nht_default_route_cmd);
   install_element (VIEW_NODE, &show_ipv6_route_cmd);
-  install_element (VIEW_NODE, &show_ipv6_route_tag_cmd);
   install_element (VIEW_NODE, &show_ipv6_route_summary_cmd);
   install_element (VIEW_NODE, &show_ipv6_route_summary_prefix_cmd);
-  install_element (VIEW_NODE, &show_ipv6_route_protocol_cmd);
   install_element (VIEW_NODE, &show_ipv6_route_addr_cmd);
   install_element (VIEW_NODE, &show_ipv6_route_prefix_cmd);
-  install_element (VIEW_NODE, &show_ipv6_route_prefix_longer_cmd);
-
   install_element (VIEW_NODE, &show_ipv6_mroute_cmd);
 
   /* Commands for VRF */
-  install_element (VIEW_NODE, &show_ipv6_route_vrf_all_cmd);
-  install_element (VIEW_NODE, &show_ipv6_route_vrf_all_tag_cmd);
   install_element (VIEW_NODE, &show_ipv6_route_vrf_all_summary_cmd);
   install_element (VIEW_NODE, &show_ipv6_route_vrf_all_summary_prefix_cmd);
-  install_element (VIEW_NODE, &show_ipv6_route_vrf_all_protocol_cmd);
   install_element (VIEW_NODE, &show_ipv6_route_vrf_all_addr_cmd);
   install_element (VIEW_NODE, &show_ipv6_route_vrf_all_prefix_cmd);
-  install_element (VIEW_NODE, &show_ipv6_route_vrf_all_prefix_longer_cmd);
 
   install_element (VIEW_NODE, &show_ipv6_mroute_vrf_all_cmd);
 }