summaryrefslogtreecommitdiffstats
path: root/zebra
diff options
context:
space:
mode:
authorRenato Westphal <renato@opensourcerouting.org>2016-10-29 18:37:11 +0200
committerRenato Westphal <renato@opensourcerouting.org>2016-11-28 19:18:35 +0100
commit1a1a70655c869a1b66e363894e5aba19f4aa08f3 (patch)
tree8eea443fc57ac5766128d41e27c9411a3c1c7afc /zebra
parentlib: convert namespace code to use red-black trees (diff)
downloadfrr-1a1a70655c869a1b66e363894e5aba19f4aa08f3.tar.xz
frr-1a1a70655c869a1b66e363894e5aba19f4aa08f3.zip
lib: convert vrf code to use red-black trees as well
Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
Diffstat (limited to 'zebra')
-rw-r--r--zebra/interface.c31
-rw-r--r--zebra/irdp_main.c7
-rw-r--r--zebra/router-id.c6
-rw-r--r--zebra/rt_netlink.c6
-rw-r--r--zebra/rtadv.c6
-rw-r--r--zebra/zebra_ptm.c12
-rw-r--r--zebra/zebra_rib.c65
-rw-r--r--zebra/zebra_routemap.c8
-rw-r--r--zebra/zebra_vrf.c5
-rw-r--r--zebra/zebra_vty.c120
-rw-r--r--zebra/zserv.c14
11 files changed, 137 insertions, 143 deletions
diff --git a/zebra/interface.c b/zebra/interface.c
index dd1f8a146..75040a87f 100644
--- a/zebra/interface.c
+++ b/zebra/interface.c
@@ -1325,15 +1325,15 @@ DEFUN (show_interface_vrf_all, show_interface_vrf_all_cmd,
"Interface status and configuration\n"
VRF_ALL_CMD_HELP_STR)
{
+ struct vrf *vrf;
struct listnode *node;
struct interface *ifp;
- vrf_iter_t iter;
interface_update_stats ();
/* All interface print. */
- for (iter = vrf_first (); iter != VRF_ITER_INVALID; iter = vrf_next (iter))
- for (ALL_LIST_ELEMENTS_RO (vrf_iter2iflist (iter), node, ifp))
+ RB_FOREACH (vrf, vrf_id_head, &vrfs_by_id)
+ for (ALL_LIST_ELEMENTS_RO (vrf->iflist, node, ifp))
if_dump_vty (vty, ifp);
return CMD_SUCCESS;
@@ -1378,17 +1378,17 @@ DEFUN (show_interface_name_vrf_all, show_interface_name_vrf_all_cmd,
"Interface name\n"
VRF_ALL_CMD_HELP_STR)
{
+ struct vrf *vrf;
struct interface *ifp;
- vrf_iter_t iter;
int found = 0;
interface_update_stats ();
/* All interface print. */
- for (iter = vrf_first (); iter != VRF_ITER_INVALID; iter = vrf_next (iter))
+ RB_FOREACH (vrf, vrf_id_head, &vrfs_by_id)
{
/* Specified interface print. */
- ifp = if_lookup_by_name_vrf (argv[0], vrf_iter2id (iter));
+ ifp = if_lookup_by_name_vrf (argv[0], vrf->vrf_id);
if (ifp)
{
if_dump_vty (vty, ifp);
@@ -1484,15 +1484,14 @@ DEFUN (show_interface_desc_vrf_all,
"Interface description\n"
VRF_ALL_CMD_HELP_STR)
{
- vrf_iter_t iter;
+ struct vrf *vrf;
- for (iter = vrf_first (); iter != VRF_ITER_INVALID; iter = vrf_next (iter))
- if (!list_isempty (vrf_iter2iflist (iter)))
+ RB_FOREACH (vrf, vrf_id_head, &vrfs_by_id)
+ if (!list_isempty (vrf->iflist))
{
- vty_out (vty, "%s\tVRF %u%s%s", VTY_NEWLINE,
- vrf_iter2id (iter),
- VTY_NEWLINE, VTY_NEWLINE);
- if_show_description (vty, vrf_iter2id (iter));
+ vty_out (vty, "%s\tVRF %u%s%s", VTY_NEWLINE, vrf->vrf_id,
+ VTY_NEWLINE, VTY_NEWLINE);
+ if_show_description (vty, vrf->vrf_id);
}
return CMD_SUCCESS;
@@ -2818,14 +2817,14 @@ link_params_config_write (struct vty *vty, struct interface *ifp)
static int
if_config_write (struct vty *vty)
{
+ struct vrf *vrf;
struct listnode *node;
struct interface *ifp;
- vrf_iter_t iter;
zebra_ptm_write (vty);
- for (iter = vrf_first (); iter != VRF_ITER_INVALID; iter = vrf_next (iter))
- for (ALL_LIST_ELEMENTS_RO (vrf_iter2iflist (iter), node, ifp))
+ RB_FOREACH (vrf, vrf_id_head, &vrfs_by_id)
+ for (ALL_LIST_ELEMENTS_RO (vrf->iflist, node, ifp))
{
struct zebra_if *if_data;
struct listnode *addrnode;
diff --git a/zebra/irdp_main.c b/zebra/irdp_main.c
index cc3a4abaf..7fa4ad4cb 100644
--- a/zebra/irdp_main.c
+++ b/zebra/irdp_main.c
@@ -304,17 +304,16 @@ void process_solicit (struct interface *ifp)
void irdp_finish()
{
-
+ struct vrf *vrf;
struct listnode *node, *nnode;
struct interface *ifp;
struct zebra_if *zi;
struct irdp_interface *irdp;
- vrf_iter_t iter;
zlog_info("IRDP: Received shutdown notification.");
- for (iter = vrf_first (); iter != VRF_ITER_INVALID; iter = vrf_next (iter))
- for (ALL_LIST_ELEMENTS (vrf_iter2iflist (iter), node, nnode, ifp))
+ RB_FOREACH (vrf, vrf_id_head, &vrfs_by_id)
+ for (ALL_LIST_ELEMENTS (vrf->iflist, node, nnode, ifp))
{
zi = ifp->info;
diff --git a/zebra/router-id.c b/zebra/router-id.c
index d5d9652c5..155a8e393 100644
--- a/zebra/router-id.c
+++ b/zebra/router-id.c
@@ -195,11 +195,11 @@ router_id_del_address (struct connected *ifc)
void
router_id_write (struct vty *vty)
{
+ struct vrf *vrf;
struct zebra_vrf *zvrf;
- vrf_iter_t iter;
- for (iter = vrf_first (); iter != VRF_ITER_INVALID; iter = vrf_next (iter))
- if ((zvrf = vrf_iter2info (iter)) != NULL)
+ RB_FOREACH (vrf, vrf_id_head, &vrfs_by_id)
+ if ((zvrf = vrf->info) != NULL)
if (zvrf->rid_user_assigned.u.prefix4.s_addr)
{
if (zvrf->vrf_id == VRF_DEFAULT)
diff --git a/zebra/rt_netlink.c b/zebra/rt_netlink.c
index f16fd55c9..b18bf1ef7 100644
--- a/zebra/rt_netlink.c
+++ b/zebra/rt_netlink.c
@@ -98,12 +98,12 @@ Pending: create an efficient table_id (in a tree/hash) based lookup)
static vrf_id_t
vrf_lookup_by_table (u_int32_t table_id)
{
+ struct vrf *vrf;
struct zebra_vrf *zvrf;
- vrf_iter_t iter;
- for (iter = vrf_first (); iter != VRF_ITER_INVALID; iter = vrf_next (iter))
+ RB_FOREACH (vrf, vrf_id_head, &vrfs_by_id)
{
- if ((zvrf = vrf_iter2info (iter)) == NULL ||
+ if ((zvrf = vrf->info) == NULL ||
(zvrf->table_id != table_id))
continue;
diff --git a/zebra/rtadv.c b/zebra/rtadv.c
index 3e0a19870..1ab7ac147 100644
--- a/zebra/rtadv.c
+++ b/zebra/rtadv.c
@@ -373,7 +373,7 @@ static int
rtadv_timer (struct thread *thread)
{
struct zebra_ns *zns = THREAD_ARG (thread);
- vrf_iter_t iter;
+ struct vrf *vrf;
struct listnode *node, *nnode;
struct interface *ifp;
struct zebra_if *zif;
@@ -391,8 +391,8 @@ rtadv_timer (struct thread *thread)
rtadv_event (zns, RTADV_TIMER_MSEC, 10 /* 10 ms */);
}
- for (iter = vrf_first (); iter != VRF_ITER_INVALID; iter = vrf_next (iter))
- for (ALL_LIST_ELEMENTS (vrf_iter2iflist (iter), node, nnode, ifp))
+ RB_FOREACH (vrf, vrf_id_head, &vrfs_by_id)
+ for (ALL_LIST_ELEMENTS (vrf->iflist, node, nnode, ifp))
{
if (if_is_loopback (ifp) ||
CHECK_FLAG(ifp->status, ZEBRA_INTERFACE_VRF_LOOPBACK) ||
diff --git a/zebra/zebra_ptm.c b/zebra/zebra_ptm.c
index 28e6c42ec..4fc117324 100644
--- a/zebra/zebra_ptm.c
+++ b/zebra/zebra_ptm.c
@@ -258,15 +258,15 @@ DEFUN (zebra_ptm_enable,
"ptm-enable",
"Enable neighbor check with specified topology\n")
{
+ struct vrf *vrf;
struct listnode *i;
struct interface *ifp;
struct zebra_if *if_data;
- vrf_iter_t iter;
ptm_cb.ptm_enable = ZEBRA_IF_PTM_ENABLE_ON;
- for (iter = vrf_first (); iter != VRF_ITER_INVALID; iter = vrf_next (iter))
- for (ALL_LIST_ELEMENTS_RO (vrf_iter2iflist (iter), i, ifp))
+ RB_FOREACH (vrf, vrf_id_head, &vrfs_by_id)
+ for (ALL_LIST_ELEMENTS_RO (vrf->iflist, i, ifp))
if (!ifp->ptm_enable)
{
if_data = (struct zebra_if *)ifp->info;
@@ -1112,13 +1112,13 @@ zebra_ptm_send_status_req(void)
void
zebra_ptm_reset_status(int ptm_disable)
{
+ struct vrf *vrf;
struct listnode *i;
struct interface *ifp;
int send_linkup;
- vrf_iter_t iter;
- for (iter = vrf_first (); iter != VRF_ITER_INVALID; iter = vrf_next (iter))
- for (ALL_LIST_ELEMENTS_RO (vrf_iter2iflist (iter), i, ifp))
+ RB_FOREACH (vrf, vrf_id_head, &vrfs_by_id)
+ for (ALL_LIST_ELEMENTS_RO (vrf->iflist, i, ifp))
{
send_linkup = 0;
if (ifp->ptm_enable)
diff --git a/zebra/zebra_rib.c b/zebra/zebra_rib.c
index 394469950..ec7d1e7fd 100644
--- a/zebra/zebra_rib.c
+++ b/zebra/zebra_rib.c
@@ -2052,24 +2052,24 @@ process_subq (struct list * subq, u_char qindex)
static void
meta_queue_process_complete (struct work_queue *dummy)
{
- vrf_iter_t iter;
+ struct vrf *vrf;
struct zebra_vrf *zvrf;
/* Evaluate nexthops for those VRFs which underwent route processing. This
* should limit the evaluation to the necessary VRFs in most common
* situations.
*/
- for (iter = vrf_first (); iter != VRF_ITER_INVALID; iter = vrf_next (iter))
+ RB_FOREACH (vrf, vrf_id_head, &vrfs_by_id)
{
- if (((zvrf = vrf_iter2info (iter)) != NULL) &&
- (zvrf->flags & ZEBRA_VRF_RIB_SCHEDULED))
- {
- zvrf->flags &= ~ZEBRA_VRF_RIB_SCHEDULED;
- zebra_evaluate_rnh(zvrf->vrf_id, AF_INET, 0, RNH_NEXTHOP_TYPE, NULL);
- zebra_evaluate_rnh(zvrf->vrf_id, AF_INET, 0, RNH_IMPORT_CHECK_TYPE, NULL);
- zebra_evaluate_rnh(zvrf->vrf_id, AF_INET6, 0, RNH_NEXTHOP_TYPE, NULL);
- zebra_evaluate_rnh(zvrf->vrf_id, AF_INET6, 0, RNH_IMPORT_CHECK_TYPE, NULL);
- }
+ zvrf = vrf->info;
+ if (zvrf == NULL || !(zvrf->flags & ZEBRA_VRF_RIB_SCHEDULED))
+ continue;
+
+ zvrf->flags &= ~ZEBRA_VRF_RIB_SCHEDULED;
+ zebra_evaluate_rnh(zvrf->vrf_id, AF_INET, 0, RNH_NEXTHOP_TYPE, NULL);
+ zebra_evaluate_rnh(zvrf->vrf_id, AF_INET, 0, RNH_IMPORT_CHECK_TYPE, NULL);
+ zebra_evaluate_rnh(zvrf->vrf_id, AF_INET6, 0, RNH_NEXTHOP_TYPE, NULL);
+ zebra_evaluate_rnh(zvrf->vrf_id, AF_INET6, 0, RNH_IMPORT_CHECK_TYPE, NULL);
}
/* Schedule LSPs for processing, if needed. */
@@ -3037,11 +3037,11 @@ rib_weed_table (struct route_table *table)
void
rib_weed_tables (void)
{
- vrf_iter_t iter;
+ struct vrf *vrf;
struct zebra_vrf *zvrf;
- for (iter = vrf_first (); iter != VRF_ITER_INVALID; iter = vrf_next (iter))
- if ((zvrf = vrf_iter2info (iter)) != NULL)
+ RB_FOREACH (vrf, vrf_id_head, &vrfs_by_id)
+ if ((zvrf = vrf->info) != NULL)
{
rib_weed_table (zvrf->table[AFI_IP][SAFI_UNICAST]);
rib_weed_table (zvrf->table[AFI_IP6][SAFI_UNICAST]);
@@ -3078,11 +3078,11 @@ rib_sweep_table (struct route_table *table)
void
rib_sweep_route (void)
{
- vrf_iter_t iter;
+ struct vrf *vrf;
struct zebra_vrf *zvrf;
- for (iter = vrf_first (); iter != VRF_ITER_INVALID; iter = vrf_next (iter))
- if ((zvrf = vrf_iter2info (iter)) != NULL)
+ RB_FOREACH (vrf, vrf_id_head, &vrfs_by_id)
+ if ((zvrf = vrf->info) != NULL)
{
rib_sweep_table (zvrf->table[AFI_IP][SAFI_UNICAST]);
rib_sweep_table (zvrf->table[AFI_IP6][SAFI_UNICAST]);
@@ -3118,12 +3118,12 @@ rib_score_proto_table (u_char proto, u_short instance, struct route_table *table
unsigned long
rib_score_proto (u_char proto, u_short instance)
{
- vrf_iter_t iter;
+ struct vrf *vrf;
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)
+ RB_FOREACH (vrf, vrf_id_head, &vrfs_by_id)
+ if ((zvrf = vrf->info) != NULL)
cnt += rib_score_proto_table (proto, instance, zvrf->table[AFI_IP][SAFI_UNICAST])
+rib_score_proto_table (proto, instance, zvrf->table[AFI_IP6][SAFI_UNICAST]);
@@ -3157,20 +3157,20 @@ rib_close_table (struct route_table *table)
void
rib_close (void)
{
- vrf_iter_t iter;
+ struct vrf *vrf;
struct zebra_vrf *zvrf;
struct listnode *node;
struct interface *ifp;
u_int32_t table_id;
- for (iter = vrf_first (); iter != VRF_ITER_INVALID; iter = vrf_next (iter))
+ RB_FOREACH (vrf, vrf_id_head, &vrfs_by_id)
{
- if ((zvrf = vrf_iter2info (iter)) != NULL)
+ if ((zvrf = vrf->info) != NULL)
{
rib_close_table (zvrf->table[AFI_IP][SAFI_UNICAST]);
rib_close_table (zvrf->table[AFI_IP6][SAFI_UNICAST]);
}
- for (ALL_LIST_ELEMENTS_RO (vrf_iter2iflist (iter), node, ifp))
+ for (ALL_LIST_ELEMENTS_RO (vrf->iflist, node, ifp))
if_nbr_ipv6ll_to_ipv4ll_neigh_del_all(ifp);
}
@@ -3207,17 +3207,16 @@ rib_init (void)
static inline int
vrf_id_get_next (vrf_id_t vrf_id, vrf_id_t *next_id_p)
{
- vrf_iter_t iter = vrf_iterator (vrf_id);
- struct zebra_vrf *zvrf = vrf_iter2info (iter);
+ struct vrf *vrf;
- /* The same one ? Then find out the next. */
- if (zvrf && (zvrf->vrf_id == vrf_id))
- zvrf = vrf_iter2info (vrf_next (iter));
-
- if (zvrf)
+ vrf = vrf_lookup (vrf_id);
+ if (vrf)
{
- *next_id_p = zvrf->vrf_id;
- return 1;
+ vrf = RB_NEXT (vrf_id_head, &vrfs_by_id, vrf);
+ if (vrf) {
+ *next_id_p = vrf->vrf_id;
+ return 1;
+ }
}
return 0;
diff --git a/zebra/zebra_routemap.c b/zebra/zebra_routemap.c
index 25091a3ea..3075a61c4 100644
--- a/zebra/zebra_routemap.c
+++ b/zebra/zebra_routemap.c
@@ -633,7 +633,7 @@ DEFUN (set_src,
struct interface *pif = NULL;
int family;
struct prefix p;
- vrf_iter_t iter;
+ struct vrf *vrf;
if (inet_pton(AF_INET, argv[0], &src.ipv4) != 1)
{
@@ -660,14 +660,14 @@ DEFUN (set_src,
return CMD_WARNING;
}
- for (iter = vrf_first (); iter != VRF_ITER_INVALID; iter = vrf_next (iter))
+ RB_FOREACH (vrf, vrf_id_head, &vrfs_by_id)
{
if (family == AF_INET)
pif = if_lookup_exact_address_vrf ((void *)&src.ipv4, AF_INET,
- vrf_iter2id (iter));
+ vrf->vrf_id);
else if (family == AF_INET6)
pif = if_lookup_exact_address_vrf ((void *)&src.ipv6, AF_INET6,
- vrf_iter2id (iter));
+ vrf->vrf_id);
if (pif != NULL)
break;
diff --git a/zebra/zebra_vrf.c b/zebra/zebra_vrf.c
index 915849c05..4c1bbbb1a 100644
--- a/zebra/zebra_vrf.c
+++ b/zebra/zebra_vrf.c
@@ -68,11 +68,10 @@ void
zebra_vrf_update_all (struct zserv *client)
{
struct vrf *vrf;
- vrf_iter_t iter;
- for (iter = vrf_first (); iter != VRF_ITER_INVALID; iter = vrf_next (iter))
+ RB_FOREACH (vrf, vrf_id_head, &vrfs_by_id)
{
- if ((vrf = vrf_iter2vrf (iter)) && vrf->vrf_id)
+ if (vrf->vrf_id)
zsend_vrf_add (client, vrf_info_lookup (vrf->vrf_id));
}
}
diff --git a/zebra/zebra_vty.c b/zebra/zebra_vty.c
index 74f64dd05..444d25135 100644
--- a/zebra/zebra_vty.c
+++ b/zebra/zebra_vty.c
@@ -2569,11 +2569,11 @@ DEFUN (show_ip_nht_vrf_all,
"IP nexthop tracking table\n"
VRF_ALL_CMD_HELP_STR)
{
+ struct vrf *vrf;
struct zebra_vrf *zvrf;
- vrf_iter_t iter;
- for (iter = vrf_first (); iter != VRF_ITER_INVALID; iter = vrf_next (iter))
- if ((zvrf = vrf_iter2info (iter)) != NULL)
+ RB_FOREACH (vrf, vrf_id_head, &vrfs_by_id)
+ if ((zvrf = vrf->info) != NULL)
{
vty_out (vty, "%sVRF %s:%s", VTY_NEWLINE, zvrf->name, VTY_NEWLINE);
zebra_print_rnh_table(zvrf->vrf_id, AF_INET, vty, RNH_NEXTHOP_TYPE);
@@ -2614,11 +2614,11 @@ DEFUN (show_ipv6_nht_vrf_all,
"IPv6 nexthop tracking table\n"
VRF_ALL_CMD_HELP_STR)
{
+ struct vrf *vrf;
struct zebra_vrf *zvrf;
- vrf_iter_t iter;
- for (iter = vrf_first (); iter != VRF_ITER_INVALID; iter = vrf_next (iter))
- if ((zvrf = vrf_iter2info (iter)) != NULL)
+ RB_FOREACH (vrf, vrf_id_head, &vrfs_by_id)
+ if ((zvrf = vrf->info) != NULL)
{
vty_out (vty, "%sVRF %s:%s", VTY_NEWLINE, zvrf->name, VTY_NEWLINE);
zebra_print_rnh_table(zvrf->vrf_id, AF_INET6, vty, RNH_NEXTHOP_TYPE);
@@ -3287,14 +3287,14 @@ DEFUN (show_ip_route_vrf_all,
struct route_table *table;
struct route_node *rn;
struct rib *rib;
+ struct vrf *vrf;
struct zebra_vrf *zvrf;
- vrf_iter_t iter;
int first = 1;
int vrf_header = 1;
- for (iter = vrf_first (); iter != VRF_ITER_INVALID; iter = vrf_next (iter))
+ RB_FOREACH (vrf, vrf_id_head, &vrfs_by_id)
{
- if ((zvrf = vrf_iter2info (iter)) == NULL ||
+ if ((zvrf = vrf->info) == NULL ||
(table = zvrf->table[AFI_IP][SAFI_UNICAST]) == NULL)
continue;
@@ -3334,8 +3334,8 @@ DEFUN (show_ip_route_vrf_all_tag,
struct route_table *table;
struct route_node *rn;
struct rib *rib;
+ struct vrf *vrf;
struct zebra_vrf *zvrf;
- vrf_iter_t iter;
int first = 1;
int vrf_header = 1;
route_tag_t tag = 0;
@@ -3343,9 +3343,9 @@ DEFUN (show_ip_route_vrf_all_tag,
if (argv[0])
tag = atol(argv[0]);
- for (iter = vrf_first (); iter != VRF_ITER_INVALID; iter = vrf_next (iter))
+ RB_FOREACH (vrf, vrf_id_head, &vrfs_by_id)
{
- if ((zvrf = vrf_iter2info (iter)) == NULL ||
+ if ((zvrf = vrf->info) == NULL ||
(table = zvrf->table[AFI_IP][SAFI_UNICAST]) == NULL)
continue;
@@ -3388,8 +3388,8 @@ DEFUN (show_ip_route_vrf_all_prefix_longer,
struct route_node *rn;
struct rib *rib;
struct prefix p;
+ struct vrf *vrf;
struct zebra_vrf *zvrf;
- vrf_iter_t iter;
int ret;
int first = 1;
int vrf_header = 1;
@@ -3401,9 +3401,9 @@ DEFUN (show_ip_route_vrf_all_prefix_longer,
return CMD_WARNING;
}
- for (iter = vrf_first (); iter != VRF_ITER_INVALID; iter = vrf_next (iter))
+ RB_FOREACH (vrf, vrf_id_head, &vrfs_by_id)
{
- if ((zvrf = vrf_iter2info (iter)) == NULL ||
+ if ((zvrf = vrf->info) == NULL ||
(table = zvrf->table[AFI_IP][SAFI_UNICAST]) == NULL)
continue;
@@ -3443,15 +3443,15 @@ DEFUN (show_ip_route_vrf_all_supernets,
struct route_table *table;
struct route_node *rn;
struct rib *rib;
+ struct vrf *vrf;
struct zebra_vrf *zvrf;
- vrf_iter_t iter;
u_int32_t addr;
int first = 1;
int vrf_header = 1;
- for (iter = vrf_first (); iter != VRF_ITER_INVALID; iter = vrf_next (iter))
+ RB_FOREACH (vrf, vrf_id_head, &vrfs_by_id)
{
- if ((zvrf = vrf_iter2info (iter)) == NULL ||
+ if ((zvrf = vrf->info) == NULL ||
(table = zvrf->table[AFI_IP][SAFI_UNICAST]) == NULL)
continue;
@@ -3498,8 +3498,8 @@ DEFUN (show_ip_route_vrf_all_protocol,
struct route_table *table;
struct route_node *rn;
struct rib *rib;
+ struct vrf *vrf;
struct zebra_vrf *zvrf;
- vrf_iter_t iter;
int first = 1;
int vrf_header = 1;
@@ -3510,9 +3510,9 @@ DEFUN (show_ip_route_vrf_all_protocol,
return CMD_WARNING;
}
- for (iter = vrf_first (); iter != VRF_ITER_INVALID; iter = vrf_next (iter))
+ RB_FOREACH (vrf, vrf_id_head, &vrfs_by_id)
{
- if ((zvrf = vrf_iter2info (iter)) == NULL ||
+ if ((zvrf = vrf->info) == NULL ||
(table = zvrf->table[AFI_IP][SAFI_UNICAST]) == NULL)
continue;
@@ -3553,8 +3553,8 @@ DEFUN (show_ip_route_vrf_all_addr,
struct prefix_ipv4 p;
struct route_table *table;
struct route_node *rn;
+ struct vrf *vrf;
struct zebra_vrf *zvrf;
- vrf_iter_t iter;
ret = str2prefix_ipv4 (argv[0], &p);
if (ret <= 0)
@@ -3563,9 +3563,9 @@ DEFUN (show_ip_route_vrf_all_addr,
return CMD_WARNING;
}
- for (iter = vrf_first (); iter != VRF_ITER_INVALID; iter = vrf_next (iter))
+ RB_FOREACH (vrf, vrf_id_head, &vrfs_by_id)
{
- if ((zvrf = vrf_iter2info (iter)) == NULL ||
+ if ((zvrf = vrf->info) == NULL ||
(table = zvrf->table[AFI_IP][SAFI_UNICAST]) == NULL)
continue;
@@ -3594,8 +3594,8 @@ DEFUN (show_ip_route_vrf_all_prefix,
struct prefix_ipv4 p;
struct route_table *table;
struct route_node *rn;
+ struct vrf *vrf;
struct zebra_vrf *zvrf;
- vrf_iter_t iter;
ret = str2prefix_ipv4 (argv[0], &p);
if (ret <= 0)
@@ -3604,9 +3604,9 @@ DEFUN (show_ip_route_vrf_all_prefix,
return CMD_WARNING;
}
- for (iter = vrf_first (); iter != VRF_ITER_INVALID; iter = vrf_next (iter))
+ RB_FOREACH (vrf, vrf_id_head, &vrfs_by_id)
{
- if ((zvrf = vrf_iter2info (iter)) == NULL ||
+ if ((zvrf = vrf->info) == NULL ||
(table = zvrf->table[AFI_IP][SAFI_UNICAST]) == NULL)
continue;
@@ -3636,11 +3636,11 @@ DEFUN (show_ip_route_vrf_all_summary,
VRF_ALL_CMD_HELP_STR
"Summary of all routes\n")
{
+ struct vrf *vrf;
struct zebra_vrf *zvrf;
- vrf_iter_t iter;
- for (iter = vrf_first (); iter != VRF_ITER_INVALID; iter = vrf_next (iter))
- if ((zvrf = vrf_iter2info (iter)) != NULL)
+ RB_FOREACH (vrf, vrf_id_head, &vrfs_by_id)
+ if ((zvrf = vrf->info) != NULL)
vty_show_ip_route_summary (vty, zvrf->table[AFI_IP][SAFI_UNICAST]);
return CMD_SUCCESS;
@@ -3656,11 +3656,11 @@ DEFUN (show_ip_route_vrf_all_summary_prefix,
"Summary of all routes\n"
"Prefix routes\n")
{
+ struct vrf *vrf;
struct zebra_vrf *zvrf;
- vrf_iter_t iter;
- for (iter = vrf_first (); iter != VRF_ITER_INVALID; iter = vrf_next (iter))
- if ((zvrf = vrf_iter2info (iter)) != NULL)
+ RB_FOREACH (vrf, vrf_id_head, &vrfs_by_id)
+ if ((zvrf = vrf->info) != NULL)
vty_show_ip_route_summary_prefix (vty, zvrf->table[AFI_IP][SAFI_UNICAST]);
return CMD_SUCCESS;
@@ -5416,14 +5416,14 @@ DEFUN (show_ipv6_route_vrf_all,
struct route_table *table;
struct route_node *rn;
struct rib *rib;
+ struct vrf *vrf;
struct zebra_vrf *zvrf;
- vrf_iter_t iter;
int first = 1;
int vrf_header = 1;
- for (iter = vrf_first (); iter != VRF_ITER_INVALID; iter = vrf_next (iter))
+ RB_FOREACH (vrf, vrf_id_head, &vrfs_by_id)
{
- if ((zvrf = vrf_iter2info (iter)) == NULL ||
+ if ((zvrf = vrf->info) == NULL ||
(table = zvrf->table[AFI_IP6][SAFI_UNICAST]) == NULL)
continue;
@@ -5463,8 +5463,8 @@ DEFUN (show_ipv6_route_vrf_all_tag,
struct route_table *table;
struct route_node *rn;
struct rib *rib;
+ struct vrf *vrf;
struct zebra_vrf *zvrf;
- vrf_iter_t iter;
int first = 1;
int vrf_header = 1;
route_tag_t tag = 0;
@@ -5472,9 +5472,9 @@ DEFUN (show_ipv6_route_vrf_all_tag,
if (argv[0])
tag = atol(argv[0]);
- for (iter = vrf_first (); iter != VRF_ITER_INVALID; iter = vrf_next (iter))
+ RB_FOREACH (vrf, vrf_id_head, &vrfs_by_id)
{
- if ((zvrf = vrf_iter2info (iter)) == NULL ||
+ if ((zvrf = vrf->info) == NULL ||
(table = zvrf->table[AFI_IP][SAFI_UNICAST]) == NULL)
continue;
@@ -5518,8 +5518,8 @@ DEFUN (show_ipv6_route_vrf_all_prefix_longer,
struct route_node *rn;
struct rib *rib;
struct prefix p;
+ struct vrf *vrf;
struct zebra_vrf *zvrf;
- vrf_iter_t iter;
int ret;
int first = 1;
int vrf_header = 1;
@@ -5531,9 +5531,9 @@ DEFUN (show_ipv6_route_vrf_all_prefix_longer,
return CMD_WARNING;
}
- for (iter = vrf_first (); iter != VRF_ITER_INVALID; iter = vrf_next (iter))
+ RB_FOREACH (vrf, vrf_id_head, &vrfs_by_id)
{
- if ((zvrf = vrf_iter2info (iter)) == NULL ||
+ if ((zvrf = vrf->info) == NULL ||
(table = zvrf->table[AFI_IP6][SAFI_UNICAST]) == NULL)
continue;
@@ -5574,8 +5574,8 @@ DEFUN (show_ipv6_route_vrf_all_protocol,
struct route_table *table;
struct route_node *rn;
struct rib *rib;
+ struct vrf *vrf;
struct zebra_vrf *zvrf;
- vrf_iter_t iter;
int first = 1;
int vrf_header = 1;
@@ -5586,9 +5586,9 @@ DEFUN (show_ipv6_route_vrf_all_protocol,
return CMD_WARNING;
}
- for (iter = vrf_first (); iter != VRF_ITER_INVALID; iter = vrf_next (iter))
+ RB_FOREACH (vrf, vrf_id_head, &vrfs_by_id)
{
- if ((zvrf = vrf_iter2info (iter)) == NULL ||
+ if ((zvrf = vrf->info) == NULL ||
(table = zvrf->table[AFI_IP6][SAFI_UNICAST]) == NULL)
continue;
@@ -5629,8 +5629,8 @@ DEFUN (show_ipv6_route_vrf_all_addr,
struct prefix_ipv6 p;
struct route_table *table;
struct route_node *rn;
+ struct vrf *vrf;
struct zebra_vrf *zvrf;
- vrf_iter_t iter;
ret = str2prefix_ipv6 (argv[0], &p);
if (ret <= 0)
@@ -5639,9 +5639,9 @@ DEFUN (show_ipv6_route_vrf_all_addr,
return CMD_WARNING;
}
- for (iter = vrf_first (); iter != VRF_ITER_INVALID; iter = vrf_next (iter))
+ RB_FOREACH (vrf, vrf_id_head, &vrfs_by_id)
{
- if ((zvrf = vrf_iter2info (iter)) == NULL ||
+ if ((zvrf = vrf->info) == NULL ||
(table = zvrf->table[AFI_IP6][SAFI_UNICAST]) == NULL)
continue;
@@ -5670,8 +5670,8 @@ DEFUN (show_ipv6_route_vrf_all_prefix,
struct prefix_ipv6 p;
struct route_table *table;
struct route_node *rn;
+ struct vrf *vrf;
struct zebra_vrf *zvrf;
- vrf_iter_t iter;
ret = str2prefix_ipv6 (argv[0], &p);
if (ret <= 0)
@@ -5680,9 +5680,9 @@ DEFUN (show_ipv6_route_vrf_all_prefix,
return CMD_WARNING;
}
- for (iter = vrf_first (); iter != VRF_ITER_INVALID; iter = vrf_next (iter))
+ RB_FOREACH (vrf, vrf_id_head, &vrfs_by_id)
{
- if ((zvrf = vrf_iter2info (iter)) == NULL ||
+ if ((zvrf = vrf->info) == NULL ||
(table = zvrf->table[AFI_IP6][SAFI_UNICAST]) == NULL)
continue;
@@ -5712,11 +5712,11 @@ DEFUN (show_ipv6_route_vrf_all_summary,
VRF_ALL_CMD_HELP_STR
"Summary of all IPv6 routes\n")
{
+ struct vrf *vrf;
struct zebra_vrf *zvrf;
- vrf_iter_t iter;
- for (iter = vrf_first (); iter != VRF_ITER_INVALID; iter = vrf_next (iter))
- if ((zvrf = vrf_iter2info (iter)) != NULL)
+ RB_FOREACH (vrf, vrf_id_head, &vrfs_by_id)
+ if ((zvrf = vrf->info) != NULL)
vty_show_ip_route_summary (vty, zvrf->table[AFI_IP6][SAFI_UNICAST]);
return CMD_SUCCESS;
@@ -5733,13 +5733,13 @@ DEFUN (show_ipv6_mroute_vrf_all,
struct route_table *table;
struct route_node *rn;
struct rib *rib;
+ struct vrf *vrf;
struct zebra_vrf *zvrf;
- vrf_iter_t iter;
int first = 1;
- for (iter = vrf_first (); iter != VRF_ITER_INVALID; iter = vrf_next (iter))
+ RB_FOREACH (vrf, vrf_id_head, &vrfs_by_id)
{
- if ((zvrf = vrf_iter2info (iter)) == NULL ||
+ if ((zvrf = vrf->info) == NULL ||
(table = zvrf->table[AFI_IP6][SAFI_UNICAST]) == NULL)
continue;
@@ -5768,11 +5768,11 @@ DEFUN (show_ipv6_route_vrf_all_summary_prefix,
"Summary of all IPv6 routes\n"
"Prefix routes\n")
{
+ struct vrf *vrf;
struct zebra_vrf *zvrf;
- vrf_iter_t iter;
- for (iter = vrf_first (); iter != VRF_ITER_INVALID; iter = vrf_next (iter))
- if ((zvrf = vrf_iter2info (iter)) != NULL)
+ RB_FOREACH (vrf, vrf_id_head, &vrfs_by_id)
+ if ((zvrf = vrf->info) != NULL)
vty_show_ip_route_summary_prefix (vty, zvrf->table[AFI_IP6][SAFI_UNICAST]);
return CMD_SUCCESS;
diff --git a/zebra/zserv.c b/zebra/zserv.c
index 0b69af512..76fdebb3a 100644
--- a/zebra/zserv.c
+++ b/zebra/zserv.c
@@ -1005,18 +1005,16 @@ zsend_router_id_update (struct zserv *client, struct prefix *p,
static int
zread_interface_add (struct zserv *client, u_short length, struct zebra_vrf *zvrf)
{
+ struct vrf *vrf;
struct listnode *ifnode, *ifnnode;
- vrf_iter_t iter;
struct interface *ifp;
- struct zebra_vrf *zvrf_iter;
/* Interface information is needed. */
vrf_bitmap_set (client->ifinfo, zvrf->vrf_id);
- for (iter = vrf_first (); iter != VRF_ITER_INVALID; iter = vrf_next (iter))
+ RB_FOREACH (vrf, vrf_id_head, &vrfs_by_id)
{
- zvrf_iter = vrf_iter2info (iter);
- for (ALL_LIST_ELEMENTS (vrf_iflist (zvrf_iter->vrf_id), ifnode, ifnnode, ifp))
+ for (ALL_LIST_ELEMENTS (vrf->iflist, ifnode, ifnnode, ifp))
{
/* Skip pseudo interface. */
if (! CHECK_FLAG (ifp->status, ZEBRA_INTERFACE_ACTIVE))
@@ -1724,12 +1722,12 @@ zread_mpls_labels (int command, struct zserv *client, u_short length,
static void
zebra_client_close_cleanup_rnh (struct zserv *client)
{
- vrf_iter_t iter;
+ struct vrf *vrf;
struct zebra_vrf *zvrf;
- for (iter = vrf_first (); iter != VRF_ITER_INVALID; iter = vrf_next (iter))
+ RB_FOREACH (vrf, vrf_id_head, &vrfs_by_id)
{
- if ((zvrf = vrf_iter2info (iter)) != NULL)
+ if ((zvrf = vrf->info) != NULL)
{
zebra_cleanup_rnh_client(zvrf->vrf_id, AF_INET, client, RNH_NEXTHOP_TYPE);
zebra_cleanup_rnh_client(zvrf->vrf_id, AF_INET6, client, RNH_NEXTHOP_TYPE);