---
lib/table.h | 1 +
zebra/main.c | 7 +-
zebra/rib.h | 61 ++++++++++++--
zebra/test_main.c | 5 +-
zebra/zebra_rib.c | 169 ++++++++++++++++++++++++++++++++-------
zebra/zebra_vty.c | 232 ++++++++++++++++++++++++++++++++++++++++--------------
6 files changed, 373 insertions(+), 102 deletions(-)
diff --git a/lib/table.h b/lib/table.h
index 2ffd79b..9906729 100644
--- a/lib/table.h
+++ b/lib/table.h
@@ -54,6 +54,7 @@ struct route_table
{
struct route_node *top;
+ int table_id;
/*
* Delegate that performs certain functions for this table.
*/
diff --git a/zebra/main.c b/zebra/main.c
index f3c08f1..4d25475 100644
--- a/zebra/main.c
+++ b/zebra/main.c
@@ -249,8 +249,11 @@ zebra_vrf_disable (vrf_id_t vrf_id, void **info)
assert (zvrf);
- rib_close_table (zvrf->table[AFI_IP][SAFI_UNICAST]);
- rib_close_table (zvrf->table[AFI_IP6][SAFI_UNICAST]);
+ ZVRF_FOREACH_RTINFO(zvrf)
+ {
+ rib_close_table (rt_info->table[AFI_IP][SAFI_UNICAST]);
+ rib_close_table (rt_info->table[AFI_IP6][SAFI_UNICAST]);
+ }
for (ALL_LIST_ELEMENTS_RO (vrf_iflist (vrf_id), list_node, ifp))
{
diff --git a/zebra/rib.h b/zebra/rib.h
index ffe7e2f..1c5dcc3 100644
--- a/zebra/rib.h
+++ b/zebra/rib.h
@@ -27,6 +27,7 @@
#include "prefix.h"
#include "table.h"
#include "queue.h"
+#include "vector.h"
#define DISTANCE_INFINITY 255
@@ -330,14 +331,29 @@ struct nlsock
};
#endif
+struct route_table_info
+{
+ /* Routing table id */
+ int table_id;
+
+ /* Routing table name. */
+ char *name;
+
+ /* Routing table. */
+ struct route_table *table[AFI_MAX][SAFI_MAX];
+
+ /* Static route configuration. */
+ struct route_table *stable[AFI_MAX][SAFI_MAX];
+
+};
/* Routing table instance. */
struct zebra_vrf
{
/* Identifier. */
vrf_id_t vrf_id;
- /* Routing table name. */
- char *name;
+ /* Contain all the route tables */
+ vector route_tables_info;
/* Description. */
char *desc;
@@ -345,12 +361,6 @@ struct zebra_vrf
/* FIB identifier. */
u_char fib_id;
- /* Routing table. */
- struct route_table *table[AFI_MAX][SAFI_MAX];
-
- /* Static route configuration. */
- struct route_table *stable[AFI_MAX][SAFI_MAX];
-
#ifdef HAVE_NETLINK
struct nlsock netlink; /* kernel messages */
struct nlsock netlink_cmd; /* command channel */
@@ -520,6 +530,11 @@ static_delete_ipv6 (struct prefix *p, u_char type, struct
in6_addr *gate,
extern int rib_gc_dest (struct route_node *rn);
extern struct route_table *rib_tables_iter_next (rib_tables_iter_t *iter);
+extern struct route_table_info *get_route_table_info(
+ struct zebra_vrf *zvrf, int table_id);
+
+extern struct route_table *zebra_vrf_table_id (
+ afi_t afi, safi_t safi, vrf_id_t vrf_id, int table_id);
/*
* Inline functions.
*/
@@ -630,4 +645,34 @@ rib_tables_iter_cleanup (rib_tables_iter_t *iter)
iter->state = RIB_TABLES_ITER_S_DONE;
}
+void
+zebra_route_tables_create(struct zebra_vrf *zvrf, int table_id);
+
+void
+init_zebra_route_tables_info(struct zebra_vrf *zvrf);
+
+void
+init_zebra_route_table(struct zebra_vrf *zvrf, struct route_table_info
*rt_info);
+
+#define VRF_FOREACH_TABLE(vrf_id, table, afi, safi)\
+ int i;\
+ struct zebra_vrf *zvrf = vrf_info_lookup (vrf_id);\
+ (table) = ((struct
route_table_info*)vector_lookup((zvrf)->route_tables_info,
0))->table[afi][safi];\
+ for(i = 0; i < vector_count((zvrf)->route_tables_info);\
+ (table) = ((struct
route_table_info*)vector_lookup((zvrf)->route_tables_info,
i))->table[afi][safi], \
+ i++)
+
+#define ZVRF_FOREACH_TABLE(zvrf, table, afi, safi)\
+ int i;\
+ (table) = ((struct
route_table_info*)vector_lookup((zvrf)->route_tables_info,
0))->table[afi][safi];\
+ for(i = 0; i < vector_count((zvrf)->route_tables_info);\
+ (table) = ((struct
route_table_info*)vector_lookup((zvrf)->route_tables_info,
i))->table[afi][safi], \
+ i++)
+
+#define ZVRF_FOREACH_RTINFO(zvrf)\
+ int i;\
+ struct route_table_info *rt_info = vector_lookup((zvrf)->route_tables_info,
0);\
+ for(i = 0; i < vector_count((zvrf)->route_tables_info);\
+ (rt_info) = vector_lookup((zvrf)->route_tables_info, i), \
+ i++)
#endif /*_ZEBRA_RIB_H */
diff --git a/zebra/test_main.c b/zebra/test_main.c
index 448d1ef..a705a20 100644
--- a/zebra/test_main.c
+++ b/zebra/test_main.c
@@ -233,11 +233,12 @@ zebra_vrf_disable (vrf_id_t vrf_id, void **info)
struct zebra_vrf *zvrf = (struct zebra_vrf *) (*info);
struct listnode *list_node;
struct interface *ifp;
+ struct route_table_info *rt_info = get_route_table_info(zvrf, RT_TABLE_MAIN);
assert (zvrf);
- rib_close_table (zvrf->table[AFI_IP][SAFI_UNICAST]);
- rib_close_table (zvrf->table[AFI_IP6][SAFI_UNICAST]);
+ rib_close_table (rt_info->table[AFI_IP][SAFI_UNICAST]);
+ rib_close_table (rt_info->table[AFI_IP6][SAFI_UNICAST]);
for (ALL_LIST_ELEMENTS_RO (vrf_iflist (vrf_id), list_node, ifp))
{
diff --git a/zebra/zebra_rib.c b/zebra/zebra_rib.c
index 38357ff..1371edc 100644
--- a/zebra/zebra_rib.c
+++ b/zebra/zebra_rib.c
@@ -1810,9 +1810,16 @@ rib_add_ipv4 (int type, int flags, struct prefix_ipv4 *p,
struct nexthop *nexthop;
/* Lookup table. */
- table = zebra_vrf_table (AFI_IP, safi, vrf_id);
+ table = zebra_vrf_table_id(AFI_IP, safi, vrf_id, table_id);
if (! table)
- return 0;
+ {
+ struct zebra_vrf *zvrf = vrf_info_lookup (vrf_id);
+ if (!zvrf)
+ return NULL;
+
+ zebra_route_tables_create(zvrf, table_id);
+ table = zebra_vrf_table_id(AFI_IP, safi, vrf_id, table_id);
+ }
/* Make it sure prefixlen is applied to the prefix. */
apply_mask_ipv4 (p);
@@ -2286,9 +2293,16 @@ static_install_route (afi_t afi, safi_t safi, struct
prefix *p, struct static_ro
struct route_table *table;
/* Lookup table. */
- table = zebra_vrf_table (afi, safi, si->vrf_id);
+ table = zebra_vrf_table_id(afi, safi, si->vrf_id, zebrad.rtm_table_default);
if (! table)
- return;
+ {
+ struct zebra_vrf *zvrf = vrf_info_lookup (si->vrf_id);
+ if (!zvrf)
+ return;
+
+ zebra_route_tables_create(zvrf, zebrad.rtm_table_default);
+ table = zebra_vrf_table_id(afi, safi, si->vrf_id,
zebrad.rtm_table_default);
+ }
/* Lookup existing route */
rn = route_node_get (table, p);
@@ -2474,7 +2488,15 @@ static_add_ipv4_safi (safi_t safi, struct prefix *p,
struct in_addr *gate,
struct static_route *cp;
struct static_route *update = NULL;
struct zebra_vrf *zvrf = vrf_info_get (vrf_id);
- struct route_table *stable = zvrf->stable[AFI_IP][safi];
+ struct route_table_info *rt_info = get_route_table_info(
+ zvrf, zebrad.rtm_table_default);
+ if (! rt_info)
+ {
+ zebra_route_tables_create(zvrf, zebrad.rtm_table_default);
+ rt_info = get_route_table_info(
+ zvrf, zebrad.rtm_table_default);
+ }
+ struct route_table *stable = rt_info->stable[AFI_IP][safi];
if (! stable)
return -1;
@@ -2868,7 +2890,15 @@ static_add_ipv6 (struct prefix *p, u_char type, struct
in6_addr *gate,
struct static_route *cp;
struct static_route *update = NULL;
struct zebra_vrf *zvrf = vrf_info_get (vrf_id);
- struct route_table *stable = zvrf->stable[AFI_IP6][SAFI_UNICAST];
+ struct route_table_info *rt_info = get_route_table_info(
+ zvrf, zebrad.rtm_table_default);
+ if (! rt_info)
+ {
+ zebra_route_tables_create(zvrf, zebrad.rtm_table_default);
+ rt_info = get_route_table_info(
+ zvrf, zebrad.rtm_table_default);
+ }
+ struct route_table *stable = rt_info->stable[AFI_IP6][SAFI_UNICAST];
if (! stable)
return -1;
@@ -3028,7 +3058,7 @@ rib_update (vrf_id_t vrf_id)
/* Remove all routes which comes from non main table. */
static void
-rib_weed_table (struct route_table *table)
+rib_weed_table (struct route_table *table, int table_id)
{
struct route_node *rn;
struct rib *rib;
@@ -3042,7 +3072,8 @@ rib_weed_table (struct route_table *table)
continue;
if (rib->table != zebrad.rtm_table_default &&
- rib->table != RT_TABLE_MAIN)
+ rib->table != RT_TABLE_MAIN &&
+ rib->table != table_id)
rib_delnode (rn, rib);
}
}
@@ -3051,14 +3082,22 @@ rib_weed_table (struct route_table *table)
void
rib_weed_tables (void)
{
+ int i;
vrf_iter_t iter;
struct zebra_vrf *zvrf;
+ struct route_table_info *rt_info;
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]);
+ for (i=0; i < vector_count(zvrf->route_tables_info); i++)
+ {
+ rt_info = vector_lookup(zvrf->route_tables_info, i);
+ rib_weed_table (rt_info->table[AFI_IP][SAFI_UNICAST],
+ rt_info->table_id);
+ rib_weed_table (rt_info->table[AFI_IP6][SAFI_UNICAST],
+ rt_info->table_id);
+ }
}
}
@@ -3100,8 +3139,11 @@ rib_sweep_route (void)
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]);
+ struct route_table_info *rt_info = get_route_table_info(zvrf,
RT_TABLE_MAIN);
+ rib_weed_table (rt_info->table[AFI_IP][SAFI_UNICAST],
+ rt_info->table_id);
+ rib_weed_table (rt_info->table[AFI_IP6][SAFI_UNICAST],
+ rt_info->table_id);
}
}
@@ -3140,8 +3182,11 @@ rib_score_proto (u_char proto)
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]);
+ {
+ struct route_table_info *rt_info = get_route_table_info(zvrf,
RT_TABLE_MAIN);
+ cnt += rib_score_proto_table (proto,
rt_info->table[AFI_IP][SAFI_UNICAST])
+ +rib_score_proto_table (proto,
rt_info->table[AFI_IP6][SAFI_UNICAST]);
+ }
return cnt;
}
@@ -3173,14 +3218,20 @@ rib_close_table (struct route_table *table)
void
rib_close (void)
{
+ int i;
vrf_iter_t iter;
struct zebra_vrf *zvrf;
+ struct route_table_info *rt_info;
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]);
+ for (i=0; i < vector_count(zvrf->route_tables_info); i++)
+ {
+ rt_info = vector_lookup(zvrf->route_tables_info, i);
+ rib_close_table (rt_info->table[AFI_IP][SAFI_UNICAST]);
+ rib_close_table (rt_info->table[AFI_IP6][SAFI_UNICAST]);
+ }
}
}
@@ -3302,15 +3353,15 @@ rib_tables_iter_next (rib_tables_iter_t *iter)
* Create a routing table for the specific AFI/SAFI in the given VRF.
*/
static void
-zebra_vrf_table_create (struct zebra_vrf *zvrf, afi_t afi, safi_t safi)
+zebra_vrf_table_create (struct zebra_vrf *zvrf, struct route_table_info
*rt_info, afi_t afi, safi_t safi)
{
rib_table_info_t *info;
struct route_table *table;
- assert (!zvrf->table[afi][safi]);
+ assert (!rt_info->table[afi][safi]);
table = route_table_init ();
- zvrf->table[afi][safi] = table;
+ rt_info->table[afi][safi] = table;
info = XCALLOC (MTYPE_RIB_TABLE_INFO, sizeof (*info));
info->zvrf = zvrf;
@@ -3330,15 +3381,7 @@ zebra_vrf_alloc (vrf_id_t vrf_id)
zvrf = XCALLOC (MTYPE_ZEBRA_VRF, sizeof (struct zebra_vrf));
- /* Allocate routing table and static table. */
- zebra_vrf_table_create (zvrf, AFI_IP, SAFI_UNICAST);
- zebra_vrf_table_create (zvrf, AFI_IP6, SAFI_UNICAST);
- zvrf->stable[AFI_IP][SAFI_UNICAST] = route_table_init ();
- zvrf->stable[AFI_IP6][SAFI_UNICAST] = route_table_init ();
- zebra_vrf_table_create (zvrf, AFI_IP, SAFI_MULTICAST);
- zebra_vrf_table_create (zvrf, AFI_IP6, SAFI_MULTICAST);
- zvrf->stable[AFI_IP][SAFI_MULTICAST] = route_table_init ();
- zvrf->stable[AFI_IP6][SAFI_MULTICAST] = route_table_init ();
+ init_zebra_route_tables_info(zvrf);
/* Set VRF ID */
zvrf->vrf_id = vrf_id;
@@ -3369,9 +3412,41 @@ zebra_vrf_table (afi_t afi, safi_t safi, vrf_id_t vrf_id)
if (afi >= AFI_MAX || safi >= SAFI_MAX)
return NULL;
- return zvrf->table[afi][safi];
+ struct route_table_info * rt_info = get_route_table_info(zvrf,
RT_TABLE_MAIN);
+
+ return rt_info->table[afi][safi];
}
+/* Lookup the routing table in an enabled VRF. */
+struct route_table *
+zebra_vrf_table_id (afi_t afi, safi_t safi, vrf_id_t vrf_id, int table_id)
+{
+ struct zebra_vrf *zvrf = vrf_info_lookup (vrf_id);
+
+ if (!zvrf)
+ return NULL;
+
+ if (afi >= AFI_MAX || safi >= SAFI_MAX)
+ return NULL;
+
+ struct route_table_info * rt_info = get_route_table_info(zvrf, table_id);
+ if (rt_info)
+ return rt_info->table[afi][safi];
+}
+
+struct route_table_info *
+get_route_table_info(struct zebra_vrf *zvrf, int table_id)
+{
+ int i;
+ struct route_table_info* rt_info;
+ for (i=0; i < vector_count(zvrf->route_tables_info); i++)
+ {
+ rt_info = vector_lookup(zvrf->route_tables_info, i);
+ if (rt_info->table_id == table_id)
+ return rt_info;
+ }
+ return NULL;
+}
/* Lookup the static routing table in a VRF. */
struct route_table *
zebra_vrf_static_table (afi_t afi, safi_t safi, vrf_id_t vrf_id)
@@ -3384,6 +3459,40 @@ zebra_vrf_static_table (afi_t afi, safi_t safi, vrf_id_t
vrf_id)
if (afi >= AFI_MAX || safi >= SAFI_MAX)
return NULL;
- return zvrf->stable[afi][safi];
+ struct route_table_info *rt_info = get_route_table_info(zvrf, RT_TABLE_MAIN);
+ return rt_info->stable[afi][safi];
}
+void
+init_zebra_route_tables_info(struct zebra_vrf *zvrf)
+{
+ zvrf->route_tables_info = vector_init(1);
+ struct route_table_info *rt_info = malloc (sizeof(struct route_table_info));
+ rt_info->table_id = RT_TABLE_MAIN;
+
+ init_zebra_route_table(zvrf, rt_info);
+ vector_set_index (zvrf->route_tables_info, 0, rt_info);
+}
+
+void
+zebra_route_tables_create(struct zebra_vrf *zvrf, int table_id)
+{
+ struct route_table_info *rt_info = malloc (sizeof(struct route_table_info));
+ rt_info->table_id = table_id;
+ init_zebra_route_table(zvrf, rt_info);
+ vector_set_index (zvrf->route_tables_info,
vector_count(zvrf->route_tables_info), rt_info);
+}
+
+void
+init_zebra_route_table(struct zebra_vrf *zvrf, struct route_table_info
*rt_info)
+{
+ /* Allocate routing table and static table. */
+ zebra_vrf_table_create (zvrf, rt_info, AFI_IP, SAFI_UNICAST);
+ zebra_vrf_table_create (zvrf, rt_info, AFI_IP6, SAFI_UNICAST);
+ rt_info->stable[AFI_IP][SAFI_UNICAST] = route_table_init ();
+ rt_info->stable[AFI_IP6][SAFI_UNICAST] = route_table_init ();
+ zebra_vrf_table_create (zvrf, rt_info, AFI_IP, SAFI_MULTICAST);
+ zebra_vrf_table_create (zvrf, rt_info, AFI_IP6, SAFI_MULTICAST);
+ rt_info->stable[AFI_IP][SAFI_MULTICAST] = route_table_init ();
+ rt_info->stable[AFI_IP6][SAFI_MULTICAST] = route_table_init ();
+}
diff --git a/zebra/zebra_vty.c b/zebra/zebra_vty.c
index 656f55d..5369212 100644
--- a/zebra/zebra_vty.c
+++ b/zebra/zebra_vty.c
@@ -404,8 +404,11 @@ DEFUN (show_ip_rpf_vrf_all,
for (iter = vrf_first (); iter != VRF_ITER_INVALID; iter = vrf_next (iter))
{
+ zvrf = vrf_iter2info (iter);
+ ZVRF_FOREACH_RTINFO(zvrf)
+ {
if ((zvrf = vrf_iter2info (iter)) == NULL ||
- (table = zvrf->table[AFI_IP][SAFI_MULTICAST]) == NULL)
+ (table = rt_info->table[AFI_IP][SAFI_MULTICAST]) == NULL)
continue;
/* Show all IPv4 routes. */
@@ -419,6 +422,7 @@ DEFUN (show_ip_rpf_vrf_all,
}
vty_show_ip_route (vty, rn, rib);
}
+ }
}
return CMD_SUCCESS;
@@ -1579,21 +1583,24 @@ static int do_show_ip_route(struct vty *vty, safi_t
safi, vrf_id_t vrf_id)
struct rib *rib;
int first = 1;
- table = zebra_vrf_table (AFI_IP, safi, vrf_id);
+
+ VRF_FOREACH_TABLE(vrf_id, table, AFI_IP, safi)
+ {
if (! table)
- return CMD_SUCCESS;
+ 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);
+ if (first)
+ {
+ vty_out (vty, SHOW_ROUTE_V4_HEADER);
+ first = 0;
}
+ vty_show_ip_route (vty, rn, rib);
+ }
+ }
return CMD_SUCCESS;
}
@@ -1632,9 +1639,10 @@ DEFUN (show_ip_route_prefix_longer,
if (argc > 1)
VTY_GET_INTEGER ("VRF ID", vrf_id, argv[1]);
- table = zebra_vrf_table (AFI_IP, SAFI_UNICAST, vrf_id);
+ VRF_FOREACH_TABLE(vrf_id, table, AFI_IP, SAFI_UNICAST)
+ {
if (! table)
- return CMD_SUCCESS;
+ continue;
/* Show matched type IPv4 routes. */
for (rn = route_top (table); rn; rn = route_next (rn))
@@ -1648,6 +1656,7 @@ DEFUN (show_ip_route_prefix_longer,
}
vty_show_ip_route (vty, rn, rib);
}
+ }
return CMD_SUCCESS;
}
@@ -1679,9 +1688,10 @@ DEFUN (show_ip_route_supernets,
if (argc > 0)
VTY_GET_INTEGER ("VRF ID", vrf_id, argv[0]);
- table = zebra_vrf_table (AFI_IP, SAFI_UNICAST, vrf_id);
+ VRF_FOREACH_TABLE(vrf_id, table, AFI_IP, SAFI_UNICAST)
+ {
if (! table)
- return CMD_SUCCESS;
+ continue;
/* Show matched type IPv4 routes. */
for (rn = route_top (table); rn; rn = route_next (rn))
@@ -1701,6 +1711,7 @@ DEFUN (show_ip_route_supernets,
vty_show_ip_route (vty, rn, rib);
}
}
+ }
return CMD_SUCCESS;
}
@@ -1738,9 +1749,10 @@ DEFUN (show_ip_route_protocol,
if (argc > 1)
VTY_GET_INTEGER ("VRF ID", vrf_id, argv[1]);
- table = zebra_vrf_table (AFI_IP, SAFI_UNICAST, vrf_id);
+ VRF_FOREACH_TABLE(vrf_id, table, AFI_IP, SAFI_UNICAST)
+ {
if (! table)
- return CMD_SUCCESS;
+ continue;
/* Show matched type IPv4 routes. */
for (rn = route_top (table); rn; rn = route_next (rn))
@@ -1754,6 +1766,7 @@ DEFUN (show_ip_route_protocol,
}
vty_show_ip_route (vty, rn, rib);
}
+ }
return CMD_SUCCESS;
}
@@ -1790,9 +1803,10 @@ DEFUN (show_ip_route_addr,
if (argc > 1)
VTY_GET_INTEGER ("VRF ID", vrf_id, argv[1]);
- table = zebra_vrf_table (AFI_IP, SAFI_UNICAST, vrf_id);
+ VRF_FOREACH_TABLE(vrf_id, table, AFI_IP, SAFI_UNICAST)
+ {
if (! table)
- return CMD_SUCCESS;
+ continue;
rn = route_node_match (table, (struct prefix *) &p);
if (! rn)
@@ -1804,6 +1818,7 @@ DEFUN (show_ip_route_addr,
vty_show_ip_route_detail (vty, rn, 0);
route_unlock_node (rn);
+ }
return CMD_SUCCESS;
}
@@ -1841,9 +1856,10 @@ DEFUN (show_ip_route_prefix,
if (argc > 1)
VTY_GET_INTEGER ("VRF ID", vrf_id, argv[1]);
- table = zebra_vrf_table (AFI_IP, SAFI_UNICAST, vrf_id);
+ VRF_FOREACH_TABLE(vrf_id, table, AFI_IP, SAFI_UNICAST)
+ {
if (! table)
- return CMD_SUCCESS;
+ continue;
rn = route_node_match (table, (struct prefix *) &p);
if (! rn || rn->p.prefixlen != p.prefixlen)
@@ -1857,6 +1873,7 @@ DEFUN (show_ip_route_prefix,
vty_show_ip_route_detail (vty, rn, 0);
route_unlock_node (rn);
+ }
return CMD_SUCCESS;
}
@@ -2033,12 +2050,14 @@ DEFUN (show_ip_route_summary,
if (argc > 0)
VTY_GET_INTEGER ("VRF ID", vrf_id, argv[0]);
- table = zebra_vrf_table (AFI_IP, SAFI_UNICAST, vrf_id);
+ VRF_FOREACH_TABLE(vrf_id, table, AFI_IP, SAFI_UNICAST)
+ {
if (! table)
- return CMD_SUCCESS;
+ continue;
vty_show_ip_route_summary (vty, table);
+ }
return CMD_SUCCESS;
}
@@ -2067,11 +2086,13 @@ DEFUN (show_ip_route_summary_prefix,
if (argc > 0)
VTY_GET_INTEGER ("VRF ID", vrf_id, argv[0]);
- table = zebra_vrf_table (AFI_IP, SAFI_UNICAST, vrf_id);
+ VRF_FOREACH_TABLE(vrf_id, table, AFI_IP, SAFI_UNICAST)
+ {
if (! table)
- return CMD_SUCCESS;
+ continue;
vty_show_ip_route_summary_prefix (vty, table);
+ }
return CMD_SUCCESS;
}
@@ -2103,8 +2124,11 @@ DEFUN (show_ip_route_vrf_all,
for (iter = vrf_first (); iter != VRF_ITER_INVALID; iter = vrf_next (iter))
{
+ zvrf = vrf_iter2info (iter);
+ ZVRF_FOREACH_RTINFO(zvrf)
+ {
if ((zvrf = vrf_iter2info (iter)) == NULL ||
- (table = zvrf->table[AFI_IP][SAFI_UNICAST]) == NULL)
+ (table = rt_info->table[AFI_IP][SAFI_UNICAST]) == NULL)
continue;
/* Show all IPv4 routes. */
@@ -2118,6 +2142,7 @@ DEFUN (show_ip_route_vrf_all,
}
vty_show_ip_route (vty, rn, rib);
}
+ }
}
return CMD_SUCCESS;
@@ -2151,8 +2176,11 @@ DEFUN (show_ip_route_prefix_longer_vrf_all,
for (iter = vrf_first (); iter != VRF_ITER_INVALID; iter = vrf_next (iter))
{
+ zvrf = vrf_iter2info (iter);
+ ZVRF_FOREACH_RTINFO(zvrf)
+ {
if ((zvrf = vrf_iter2info (iter)) == NULL ||
- (table = zvrf->table[AFI_IP][SAFI_UNICAST]) == NULL)
+ (table = rt_info->table[AFI_IP][SAFI_UNICAST]) == NULL)
continue;
/* Show matched type IPv4 routes. */
@@ -2167,6 +2195,7 @@ DEFUN (show_ip_route_prefix_longer_vrf_all,
}
vty_show_ip_route (vty, rn, rib);
}
+ }
}
return CMD_SUCCESS;
@@ -2191,8 +2220,11 @@ DEFUN (show_ip_route_supernets_vrf_all,
for (iter = vrf_first (); iter != VRF_ITER_INVALID; iter = vrf_next (iter))
{
+ zvrf = vrf_iter2info (iter);
+ ZVRF_FOREACH_RTINFO(zvrf)
+ {
if ((zvrf = vrf_iter2info (iter)) == NULL ||
- (table = zvrf->table[AFI_IP][SAFI_UNICAST]) == NULL)
+ (table = rt_info->table[AFI_IP][SAFI_UNICAST]) == NULL)
continue;
/* Show matched type IPv4 routes. */
@@ -2213,6 +2245,7 @@ DEFUN (show_ip_route_supernets_vrf_all,
vty_show_ip_route (vty, rn, rib);
}
}
+ }
}
return CMD_SUCCESS;
@@ -2244,8 +2277,11 @@ DEFUN (show_ip_route_protocol_vrf_all,
for (iter = vrf_first (); iter != VRF_ITER_INVALID; iter = vrf_next (iter))
{
+ zvrf = vrf_iter2info (iter);
+ ZVRF_FOREACH_RTINFO(zvrf)
+ {
if ((zvrf = vrf_iter2info (iter)) == NULL ||
- (table = zvrf->table[AFI_IP][SAFI_UNICAST]) == NULL)
+ (table = rt_info->table[AFI_IP][SAFI_UNICAST]) == NULL)
continue;
/* Show matched type IPv4 routes. */
@@ -2260,6 +2296,7 @@ DEFUN (show_ip_route_protocol_vrf_all,
}
vty_show_ip_route (vty, rn, rib);
}
+ }
}
return CMD_SUCCESS;
@@ -2290,8 +2327,11 @@ DEFUN (show_ip_route_addr_vrf_all,
for (iter = vrf_first (); iter != VRF_ITER_INVALID; iter = vrf_next (iter))
{
+ zvrf = vrf_iter2info (iter);
+ ZVRF_FOREACH_RTINFO(zvrf)
+ {
if ((zvrf = vrf_iter2info (iter)) == NULL ||
- (table = zvrf->table[AFI_IP][SAFI_UNICAST]) == NULL)
+ (table = rt_info->table[AFI_IP][SAFI_UNICAST]) == NULL)
continue;
rn = route_node_match (table, (struct prefix *) &p);
@@ -2302,6 +2342,7 @@ DEFUN (show_ip_route_addr_vrf_all,
route_unlock_node (rn);
}
+ }
return CMD_SUCCESS;
}
@@ -2331,8 +2372,11 @@ DEFUN (show_ip_route_prefix_vrf_all,
for (iter = vrf_first (); iter != VRF_ITER_INVALID; iter = vrf_next (iter))
{
+ zvrf = vrf_iter2info (iter);
+ ZVRF_FOREACH_RTINFO(zvrf)
+ {
if ((zvrf = vrf_iter2info (iter)) == NULL ||
- (table = zvrf->table[AFI_IP][SAFI_UNICAST]) == NULL)
+ (table = rt_info->table[AFI_IP][SAFI_UNICAST]) == NULL)
continue;
rn = route_node_match (table, (struct prefix *) &p);
@@ -2348,6 +2392,7 @@ DEFUN (show_ip_route_prefix_vrf_all,
route_unlock_node (rn);
}
+ }
return CMD_SUCCESS;
}
@@ -2366,7 +2411,12 @@ DEFUN (show_ip_route_summary_vrf_all,
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]);
+ {
+ ZVRF_FOREACH_RTINFO(zvrf)
+ {
+ vty_show_ip_route_summary (vty, rt_info->table[AFI_IP][SAFI_UNICAST]);
+ }
+ }
return CMD_SUCCESS;
}
@@ -2386,7 +2436,12 @@ DEFUN (show_ip_route_summary_prefix_vrf_all,
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]);
+ {
+ ZVRF_FOREACH_RTINFO(zvrf)
+ {
+ vty_show_ip_route_summary_prefix (vty,
rt_info->table[AFI_IP][SAFI_UNICAST]);
+ }
+ }
return CMD_SUCCESS;
}
@@ -2406,8 +2461,11 @@ static_config_ipv4 (struct vty *vty, safi_t safi, const
char *cmd)
for (iter = vrf_first (); iter != VRF_ITER_INVALID; iter = vrf_next (iter))
{
+ zvrf = vrf_iter2info (iter);
+ ZVRF_FOREACH_RTINFO(zvrf)
+ {
if ((zvrf = vrf_iter2info (iter)) == NULL ||
- (stable = zvrf->stable[AFI_IP][safi]) == NULL)
+ (stable = rt_info->stable[AFI_IP][safi]) == NULL)
continue;
for (rn = route_top (stable); rn; rn = route_next (rn))
@@ -2449,6 +2507,7 @@ static_config_ipv4 (struct vty *vty, safi_t safi, const
char *cmd)
write = 1;
}
+ }
}
return write;
}
@@ -3072,9 +3131,10 @@ DEFUN (show_ipv6_route,
if (argc > 0)
VTY_GET_INTEGER ("VRF ID", vrf_id, argv[0]);
- table = zebra_vrf_table (AFI_IP6, SAFI_UNICAST, vrf_id);
+ VRF_FOREACH_TABLE(vrf_id, table, AFI_IP6, SAFI_UNICAST)
+ {
if (! table)
- return CMD_SUCCESS;
+ continue;
/* Show all IPv6 route. */
for (rn = route_top (table); rn; rn = route_next (rn))
@@ -3087,6 +3147,7 @@ DEFUN (show_ipv6_route,
}
vty_show_ip_route (vty, rn, rib);
}
+ }
return CMD_SUCCESS;
}
@@ -3125,9 +3186,10 @@ DEFUN (show_ipv6_route_prefix_longer,
if (argc > 1)
VTY_GET_INTEGER ("VRF ID", vrf_id, argv[1]);
- table = zebra_vrf_table (AFI_IP6, SAFI_UNICAST, vrf_id);
+ VRF_FOREACH_TABLE(vrf_id, table, AFI_IP6, SAFI_UNICAST)
+ {
if (! table)
- return CMD_SUCCESS;
+ continue;
/* Show matched type IPv6 routes. */
for (rn = route_top (table); rn; rn = route_next (rn))
@@ -3141,6 +3203,7 @@ DEFUN (show_ipv6_route_prefix_longer,
}
vty_show_ip_route (vty, rn, rib);
}
+ }
return CMD_SUCCESS;
}
@@ -3179,9 +3242,10 @@ DEFUN (show_ipv6_route_protocol,
if (argc > 1)
VTY_GET_INTEGER ("VRF ID", vrf_id, argv[1]);
- table = zebra_vrf_table (AFI_IP6, SAFI_UNICAST, vrf_id);
+ VRF_FOREACH_TABLE(vrf_id, table, AFI_IP6, SAFI_UNICAST)
+ {
if (! table)
- return CMD_SUCCESS;
+ continue;
/* Show matched type IPv6 routes. */
for (rn = route_top (table); rn; rn = route_next (rn))
@@ -3195,6 +3259,7 @@ DEFUN (show_ipv6_route_protocol,
}
vty_show_ip_route (vty, rn, rib);
}
+ }
return CMD_SUCCESS;
}
@@ -3231,9 +3296,10 @@ DEFUN (show_ipv6_route_addr,
if (argc > 1)
VTY_GET_INTEGER ("VRF ID", vrf_id, argv[1]);
- table = zebra_vrf_table (AFI_IP6, SAFI_UNICAST, vrf_id);
+ VRF_FOREACH_TABLE(vrf_id, table, AFI_IP6, SAFI_UNICAST)
+ {
if (! table)
- return CMD_SUCCESS;
+ continue;
rn = route_node_match (table, (struct prefix *) &p);
if (! rn)
@@ -3246,6 +3312,7 @@ DEFUN (show_ipv6_route_addr,
route_unlock_node (rn);
+ }
return CMD_SUCCESS;
}
@@ -3282,9 +3349,10 @@ DEFUN (show_ipv6_route_prefix,
if (argc > 1)
VTY_GET_INTEGER ("VRF ID", vrf_id, argv[1]);
- table = zebra_vrf_table (AFI_IP6, SAFI_UNICAST, vrf_id);
+ VRF_FOREACH_TABLE(vrf_id, table, AFI_IP6, SAFI_UNICAST)
+ {
if (! table)
- return CMD_SUCCESS;
+ continue;
rn = route_node_match (table, (struct prefix *) &p);
if (! rn || rn->p.prefixlen != p.prefixlen)
@@ -3298,6 +3366,7 @@ DEFUN (show_ipv6_route_prefix,
vty_show_ip_route_detail (vty, rn, 0);
route_unlock_node (rn);
+ }
return CMD_SUCCESS;
}
@@ -3326,12 +3395,13 @@ DEFUN (show_ipv6_route_summary,
if (argc > 0)
VTY_GET_INTEGER ("VRF ID", vrf_id, argv[0]);
- table = zebra_vrf_table (AFI_IP6, SAFI_UNICAST, vrf_id);
+ VRF_FOREACH_TABLE(vrf_id, table, AFI_IP6, SAFI_UNICAST)
+ {
if (! table)
- return CMD_SUCCESS;
+ continue;
vty_show_ip_route_summary (vty, table);
-
+ }
return CMD_SUCCESS;
}
@@ -3360,11 +3430,13 @@ DEFUN (show_ipv6_route_summary_prefix,
if (argc > 0)
VTY_GET_INTEGER ("VRF ID", vrf_id, argv[0]);
- table = zebra_vrf_table (AFI_IP6, SAFI_UNICAST, vrf_id);
+ VRF_FOREACH_TABLE(vrf_id, table, AFI_IP6, SAFI_UNICAST)
+ {
if (! table)
- return CMD_SUCCESS;
+ continue;
vty_show_ip_route_summary_prefix (vty, table);
+ }
return CMD_SUCCESS;
}
@@ -3400,14 +3472,14 @@ DEFUN (show_ipv6_mroute,
if (argc > 0)
VTY_GET_INTEGER ("VRF ID", vrf_id, argv[0]);
- table = zebra_vrf_table (AFI_IP6, SAFI_MULTICAST, vrf_id);
+ VRF_FOREACH_TABLE(vrf_id, table, AFI_IP6, SAFI_MULTICAST)
+ {
if (! table)
- return CMD_SUCCESS;
+ continue;
/* Show all IPv6 route. */
for (rn = route_top (table); rn; rn = route_next (rn))
- RNODE_FOREACH_RIB (rn, rib)
- {
+ RNODE_FOREACH_RIB (rn, rib) {
if (first)
{
vty_out (vty, SHOW_ROUTE_V6_HEADER);
@@ -3415,6 +3487,7 @@ DEFUN (show_ipv6_mroute,
}
vty_show_ip_route (vty, rn, rib);
}
+ }
return CMD_SUCCESS;
}
@@ -3443,8 +3516,11 @@ DEFUN (show_ipv6_route_vrf_all,
for (iter = vrf_first (); iter != VRF_ITER_INVALID; iter = vrf_next (iter))
{
+ zvrf = vrf_iter2info (iter);
+ ZVRF_FOREACH_RTINFO(zvrf)
+ {
if ((zvrf = vrf_iter2info (iter)) == NULL ||
- (table = zvrf->table[AFI_IP6][SAFI_UNICAST]) == NULL)
+ (table = rt_info->table[AFI_IP6][SAFI_UNICAST]) == NULL)
continue;
/* Show all IPv6 route. */
@@ -3458,6 +3534,7 @@ DEFUN (show_ipv6_route_vrf_all,
}
vty_show_ip_route (vty, rn, rib);
}
+ }
}
return CMD_SUCCESS;
@@ -3491,8 +3568,11 @@ DEFUN (show_ipv6_route_prefix_longer_vrf_all,
for (iter = vrf_first (); iter != VRF_ITER_INVALID; iter = vrf_next (iter))
{
+ zvrf = vrf_iter2info (iter);
+ ZVRF_FOREACH_RTINFO(zvrf)
+ {
if ((zvrf = vrf_iter2info (iter)) == NULL ||
- (table = zvrf->table[AFI_IP6][SAFI_UNICAST]) == NULL)
+ (table = rt_info->table[AFI_IP6][SAFI_UNICAST]) == NULL)
continue;
/* Show matched type IPv6 routes. */
@@ -3507,6 +3587,7 @@ DEFUN (show_ipv6_route_prefix_longer_vrf_all,
}
vty_show_ip_route (vty, rn, rib);
}
+ }
}
return CMD_SUCCESS;
@@ -3538,8 +3619,11 @@ DEFUN (show_ipv6_route_protocol_vrf_all,
for (iter = vrf_first (); iter != VRF_ITER_INVALID; iter = vrf_next (iter))
{
+ zvrf = vrf_iter2info (iter);
+ ZVRF_FOREACH_RTINFO(zvrf)
+ {
if ((zvrf = vrf_iter2info (iter)) == NULL ||
- (table = zvrf->table[AFI_IP6][SAFI_UNICAST]) == NULL)
+ (table = rt_info->table[AFI_IP6][SAFI_UNICAST]) == NULL)
continue;
/* Show matched type IPv6 routes. */
@@ -3554,6 +3638,7 @@ DEFUN (show_ipv6_route_protocol_vrf_all,
}
vty_show_ip_route (vty, rn, rib);
}
+ }
}
return CMD_SUCCESS;
@@ -3584,8 +3669,11 @@ DEFUN (show_ipv6_route_addr_vrf_all,
for (iter = vrf_first (); iter != VRF_ITER_INVALID; iter = vrf_next (iter))
{
+ zvrf = vrf_iter2info (iter);
+ ZVRF_FOREACH_RTINFO(zvrf)
+ {
if ((zvrf = vrf_iter2info (iter)) == NULL ||
- (table = zvrf->table[AFI_IP6][SAFI_UNICAST]) == NULL)
+ (table = rt_info->table[AFI_IP6][SAFI_UNICAST]) == NULL)
continue;
rn = route_node_match (table, (struct prefix *) &p);
@@ -3596,6 +3684,7 @@ DEFUN (show_ipv6_route_addr_vrf_all,
route_unlock_node (rn);
}
+ }
return CMD_SUCCESS;
}
@@ -3625,8 +3714,11 @@ DEFUN (show_ipv6_route_prefix_vrf_all,
for (iter = vrf_first (); iter != VRF_ITER_INVALID; iter = vrf_next (iter))
{
+ zvrf = vrf_iter2info (iter);
+ ZVRF_FOREACH_RTINFO(zvrf)
+ {
if ((zvrf = vrf_iter2info (iter)) == NULL ||
- (table = zvrf->table[AFI_IP6][SAFI_UNICAST]) == NULL)
+ (table = rt_info->table[AFI_IP6][SAFI_UNICAST]) == NULL)
continue;
rn = route_node_match (table, (struct prefix *) &p);
@@ -3642,6 +3734,7 @@ DEFUN (show_ipv6_route_prefix_vrf_all,
route_unlock_node (rn);
}
+ }
return CMD_SUCCESS;
}
@@ -3660,8 +3753,14 @@ DEFUN (show_ipv6_route_summary_vrf_all,
vrf_iter_t iter;
for (iter = vrf_first (); iter != VRF_ITER_INVALID; iter = vrf_next (iter))
+ {
+ zvrf = vrf_iter2info (iter);
+ ZVRF_FOREACH_RTINFO(zvrf)
+ {
if ((zvrf = vrf_iter2info (iter)) != NULL)
- vty_show_ip_route_summary (vty, zvrf->table[AFI_IP6][SAFI_UNICAST]);
+ vty_show_ip_route_summary (vty, rt_info->table[AFI_IP6][SAFI_UNICAST]);
+ }
+ }
return CMD_SUCCESS;
}
@@ -3683,8 +3782,11 @@ DEFUN (show_ipv6_mroute_vrf_all,
for (iter = vrf_first (); iter != VRF_ITER_INVALID; iter = vrf_next (iter))
{
+ zvrf = vrf_iter2info (iter);
+ ZVRF_FOREACH_RTINFO(zvrf)
+ {
if ((zvrf = vrf_iter2info (iter)) == NULL ||
- (table = zvrf->table[AFI_IP6][SAFI_UNICAST]) == NULL)
+ (table = rt_info->table[AFI_IP6][SAFI_UNICAST]) == NULL)
continue;
/* Show all IPv6 route. */
@@ -3698,6 +3800,7 @@ DEFUN (show_ipv6_mroute_vrf_all,
}
vty_show_ip_route (vty, rn, rib);
}
+ }
}
return CMD_SUCCESS;
}
@@ -3717,7 +3820,12 @@ DEFUN (show_ipv6_route_summary_prefix_vrf_all,
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]);
+ {
+ ZVRF_FOREACH_RTINFO(zvrf)
+ {
+ vty_show_ip_route_summary_prefix (vty,
rt_info->table[AFI_IP6][SAFI_UNICAST]);
+ }
+ }
return CMD_SUCCESS;
}
@@ -3738,8 +3846,11 @@ static_config_ipv6 (struct vty *vty)
for (iter = vrf_first (); iter != VRF_ITER_INVALID; iter = vrf_next (iter))
{
+ zvrf = vrf_iter2info (iter);
+ ZVRF_FOREACH_RTINFO(zvrf)
+ {
if ((zvrf = vrf_iter2info (iter)) == NULL ||
- (stable = zvrf->stable[AFI_IP6][SAFI_UNICAST]) == NULL)
+ (stable = rt_info->stable[AFI_IP6][SAFI_UNICAST]) == NULL)
continue;
for (rn = route_top (stable); rn; rn = route_next (rn))
@@ -3779,6 +3890,7 @@ static_config_ipv6 (struct vty *vty)
write = 1;
}
+ }
}
return write;
}
--
2.7.0
_______________________________________________
Quagga-dev mailing list
[email protected]
https://lists.quagga.net/mailman/listinfo/quagga-dev