]> git.puffer.fish Git - matthieu/frr.git/commitdiff
zebra: show routes in a specified VRF or all VRFs
authorFeng Lu <lu.feng@6wind.com>
Fri, 22 May 2015 09:40:03 +0000 (11:40 +0200)
committerVipin Kumar <vipin@cumulusnetworks.com>
Fri, 30 Oct 2015 06:46:03 +0000 (23:46 -0700)
The present "show ip[v6] [m]route [xxx]" and "show ip rpf [xxx]"
commands now show routes only in the default VRF.

A new option is introduced to show routes in a specified VRF:
    show ip[v6] [m]route [xxx] vrf N
    show ip rpf [xxx] vrf N

and a new option is used to show routes through all VRFs:
    show ip[v6] [m]route [xxx] vrf all
    show ip rpf [xxx] vrf all

Signed-off-by: Feng Lu <lu.feng@6wind.com>
Reviewed-by: Alain Ritoux <alain.ritoux@6wind.com>
Signed-off-by: Nicolas Dichtel <nicolas.dichtel@6wind.com>
Acked-by: Vincent JARDIN <vincent.jardin@6wind.com>
[DL: conflicts resolved]
Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
Conflicts:
zebra/zebra_vty.c

Conflicts:
nhrpd/nhrp_interface.c
zebra/zebra_rib.c
zebra/zebra_rnh_null.c
zebra/zebra_vty.c

zebra/zebra_rnh_null.c
zebra/zebra_vty.c

index 5bd00a3ecdd428f906c9498751ee903e37a5aef3..58fba418afa70a600d6a299f126db543051d60ff 100644 (file)
@@ -6,11 +6,11 @@
 int zebra_rnh_ip_default_route = 0;
 int zebra_rnh_ipv6_default_route = 0;
 
-int zebra_evaluate_rnh (int vrfid, int family, int force, rnh_type_t type,
+int zebra_evaluate_rnh (vrf_id_t vrfid, int family, int force, rnh_type_t type,
                        struct prefix *p)
 { return 0; }
 
-void zebra_print_rnh_table (int vrfid, int family, struct vty *vty,
+void zebra_print_rnh_table (vrf_id_t vrfid, int family, struct vty *vty,
                            rnh_type_t type)
 {}
 
index 1a50ab6990b9e4061bed73d8cf32b8d7ceae96c1..a9fb278aab4af422d241c1e313f9d58f6ba5eb4b 100644 (file)
@@ -94,9 +94,9 @@ zebra_static_ipv4 (struct vty *vty, int add_cmd, const char *dest_str,
           return CMD_WARNING;
         }
       if (add_cmd)
-        static_add_ipv4 (&p, NULL, NULL, ZEBRA_FLAG_BLACKHOLE, tag, distance, 0);
+        static_add_ipv4 (&p, NULL, NULL, ZEBRA_FLAG_BLACKHOLE, tag, distance, VRF_DEFAULT);
       else
-        static_delete_ipv4 (&p, NULL, NULL, tag, distance, 0);
+        static_delete_ipv4 (&p, NULL, NULL, tag, distance, VRF_DEFAULT);
       return CMD_SUCCESS;
     }
 
@@ -120,9 +120,9 @@ zebra_static_ipv4 (struct vty *vty, int add_cmd, const char *dest_str,
   if (gate_str == NULL)
   {
     if (add_cmd)
-      static_add_ipv4 (&p, NULL, NULL, flag, tag, distance, 0);
+      static_add_ipv4 (&p, NULL, NULL, flag, tag, distance, VRF_DEFAULT);
     else
-      static_delete_ipv4 (&p, NULL, NULL, tag, distance, 0);
+      static_delete_ipv4 (&p, NULL, NULL, tag, distance, VRF_DEFAULT);
 
     return CMD_SUCCESS;
   }
@@ -136,9 +136,9 @@ zebra_static_ipv4 (struct vty *vty, int add_cmd, const char *dest_str,
     ifname = gate_str;
 
   if (add_cmd)
-    static_add_ipv4 (&p, ifname ? NULL : &gate, ifname, flag, tag, distance, 0);
+    static_add_ipv4 (&p, ifname ? NULL : &gate, ifname, flag, tag, distance, VRF_DEFAULT);
   else
-    static_delete_ipv4 (&p, ifname ? NULL : &gate, ifname, tag, distance, 0);
+    static_delete_ipv4 (&p, ifname ? NULL : &gate, ifname, tag, distance, VRF_DEFAULT);
 
   return CMD_SUCCESS;
 }
@@ -906,6 +906,7 @@ vty_show_ip_route_detail (struct vty *vty, struct route_node *rn)
       vty_out (vty, ", distance %u, metric %u", rib->distance, rib->metric);
       if (rib->tag)
        vty_out (vty, ", tag %d", rib->tag);
+      vty_out (vty, ", vrf %u", rib->vrf_id);
       if (CHECK_FLAG (rib->flags, ZEBRA_FLAG_SELECTED))
        vty_out (vty, ", best");
       if (rib->refcnt)
@@ -1062,6 +1063,9 @@ vty_show_ip_route (struct vty *vty, struct route_node *rn, struct rib *rib)
              && rib->type != ZEBRA_ROUTE_KERNEL)
            len += vty_out (vty, " [%d/%d]", rib->distance,
                            rib->metric);
+
+          if (rib->vrf_id != VRF_DEFAULT)
+            len += vty_out (vty, " [vrf %u]", rib->vrf_id);
        }
       else
        vty_out (vty, "  %c%*c",
@@ -1331,6 +1335,14 @@ DEFUN (show_ip_route_tag,
   return CMD_SUCCESS;
 }
 
+ALIAS (show_ip_route,
+       show_ip_route_vrf_cmd,
+       "show ip route " VRF_CMD_STR,
+       SHOW_STR
+       IP_STR
+       "IP routing table\n"
+       VRF_CMD_HELP_STR)
+
 DEFUN (show_ip_route_prefix_longer,
        show_ip_route_prefix_longer_cmd,
        "show ip route A.B.C.D/M longer-prefixes",
@@ -1346,6 +1358,7 @@ DEFUN (show_ip_route_prefix_longer,
   struct prefix p;
   int ret;
   int first = 1;
+  vrf_id_t vrf_id = VRF_DEFAULT;
 
   ret = str2prefix (argv[0], &p);
   if (! ret)
@@ -1353,8 +1366,11 @@ DEFUN (show_ip_route_prefix_longer,
       vty_out (vty, "%% Malformed Prefix%s", VTY_NEWLINE);
       return CMD_WARNING;
     }
-  
-  table = zebra_vrf_table (AFI_IP, SAFI_UNICAST, VRF_DEFAULT);
+
+  if (argc > 1)
+    VTY_GET_INTEGER ("VRF ID", vrf_id, argv[1]);
+
+  table = zebra_vrf_table (AFI_IP, SAFI_UNICAST, vrf_id);
   if (! table)
     return CMD_SUCCESS;
 
@@ -1373,6 +1389,16 @@ DEFUN (show_ip_route_prefix_longer,
   return CMD_SUCCESS;
 }
 
+ALIAS (show_ip_route_prefix_longer,
+       show_ip_route_prefix_longer_vrf_cmd,
+       "show ip route A.B.C.D/M longer-prefixes " VRF_CMD_STR,
+       SHOW_STR
+       IP_STR
+       "IP routing table\n"
+       "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
+       "Show route matching the specified Network/Mask pair only\n"
+       VRF_CMD_HELP_STR)
+
 DEFUN (show_ip_route_supernets,
        show_ip_route_supernets_cmd,
        "show ip route supernets-only",
@@ -1384,10 +1410,14 @@ DEFUN (show_ip_route_supernets,
   struct route_table *table;
   struct route_node *rn;
   struct rib *rib;
-  u_int32_t addr; 
+  u_int32_t addr;
   int first = 1;
+  vrf_id_t vrf_id = VRF_DEFAULT;
 
-  table = zebra_vrf_table (AFI_IP, SAFI_UNICAST, VRF_DEFAULT);
+  if (argc > 0)
+    VTY_GET_INTEGER ("VRF ID", vrf_id, argv[0]);
+
+  table = zebra_vrf_table (AFI_IP, SAFI_UNICAST, vrf_id);
   if (! table)
     return CMD_SUCCESS;
 
@@ -1399,7 +1429,7 @@ DEFUN (show_ip_route_supernets,
 
        if ((IN_CLASSC (addr) && rn->p.prefixlen < 24)
           || (IN_CLASSB (addr) && rn->p.prefixlen < 16)
-          || (IN_CLASSA (addr) && rn->p.prefixlen < 8)) 
+          || (IN_CLASSA (addr) && rn->p.prefixlen < 8))
          {
            if (first)
              {
@@ -1412,6 +1442,15 @@ DEFUN (show_ip_route_supernets,
   return CMD_SUCCESS;
 }
 
+ALIAS (show_ip_route_supernets,
+       show_ip_route_supernets_vrf_cmd,
+       "show ip route supernets-only " VRF_CMD_STR,
+       SHOW_STR
+       IP_STR
+       "IP routing table\n"
+       "Show supernet entries only\n"
+       VRF_CMD_HELP_STR)
+
 DEFUN (show_ip_route_protocol,
        show_ip_route_protocol_cmd,
        "show ip route " QUAGGA_IP_REDIST_STR_ZEBRA,
@@ -1425,6 +1464,7 @@ DEFUN (show_ip_route_protocol,
   struct route_node *rn;
   struct rib *rib;
   int first = 1;
+  vrf_id_t vrf_id = VRF_DEFAULT;
 
   type = proto_redistnum (AFI_IP, argv[0]);
   if (type < 0)
@@ -1432,8 +1472,11 @@ DEFUN (show_ip_route_protocol,
       vty_out (vty, "Unknown route type%s", VTY_NEWLINE);
       return CMD_WARNING;
     }
-  
-  table = zebra_vrf_table (AFI_IP, SAFI_UNICAST, VRF_DEFAULT);
+
+  if (argc > 1)
+    VTY_GET_INTEGER ("VRF ID", vrf_id, argv[1]);
+
+  table = zebra_vrf_table (AFI_IP, SAFI_UNICAST, vrf_id);
   if (! table)
     return CMD_SUCCESS;
 
@@ -1452,6 +1495,15 @@ DEFUN (show_ip_route_protocol,
   return CMD_SUCCESS;
 }
 
+ALIAS (show_ip_route_protocol,
+       show_ip_route_protocol_vrf_cmd,
+       "show ip route " QUAGGA_IP_REDIST_STR_ZEBRA " " VRF_CMD_STR,
+       SHOW_STR
+       IP_STR
+       "IP routing table\n"
+       QUAGGA_IP_REDIST_HELP_STR_ZEBRA
+       VRF_CMD_HELP_STR)
+
 DEFUN (show_ip_route_ospf_instance,
        show_ip_route_ospf_instance_cmd,
        "show ip route ospf <1-65535>",
@@ -1500,6 +1552,7 @@ DEFUN (show_ip_route_addr,
   struct prefix_ipv4 p;
   struct route_table *table;
   struct route_node *rn;
+  vrf_id_t vrf_id = VRF_DEFAULT;
 
   ret = str2prefix_ipv4 (argv[0], &p);
   if (ret <= 0)
@@ -1508,7 +1561,10 @@ DEFUN (show_ip_route_addr,
       return CMD_WARNING;
     }
 
-  table = zebra_vrf_table (AFI_IP, SAFI_UNICAST, VRF_DEFAULT);
+  if (argc > 1)
+    VTY_GET_INTEGER ("VRF ID", vrf_id, argv[1]);
+
+  table = zebra_vrf_table (AFI_IP, SAFI_UNICAST, vrf_id);
   if (! table)
     return CMD_SUCCESS;
 
@@ -1526,6 +1582,15 @@ DEFUN (show_ip_route_addr,
   return CMD_SUCCESS;
 }
 
+ALIAS (show_ip_route_addr,
+       show_ip_route_addr_vrf_cmd,
+       "show ip route A.B.C.D " VRF_CMD_STR,
+       SHOW_STR
+       IP_STR
+       "IP routing table\n"
+       "Network in the IP routing table to display\n"
+       VRF_CMD_HELP_STR)
+
 DEFUN (show_ip_route_prefix,
        show_ip_route_prefix_cmd,
        "show ip route A.B.C.D/M",
@@ -1538,6 +1603,7 @@ DEFUN (show_ip_route_prefix,
   struct prefix_ipv4 p;
   struct route_table *table;
   struct route_node *rn;
+  vrf_id_t vrf_id = VRF_DEFAULT;
 
   ret = str2prefix_ipv4 (argv[0], &p);
   if (ret <= 0)
@@ -1546,7 +1612,10 @@ DEFUN (show_ip_route_prefix,
       return CMD_WARNING;
     }
 
-  table = zebra_vrf_table (AFI_IP, SAFI_UNICAST, VRF_DEFAULT);
+  if (argc > 1)
+    VTY_GET_INTEGER ("VRF ID", vrf_id, argv[1]);
+
+  table = zebra_vrf_table (AFI_IP, SAFI_UNICAST, vrf_id);
   if (! table)
     return CMD_SUCCESS;
 
@@ -1564,6 +1633,15 @@ DEFUN (show_ip_route_prefix,
   return CMD_SUCCESS;
 }
 
+ALIAS (show_ip_route_prefix,
+       show_ip_route_prefix_vrf_cmd,
+       "show ip route A.B.C.D/M " VRF_CMD_STR,
+       SHOW_STR
+       IP_STR
+       "IP routing table\n"
+       "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
+       VRF_CMD_HELP_STR)
+
 static void
 vty_show_ip_route_summary (struct vty *vty, struct route_table *table)
 {
@@ -1600,8 +1678,10 @@ vty_show_ip_route_summary (struct vty *vty, struct route_table *table)
            }
        }
 
-  vty_out (vty, "%-20s %-20s %-20s %s", 
-          "Route Source", "Routes", "FIB", VTY_NEWLINE);
+  vty_out (vty, "%-20s %-20s %s  (vrf %u)%s",
+           "Route Source", "Routes", "FIB",
+           ((rib_table_info_t *)table->info)->zvrf->vrf_id,
+           VTY_NEWLINE);
 
   for (i = 0; i < ZEBRA_ROUTE_MAX; i++) 
     {
@@ -1626,6 +1706,7 @@ vty_show_ip_route_summary (struct vty *vty, struct route_table *table)
   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);
 }
 
 /*
@@ -1678,8 +1759,10 @@ vty_show_ip_route_summary_prefix (struct vty *vty, struct route_table *table)
             }
       }
 
-  vty_out (vty, "%-20s %-20s %-20s %s",
-          "Route Source", "Prefix Routes", "FIB", VTY_NEWLINE);
+  vty_out (vty, "%-20s %-20s %s  (vrf %u)%s",
+           "Route Source", "Prefix Routes", "FIB",
+           ((rib_table_info_t *)table->info)->zvrf->vrf_id,
+           VTY_NEWLINE);
 
   for (i = 0; i < ZEBRA_ROUTE_MAX; i++)
     {
@@ -1704,6 +1787,7 @@ vty_show_ip_route_summary_prefix (struct vty *vty, struct route_table *table)
   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);
 }
 
 /* Show route summary.  */
@@ -1716,8 +1800,12 @@ DEFUN (show_ip_route_summary,
        "Summary of all routes\n")
 {
   struct route_table *table;
+  vrf_id_t vrf_id = VRF_DEFAULT;
 
-  table = zebra_vrf_table (AFI_IP, SAFI_UNICAST, VRF_DEFAULT);
+  if (argc > 0)
+    VTY_GET_INTEGER ("VRF ID", vrf_id, argv[0]);
+
+  table = zebra_vrf_table (AFI_IP, SAFI_UNICAST, vrf_id);
   if (! table)
     return CMD_SUCCESS;
 
@@ -1726,6 +1814,15 @@ DEFUN (show_ip_route_summary,
   return CMD_SUCCESS;
 }
 
+ALIAS (show_ip_route_summary,
+       show_ip_route_summary_vrf_cmd,
+       "show ip route summary " VRF_CMD_STR,
+       SHOW_STR
+       IP_STR
+       "IP routing table\n"
+       "Summary of all routes\n"
+       VRF_CMD_HELP_STR)
+
 /* Show route summary prefix.  */
 DEFUN (show_ip_route_summary_prefix,
        show_ip_route_summary_prefix_cmd,
@@ -1737,8 +1834,12 @@ DEFUN (show_ip_route_summary_prefix,
        "Prefix routes\n")
 {
   struct route_table *table;
+  vrf_id_t vrf_id = VRF_DEFAULT;
 
-  table = zebra_vrf_table (AFI_IP, SAFI_UNICAST, VRF_DEFAULT);
+  if (argc > 0)
+    VTY_GET_INTEGER ("VRF ID", vrf_id, argv[0]);
+
+  table = zebra_vrf_table (AFI_IP, SAFI_UNICAST, vrf_id);
   if (! table)
     return CMD_SUCCESS;
 
@@ -1747,61 +1848,380 @@ DEFUN (show_ip_route_summary_prefix,
   return CMD_SUCCESS;
 }
 
+ALIAS (show_ip_route_summary_prefix,
+       show_ip_route_summary_prefix_vrf_cmd,
+       "show ip route summary prefix " VRF_CMD_STR,
+       SHOW_STR
+       IP_STR
+       "IP routing table\n"
+       "Summary of all routes\n"
+       "Prefix routes\n"
+       VRF_CMD_HELP_STR)
+
+DEFUN (show_ip_route_vrf_all,
+       show_ip_route_vrf_all_cmd,
+       "show ip route " VRF_ALL_CMD_STR,
+       SHOW_STR
+       IP_STR
+       "IP routing table\n"
+       VRF_ALL_CMD_HELP_STR)
+{
+  struct route_table *table;
+  struct route_node *rn;
+  struct rib *rib;
+  struct zebra_vrf *zvrf;
+  vrf_iter_t iter;
+  int first = 1;
+
+  for (iter = vrf_first (); iter != VRF_ITER_INVALID; iter = vrf_next (iter))
+    {
+      if ((zvrf = vrf_iter2info (iter)) == 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 (first)
+              {
+                vty_out (vty, SHOW_ROUTE_V4_HEADER);
+                first = 0;
+              }
+            vty_show_ip_route (vty, rn, rib);
+          }
+    }
+
+  return CMD_SUCCESS;
+}
+
+DEFUN (show_ip_route_prefix_longer_vrf_all,
+       show_ip_route_prefix_longer_vrf_all_cmd,
+       "show ip route A.B.C.D/M longer-prefixes " VRF_ALL_CMD_STR,
+       SHOW_STR
+       IP_STR
+       "IP routing table\n"
+       "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
+       "Show route matching the specified Network/Mask pair only\n"
+       VRF_ALL_CMD_HELP_STR)
+{
+  struct route_table *table;
+  struct route_node *rn;
+  struct rib *rib;
+  struct prefix p;
+  struct zebra_vrf *zvrf;
+  vrf_iter_t iter;
+  int ret;
+  int first = 1;
+
+  ret = str2prefix (argv[0], &p);
+  if (! ret)
+    {
+      vty_out (vty, "%% Malformed Prefix%s", VTY_NEWLINE);
+      return CMD_WARNING;
+    }
+
+  for (iter = vrf_first (); iter != VRF_ITER_INVALID; iter = vrf_next (iter))
+    {
+      if ((zvrf = vrf_iter2info (iter)) == 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 (first)
+                {
+                  vty_out (vty, SHOW_ROUTE_V4_HEADER);
+                  first = 0;
+                }
+              vty_show_ip_route (vty, rn, rib);
+            }
+    }
+
+  return CMD_SUCCESS;
+}
+
+DEFUN (show_ip_route_supernets_vrf_all,
+       show_ip_route_supernets_vrf_all_cmd,
+       "show ip route supernets-only " VRF_ALL_CMD_STR,
+       SHOW_STR
+       IP_STR
+       "IP routing table\n"
+       "Show supernet entries only\n"
+       VRF_ALL_CMD_HELP_STR)
+{
+  struct route_table *table;
+  struct route_node *rn;
+  struct rib *rib;
+  struct zebra_vrf *zvrf;
+  vrf_iter_t iter;
+  u_int32_t addr;
+  int first = 1;
+
+  for (iter = vrf_first (); iter != VRF_ITER_INVALID; iter = vrf_next (iter))
+    {
+      if ((zvrf = vrf_iter2info (iter)) == 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)
+          {
+            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);
+              }
+          }
+    }
+
+  return CMD_SUCCESS;
+}
+
+DEFUN (show_ip_route_protocol_vrf_all,
+       show_ip_route_protocol_vrf_all_cmd,
+       "show ip route " QUAGGA_IP_REDIST_STR_ZEBRA " " VRF_ALL_CMD_STR,
+       SHOW_STR
+       IP_STR
+       "IP routing table\n"
+       QUAGGA_IP_REDIST_HELP_STR_ZEBRA
+       VRF_ALL_CMD_HELP_STR)
+{
+  int type;
+  struct route_table *table;
+  struct route_node *rn;
+  struct rib *rib;
+  struct zebra_vrf *zvrf;
+  vrf_iter_t iter;
+  int first = 1;
+
+  type = proto_redistnum (AFI_IP, argv[0]);
+  if (type < 0)
+    {
+      vty_out (vty, "Unknown route type%s", VTY_NEWLINE);
+      return CMD_WARNING;
+    }
+
+  for (iter = vrf_first (); iter != VRF_ITER_INVALID; iter = vrf_next (iter))
+    {
+      if ((zvrf = vrf_iter2info (iter)) == 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 (first)
+                {
+                  vty_out (vty, SHOW_ROUTE_V4_HEADER);
+                  first = 0;
+                }
+              vty_show_ip_route (vty, rn, rib);
+            }
+    }
+
+  return CMD_SUCCESS;
+}
+
+DEFUN (show_ip_route_addr_vrf_all,
+       show_ip_route_addr_vrf_all_cmd,
+       "show ip route A.B.C.D " VRF_ALL_CMD_STR,
+       SHOW_STR
+       IP_STR
+       "IP routing table\n"
+       "Network in the IP routing table to display\n"
+       VRF_ALL_CMD_HELP_STR)
+{
+  int ret;
+  struct prefix_ipv4 p;
+  struct route_table *table;
+  struct route_node *rn;
+  struct zebra_vrf *zvrf;
+  vrf_iter_t iter;
+
+  ret = str2prefix_ipv4 (argv[0], &p);
+  if (ret <= 0)
+    {
+      vty_out (vty, "%% Malformed IPv4 address%s", VTY_NEWLINE);
+      return CMD_WARNING;
+    }
+
+  for (iter = vrf_first (); iter != VRF_ITER_INVALID; iter = vrf_next (iter))
+    {
+      if ((zvrf = vrf_iter2info (iter)) == NULL ||
+          (table = zvrf->table[AFI_IP][SAFI_UNICAST]) == NULL)
+        continue;
+
+      rn = route_node_match (table, (struct prefix *) &p);
+      if (! rn)
+        continue;
+
+      vty_show_ip_route_detail (vty, rn);
+
+      route_unlock_node (rn);
+    }
+
+  return CMD_SUCCESS;
+}
+
+DEFUN (show_ip_route_prefix_vrf_all,
+       show_ip_route_prefix_vrf_all_cmd,
+       "show ip route A.B.C.D/M " VRF_ALL_CMD_STR,
+       SHOW_STR
+       IP_STR
+       "IP routing table\n"
+       "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
+       VRF_ALL_CMD_HELP_STR)
+{
+  int ret;
+  struct prefix_ipv4 p;
+  struct route_table *table;
+  struct route_node *rn;
+  struct zebra_vrf *zvrf;
+  vrf_iter_t iter;
+
+  ret = str2prefix_ipv4 (argv[0], &p);
+  if (ret <= 0)
+    {
+      vty_out (vty, "%% Malformed IPv4 address%s", VTY_NEWLINE);
+      return CMD_WARNING;
+    }
+
+  for (iter = vrf_first (); iter != VRF_ITER_INVALID; iter = vrf_next (iter))
+    {
+      if ((zvrf = vrf_iter2info (iter)) == NULL ||
+          (table = zvrf->table[AFI_IP][SAFI_UNICAST]) == NULL)
+        continue;
+
+      rn = route_node_match (table, (struct prefix *) &p);
+      if (! rn)
+        continue;
+      if (rn->p.prefixlen != p.prefixlen)
+        {
+          route_unlock_node (rn);
+          continue;
+        }
+
+      vty_show_ip_route_detail (vty, rn);
+
+      route_unlock_node (rn);
+    }
+
+  return CMD_SUCCESS;
+}
+
+DEFUN (show_ip_route_summary_vrf_all,
+       show_ip_route_summary_vrf_all_cmd,
+       "show ip route summary " VRF_ALL_CMD_STR,
+       SHOW_STR
+       IP_STR
+       "IP routing table\n"
+       "Summary of all routes\n"
+       VRF_ALL_CMD_HELP_STR)
+{
+  struct zebra_vrf *zvrf;
+  vrf_iter_t iter;
+
+  for (iter = vrf_first (); iter != VRF_ITER_INVALID; iter = vrf_next (iter))
+    if ((zvrf = vrf_iter2info (iter)) != NULL)
+      vty_show_ip_route_summary (vty, zvrf->table[AFI_IP][SAFI_UNICAST]);
+
+  return CMD_SUCCESS;
+}
+
+DEFUN (show_ip_route_summary_prefix_vrf_all,
+       show_ip_route_summary_prefix_vrf_all_cmd,
+       "show ip route summary prefix " VRF_ALL_CMD_STR,
+       SHOW_STR
+       IP_STR
+       "IP routing table\n"
+       "Summary of all routes\n"
+       "Prefix routes\n"
+       VRF_ALL_CMD_HELP_STR)
+{
+  struct zebra_vrf *zvrf;
+  vrf_iter_t iter;
+
+  for (iter = vrf_first (); iter != VRF_ITER_INVALID; iter = vrf_next (iter))
+    if ((zvrf = vrf_iter2info (iter)) != NULL)
+      vty_show_ip_route_summary_prefix (vty, zvrf->table[AFI_IP][SAFI_UNICAST]);
+
+  return CMD_SUCCESS;
+}
+
 /* Write IPv4 static route configuration. */
 static int
-static_config_ipv4 (struct vty *vty)
+static_config_ipv4 (struct vty *vty, safi_t safi, const char *cmd)
 {
   struct route_node *rn;
   struct static_ipv4 *si;  
   struct route_table *stable;
+  struct zebra_vrf *zvrf;
+  vrf_iter_t iter;
   int write;
 
   write = 0;
 
-  /* Lookup table.  */
-  stable = zebra_vrf_static_table (AFI_IP, SAFI_UNICAST, VRF_DEFAULT);
-  if (! stable)
-    return -1;
-
-  for (rn = route_top (stable); rn; rn = route_next (rn))
-    for (si = rn->info; si; si = si->next)
-      {
-        vty_out (vty, "ip route %s/%d", inet_ntoa (rn->p.u.prefix4),
-                 rn->p.prefixlen);
+  for (iter = vrf_first (); iter != VRF_ITER_INVALID; iter = vrf_next (iter))
+    {
+      if ((zvrf = vrf_iter2info (iter)) == NULL ||
+          (stable = zvrf->stable[AFI_IP][safi]) == NULL)
+        continue;
 
-        switch (si->type)
+      for (rn = route_top (stable); rn; rn = route_next (rn))
+        for (si = rn->info; si; si = si->next)
           {
-            case STATIC_IPV4_GATEWAY:
-              vty_out (vty, " %s", inet_ntoa (si->gate.ipv4));
-              break;
-            case STATIC_IPV4_IFNAME:
-              vty_out (vty, " %s", si->gate.ifname);
-              break;
-            case STATIC_IPV4_BLACKHOLE:
-              vty_out (vty, " Null0");
-              break;
-          }
-        
-        /* flags are incompatible with STATIC_IPV4_BLACKHOLE */
-        if (si->type != STATIC_IPV4_BLACKHOLE)
-          {
-            if (CHECK_FLAG(si->flags, ZEBRA_FLAG_REJECT))
-              vty_out (vty, " %s", "reject");
+            vty_out (vty, "%s %s/%d", cmd, inet_ntoa (rn->p.u.prefix4),
+                     rn->p.prefixlen);
 
-            if (CHECK_FLAG(si->flags, ZEBRA_FLAG_BLACKHOLE))
-              vty_out (vty, " %s", "blackhole");
-          }
+            switch (si->type)
+              {
+              case STATIC_IPV4_GATEWAY:
+                vty_out (vty, " %s", inet_ntoa (si->gate.ipv4));
+                break;
+              case STATIC_IPV4_IFNAME:
+                vty_out (vty, " %s", si->gate.ifname);
+                break;
+              case STATIC_IPV4_BLACKHOLE:
+                vty_out (vty, " Null0");
+                break;
+              }
 
-        if (si->tag)
-          vty_out (vty, " tag %d", si->tag);
+            /* flags are incompatible with STATIC_IPV4_BLACKHOLE */
+            if (si->type != STATIC_IPV4_BLACKHOLE)
+              {
+                if (CHECK_FLAG(si->flags, ZEBRA_FLAG_REJECT))
+                  vty_out (vty, " %s", "reject");
 
-        if (si->distance != ZEBRA_STATIC_DISTANCE_DEFAULT)
-          vty_out (vty, " %d", si->distance);
+                if (CHECK_FLAG(si->flags, ZEBRA_FLAG_BLACKHOLE))
+                  vty_out (vty, " %s", "blackhole");
+              }
 
-        vty_out (vty, "%s", VTY_NEWLINE);
+            if (si->tag)
+              vty_out (vty, " tag %d", si->tag);
 
-        write = 1;
-      }
+            if (si->distance != ZEBRA_STATIC_DISTANCE_DEFAULT)
+              vty_out (vty, " %d", si->distance);
+
+            vty_out (vty, "%s", VTY_NEWLINE);
+
+            write = 1;
+          }
+    }
   return write;
 }
 
@@ -1820,8 +2240,12 @@ DEFUN (show_ip_mroute,
   struct route_node *rn;
   struct rib *rib;
   int first = 1;
+  vrf_id_t vrf_id = VRF_DEFAULT;
 
-  table = zebra_vrf_table (AFI_IP, SAFI_MULTICAST, VRF_DEFAULT);
+  if (argc > 0)
+    VTY_GET_INTEGER ("VRF ID", vrf_id, argv[0]);
+
+  table = zebra_vrf_table (AFI_IP, SAFI_MULTICAST, vrf_id);
   if (! table)
     return CMD_SUCCESS;
 
@@ -1839,6 +2263,50 @@ DEFUN (show_ip_mroute,
   return CMD_SUCCESS;
 }
 
+ALIAS (show_ip_mroute,
+       show_ip_mroute_vrf_cmd,
+       "show ip mroute " VRF_CMD_STR,
+       SHOW_STR
+       IP_STR
+       "IP Multicast routing table\n"
+       VRF_CMD_HELP_STR)
+
+DEFUN (show_ip_mroute_vrf_all,
+       show_ip_mroute_vrf_all_cmd,
+       "show ip mroute " VRF_ALL_CMD_STR,
+       SHOW_STR
+       IP_STR
+       "IP Multicast routing table\n"
+       VRF_ALL_CMD_HELP_STR)
+{
+  struct route_table *table;
+  struct route_node *rn;
+  struct rib *rib;
+  struct zebra_vrf *zvrf;
+  vrf_iter_t iter;
+  int first = 1;
+
+  for (iter = vrf_first (); iter != VRF_ITER_INVALID; iter = vrf_next (iter))
+    {
+      if ((zvrf = vrf_iter2info (iter)) == 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 (first)
+             {
+               vty_out (vty, SHOW_ROUTE_V4_HEADER);
+               first = 0;
+             }
+           vty_show_ip_route (vty, rn, rib);
+          }
+    }
+
+  return CMD_SUCCESS;
+}
 
 #ifdef HAVE_IPV6
 /* General fucntion for IPv6 static route. */
@@ -1854,7 +2322,6 @@ static_ipv6_func (struct vty *vty, int add_cmd, const char *dest_str,
   struct in6_addr *gate = NULL;
   struct in6_addr gate_addr;
   u_char type = 0;
-  int table = 0;
   u_char flag = 0;
   u_short tag = 0;
   
@@ -1926,9 +2393,9 @@ static_ipv6_func (struct vty *vty, int add_cmd, const char *dest_str,
     }
 
   if (add_cmd)
-    static_add_ipv6 (&p, type, gate, ifname, flag, tag, distance, table);
+    static_add_ipv6 (&p, type, gate, ifname, flag, tag, distance, VRF_DEFAULT);
   else
-    static_delete_ipv6 (&p, type, gate, ifname, tag, distance, table);
+    static_delete_ipv6 (&p, type, gate, ifname, tag, distance, VRF_DEFAULT);
 
   return CMD_SUCCESS;
 }
@@ -2617,8 +3084,12 @@ DEFUN (show_ipv6_route,
   struct route_node *rn;
   struct rib *rib;
   int first = 1;
+  vrf_id_t vrf_id = VRF_DEFAULT;
 
-  table = zebra_vrf_table (AFI_IP6, SAFI_UNICAST, VRF_DEFAULT);
+  if (argc > 0)
+    VTY_GET_INTEGER ("VRF ID", vrf_id, argv[0]);
+
+  table = zebra_vrf_table (AFI_IP6, SAFI_UNICAST, vrf_id);
   if (! table)
     return CMD_SUCCESS;
 
@@ -2675,6 +3146,14 @@ DEFUN (show_ipv6_route_tag,
   return CMD_SUCCESS;
 }
 
+ALIAS (show_ipv6_route,
+       show_ipv6_route_vrf_cmd,
+       "show ipv6 route " VRF_CMD_STR,
+       SHOW_STR
+       IP_STR
+       "IPv6 routing table\n"
+       VRF_CMD_HELP_STR)
+
 DEFUN (show_ipv6_route_prefix_longer,
        show_ipv6_route_prefix_longer_cmd,
        "show ipv6 route X:X::X:X/M longer-prefixes",
@@ -2690,10 +3169,7 @@ DEFUN (show_ipv6_route_prefix_longer,
   struct prefix p;
   int ret;
   int first = 1;
-
-  table = zebra_vrf_table (AFI_IP6, SAFI_UNICAST, VRF_DEFAULT);
-  if (! table)
-    return CMD_SUCCESS;
+  vrf_id_t vrf_id = VRF_DEFAULT;
 
   ret = str2prefix (argv[0], &p);
   if (! ret)
@@ -2702,6 +3178,13 @@ DEFUN (show_ipv6_route_prefix_longer,
       return CMD_WARNING;
     }
 
+  if (argc > 1)
+    VTY_GET_INTEGER ("VRF ID", vrf_id, argv[1]);
+
+  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 = route_next (rn))
     RNODE_FOREACH_RIB (rn, rib)
@@ -2717,6 +3200,16 @@ DEFUN (show_ipv6_route_prefix_longer,
   return CMD_SUCCESS;
 }
 
+ALIAS (show_ipv6_route_prefix_longer,
+       show_ipv6_route_prefix_longer_vrf_cmd,
+       "show ipv6 route X:X::X:X/M longer-prefixes " VRF_CMD_STR,
+       SHOW_STR
+       IP_STR
+       "IPv6 routing table\n"
+       "IPv6 prefix\n"
+       "Show route matching the specified Network/Mask pair only\n"
+       VRF_CMD_HELP_STR)
+
 DEFUN (show_ipv6_route_protocol,
        show_ipv6_route_protocol_cmd,
        "show ipv6 route " QUAGGA_IP6_REDIST_STR_ZEBRA,
@@ -2730,6 +3223,7 @@ DEFUN (show_ipv6_route_protocol,
   struct route_node *rn;
   struct rib *rib;
   int first = 1;
+  vrf_id_t vrf_id = VRF_DEFAULT;
 
   type = proto_redistnum (AFI_IP6, argv[0]);
   if (type < 0)
@@ -2737,8 +3231,11 @@ DEFUN (show_ipv6_route_protocol,
       vty_out (vty, "Unknown route type%s", VTY_NEWLINE);
       return CMD_WARNING;
     }
-  
-  table = zebra_vrf_table (AFI_IP6, SAFI_UNICAST, VRF_DEFAULT);
+
+  if (argc > 1)
+    VTY_GET_INTEGER ("VRF ID", vrf_id, argv[1]);
+
+  table = zebra_vrf_table (AFI_IP6, SAFI_UNICAST, vrf_id);
   if (! table)
     return CMD_SUCCESS;
 
@@ -2757,6 +3254,15 @@ DEFUN (show_ipv6_route_protocol,
   return CMD_SUCCESS;
 }
 
+ALIAS (show_ipv6_route_protocol,
+       show_ipv6_route_protocol_vrf_cmd,
+       "show ipv6 route " QUAGGA_IP6_REDIST_STR_ZEBRA " " VRF_CMD_STR,
+       SHOW_STR
+       IP_STR
+       "IP routing table\n"
+       QUAGGA_IP6_REDIST_HELP_STR_ZEBRA
+       VRF_CMD_HELP_STR)
+
 DEFUN (show_ipv6_route_addr,
        show_ipv6_route_addr_cmd,
        "show ipv6 route X:X::X:X",
@@ -2769,6 +3275,7 @@ DEFUN (show_ipv6_route_addr,
   struct prefix_ipv6 p;
   struct route_table *table;
   struct route_node *rn;
+  vrf_id_t vrf_id = VRF_DEFAULT;
 
   ret = str2prefix_ipv6 (argv[0], &p);
   if (ret <= 0)
@@ -2777,7 +3284,10 @@ DEFUN (show_ipv6_route_addr,
       return CMD_WARNING;
     }
 
-  table = zebra_vrf_table (AFI_IP6, SAFI_UNICAST, VRF_DEFAULT);
+  if (argc > 1)
+    VTY_GET_INTEGER ("VRF ID", vrf_id, argv[1]);
+
+  table = zebra_vrf_table (AFI_IP6, SAFI_UNICAST, vrf_id);
   if (! table)
     return CMD_SUCCESS;
 
@@ -2795,6 +3305,15 @@ DEFUN (show_ipv6_route_addr,
   return CMD_SUCCESS;
 }
 
+ALIAS (show_ipv6_route_addr,
+       show_ipv6_route_addr_vrf_cmd,
+       "show ipv6 route X:X::X:X " VRF_CMD_STR,
+       SHOW_STR
+       IP_STR
+       "IPv6 routing table\n"
+       "IPv6 Address\n"
+       VRF_CMD_HELP_STR)
+
 DEFUN (show_ipv6_route_prefix,
        show_ipv6_route_prefix_cmd,
        "show ipv6 route X:X::X:X/M",
@@ -2807,6 +3326,7 @@ DEFUN (show_ipv6_route_prefix,
   struct prefix_ipv6 p;
   struct route_table *table;
   struct route_node *rn;
+  vrf_id_t vrf_id = VRF_DEFAULT;
 
   ret = str2prefix_ipv6 (argv[0], &p);
   if (ret <= 0)
@@ -2815,7 +3335,10 @@ DEFUN (show_ipv6_route_prefix,
       return CMD_WARNING;
     }
 
-  table = zebra_vrf_table (AFI_IP6, SAFI_UNICAST, VRF_DEFAULT);
+  if (argc > 1)
+    VTY_GET_INTEGER ("VRF ID", vrf_id, argv[1]);
+
+  table = zebra_vrf_table (AFI_IP6, SAFI_UNICAST, vrf_id);
   if (! table)
     return CMD_SUCCESS;
 
@@ -2833,6 +3356,15 @@ DEFUN (show_ipv6_route_prefix,
   return CMD_SUCCESS;
 }
 
+ALIAS (show_ipv6_route_prefix,
+       show_ipv6_route_prefix_vrf_cmd,
+       "show ipv6 route X:X::X:X/M " VRF_CMD_STR,
+       SHOW_STR
+       IP_STR
+       "IPv6 routing table\n"
+       "IPv6 prefix\n"
+       VRF_CMD_HELP_STR)
+
 /* Show route summary.  */
 DEFUN (show_ipv6_route_summary,
        show_ipv6_route_summary_cmd,
@@ -2843,8 +3375,12 @@ DEFUN (show_ipv6_route_summary,
        "Summary of all IPv6 routes\n")
 {
   struct route_table *table;
+  vrf_id_t vrf_id = VRF_DEFAULT;
 
-  table = zebra_vrf_table (AFI_IP6, SAFI_UNICAST, VRF_DEFAULT);
+  if (argc > 0)
+    VTY_GET_INTEGER ("VRF ID", vrf_id, argv[0]);
+
+  table = zebra_vrf_table (AFI_IP6, SAFI_UNICAST, vrf_id);
   if (! table)
     return CMD_SUCCESS;
 
@@ -2853,6 +3389,15 @@ DEFUN (show_ipv6_route_summary,
   return CMD_SUCCESS;
 }
 
+ALIAS (show_ipv6_route_summary,
+       show_ipv6_route_summary_vrf_cmd,
+       "show ipv6 route summary " VRF_CMD_STR,
+       SHOW_STR
+       IP_STR
+       "IPv6 routing table\n"
+       "Summary of all IPv6 routes\n"
+       VRF_CMD_HELP_STR)
+
 /* Show ipv6 route summary prefix.  */
 DEFUN (show_ipv6_route_summary_prefix,
        show_ipv6_route_summary_prefix_cmd,
@@ -2864,8 +3409,12 @@ DEFUN (show_ipv6_route_summary_prefix,
        "Prefix routes\n")
 {
   struct route_table *table;
+  vrf_id_t vrf_id = VRF_DEFAULT;
 
-  table = zebra_vrf_table (AFI_IP6, SAFI_UNICAST, VRF_DEFAULT);
+  if (argc > 0)
+    VTY_GET_INTEGER ("VRF ID", vrf_id, argv[0]);
+
+  table = zebra_vrf_table (AFI_IP6, SAFI_UNICAST, vrf_id);
   if (! table)
     return CMD_SUCCESS;
 
@@ -2874,6 +3423,16 @@ DEFUN (show_ipv6_route_summary_prefix,
   return CMD_SUCCESS;
 }
 
+ALIAS (show_ipv6_route_summary_prefix,
+       show_ipv6_route_summary_prefix_vrf_cmd,
+       "show ipv6 route summary prefix " VRF_CMD_STR,
+       SHOW_STR
+       IP_STR
+       "IPv6 routing table\n"
+       "Summary of all IPv6 routes\n"
+       "Prefix routes\n"
+       VRF_CMD_HELP_STR)
+
 /*
  * Show IPv6 mroute command.Used to dump
  * the Multicast routing table.
@@ -2890,8 +3449,12 @@ DEFUN (show_ipv6_mroute,
   struct route_node *rn;
   struct rib *rib;
   int first = 1;
+  vrf_id_t vrf_id = VRF_DEFAULT;
+
+  if (argc > 0)
+    VTY_GET_INTEGER ("VRF ID", vrf_id, argv[0]);
 
-  table = zebra_vrf_table (AFI_IP6, SAFI_MULTICAST, VRF_DEFAULT);
+  table = zebra_vrf_table (AFI_IP6, SAFI_MULTICAST, vrf_id);
   if (! table)
     return CMD_SUCCESS;
 
@@ -2909,6 +3472,310 @@ DEFUN (show_ipv6_mroute,
   return CMD_SUCCESS;
 }
 
+ALIAS (show_ipv6_mroute,
+       show_ipv6_mroute_vrf_cmd,
+       "show ipv6 mroute " VRF_CMD_STR,
+       SHOW_STR
+       IP_STR
+       "IPv6 Multicast routing table\n"
+       VRF_CMD_HELP_STR)
+
+DEFUN (show_ipv6_route_vrf_all,
+       show_ipv6_route_vrf_all_cmd,
+       "show ipv6 route " VRF_ALL_CMD_STR,
+       SHOW_STR
+       IP_STR
+       "IPv6 routing table\n"
+       VRF_ALL_CMD_HELP_STR)
+{
+  struct route_table *table;
+  struct route_node *rn;
+  struct rib *rib;
+  struct zebra_vrf *zvrf;
+  vrf_iter_t iter;
+  int first = 1;
+
+  for (iter = vrf_first (); iter != VRF_ITER_INVALID; iter = vrf_next (iter))
+    {
+      if ((zvrf = vrf_iter2info (iter)) == NULL ||
+          (table = zvrf->table[AFI_IP6][SAFI_UNICAST]) == NULL)
+        continue;
+
+      /* Show all IPv6 route. */
+      for (rn = route_top (table); rn; rn = route_next (rn))
+        RNODE_FOREACH_RIB (rn, rib)
+          {
+            if (first)
+              {
+                vty_out (vty, SHOW_ROUTE_V6_HEADER);
+                first = 0;
+              }
+            vty_show_ip_route (vty, rn, rib);
+          }
+    }
+
+  return CMD_SUCCESS;
+}
+
+DEFUN (show_ipv6_route_prefix_longer_vrf_all,
+       show_ipv6_route_prefix_longer_vrf_all_cmd,
+       "show ipv6 route X:X::X:X/M longer-prefixes " VRF_ALL_CMD_STR,
+       SHOW_STR
+       IP_STR
+       "IPv6 routing table\n"
+       "IPv6 prefix\n"
+       "Show route matching the specified Network/Mask pair only\n"
+       VRF_ALL_CMD_HELP_STR)
+{
+  struct route_table *table;
+  struct route_node *rn;
+  struct rib *rib;
+  struct prefix p;
+  struct zebra_vrf *zvrf;
+  vrf_iter_t iter;
+  int ret;
+  int first = 1;
+
+  ret = str2prefix (argv[0], &p);
+  if (! ret)
+    {
+      vty_out (vty, "%% Malformed Prefix%s", VTY_NEWLINE);
+      return CMD_WARNING;
+    }
+
+  for (iter = vrf_first (); iter != VRF_ITER_INVALID; iter = vrf_next (iter))
+    {
+      if ((zvrf = vrf_iter2info (iter)) == NULL ||
+          (table = zvrf->table[AFI_IP6][SAFI_UNICAST]) == NULL)
+        continue;
+
+      /* Show matched type IPv6 routes. */
+      for (rn = route_top (table); rn; rn = route_next (rn))
+        RNODE_FOREACH_RIB (rn, rib)
+          if (prefix_match (&p, &rn->p))
+            {
+              if (first)
+                {
+                  vty_out (vty, SHOW_ROUTE_V6_HEADER);
+                  first = 0;
+                }
+              vty_show_ip_route (vty, rn, rib);
+            }
+    }
+
+  return CMD_SUCCESS;
+}
+
+DEFUN (show_ipv6_route_protocol_vrf_all,
+       show_ipv6_route_protocol_vrf_all_cmd,
+       "show ipv6 route " QUAGGA_IP6_REDIST_STR_ZEBRA " " VRF_ALL_CMD_STR,
+       SHOW_STR
+       IP_STR
+       "IP routing table\n"
+       QUAGGA_IP6_REDIST_HELP_STR_ZEBRA
+       VRF_ALL_CMD_HELP_STR)
+{
+  int type;
+  struct route_table *table;
+  struct route_node *rn;
+  struct rib *rib;
+  struct zebra_vrf *zvrf;
+  vrf_iter_t iter;
+  int first = 1;
+
+  type = proto_redistnum (AFI_IP6, argv[0]);
+  if (type < 0)
+    {
+      vty_out (vty, "Unknown route type%s", VTY_NEWLINE);
+      return CMD_WARNING;
+    }
+
+  for (iter = vrf_first (); iter != VRF_ITER_INVALID; iter = vrf_next (iter))
+    {
+      if ((zvrf = vrf_iter2info (iter)) == NULL ||
+          (table = zvrf->table[AFI_IP6][SAFI_UNICAST]) == NULL)
+        continue;
+
+      /* Show matched type IPv6 routes. */
+      for (rn = route_top (table); rn; rn = route_next (rn))
+        RNODE_FOREACH_RIB (rn, rib)
+          if (rib->type == type)
+            {
+              if (first)
+                {
+                  vty_out (vty, SHOW_ROUTE_V6_HEADER);
+                  first = 0;
+                }
+              vty_show_ip_route (vty, rn, rib);
+            }
+    }
+
+  return CMD_SUCCESS;
+}
+
+DEFUN (show_ipv6_route_addr_vrf_all,
+       show_ipv6_route_addr_vrf_all_cmd,
+       "show ipv6 route X:X::X:X " VRF_ALL_CMD_STR,
+       SHOW_STR
+       IP_STR
+       "IPv6 routing table\n"
+       "IPv6 Address\n"
+       VRF_ALL_CMD_HELP_STR)
+{
+  int ret;
+  struct prefix_ipv6 p;
+  struct route_table *table;
+  struct route_node *rn;
+  struct zebra_vrf *zvrf;
+  vrf_iter_t iter;
+
+  ret = str2prefix_ipv6 (argv[0], &p);
+  if (ret <= 0)
+    {
+      vty_out (vty, "Malformed IPv6 address%s", VTY_NEWLINE);
+      return CMD_WARNING;
+    }
+
+  for (iter = vrf_first (); iter != VRF_ITER_INVALID; iter = vrf_next (iter))
+    {
+      if ((zvrf = vrf_iter2info (iter)) == NULL ||
+          (table = zvrf->table[AFI_IP6][SAFI_UNICAST]) == NULL)
+        continue;
+
+      rn = route_node_match (table, (struct prefix *) &p);
+      if (! rn)
+        continue;
+
+      vty_show_ip_route_detail (vty, rn);
+
+      route_unlock_node (rn);
+    }
+
+  return CMD_SUCCESS;
+}
+
+DEFUN (show_ipv6_route_prefix_vrf_all,
+       show_ipv6_route_prefix_vrf_all_cmd,
+       "show ipv6 route X:X::X:X/M " VRF_ALL_CMD_STR,
+       SHOW_STR
+       IP_STR
+       "IPv6 routing table\n"
+       "IPv6 prefix\n"
+       VRF_ALL_CMD_HELP_STR)
+{
+  int ret;
+  struct prefix_ipv6 p;
+  struct route_table *table;
+  struct route_node *rn;
+  struct zebra_vrf *zvrf;
+  vrf_iter_t iter;
+
+  ret = str2prefix_ipv6 (argv[0], &p);
+  if (ret <= 0)
+    {
+      vty_out (vty, "Malformed IPv6 prefix%s", VTY_NEWLINE);
+      return CMD_WARNING;
+    }
+
+  for (iter = vrf_first (); iter != VRF_ITER_INVALID; iter = vrf_next (iter))
+    {
+      if ((zvrf = vrf_iter2info (iter)) == NULL ||
+          (table = zvrf->table[AFI_IP6][SAFI_UNICAST]) == NULL)
+        continue;
+
+      rn = route_node_match (table, (struct prefix *) &p);
+      if (! rn)
+        continue;
+      if (rn->p.prefixlen != p.prefixlen)
+        {
+          route_unlock_node (rn);
+          continue;
+        }
+
+      vty_show_ip_route_detail (vty, rn);
+
+      route_unlock_node (rn);
+    }
+
+  return CMD_SUCCESS;
+}
+
+/* Show route summary.  */
+DEFUN (show_ipv6_route_summary_vrf_all,
+       show_ipv6_route_summary_vrf_all_cmd,
+       "show ipv6 route summary " VRF_ALL_CMD_STR,
+       SHOW_STR
+       IP_STR
+       "IPv6 routing table\n"
+       "Summary of all IPv6 routes\n"
+       VRF_ALL_CMD_HELP_STR)
+{
+  struct zebra_vrf *zvrf;
+  vrf_iter_t iter;
+
+  for (iter = vrf_first (); iter != VRF_ITER_INVALID; iter = vrf_next (iter))
+    if ((zvrf = vrf_iter2info (iter)) != NULL)
+      vty_show_ip_route_summary (vty, zvrf->table[AFI_IP6][SAFI_UNICAST]);
+
+  return CMD_SUCCESS;
+}
+
+DEFUN (show_ipv6_mroute_vrf_all,
+       show_ipv6_mroute_vrf_all_cmd,
+       "show ipv6 mroute " VRF_ALL_CMD_STR,
+       SHOW_STR
+       IP_STR
+       "IPv6 Multicast routing table\n"
+       VRF_ALL_CMD_HELP_STR)
+{
+  struct route_table *table;
+  struct route_node *rn;
+  struct rib *rib;
+  struct zebra_vrf *zvrf;
+  vrf_iter_t iter;
+  int first = 1;
+
+  for (iter = vrf_first (); iter != VRF_ITER_INVALID; iter = vrf_next (iter))
+    {
+      if ((zvrf = vrf_iter2info (iter)) == NULL ||
+          (table = zvrf->table[AFI_IP6][SAFI_UNICAST]) == NULL)
+        continue;
+
+      /* Show all IPv6 route. */
+      for (rn = route_top (table); rn; rn = route_next (rn))
+        RNODE_FOREACH_RIB (rn, rib)
+          {
+           if (first)
+             {
+               vty_out (vty, SHOW_ROUTE_V6_HEADER);
+               first = 0;
+             }
+           vty_show_ip_route (vty, rn, rib);
+          }
+    }
+  return CMD_SUCCESS;
+}
+
+DEFUN (show_ipv6_route_summary_prefix_vrf_all,
+       show_ipv6_route_summary_prefix_vrf_all_cmd,
+       "show ipv6 route summary prefix " VRF_ALL_CMD_STR,
+       SHOW_STR
+       IP_STR
+       "IPv6 routing table\n"
+       "Summary of all IPv6 routes\n"
+       "Prefix routes\n"
+       VRF_ALL_CMD_HELP_STR)
+{
+  struct zebra_vrf *zvrf;
+  vrf_iter_t iter;
+
+  for (iter = vrf_first (); iter != VRF_ITER_INVALID; iter = vrf_next (iter))
+    if ((zvrf = vrf_iter2info (iter)) != NULL)
+      vty_show_ip_route_summary_prefix (vty, zvrf->table[AFI_IP6][SAFI_UNICAST]);
+
+  return CMD_SUCCESS;
+}
+
 /* Write IPv6 static route configuration. */
 static int
 static_config_ipv6 (struct vty *vty)
@@ -2992,7 +3859,7 @@ zebra_ip_config (struct vty *vty)
 {
   int write = 0;
 
-  write += static_config_ipv4 (vty);
+  write += static_config_ipv4 (vty, SAFI_UNICAST, "ip route");
 #ifdef HAVE_IPV6
   write += static_config_ipv6 (vty);
 #endif /* HAVE_IPV6 */
@@ -3200,6 +4067,48 @@ zebra_vty_init (void)
   install_element (ENABLE_NODE, &show_ip_mroute_cmd);
 
 
+  /* Commands for VRF */
+
+  install_element (VIEW_NODE, &show_ip_route_vrf_cmd);
+  install_element (VIEW_NODE, &show_ip_route_addr_vrf_cmd);
+  install_element (VIEW_NODE, &show_ip_route_prefix_vrf_cmd);
+  install_element (VIEW_NODE, &show_ip_route_prefix_longer_vrf_cmd);
+  install_element (VIEW_NODE, &show_ip_route_protocol_vrf_cmd);
+  install_element (VIEW_NODE, &show_ip_route_supernets_vrf_cmd);
+  install_element (VIEW_NODE, &show_ip_route_summary_vrf_cmd);
+  install_element (VIEW_NODE, &show_ip_route_summary_prefix_vrf_cmd);
+  install_element (ENABLE_NODE, &show_ip_route_vrf_cmd);
+  install_element (ENABLE_NODE, &show_ip_route_addr_vrf_cmd);
+  install_element (ENABLE_NODE, &show_ip_route_prefix_vrf_cmd);
+  install_element (ENABLE_NODE, &show_ip_route_prefix_longer_vrf_cmd);
+  install_element (ENABLE_NODE, &show_ip_route_protocol_vrf_cmd);
+  install_element (ENABLE_NODE, &show_ip_route_supernets_vrf_cmd);
+  install_element (ENABLE_NODE, &show_ip_route_summary_vrf_cmd);
+  install_element (ENABLE_NODE, &show_ip_route_summary_prefix_vrf_cmd);
+
+  install_element (VIEW_NODE, &show_ip_route_vrf_all_cmd);
+  install_element (VIEW_NODE, &show_ip_route_addr_vrf_all_cmd);
+  install_element (VIEW_NODE, &show_ip_route_prefix_vrf_all_cmd);
+  install_element (VIEW_NODE, &show_ip_route_prefix_longer_vrf_all_cmd);
+  install_element (VIEW_NODE, &show_ip_route_protocol_vrf_all_cmd);
+  install_element (VIEW_NODE, &show_ip_route_supernets_vrf_all_cmd);
+  install_element (VIEW_NODE, &show_ip_route_summary_vrf_all_cmd);
+  install_element (VIEW_NODE, &show_ip_route_summary_prefix_vrf_all_cmd);
+  install_element (ENABLE_NODE, &show_ip_route_vrf_all_cmd);
+  install_element (ENABLE_NODE, &show_ip_route_addr_vrf_all_cmd);
+  install_element (ENABLE_NODE, &show_ip_route_prefix_vrf_all_cmd);
+  install_element (ENABLE_NODE, &show_ip_route_prefix_longer_vrf_all_cmd);
+  install_element (ENABLE_NODE, &show_ip_route_protocol_vrf_all_cmd);
+  install_element (ENABLE_NODE, &show_ip_route_supernets_vrf_all_cmd);
+  install_element (ENABLE_NODE, &show_ip_route_summary_vrf_all_cmd);
+  install_element (ENABLE_NODE, &show_ip_route_summary_prefix_vrf_all_cmd);
+
+  install_element (VIEW_NODE, &show_ip_mroute_vrf_cmd);
+  install_element (ENABLE_NODE, &show_ip_mroute_vrf_cmd);
+
+  install_element (VIEW_NODE, &show_ip_mroute_vrf_all_cmd);
+  install_element (ENABLE_NODE, &show_ip_mroute_vrf_all_cmd);
+
 #ifdef HAVE_IPV6
   install_element (CONFIG_NODE, &ipv6_route_cmd);
   install_element (CONFIG_NODE, &ipv6_route_flags_cmd);
@@ -3256,5 +4165,43 @@ zebra_vty_init (void)
 
   install_element (VIEW_NODE, &show_ipv6_mroute_cmd);
   install_element (ENABLE_NODE, &show_ipv6_mroute_cmd);
+
+  /* Commands for VRF */
+
+  install_element (VIEW_NODE, &show_ipv6_route_vrf_cmd);
+  install_element (VIEW_NODE, &show_ipv6_route_summary_vrf_cmd);
+  install_element (VIEW_NODE, &show_ipv6_route_summary_prefix_vrf_cmd);
+  install_element (VIEW_NODE, &show_ipv6_route_protocol_vrf_cmd);
+  install_element (VIEW_NODE, &show_ipv6_route_addr_vrf_cmd);
+  install_element (VIEW_NODE, &show_ipv6_route_prefix_vrf_cmd);
+  install_element (VIEW_NODE, &show_ipv6_route_prefix_longer_vrf_cmd);
+  install_element (ENABLE_NODE, &show_ipv6_route_vrf_cmd);
+  install_element (ENABLE_NODE, &show_ipv6_route_protocol_vrf_cmd);
+  install_element (ENABLE_NODE, &show_ipv6_route_addr_vrf_cmd);
+  install_element (ENABLE_NODE, &show_ipv6_route_prefix_vrf_cmd);
+  install_element (ENABLE_NODE, &show_ipv6_route_prefix_longer_vrf_cmd);
+  install_element (ENABLE_NODE, &show_ipv6_route_summary_vrf_cmd);
+  install_element (ENABLE_NODE, &show_ipv6_route_summary_prefix_vrf_cmd);
+
+  install_element (VIEW_NODE, &show_ipv6_route_vrf_all_cmd);
+  install_element (VIEW_NODE, &show_ipv6_route_summary_vrf_all_cmd);
+  install_element (VIEW_NODE, &show_ipv6_route_summary_prefix_vrf_all_cmd);
+  install_element (VIEW_NODE, &show_ipv6_route_protocol_vrf_all_cmd);
+  install_element (VIEW_NODE, &show_ipv6_route_addr_vrf_all_cmd);
+  install_element (VIEW_NODE, &show_ipv6_route_prefix_vrf_all_cmd);
+  install_element (VIEW_NODE, &show_ipv6_route_prefix_longer_vrf_all_cmd);
+  install_element (ENABLE_NODE, &show_ipv6_route_vrf_all_cmd);
+  install_element (ENABLE_NODE, &show_ipv6_route_protocol_vrf_all_cmd);
+  install_element (ENABLE_NODE, &show_ipv6_route_addr_vrf_all_cmd);
+  install_element (ENABLE_NODE, &show_ipv6_route_prefix_vrf_all_cmd);
+  install_element (ENABLE_NODE, &show_ipv6_route_prefix_longer_vrf_all_cmd);
+  install_element (ENABLE_NODE, &show_ipv6_route_summary_vrf_all_cmd);
+  install_element (ENABLE_NODE, &show_ipv6_route_summary_prefix_vrf_all_cmd);
+
+  install_element (VIEW_NODE, &show_ipv6_mroute_vrf_cmd);
+  install_element (ENABLE_NODE, &show_ipv6_mroute_vrf_cmd);
+
+  install_element (VIEW_NODE, &show_ipv6_mroute_vrf_all_cmd);
+  install_element (ENABLE_NODE, &show_ipv6_mroute_vrf_all_cmd);
 #endif /* HAVE_IPV6 */
 }