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/connected.c b/zebra/connected.c
index 2db981b..244f291 100644
--- a/zebra/connected.c
+++ b/zebra/connected.c
@@ -192,12 +192,12 @@
     return;
 
   rib_add_ipv4 (ZEBRA_ROUTE_CONNECT, 0, &p, NULL, NULL, ifp->ifindex,
-	RT_TABLE_MAIN, ifp->metric, 0, SAFI_UNICAST);
+       ifp->vrf_id, RT_TABLE_MAIN, ifp->metric, 0, SAFI_UNICAST);
 
   rib_add_ipv4 (ZEBRA_ROUTE_CONNECT, 0, &p, NULL, NULL, ifp->ifindex,
-	RT_TABLE_MAIN, ifp->metric, 0, SAFI_MULTICAST);
+       ifp->vrf_id, RT_TABLE_MAIN, ifp->metric, 0, SAFI_MULTICAST);
 
-  rib_update ();
+  rib_update (ifp->vrf_id);
 }
 
 /* Add connected IPv4 route to the interface. */
@@ -304,11 +304,13 @@
     return;
 
   /* Same logic as for connected_up_ipv4(): push the changes into the head. */
-  rib_delete_ipv4 (ZEBRA_ROUTE_CONNECT, 0, &p, NULL, ifp->ifindex, 0, SAFI_UNICAST);
+  rib_delete_ipv4 (ZEBRA_ROUTE_CONNECT, 0, &p, NULL, ifp->ifindex, ifp->vrf_id,
+                   SAFI_UNICAST);
 
-  rib_delete_ipv4 (ZEBRA_ROUTE_CONNECT, 0, &p, NULL, ifp->ifindex, 0, SAFI_MULTICAST);
+  rib_delete_ipv4 (ZEBRA_ROUTE_CONNECT, 0, &p, NULL, ifp->ifindex, ifp->vrf_id,
+                   SAFI_MULTICAST);
 
-  rib_update ();
+  rib_update (ifp->vrf_id);
 }
 
 /* Delete connected IPv4 route to the interface. */
@@ -330,7 +332,7 @@
     
   connected_withdraw (ifc);
 
-  rib_update();
+  rib_update (ifp->vrf_id);
 }
 
 #ifdef HAVE_IPV6
@@ -353,10 +355,10 @@
     return;
 #endif
 
-  rib_add_ipv6 (ZEBRA_ROUTE_CONNECT, 0, &p, NULL, ifp->ifindex, RT_TABLE_MAIN,
-                ifp->metric, 0, SAFI_UNICAST);
+  rib_add_ipv6 (ZEBRA_ROUTE_CONNECT, 0, &p, NULL, ifp->ifindex, ifp->vrf_id,
+                RT_TABLE_MAIN, ifp->metric, 0, SAFI_UNICAST);
 
-  rib_update ();
+  rib_update (ifp->vrf_id);
 }
 
 /* Add connected IPv6 route to the interface. */
@@ -436,9 +438,10 @@
   if (IN6_IS_ADDR_UNSPECIFIED (&p.prefix))
     return;
 
-  rib_delete_ipv6 (ZEBRA_ROUTE_CONNECT, 0, &p, NULL, ifp->ifindex, 0, SAFI_UNICAST);
+  rib_delete_ipv6 (ZEBRA_ROUTE_CONNECT, 0, &p, NULL, ifp->ifindex, ifp->vrf_id,
+                   SAFI_UNICAST);
 
-  rib_update ();
+  rib_update (ifp->vrf_id);
 }
 
 void
@@ -459,6 +462,6 @@
 
   connected_withdraw (ifc);
 
-  rib_update();
+  rib_update (ifp->vrf_id);
 }
 #endif /* HAVE_IPV6 */