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/zserv.c b/zebra/zserv.c
index 432c318..85f448c 100644
--- a/zebra/zserv.c
+++ b/zebra/zserv.c
@@ -36,6 +36,7 @@
#include "privs.h"
#include "network.h"
#include "buffer.h"
+#include "vrf.h"
#include "zebra/zserv.h"
#include "zebra/router-id.h"
@@ -473,7 +474,7 @@
struct nexthop *nexthop;
/* Lookup nexthop. */
- rib = rib_match_ipv6 (addr);
+ rib = rib_match_ipv6 (addr, VRF_DEFAULT);
/* Get output stream. */
s = client->obuf;
@@ -540,7 +541,7 @@
struct nexthop *nexthop;
/* Lookup nexthop - eBGP excluded */
- rib = rib_match_ipv4_safi (addr, SAFI_UNICAST, 1, NULL);
+ rib = rib_match_ipv4_safi (addr, SAFI_UNICAST, 1, NULL, VRF_DEFAULT);
/* Get output stream. */
s = client->obuf;
@@ -679,7 +680,7 @@
struct nexthop *nexthop;
/* Lookup nexthop. */
- rib = rib_lookup_ipv4 (p);
+ rib = rib_lookup_ipv4 (p, VRF_DEFAULT);
/* Get output stream. */
s = client->obuf;
@@ -842,6 +843,9 @@
p.prefixlen = stream_getc (s);
stream_get (&p.prefix, s, PSIZE (p.prefixlen));
+ /* VRF ID */
+ rib->vrf_id = VRF_DEFAULT;
+
/* Nexthop parse. */
if (CHECK_FLAG (message, ZAPI_MESSAGE_NEXTHOP))
{
@@ -972,7 +976,7 @@
api.metric = 0;
rib_delete_ipv4 (api.type, api.flags, &p, nexthop_p, ifindex,
- client->rtm_table, api.safi);
+ VRF_DEFAULT, api.safi);
return 0;
}
@@ -998,7 +1002,7 @@
struct rib *rib;
addr.s_addr = stream_get_ipv4 (client->ibuf);
- rib = rib_match_ipv4_multicast (addr, NULL);
+ rib = rib_match_ipv4_multicast (addr, NULL, VRF_DEFAULT);
return zsend_ipv4_nexthop_lookup_mrib (client, addr, rib);
}
@@ -1076,11 +1080,13 @@
api.metric = 0;
if (IN6_IS_ADDR_UNSPECIFIED (&nexthop))
- rib_add_ipv6 (api.type, api.flags, &p, NULL, ifindex, zebrad.rtm_table_default, api.metric,
- api.distance, api.safi);
+ rib_add_ipv6 (api.type, api.flags, &p, NULL, ifindex,
+ VRF_DEFAULT, zebrad.rtm_table_default, api.metric,
+ api.distance, api.safi);
else
- rib_add_ipv6 (api.type, api.flags, &p, &nexthop, ifindex, zebrad.rtm_table_default, api.metric,
- api.distance, api.safi);
+ rib_add_ipv6 (api.type, api.flags, &p, &nexthop, ifindex,
+ VRF_DEFAULT, zebrad.rtm_table_default, api.metric,
+ api.distance, api.safi);
return 0;
}
@@ -1143,9 +1149,11 @@
api.metric = 0;
if (IN6_IS_ADDR_UNSPECIFIED (&nexthop))
- rib_delete_ipv6 (api.type, api.flags, &p, NULL, ifindex, client->rtm_table, api.safi);
+ rib_delete_ipv6 (api.type, api.flags, &p, NULL, ifindex, VRF_DEFAULT,
+ api.safi);
else
- rib_delete_ipv6 (api.type, api.flags, &p, &nexthop, ifindex, client->rtm_table, api.safi);
+ rib_delete_ipv6 (api.type, api.flags, &p, &nexthop, ifindex, VRF_DEFAULT,
+ api.safi);
return 0;
}