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_rib.c b/zebra/zebra_rib.c
index f206205..336b566 100644
--- a/zebra/zebra_rib.c
+++ b/zebra/zebra_rib.c
@@ -80,7 +80,7 @@
_rnode_zlog(const char *_func, struct route_node *rn, int priority,
const char *msgfmt, ...)
{
- char buf[PREFIX_STRLEN + 8];
+ char prefix[PREFIX_STRLEN], buf[256];
char msgbuf[512];
va_list ap;
@@ -92,9 +92,10 @@
{
rib_table_info_t *info = rn->table->info;
- prefix2str(&rn->p, buf, sizeof(buf));
- if (info->safi == SAFI_MULTICAST)
- strcat(buf, " (MRIB)");
+ snprintf(buf, sizeof(buf), "%s%s vrf %u",
+ prefix2str(&rn->p, prefix, sizeof(prefix)),
+ info->safi == SAFI_MULTICAST ? " (MRIB)" : "",
+ info->zvrf->vrf_id);
}
else
{
@@ -369,7 +370,7 @@
p.prefix = nexthop->gate.ipv4;
/* Lookup table. */
- table = zebra_vrf_table (AFI_IP, SAFI_UNICAST, VRF_DEFAULT);
+ table = zebra_vrf_table (AFI_IP, SAFI_UNICAST, rib->vrf_id);
if (! table)
return 0;
@@ -511,7 +512,7 @@
p.prefix = nexthop->gate.ipv6;
/* Lookup table. */
- table = zebra_vrf_table (AFI_IP6, SAFI_UNICAST, VRF_DEFAULT);
+ table = zebra_vrf_table (AFI_IP6, SAFI_UNICAST, rib->vrf_id);
if (! table)
return 0;
@@ -618,7 +619,7 @@
struct rib *
rib_match_ipv4_safi (struct in_addr addr, safi_t safi, int skip_bgp,
- struct route_node **rn_out)
+ struct route_node **rn_out, vrf_id_t vrf_id)
{
struct route_table *table;
struct route_node *rn;
@@ -627,7 +628,7 @@
int recursing;
/* Lookup table. */
- table = zebra_vrf_table (AFI_IP, safi, VRF_DEFAULT);
+ table = zebra_vrf_table (AFI_IP, safi, vrf_id);
if (! table)
return 0;
@@ -680,7 +681,8 @@
}
struct rib *
-rib_match_ipv4_multicast (struct in_addr addr, struct route_node **rn_out)
+rib_match_ipv4_multicast (struct in_addr addr, struct route_node **rn_out,
+ vrf_id_t vrf_id)
{
struct rib *rib = NULL, *mrib = NULL, *urib = NULL;
struct route_node *m_rn = NULL, *u_rn = NULL;
@@ -689,18 +691,24 @@
switch (ipv4_multicast_mode)
{
case MCAST_MRIB_ONLY:
- return rib_match_ipv4_safi (addr, SAFI_MULTICAST, skip_bgp, rn_out);
+ return rib_match_ipv4_safi (addr, SAFI_MULTICAST, skip_bgp, rn_out,
+ vrf_id);
case MCAST_URIB_ONLY:
- return rib_match_ipv4_safi (addr, SAFI_UNICAST, skip_bgp, rn_out);
+ return rib_match_ipv4_safi (addr, SAFI_UNICAST, skip_bgp, rn_out,
+ vrf_id);
case MCAST_NO_CONFIG:
case MCAST_MIX_MRIB_FIRST:
- rib = mrib = rib_match_ipv4_safi (addr, SAFI_MULTICAST, skip_bgp, &m_rn);
+ rib = mrib = rib_match_ipv4_safi (addr, SAFI_MULTICAST, skip_bgp, &m_rn,
+ vrf_id);
if (!mrib)
- rib = urib = rib_match_ipv4_safi (addr, SAFI_UNICAST, skip_bgp, &u_rn);
+ rib = urib = rib_match_ipv4_safi (addr, SAFI_UNICAST, skip_bgp, &u_rn,
+ vrf_id);
break;
case MCAST_MIX_DISTANCE:
- mrib = rib_match_ipv4_safi (addr, SAFI_MULTICAST, skip_bgp, &m_rn);
- urib = rib_match_ipv4_safi (addr, SAFI_UNICAST, skip_bgp, &u_rn);
+ mrib = rib_match_ipv4_safi (addr, SAFI_MULTICAST, skip_bgp, &m_rn,
+ vrf_id);
+ urib = rib_match_ipv4_safi (addr, SAFI_UNICAST, skip_bgp, &u_rn,
+ vrf_id);
if (mrib && urib)
rib = urib->distance < mrib->distance ? urib : mrib;
else if (mrib)
@@ -709,8 +717,10 @@
rib = urib;
break;
case MCAST_MIX_PFXLEN:
- mrib = rib_match_ipv4_safi (addr, SAFI_MULTICAST, skip_bgp, &m_rn);
- urib = rib_match_ipv4_safi (addr, SAFI_UNICAST, skip_bgp, &u_rn);
+ mrib = rib_match_ipv4_safi (addr, SAFI_MULTICAST, skip_bgp, &m_rn,
+ vrf_id);
+ urib = rib_match_ipv4_safi (addr, SAFI_UNICAST, skip_bgp, &u_rn,
+ vrf_id);
if (mrib && urib)
rib = u_rn->p.prefixlen > m_rn->p.prefixlen ? urib : mrib;
else if (mrib)
@@ -728,8 +738,8 @@
char buf[BUFSIZ];
inet_ntop (AF_INET, &addr, buf, BUFSIZ);
- zlog_debug("%s: %s: found %s, using %s",
- __func__, buf,
+ zlog_debug("%s: %s vrf %u: found %s, using %s",
+ __func__, buf, vrf_id,
mrib ? (urib ? "MRIB+URIB" : "MRIB") :
urib ? "URIB" : "nothing",
rib == urib ? "URIB" : rib == mrib ? "MRIB" : "none");
@@ -752,7 +762,7 @@
}
struct rib *
-rib_lookup_ipv4 (struct prefix_ipv4 *p)
+rib_lookup_ipv4 (struct prefix_ipv4 *p, vrf_id_t vrf_id)
{
struct route_table *table;
struct route_node *rn;
@@ -761,7 +771,7 @@
int recursing;
/* Lookup table. */
- table = zebra_vrf_table (AFI_IP, SAFI_UNICAST, VRF_DEFAULT);
+ table = zebra_vrf_table (AFI_IP, SAFI_UNICAST, vrf_id);
if (! table)
return 0;
@@ -808,7 +818,8 @@
* 3: no matches found
*/
int
-rib_lookup_ipv4_route (struct prefix_ipv4 *p, union sockunion * qgate)
+rib_lookup_ipv4_route (struct prefix_ipv4 *p, union sockunion * qgate,
+ vrf_id_t vrf_id)
{
struct route_table *table;
struct route_node *rn;
@@ -818,7 +829,7 @@
int nexthops_active;
/* Lookup table. */
- table = zebra_vrf_table (AFI_IP, SAFI_UNICAST, VRF_DEFAULT);
+ table = zebra_vrf_table (AFI_IP, SAFI_UNICAST, vrf_id);
if (! table)
return ZEBRA_RIB_LOOKUP_ERROR;
@@ -874,7 +885,7 @@
#ifdef HAVE_IPV6
struct rib *
-rib_match_ipv6 (struct in6_addr *addr)
+rib_match_ipv6 (struct in6_addr *addr, vrf_id_t vrf_id)
{
struct prefix_ipv6 p;
struct route_table *table;
@@ -884,7 +895,7 @@
int recursing;
/* Lookup table. */
- table = zebra_vrf_table (AFI_IP6, SAFI_UNICAST, VRF_DEFAULT);
+ table = zebra_vrf_table (AFI_IP6, SAFI_UNICAST, vrf_id);
if (! table)
return 0;
@@ -965,7 +976,7 @@
switch (nexthop->type)
{
case NEXTHOP_TYPE_IFINDEX:
- ifp = if_lookup_by_index (nexthop->ifindex);
+ ifp = if_lookup_by_index_vrf (nexthop->ifindex, rib->vrf_id);
if (ifp && if_is_operative(ifp))
SET_FLAG (nexthop->flags, NEXTHOP_FLAG_ACTIVE);
else
@@ -974,7 +985,7 @@
case NEXTHOP_TYPE_IPV6_IFNAME:
family = AFI_IP6;
case NEXTHOP_TYPE_IFNAME:
- ifp = if_lookup_by_name (nexthop->ifname);
+ ifp = if_lookup_by_name_vrf (nexthop->ifname, rib->vrf_id);
if (ifp && if_is_operative(ifp))
{
if (set)
@@ -1008,7 +1019,7 @@
family = AFI_IP6;
if (IN6_IS_ADDR_LINKLOCAL (&nexthop->gate.ipv6))
{
- ifp = if_lookup_by_index (nexthop->ifindex);
+ ifp = if_lookup_by_index_vrf (nexthop->ifindex, rib->vrf_id);
if (ifp && if_is_operative(ifp))
SET_FLAG (nexthop->flags, NEXTHOP_FLAG_ACTIVE);
else
@@ -1793,7 +1804,7 @@
int
rib_add_ipv4 (int type, int flags, struct prefix_ipv4 *p,
struct in_addr *gate, struct in_addr *src,
- unsigned int ifindex, u_int32_t vrf_id,
+ unsigned int ifindex, vrf_id_t vrf_id, int table_id,
u_int32_t metric, u_char distance, safi_t safi)
{
struct rib *rib;
@@ -1803,7 +1814,7 @@
struct nexthop *nexthop;
/* Lookup table. */
- table = zebra_vrf_table (AFI_IP, safi, VRF_DEFAULT);
+ table = zebra_vrf_table (AFI_IP, safi, vrf_id);
if (! table)
return 0;
@@ -1857,7 +1868,8 @@
rib->distance = distance;
rib->flags = flags;
rib->metric = metric;
- rib->table = vrf_id;
+ rib->vrf_id = vrf_id;
+ rib->table = table_id;
rib->nexthop_num = 0;
rib->uptime = time (NULL);
@@ -1909,8 +1921,8 @@
struct nexthop *nexthop, *tnexthop;
int recursing;
- zlog_debug ("%s: dumping RIB entry %p for %s", func, (void *)rib,
- prefix2str(p, straddr, sizeof(straddr)));
+ zlog_debug ("%s: dumping RIB entry %p for %s vrf %u", func, (void *)rib,
+ prefix2str(p, straddr, sizeof(straddr)), rib->vrf_id);
zlog_debug
(
"%s: refcnt == %lu, uptime == %lu, type == %u, table == %d",
@@ -2065,7 +2077,7 @@
struct nexthop *nexthop;
/* Lookup table. */
- table = zebra_vrf_table (AFI_IP, safi, VRF_DEFAULT);
+ table = zebra_vrf_table (AFI_IP, safi, rib->vrf_id);
if (! table)
return 0;
@@ -2131,7 +2143,7 @@
/* XXX factor with rib_delete_ipv6 */
int
rib_delete_ipv4 (int type, int flags, struct prefix_ipv4 *p,
- struct in_addr *gate, unsigned int ifindex, u_int32_t vrf_id, safi_t safi)
+ struct in_addr *gate, unsigned int ifindex, vrf_id_t vrf_id, safi_t safi)
{
struct route_table *table;
struct route_node *rn;
@@ -2144,7 +2156,7 @@
char buf2[INET_ADDRSTRLEN];
/* Lookup table. */
- table = zebra_vrf_table (AFI_IP, safi, VRF_DEFAULT);
+ table = zebra_vrf_table (AFI_IP, safi, vrf_id);
if (! table)
return 0;
@@ -2154,13 +2166,13 @@
if (IS_ZEBRA_DEBUG_KERNEL)
{
if (gate)
- zlog_debug ("rib_delete_ipv4(): route delete %s via %s ifindex %d",
- prefix2str (p, buf1, sizeof(buf1)),
+ zlog_debug ("rib_delete_ipv4(): route delete %s vrf %u via %s ifindex %d",
+ prefix2str (p, buf1, sizeof(buf1)), vrf_id,
inet_ntoa (*gate),
ifindex);
else
- zlog_debug ("rib_delete_ipv4(): route delete %s ifindex %d",
- prefix2str (p, buf1, sizeof(buf1)),
+ zlog_debug ("rib_delete_ipv4(): route delete %s vrf %u ifindex %d",
+ prefix2str (p, buf1, sizeof(buf1)), vrf_id,
ifindex);
}
@@ -2171,13 +2183,13 @@
if (IS_ZEBRA_DEBUG_KERNEL)
{
if (gate)
- zlog_debug ("route %s via %s ifindex %d doesn't exist in rib",
- prefix2str (p, buf1, sizeof(buf1)),
+ zlog_debug ("route %s vrf %u via %s ifindex %d doesn't exist in rib",
+ prefix2str (p, buf1, sizeof(buf1)), vrf_id,
inet_ntop (AF_INET, gate, buf2, INET_ADDRSTRLEN),
ifindex);
else
- zlog_debug ("route %s ifindex %d doesn't exist in rib",
- prefix2str (p, buf1, sizeof(buf1)),
+ zlog_debug ("route %s vrf %u ifindex %d doesn't exist in rib",
+ prefix2str (p, buf1, sizeof(buf1)), vrf_id,
ifindex);
}
return ZEBRA_ERR_RTNOEXIST;
@@ -2244,14 +2256,15 @@
if (IS_ZEBRA_DEBUG_KERNEL)
{
if (gate)
- zlog_debug ("route %s via %s ifindex %d type %d doesn't exist in rib",
- prefix2str (p, buf1, sizeof(buf1)),
+ zlog_debug ("route %s vrf %u via %s ifindex %d type %d "
+ "doesn't exist in rib",
+ prefix2str (p, buf1, sizeof(buf1)), vrf_id,
inet_ntop (AF_INET, gate, buf2, INET_ADDRSTRLEN),
ifindex,
type);
else
- zlog_debug ("route %s ifindex %d type %d doesn't exist in rib",
- prefix2str (p, buf1, sizeof(buf1)),
+ zlog_debug ("route %s vrf %u ifindex %d type %d doesn't exist in rib",
+ prefix2str (p, buf1, sizeof(buf1)), vrf_id,
ifindex,
type);
}
@@ -2318,6 +2331,7 @@
rib->type = ZEBRA_ROUTE_STATIC;
rib->distance = si->distance;
rib->metric = 0;
+ rib->vrf_id = VRF_DEFAULT;
rib->table = zebrad.rtm_table_default;
rib->nexthop_num = 0;
@@ -2423,7 +2437,7 @@
int
static_add_ipv4_safi (safi_t safi, struct prefix *p, struct in_addr *gate,
const char *ifname, u_char flags, u_char distance,
- u_int32_t vrf_id)
+ vrf_id_t vrf_id)
{
u_char type = 0;
struct route_node *rn;
@@ -2431,10 +2445,9 @@
struct static_ipv4 *pp;
struct static_ipv4 *cp;
struct static_ipv4 *update = NULL;
- struct route_table *stable;
+ struct zebra_vrf *zvrf = vrf_info_get (vrf_id);
+ struct route_table *stable = zvrf->stable[AFI_IP][safi];
- /* Lookup table. */
- stable = zebra_vrf_static_table (AFI_IP, safi, vrf_id);
if (! stable)
return -1;
@@ -2517,7 +2530,7 @@
int
static_delete_ipv4_safi (safi_t safi, struct prefix *p, struct in_addr *gate,
- const char *ifname, u_char distance, u_int32_t vrf_id)
+ const char *ifname, u_char distance, vrf_id_t vrf_id)
{
u_char type = 0;
struct route_node *rn;
@@ -2581,7 +2594,8 @@
#ifdef HAVE_IPV6
int
rib_add_ipv6 (int type, int flags, struct prefix_ipv6 *p,
- struct in6_addr *gate, unsigned int ifindex, u_int32_t vrf_id,
+ struct in6_addr *gate, unsigned int ifindex,
+ vrf_id_t vrf_id, int table_id,
u_int32_t metric, u_char distance, safi_t safi)
{
struct rib *rib;
@@ -2591,7 +2605,7 @@
struct nexthop *nexthop;
/* Lookup table. */
- table = zebra_vrf_table (AFI_IP6, safi, VRF_DEFAULT);
+ table = zebra_vrf_table (AFI_IP6, safi, vrf_id);
if (! table)
return 0;
@@ -2638,7 +2652,8 @@
rib->distance = distance;
rib->flags = flags;
rib->metric = metric;
- rib->table = vrf_id;
+ rib->vrf_id = vrf_id;
+ rib->table = table_id;
rib->nexthop_num = 0;
rib->uptime = time (NULL);
@@ -2686,7 +2701,7 @@
/* XXX factor with rib_delete_ipv6 */
int
rib_delete_ipv6 (int type, int flags, struct prefix_ipv6 *p,
- struct in6_addr *gate, unsigned int ifindex, u_int32_t vrf_id, safi_t safi)
+ struct in6_addr *gate, unsigned int ifindex, vrf_id_t vrf_id, safi_t safi)
{
struct route_table *table;
struct route_node *rn;
@@ -2702,7 +2717,7 @@
apply_mask_ipv6 (p);
/* Lookup table. */
- table = zebra_vrf_table (AFI_IP6, safi, VRF_DEFAULT);
+ table = zebra_vrf_table (AFI_IP6, safi, vrf_id);
if (! table)
return 0;
@@ -2713,13 +2728,13 @@
if (IS_ZEBRA_DEBUG_KERNEL)
{
if (gate)
- zlog_debug ("route %s via %s ifindex %d doesn't exist in rib",
- prefix2str (p, buf1, sizeof(buf1)),
+ zlog_debug ("route %s vrf %u via %s ifindex %d doesn't exist in rib",
+ prefix2str (p, buf1, sizeof(buf1)), vrf_id,
inet_ntop (AF_INET6, gate, buf2, INET6_ADDRSTRLEN),
ifindex);
else
- zlog_debug ("route %s ifindex %d doesn't exist in rib",
- prefix2str (p, buf1, sizeof(buf1)),
+ zlog_debug ("route %s vrf %u ifindex %d doesn't exist in rib",
+ prefix2str (p, buf1, sizeof(buf1)), vrf_id,
ifindex);
}
return ZEBRA_ERR_RTNOEXIST;
@@ -2787,14 +2802,15 @@
if (IS_ZEBRA_DEBUG_KERNEL)
{
if (gate)
- zlog_debug ("route %s via %s ifindex %d type %d doesn't exist in rib",
- prefix2str (p, buf1, sizeof(buf1)),
+ zlog_debug ("route %s vrf %u via %s ifindex %d type %d "
+ "doesn't exist in rib",
+ prefix2str (p, buf1, sizeof(buf1)), vrf_id,
inet_ntop (AF_INET6, gate, buf2, INET6_ADDRSTRLEN),
ifindex,
type);
else
- zlog_debug ("route %s ifindex %d type %d doesn't exist in rib",
- prefix2str (p, buf1, sizeof(buf1)),
+ zlog_debug ("route %s vrf %u ifindex %d type %d doesn't exist in rib",
+ prefix2str (p, buf1, sizeof(buf1)), vrf_id,
ifindex,
type);
}
@@ -2862,6 +2878,7 @@
rib->type = ZEBRA_ROUTE_STATIC;
rib->distance = si->distance;
rib->metric = 0;
+ rib->vrf_id = VRF_DEFAULT;
rib->table = zebrad.rtm_table_default;
rib->nexthop_num = 0;
@@ -2971,16 +2988,15 @@
int
static_add_ipv6 (struct prefix *p, u_char type, struct in6_addr *gate,
const char *ifname, u_char flags, u_char distance,
- u_int32_t vrf_id)
+ vrf_id_t vrf_id)
{
struct route_node *rn;
struct static_ipv6 *si;
struct static_ipv6 *pp;
struct static_ipv6 *cp;
- struct route_table *stable;
+ struct zebra_vrf *zvrf = vrf_info_get (vrf_id);
+ struct route_table *stable = zvrf->stable[AFI_IP6][SAFI_UNICAST];
- /* Lookup table. */
- stable = zebra_vrf_static_table (AFI_IP6, SAFI_UNICAST, vrf_id);
if (! stable)
return -1;
@@ -3058,7 +3074,7 @@
/* Delete static route from static route configuration. */
int
static_delete_ipv6 (struct prefix *p, u_char type, struct in6_addr *gate,
- const char *ifname, u_char distance, u_int32_t vrf_id)
+ const char *ifname, u_char distance, vrf_id_t vrf_id)
{
struct route_node *rn;
struct static_ipv6 *si;
@@ -3111,18 +3127,18 @@
/* RIB update function. */
void
-rib_update (void)
+rib_update (vrf_id_t vrf_id)
{
struct route_node *rn;
struct route_table *table;
- table = zebra_vrf_table (AFI_IP, SAFI_UNICAST, VRF_DEFAULT);
+ table = zebra_vrf_table (AFI_IP, SAFI_UNICAST, vrf_id);
if (table)
for (rn = route_top (table); rn; rn = route_next (rn))
if (rnode_to_ribs (rn))
rib_queue_add (&zebrad, rn);
- table = zebra_vrf_table (AFI_IP6, SAFI_UNICAST, VRF_DEFAULT);
+ table = zebra_vrf_table (AFI_IP6, SAFI_UNICAST, vrf_id);
if (table)
for (rn = route_top (table); rn; rn = route_next (rn))
if (rnode_to_ribs (rn))
@@ -3155,10 +3171,18 @@
void
rib_weed_tables (void)
{
- rib_weed_table (zebra_vrf_table (AFI_IP, SAFI_UNICAST, VRF_DEFAULT));
- rib_weed_table (zebra_vrf_table (AFI_IP6, SAFI_UNICAST, VRF_DEFAULT));
+ vrf_iter_t iter;
+ struct zebra_vrf *zvrf;
+
+ for (iter = vrf_first (); iter != VRF_ITER_INVALID; iter = vrf_next (iter))
+ if ((zvrf = vrf_iter2info (iter)) != NULL)
+ {
+ rib_weed_table (zvrf->table[AFI_IP][SAFI_UNICAST]);
+ rib_weed_table (zvrf->table[AFI_IP6][SAFI_UNICAST]);
+ }
}
+#if 0
/* Delete self installed routes after zebra is relaunched. */
static void
rib_sweep_table (struct route_table *table)
@@ -3184,13 +3208,21 @@
}
}
}
+#endif
/* Sweep all RIB tables. */
void
rib_sweep_route (void)
{
- rib_sweep_table (zebra_vrf_table (AFI_IP, SAFI_UNICAST, VRF_DEFAULT));
- rib_sweep_table (zebra_vrf_table (AFI_IP6, SAFI_UNICAST, VRF_DEFAULT));
+ vrf_iter_t iter;
+ struct zebra_vrf *zvrf;
+
+ for (iter = vrf_first (); iter != VRF_ITER_INVALID; iter = vrf_next (iter))
+ if ((zvrf = vrf_iter2info (iter)) != NULL)
+ {
+ rib_weed_table (zvrf->table[AFI_IP][SAFI_UNICAST]);
+ rib_weed_table (zvrf->table[AFI_IP6][SAFI_UNICAST]);
+ }
}
/* Remove specific by protocol routes from 'table'. */
@@ -3222,8 +3254,16 @@
unsigned long
rib_score_proto (u_char proto)
{
- return rib_score_proto_table (proto, zebra_vrf_table (AFI_IP, SAFI_UNICAST, VRF_DEFAULT))
- +rib_score_proto_table (proto, zebra_vrf_table (AFI_IP6, SAFI_UNICAST, VRF_DEFAULT));
+ vrf_iter_t iter;
+ struct zebra_vrf *zvrf;
+ unsigned long cnt = 0;
+
+ for (iter = vrf_first (); iter != VRF_ITER_INVALID; iter = vrf_next (iter))
+ if ((zvrf = vrf_iter2info (iter)) != NULL)
+ cnt += rib_score_proto_table (proto, zvrf->table[AFI_IP][SAFI_UNICAST])
+ +rib_score_proto_table (proto, zvrf->table[AFI_IP6][SAFI_UNICAST]);
+
+ return cnt;
}
/* Close RIB and clean up kernel routes. */
@@ -3253,8 +3293,15 @@
void
rib_close (void)
{
- rib_close_table (zebra_vrf_table (AFI_IP, SAFI_UNICAST, VRF_DEFAULT));
- rib_close_table (zebra_vrf_table (AFI_IP6, SAFI_UNICAST, VRF_DEFAULT));
+ vrf_iter_t iter;
+ struct zebra_vrf *zvrf;
+
+ for (iter = vrf_first (); iter != VRF_ITER_INVALID; iter = vrf_next (iter))
+ if ((zvrf = vrf_iter2info (iter)) != NULL)
+ {
+ rib_close_table (zvrf->table[AFI_IP][SAFI_UNICAST]);
+ rib_close_table (zvrf->table[AFI_IP6][SAFI_UNICAST]);
+ }
}
/* Routing information base initialize. */