zebra: let FIB stand for its respective VRF

A new member "vrf_id" is added to "struct rib", reflecting the VRF
which it belongs to.

A new parameter "vrf_id" is added to the relative functions where
need, except those:
- which already have the parameter "vrf_id"; or
- which have a parameter in type of "struct rib"; or
- which have a parameter in type of "struct interface".

All incoming routes are set to default VRF.

In fact, all routes in FIB are kept in default VRF. And the logic
is not changed.

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 fixed + compile warning fix]
Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
diff --git a/zebra/zebra_vty.c b/zebra/zebra_vty.c
index a4e6af7..78e7366 100644
--- a/zebra/zebra_vty.c
+++ b/zebra/zebra_vty.c
@@ -285,7 +285,7 @@
       return CMD_WARNING;
     }
 
-  rib = rib_match_ipv4_multicast (addr, &rn);
+  rib = rib_match_ipv4_multicast (addr, &rn, VRF_DEFAULT);
 
   if (rib)
     vty_show_ip_route_detail (vty, rn, 1);
@@ -771,7 +771,8 @@
             case NEXTHOP_TYPE_IPV4_IFINDEX:
               vty_out (vty, " %s", inet_ntoa (nexthop->gate.ipv4));
               if (nexthop->ifindex)
-                vty_out (vty, ", via %s", ifindex2ifname (nexthop->ifindex));
+                vty_out (vty, ", via %s",
+                         ifindex2ifname_vrf (nexthop->ifindex, rib->vrf_id));
               break;
             case NEXTHOP_TYPE_IPV6:
             case NEXTHOP_TYPE_IPV6_IFINDEX:
@@ -781,11 +782,12 @@
               if (nexthop->type == NEXTHOP_TYPE_IPV6_IFNAME)
                 vty_out (vty, ", %s", nexthop->ifname);
               else if (nexthop->ifindex)
-                vty_out (vty, ", via %s", ifindex2ifname (nexthop->ifindex));
+                vty_out (vty, ", via %s",
+                         ifindex2ifname_vrf (nexthop->ifindex, rib->vrf_id));
               break;
             case NEXTHOP_TYPE_IFINDEX:
               vty_out (vty, " directly connected, %s",
-                       ifindex2ifname (nexthop->ifindex));
+                       ifindex2ifname_vrf (nexthop->ifindex, rib->vrf_id));
               break;
             case NEXTHOP_TYPE_IFNAME:
               vty_out (vty, " directly connected, %s", nexthop->ifname);
@@ -876,7 +878,8 @@
         case NEXTHOP_TYPE_IPV4_IFINDEX:
           vty_out (vty, " via %s", inet_ntoa (nexthop->gate.ipv4));
           if (nexthop->ifindex)
-            vty_out (vty, ", %s", ifindex2ifname (nexthop->ifindex));
+            vty_out (vty, ", %s",
+                     ifindex2ifname_vrf (nexthop->ifindex, rib->vrf_id));
           break;
         case NEXTHOP_TYPE_IPV6:
         case NEXTHOP_TYPE_IPV6_IFINDEX:
@@ -886,11 +889,12 @@
           if (nexthop->type == NEXTHOP_TYPE_IPV6_IFNAME)
             vty_out (vty, ", %s", nexthop->ifname);
           else if (nexthop->ifindex)
-            vty_out (vty, ", %s", ifindex2ifname (nexthop->ifindex));
+            vty_out (vty, ", %s",
+                     ifindex2ifname_vrf (nexthop->ifindex, rib->vrf_id));
           break;
         case NEXTHOP_TYPE_IFINDEX:
           vty_out (vty, " is directly connected, %s",
-                   ifindex2ifname (nexthop->ifindex));
+                   ifindex2ifname_vrf (nexthop->ifindex, rib->vrf_id));
           break;
         case NEXTHOP_TYPE_IFNAME:
           vty_out (vty, " is directly connected, %s", nexthop->ifname);