]> git.puffer.fish Git - matthieu/frr.git/commitdiff
*: use rb-trees to store interfaces instead of sorted linked-lists
authorRenato Westphal <renato@opensourcerouting.org>
Tue, 3 Oct 2017 01:06:01 +0000 (22:06 -0300)
committerRenato Westphal <renato@opensourcerouting.org>
Tue, 10 Oct 2017 12:05:02 +0000 (09:05 -0300)
This is an important optimization for users running FRR on systems with
a large number of interfaces (e.g. thousands of tunnels). Red-black
trees scale much better than sorted linked-lists and also store the
elements in an ordered way (contrary to hash tables).

This is a big patch but the interesting bits are all in lib/if.[ch].

Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
49 files changed:
babeld/babel_interface.c
babeld/babel_interface.h
babeld/babeld.c
babeld/message.c
bgpd/bgp_zebra.c
bgpd/bgpd.c
eigrpd/eigrp_filter.c
eigrpd/eigrp_network.c
eigrpd/eigrp_vty.c
eigrpd/eigrpd.c
isisd/isis_circuit.c
isisd/isis_te.c
ldpd/ldp_zebra.c
lib/if.c
lib/if.h
lib/vrf.c
lib/vrf.h
nhrpd/nhrp_nhs.c
nhrpd/nhrp_vty.c
ospf6d/ospf6_bfd.c
ospf6d/ospf6_interface.c
ospf6d/ospf6_main.c
ospf6d/ospf6_snmp.c
ospfd/ospf_te.c
ospfd/ospf_vty.c
ospfd/ospfd.c
pimd/pim_bfd.c
pimd/pim_cmd.c
pimd/pim_iface.c
pimd/pim_ifchannel.c
pimd/pim_jp_agg.c
pimd/pim_nht.c
pimd/pim_rp.c
pimd/pim_upstream.c
pimd/pim_vty.c
pimd/pim_zebra.c
ripd/rip_interface.c
ripd/ripd.c
ripngd/ripng_interface.c
ripngd/ripngd.c
zebra/if_ioctl.c
zebra/interface.c
zebra/irdp_main.c
zebra/rtadv.c
zebra/zebra_l2.c
zebra/zebra_ptm.c
zebra/zebra_vrf.c
zebra/zebra_vxlan.c
zebra/zserv.c

index 4419160cd70bf567256d8fc35adf6d34dc1f6015..49c848d49e69f24398617927d030926db1efcfde 100644 (file)
@@ -809,10 +809,10 @@ interface_reset(struct interface *ifp)
 void
 babel_interface_close_all(void)
 {
+    struct vrf *vrf = vrf_lookup_by_id(VRF_DEFAULT);
     struct interface *ifp = NULL;
-    struct listnode *linklist_node = NULL;
 
-    FOR_ALL_INTERFACES(ifp, linklist_node) {
+    FOR_ALL_INTERFACES(vrf, ifp) {
         if(!if_up(ifp))
             continue;
         send_wildcard_retraction(ifp);
@@ -823,7 +823,7 @@ babel_interface_close_all(void)
         usleep(roughly(1000));
         gettime(&babel_now);
     }
-    FOR_ALL_INTERFACES(ifp, linklist_node) {
+    FOR_ALL_INTERFACES(vrf, ifp) {
         if(!if_up(ifp))
             continue;
         /* Make sure they got it. */
@@ -896,12 +896,12 @@ DEFUN (show_babel_interface,
        "Interface information\n"
        "Interface\n")
 {
+  struct vrf *vrf = vrf_lookup_by_id(VRF_DEFAULT);
   struct interface *ifp;
-  struct listnode *node;
 
   if (argc == 3)
   {
-    for (ALL_LIST_ELEMENTS_RO (vrf_iflist(VRF_DEFAULT), node, ifp))
+    RB_FOREACH (ifp, if_name_head, &vrf->ifaces_by_name)
       show_babel_interface_sub (vty, ifp);
     return CMD_SUCCESS;
   }
@@ -1316,11 +1316,11 @@ babeld-specific statement lines where appropriate. */
 static int
 interface_config_write (struct vty *vty)
 {
-    struct listnode *node;
+    struct vrf *vrf = vrf_lookup_by_id(VRF_DEFAULT);
     struct interface *ifp;
     int write = 0;
 
-    for (ALL_LIST_ELEMENTS_RO (vrf_iflist(VRF_DEFAULT), node, ifp)) {
+    RB_FOREACH (ifp, if_name_head, &vrf->ifaces_by_name) {
         vty_frame (vty, "interface %s\n",ifp->name);
         if (ifp->desc)
             vty_out (vty, " description %s\n",ifp->desc);
index 64509afa17d2efe08dcd7bdac2a0645091d8029e..ce14e5906009b89773b66cc8d393e618214553cb 100644 (file)
@@ -104,9 +104,9 @@ if_up(struct interface *ifp)
 }
 
 /* types:
- struct interface _ifp, struct listnode node */
-#define FOR_ALL_INTERFACES(_ifp, _node)                                              \
-  for(ALL_LIST_ELEMENTS_RO(vrf_iflist(VRF_DEFAULT), _node, _ifp))
+ struct vrf _vrf, struct interface _ifp */
+#define FOR_ALL_INTERFACES(_vrf, _ifp)                                         \
+  RB_FOREACH(_ifp, if_name_head, &_vrf->ifaces_by_name)
 
 /* types:
  struct interface *ifp, struct connected *_connected, struct listnode *node */
index 207c37d9b1f44bf4319d623954b0218fcb295abd..b668444656c76cd3d1bec4b1ebefb0686682d45b 100644 (file)
@@ -164,9 +164,9 @@ static int
 babel_read_protocol (struct thread *thread)
 {
     int rc;
+    struct vrf *vrf = vrf_lookup_by_id(VRF_DEFAULT);
     struct interface *ifp = NULL;
     struct sockaddr_in6 sin6;
-    struct listnode *linklist_node = NULL;
 
     assert(babel_routing_process != NULL);
     assert(protocol_socket >= 0);
@@ -179,7 +179,7 @@ babel_read_protocol (struct thread *thread)
             zlog_err("recv: %s", safe_strerror(errno));
         }
     } else {
-        FOR_ALL_INTERFACES(ifp, linklist_node) {
+        FOR_ALL_INTERFACES(vrf, ifp) {
             if(!if_up(ifp))
                 continue;
             if(ifp->ifindex == (ifindex_t)sin6.sin6_scope_id) {
@@ -214,8 +214,8 @@ babel_init_routing_process(struct thread *thread)
 static void
 babel_get_myid(void)
 {
+    struct vrf *vrf = vrf_lookup_by_id(VRF_DEFAULT);
     struct interface *ifp = NULL;
-    struct listnode *linklist_node = NULL;
     int rc;
     int i;
 
@@ -224,7 +224,7 @@ babel_get_myid(void)
         return;
     }
 
-    FOR_ALL_INTERFACES(ifp, linklist_node) {
+    FOR_ALL_INTERFACES(vrf, ifp) {
         /* ifp->ifindex is not necessarily valid at this point */
         int ifindex = if_nametoindex(ifp->name);
         if(ifindex > 0) {
@@ -268,10 +268,10 @@ babel_get_myid(void)
 static void
 babel_initial_noise(void)
 {
+    struct vrf *vrf = vrf_lookup_by_id(VRF_DEFAULT);
     struct interface *ifp = NULL;
-    struct listnode *linklist_node = NULL;
 
-    FOR_ALL_INTERFACES(ifp, linklist_node) {
+    FOR_ALL_INTERFACES(vrf, ifp) {
         if(!if_up(ifp))
             continue;
         /* Apply jitter before we send the first message. */
@@ -281,7 +281,7 @@ babel_initial_noise(void)
         send_wildcard_retraction(ifp);
     }
 
-    FOR_ALL_INTERFACES(ifp, linklist_node) {
+    FOR_ALL_INTERFACES(vrf, ifp) {
         if(!if_up(ifp))
             continue;
         usleep(roughly(10000));
@@ -319,8 +319,8 @@ static int
 babel_main_loop(struct thread *thread)
 {
     struct timeval tv;
+    struct vrf *vrf = vrf_lookup_by_id(VRF_DEFAULT);
     struct interface *ifp = NULL;
-    struct listnode *linklist_node = NULL;
 
     while(1) {
         gettime(&babel_now);
@@ -361,7 +361,7 @@ babel_main_loop(struct thread *thread)
             source_expiry_time = babel_now.tv_sec + roughly(300);
         }
 
-        FOR_ALL_INTERFACES(ifp, linklist_node) {
+        FOR_ALL_INTERFACES(vrf, ifp) {
             babel_interface_nfo *babel_ifp = NULL;
             if(!if_up(ifp))
                 continue;
@@ -385,7 +385,7 @@ babel_main_loop(struct thread *thread)
                 flush_unicast(1);
         }
 
-        FOR_ALL_INTERFACES(ifp, linklist_node) {
+        FOR_ALL_INTERFACES(vrf, ifp) {
             babel_interface_nfo *babel_ifp = NULL;
             if(!if_up(ifp))
                 continue;
@@ -449,8 +449,8 @@ babel_fill_with_next_timeout(struct timeval *tv)
 #define printIfMin(a,b,c,d) \
   if (UNLIKELY(debug & BABEL_DEBUG_TIMEOUT)) {printIfMin(a,b,c,d);}
 
+    struct vrf *vrf = vrf_lookup_by_id(VRF_DEFAULT);
     struct interface *ifp = NULL;
-    struct listnode *linklist_node = NULL;
 
     *tv = check_neighbours_timeout;
     printIfMin(tv, 0, "check_neighbours_timeout", NULL);
@@ -460,7 +460,7 @@ babel_fill_with_next_timeout(struct timeval *tv)
     printIfMin(tv, 1, "source_expiry_time", NULL);
     timeval_min(tv, &resend_time);
     printIfMin(tv, 1, "resend_time", NULL);
-    FOR_ALL_INTERFACES(ifp, linklist_node) {
+    FOR_ALL_INTERFACES(vrf, ifp) {
         babel_interface_nfo *babel_ifp = NULL;
         if(!if_up(ifp))
             continue;
@@ -578,10 +578,10 @@ babel_distribute_update_interface (struct interface *ifp)
 static void
 babel_distribute_update_all (struct prefix_list *notused)
 {
+    struct vrf *vrf = vrf_lookup_by_id(VRF_DEFAULT);
     struct interface *ifp;
-    struct listnode *node;
 
-    for (ALL_LIST_ELEMENTS_RO (vrf_iflist(VRF_DEFAULT), node, ifp))
+    RB_FOREACH (ifp, if_name_head, &vrf->ifaces_by_name)
         babel_distribute_update_interface (ifp);
 }
 
index e31d5de5df64326c26dce6c2b293e52d96ab31f7..ea378240be4f813d4215cf3e2de22125e110ec99 100644 (file)
@@ -1154,9 +1154,9 @@ flushupdates(struct interface *ifp)
     int i;
 
     if(ifp == NULL) {
-      struct interface *ifp_aux;
-      struct listnode *linklist_node = NULL;
-        FOR_ALL_INTERFACES(ifp_aux, linklist_node)
+       struct vrf *vrf = vrf_lookup_by_id(VRF_DEFAULT);
+        struct interface *ifp_aux;
+        FOR_ALL_INTERFACES(vrf, ifp_aux)
             flushupdates(ifp_aux);
         return;
     }
@@ -1326,10 +1326,10 @@ send_update(struct interface *ifp, int urgent,
     babel_interface_nfo *babel_ifp = NULL;
 
     if(ifp == NULL) {
-      struct interface *ifp_aux;
-      struct listnode *linklist_node = NULL;
+       struct vrf *vrf = vrf_lookup_by_id(VRF_DEFAULT);
+        struct interface *ifp_aux;
         struct babel_route *route;
-        FOR_ALL_INTERFACES(ifp_aux, linklist_node)
+        FOR_ALL_INTERFACES(vrf, ifp_aux)
             send_update(ifp_aux, urgent, prefix, plen);
         if(prefix) {
             /* Since flushupdates only deals with non-wildcard interfaces, we
@@ -1387,9 +1387,9 @@ send_wildcard_retraction(struct interface *ifp)
 {
     babel_interface_nfo *babel_ifp = NULL;
     if(ifp == NULL) {
-      struct interface *ifp_aux;
-      struct listnode *linklist_node = NULL;
-        FOR_ALL_INTERFACES(ifp_aux, linklist_node)
+       struct vrf *vrf = vrf_lookup_by_id(VRF_DEFAULT);
+        struct interface *ifp_aux;
+        FOR_ALL_INTERFACES(vrf, ifp_aux)
             send_wildcard_retraction(ifp_aux);
         return;
     }
@@ -1422,9 +1422,9 @@ send_self_update(struct interface *ifp)
 {
     struct xroute_stream *xroutes;
     if(ifp == NULL) {
-      struct interface *ifp_aux;
-      struct listnode *linklist_node = NULL;
-        FOR_ALL_INTERFACES(ifp_aux, linklist_node) {
+       struct vrf *vrf = vrf_lookup_by_id(VRF_DEFAULT);
+        struct interface *ifp_aux;
+        FOR_ALL_INTERFACES(vrf, ifp_aux) {
             if(!if_up(ifp_aux))
                 continue;
             send_self_update(ifp_aux);
@@ -1456,9 +1456,9 @@ send_ihu(struct neighbour *neigh, struct interface *ifp)
     int msglen;
 
     if(neigh == NULL && ifp == NULL) {
+       struct vrf *vrf = vrf_lookup_by_id(VRF_DEFAULT);
         struct interface *ifp_aux;
-      struct listnode *linklist_node = NULL;
-        FOR_ALL_INTERFACES(ifp_aux, linklist_node) {
+        FOR_ALL_INTERFACES(vrf, ifp_aux) {
             if(if_up(ifp_aux))
                 continue;
             send_ihu(NULL, ifp_aux);
@@ -1573,9 +1573,9 @@ send_request(struct interface *ifp,
     int v4, pb, len;
 
     if(ifp == NULL) {
-      struct interface *ifp_aux;
-      struct listnode *linklist_node = NULL;
-        FOR_ALL_INTERFACES(ifp_aux, linklist_node) {
+       struct vrf *vrf = vrf_lookup_by_id(VRF_DEFAULT);
+        struct interface *ifp_aux;
+        FOR_ALL_INTERFACES(vrf, ifp_aux) {
             if(if_up(ifp_aux))
                 continue;
             send_request(ifp_aux, prefix, plen);
@@ -1648,9 +1648,9 @@ send_multihop_request(struct interface *ifp,
     flushupdates(ifp);
 
     if(ifp == NULL) {
-      struct interface *ifp_aux;
-      struct listnode *linklist_node = NULL;
-        FOR_ALL_INTERFACES(ifp_aux, linklist_node) {
+       struct vrf *vrf = vrf_lookup_by_id(VRF_DEFAULT);
+        struct interface *ifp_aux;
+        FOR_ALL_INTERFACES(vrf, ifp_aux) {
             if(!if_up(ifp_aux))
                 continue;
             send_multihop_request(ifp_aux, prefix, plen, seqno, id, hop_count);
index c90257d6598583103fc7ea159421653eeca360db..9c8f56636c37f3905359c82cb211184c6be954c9 100644 (file)
@@ -591,18 +591,22 @@ static int zebra_read_route(int command, struct zclient *zclient,
 
 struct interface *if_lookup_by_ipv4(struct in_addr *addr, vrf_id_t vrf_id)
 {
-       struct listnode *ifnode;
+       struct vrf *vrf;
        struct listnode *cnode;
        struct interface *ifp;
        struct connected *connected;
        struct prefix_ipv4 p;
        struct prefix *cp;
 
+       vrf = vrf_lookup_by_id(vrf_id);
+       if (!vrf)
+               return NULL;
+
        p.family = AF_INET;
        p.prefix = *addr;
        p.prefixlen = IPV4_MAX_BITLEN;
 
-       for (ALL_LIST_ELEMENTS_RO(vrf_iflist(vrf_id), ifnode, ifp)) {
+       RB_FOREACH (ifp, if_name_head, &vrf->ifaces_by_name) {
                for (ALL_LIST_ELEMENTS_RO(ifp->connected, cnode, connected)) {
                        cp = connected->address;
 
@@ -616,13 +620,17 @@ struct interface *if_lookup_by_ipv4(struct in_addr *addr, vrf_id_t vrf_id)
 
 struct interface *if_lookup_by_ipv4_exact(struct in_addr *addr, vrf_id_t vrf_id)
 {
-       struct listnode *ifnode;
+       struct vrf *vrf;
        struct listnode *cnode;
        struct interface *ifp;
        struct connected *connected;
        struct prefix *cp;
 
-       for (ALL_LIST_ELEMENTS_RO(vrf_iflist(vrf_id), ifnode, ifp)) {
+       vrf = vrf_lookup_by_id(vrf_id);
+       if (!vrf)
+               return NULL;
+
+       RB_FOREACH (ifp, if_name_head, &vrf->ifaces_by_name) {
                for (ALL_LIST_ELEMENTS_RO(ifp->connected, cnode, connected)) {
                        cp = connected->address;
 
@@ -637,18 +645,22 @@ struct interface *if_lookup_by_ipv4_exact(struct in_addr *addr, vrf_id_t vrf_id)
 struct interface *if_lookup_by_ipv6(struct in6_addr *addr, ifindex_t ifindex,
                                    vrf_id_t vrf_id)
 {
-       struct listnode *ifnode;
+       struct vrf *vrf;
        struct listnode *cnode;
        struct interface *ifp;
        struct connected *connected;
        struct prefix_ipv6 p;
        struct prefix *cp;
 
+       vrf = vrf_lookup_by_id(vrf_id);
+       if (!vrf)
+               return NULL;
+
        p.family = AF_INET6;
        p.prefix = *addr;
        p.prefixlen = IPV6_MAX_BITLEN;
 
-       for (ALL_LIST_ELEMENTS_RO(vrf_iflist(vrf_id), ifnode, ifp)) {
+       RB_FOREACH (ifp, if_name_head, &vrf->ifaces_by_name) {
                for (ALL_LIST_ELEMENTS_RO(ifp->connected, cnode, connected)) {
                        cp = connected->address;
 
@@ -669,13 +681,17 @@ struct interface *if_lookup_by_ipv6(struct in6_addr *addr, ifindex_t ifindex,
 struct interface *if_lookup_by_ipv6_exact(struct in6_addr *addr,
                                          ifindex_t ifindex, vrf_id_t vrf_id)
 {
-       struct listnode *ifnode;
+       struct vrf *vrf;
        struct listnode *cnode;
        struct interface *ifp;
        struct connected *connected;
        struct prefix *cp;
 
-       for (ALL_LIST_ELEMENTS_RO(vrf_iflist(vrf_id), ifnode, ifp)) {
+       vrf = vrf_lookup_by_id(vrf_id);
+       if (!vrf)
+               return NULL;
+
+       RB_FOREACH (ifp, if_name_head, &vrf->ifaces_by_name) {
                for (ALL_LIST_ELEMENTS_RO(ifp->connected, cnode, connected)) {
                        cp = connected->address;
 
index 308698e1c539e77b338b3a6628f49975d886d9a2..d8a4852ff66f2abb1b86841e41e71fbcdb5e2093 100644 (file)
@@ -7342,13 +7342,13 @@ void bgp_master_init(struct thread_master *master)
  */
 static void bgp_if_finish(struct bgp *bgp)
 {
-       struct listnode *ifnode, *ifnnode;
+       struct vrf *vrf = vrf_lookup_by_id(bgp->vrf_id);
        struct interface *ifp;
 
-       if (bgp->inst_type == BGP_INSTANCE_TYPE_VIEW)
+       if (bgp->inst_type == BGP_INSTANCE_TYPE_VIEW || !vrf)
                return;
 
-       for (ALL_LIST_ELEMENTS(vrf_iflist(bgp->vrf_id), ifnode, ifnnode, ifp)) {
+       RB_FOREACH (ifp, if_name_head, &vrf->ifaces_by_name) {
                struct listnode *c_node, *c_nnode;
                struct connected *c;
 
index b74127aa42c55272dbb139c892cacf499017a19f..fd2e71466a573245af9a3b1eb289c9a086bc5b7d 100644 (file)
@@ -295,10 +295,10 @@ void eigrp_distribute_update_interface(struct interface *ifp)
  */
 void eigrp_distribute_update_all(struct prefix_list *notused)
 {
+       struct vrf *vrf = vrf_lookup_by_id(VRF_DEFAULT);
        struct interface *ifp;
-       struct listnode *node, *nnode;
 
-       for (ALL_LIST_ELEMENTS(vrf_iflist(VRF_DEFAULT), node, nnode, ifp))
+       RB_FOREACH (ifp, if_name_head, &vrf->ifaces_by_name)
                eigrp_distribute_update_interface(ifp);
 }
 
index 50e6b7b3be7eeaaf807997039c58adf9b09b4d8e..56b63597e12aaa26a04397c315794d4c81472978 100644 (file)
@@ -231,9 +231,9 @@ int eigrp_if_drop_allspfrouters(struct eigrp *top, struct prefix *p,
 
 int eigrp_network_set(struct eigrp *eigrp, struct prefix *p)
 {
+       struct vrf *vrf = vrf_lookup_by_id(VRF_DEFAULT);
        struct route_node *rn;
        struct interface *ifp;
-       struct listnode *node;
 
        rn = route_node_get(eigrp->networks, (struct prefix *)p);
        if (rn->info) {
@@ -251,7 +251,7 @@ int eigrp_network_set(struct eigrp *eigrp, struct prefix *p)
                eigrp_router_id_update(eigrp);
        /* Run network config now. */
        /* Get target interface. */
-       for (ALL_LIST_ELEMENTS_RO(vrf_iflist(VRF_DEFAULT), node, ifp)) {
+       RB_FOREACH (ifp, if_name_head, &vrf->ifaces_by_name) {
                zlog_debug("Setting up %s", ifp->name);
                eigrp_network_run_interface(eigrp, p, ifp);
        }
index 59ec5716840c212466d5bdc117d722296b01581b..5ca3a3bef28634693847cb0c680ff0de6fac1154 100644 (file)
@@ -132,11 +132,11 @@ static int config_write_interfaces(struct vty *vty, struct eigrp *eigrp)
 
 static int eigrp_write_interface(struct vty *vty)
 {
-       struct listnode *node;
+       struct vrf *vrf = vrf_lookup_by_id(VRF_DEFAULT);
        struct interface *ifp;
        struct eigrp_interface *ei;
 
-       for (ALL_LIST_ELEMENTS_RO(vrf_iflist(VRF_DEFAULT), node, ifp)) {
+       RB_FOREACH (ifp, if_name_head, &vrf->ifaces_by_name) {
                ei = ifp->info;
                if (!ei)
                        continue;
index c70e198bdb627abd14f65f2531f4a3d8f0f018f9..1f2c5927163b1e7949369fa002e23a8f47875a67 100644 (file)
@@ -94,8 +94,8 @@ extern struct in_addr router_id_zebra;
  */
 void eigrp_router_id_update(struct eigrp *eigrp)
 {
+       struct vrf *vrf = vrf_lookup_by_id(VRF_DEFAULT);
        struct interface *ifp;
-       struct listnode *node;
        u_int32_t router_id, router_id_old;
 
        router_id_old = eigrp->router_id;
@@ -116,7 +116,7 @@ void eigrp_router_id_update(struct eigrp *eigrp)
                //        inet_ntoa(eigrp->router_id));
 
                /* update eigrp_interface's */
-               for (ALL_LIST_ELEMENTS_RO(vrf_iflist(VRF_DEFAULT), node, ifp))
+               RB_FOREACH (ifp, if_name_head, &vrf->ifaces_by_name)
                        eigrp_if_update(ifp);
        }
 }
index 4179de1c01c9805be87bfe1598627331e788f8b4..761e73aa83c7d4d789c771c5971c662789079a74 100644 (file)
@@ -932,14 +932,15 @@ void isis_circuit_print_vty(struct isis_circuit *circuit, struct vty *vty,
 
 int isis_interface_config_write(struct vty *vty)
 {
+       struct vrf *vrf = vrf_lookup_by_id(VRF_DEFAULT);
        int write = 0;
-       struct listnode *node, *node2;
+       struct listnode *node;
        struct interface *ifp;
        struct isis_area *area;
        struct isis_circuit *circuit;
        int i;
 
-       for (ALL_LIST_ELEMENTS_RO(vrf_iflist(VRF_DEFAULT), node, ifp)) {
+       RB_FOREACH (ifp, if_name_head, &vrf->ifaces_by_name) {
                if (ifp->ifindex == IFINDEX_DELETED)
                        continue;
 
@@ -952,7 +953,7 @@ int isis_interface_config_write(struct vty *vty)
                        write++;
                }
                /* ISIS Circuit */
-               for (ALL_LIST_ELEMENTS_RO(isis->area_list, node2, area)) {
+               for (ALL_LIST_ELEMENTS_RO(isis->area_list, node, area)) {
                        circuit =
                                circuit_lookup_by_ifp(ifp, area->circuit_list);
                        if (circuit == NULL)
index 5a4fe82c914bae8c75f6b20bf3437b97b4c72db1..dda5781c2cbc495847707951a60b937129c6705a 100644 (file)
@@ -1245,13 +1245,13 @@ DEFUN (show_isis_mpls_te_interface,
        "Interface information\n"
        "Interface name\n")
 {
+       struct vrf *vrf = vrf_lookup_by_id(VRF_DEFAULT);
        int idx_interface = 4;
        struct interface *ifp;
-       struct listnode *node;
 
        /* Show All Interfaces. */
        if (argc == 4) {
-               for (ALL_LIST_ELEMENTS_RO(vrf_iflist(VRF_DEFAULT), node, ifp))
+               RB_FOREACH (ifp, if_name_head, &vrf->ifaces_by_name)
                        show_mpls_te_sub(vty, ifp);
        }
        /* Interface name is specified. */
index c50cc0fda2e2227306f0598bd33ef3ad37e0e43a..2dda5f57bf608770b015bce2c49dc327c97e5443 100644 (file)
@@ -212,13 +212,14 @@ kmpw_unset(struct zapi_pw *zpw)
 void
 kif_redistribute(const char *ifname)
 {
-       struct listnode         *node, *cnode;
+       struct vrf              *vrf = vrf_lookup_by_id(VRF_DEFAULT);
+       struct listnode         *cnode;
        struct interface        *ifp;
        struct connected        *ifc;
        struct kif               kif;
        struct kaddr             ka;
 
-       for (ALL_LIST_ELEMENTS_RO(vrf_iflist(VRF_DEFAULT), node, ifp)) {
+       RB_FOREACH (ifp, if_name_head, &vrf->ifaces_by_name) {
                if (ifname && strcmp(ifname, ifp->name) != 0)
                        continue;
 
index 2bca93240c837846b102dabab97df36de2f26528..c40daf7ef5975c0865cc514940ae2e9167b34d2d 100644 (file)
--- a/lib/if.c
+++ b/lib/if.c
@@ -40,6 +40,9 @@ DEFINE_MTYPE_STATIC(LIB, NBR_CONNECTED, "Neighbor Connected")
 DEFINE_MTYPE(LIB, CONNECTED_LABEL, "Connected interface label")
 DEFINE_MTYPE_STATIC(LIB, IF_LINK_PARAMS, "Informational Link Parameters")
 
+static int if_cmp_func(const struct interface *, const struct interface *);
+RB_GENERATE(if_name_head, interface, name_entry, if_cmp_func);
+
 DEFINE_QOBJ_TYPE(interface)
 
 DEFINE_HOOK(if_add, (struct interface *ifp), (ifp))
@@ -109,16 +112,17 @@ int if_cmp_name_func(char *p1, char *p2)
        return 0;
 }
 
-static int if_cmp_func(struct interface *ifp1, struct interface *ifp2)
+static int if_cmp_func(const struct interface *ifp1,
+                      const struct interface *ifp2)
 {
-       return if_cmp_name_func(ifp1->name, ifp2->name);
+       return if_cmp_name_func((char *)ifp1->name, (char *)ifp2->name);
 }
 
 /* Create new interface structure. */
 struct interface *if_create(const char *name, vrf_id_t vrf_id)
 {
+       struct vrf *vrf = vrf_get(vrf_id, NULL);
        struct interface *ifp;
-       struct list *intf_list = vrf_iflist_get(vrf_id);
 
        ifp = XCALLOC(MTYPE_IF, sizeof(struct interface));
        ifp->ifindex = IFINDEX_INTERNAL;
@@ -126,9 +130,7 @@ struct interface *if_create(const char *name, vrf_id_t vrf_id)
        assert(name);
        strlcpy(ifp->name, name, sizeof(ifp->name));
        ifp->vrf_id = vrf_id;
-       if (if_lookup_by_name(ifp->name, vrf_id) == NULL)
-               listnode_add_sort(intf_list, ifp);
-       else
+       if (RB_INSERT(if_name_head, &vrf->ifaces_by_name, ifp))
                zlog_err(
                        "if_create(%s): corruption detected -- interface with this "
                        "name exists already in VRF %u!",
@@ -150,22 +152,20 @@ struct interface *if_create(const char *name, vrf_id_t vrf_id)
 /* Create new interface structure. */
 void if_update_to_new_vrf(struct interface *ifp, vrf_id_t vrf_id)
 {
-       struct list *intf_list = vrf_iflist_get(vrf_id);
+       struct vrf *vrf;
 
        /* remove interface from old master vrf list */
-       if (vrf_iflist(ifp->vrf_id))
-               listnode_delete(vrf_iflist(ifp->vrf_id), ifp);
+       vrf = vrf_lookup_by_id(ifp->vrf_id);
+       if (vrf)
+               RB_REMOVE(if_name_head, &vrf->ifaces_by_name, ifp);
 
        ifp->vrf_id = vrf_id;
-       if (if_lookup_by_name(ifp->name, vrf_id) == NULL)
-               listnode_add_sort(intf_list, ifp);
-       else
+       vrf = vrf_get(ifp->vrf_id, NULL);
+       if (RB_INSERT(if_name_head, &vrf->ifaces_by_name, ifp))
                zlog_err(
                        "%s(%s): corruption detected -- interface with this "
-                       "name exists already in VRF %u!", __func__,
-                       ifp->name, vrf_id);
-
-       return;
+                       "name exists already in VRF %u!",
+                       __func__, ifp->name, vrf_id);
 }
 
 
@@ -185,7 +185,9 @@ void if_delete_retain(struct interface *ifp)
 /* Delete and free interface structure. */
 void if_delete(struct interface *ifp)
 {
-       listnode_delete(vrf_iflist(ifp->vrf_id), ifp);
+       struct vrf *vrf = vrf_lookup_by_id(ifp->vrf_id);
+
+       RB_REMOVE(if_name_head, &vrf->ifaces_by_name, ifp);
 
        if_delete_retain(ifp);
 
@@ -200,13 +202,13 @@ void if_delete(struct interface *ifp)
 /* Interface existance check by index. */
 struct interface *if_lookup_by_index(ifindex_t ifindex, vrf_id_t vrf_id)
 {
-       struct listnode *node;
+       struct vrf *vrf = vrf_lookup_by_id(vrf_id);
        struct interface *ifp;
 
-       for (ALL_LIST_ELEMENTS_RO(vrf_iflist(vrf_id), node, ifp)) {
+       RB_FOREACH (ifp, if_name_head, &vrf->ifaces_by_name)
                if (ifp->ifindex == ifindex)
                        return ifp;
-       }
+
        return NULL;
 }
 
@@ -231,18 +233,14 @@ ifindex_t ifname2ifindex(const char *name, vrf_id_t vrf_id)
 /* Interface existance check by interface name. */
 struct interface *if_lookup_by_name(const char *name, vrf_id_t vrf_id)
 {
-       struct listnode *node;
-       struct interface *ifp;
+       struct vrf *vrf = vrf_lookup_by_id(vrf_id);
+       struct interface if_tmp;
 
        if (!name || strnlen(name, INTERFACE_NAMSIZ) == INTERFACE_NAMSIZ)
                return NULL;
 
-       for (ALL_LIST_ELEMENTS_RO(vrf_iflist(vrf_id), node, ifp)) {
-               if (strcmp(name, ifp->name) == 0)
-                       return ifp;
-       }
-
-       return NULL;
+       strlcpy(if_tmp.name, name, sizeof(if_tmp.name));
+       return RB_FIND(if_name_head, &vrf->ifaces_by_name, &if_tmp);
 }
 
 struct interface *if_lookup_by_name_all_vrf(const char *name)
@@ -266,13 +264,13 @@ struct interface *if_lookup_by_name_all_vrf(const char *name)
 struct interface *if_lookup_exact_address(void *src, int family,
                                          vrf_id_t vrf_id)
 {
-       struct listnode *node;
+       struct vrf *vrf = vrf_lookup_by_id(vrf_id);
        struct listnode *cnode;
        struct interface *ifp;
        struct prefix *p;
        struct connected *c;
 
-       for (ALL_LIST_ELEMENTS_RO(vrf_iflist(vrf_id), node, ifp)) {
+       RB_FOREACH (ifp, if_name_head, &vrf->ifaces_by_name) {
                for (ALL_LIST_ELEMENTS_RO(ifp->connected, cnode, c)) {
                        p = c->address;
 
@@ -298,7 +296,7 @@ struct interface *if_lookup_exact_address(void *src, int family,
 struct connected *if_lookup_address(void *matchaddr, int family,
                                    vrf_id_t vrf_id)
 {
-       struct listnode *node;
+       struct vrf *vrf = vrf_lookup_by_id(vrf_id);
        struct prefix addr;
        int bestlen = 0;
        struct listnode *cnode;
@@ -318,7 +316,7 @@ struct connected *if_lookup_address(void *matchaddr, int family,
 
        match = NULL;
 
-       for (ALL_LIST_ELEMENTS_RO(vrf_iflist(vrf_id), node, ifp)) {
+       RB_FOREACH (ifp, if_name_head, &vrf->ifaces_by_name) {
                for (ALL_LIST_ELEMENTS_RO(ifp->connected, cnode, c)) {
                        if (c->address && (c->address->family == AF_INET)
                            && prefix_match(CONNECTED_PREFIX(c), &addr)
@@ -334,12 +332,12 @@ struct connected *if_lookup_address(void *matchaddr, int family,
 /* Lookup interface by prefix */
 struct interface *if_lookup_prefix(struct prefix *prefix, vrf_id_t vrf_id)
 {
-       struct listnode *node;
+       struct vrf *vrf = vrf_lookup_by_id(vrf_id);
        struct listnode *cnode;
        struct interface *ifp;
        struct connected *c;
 
-       for (ALL_LIST_ELEMENTS_RO(vrf_iflist(vrf_id), node, ifp)) {
+       RB_FOREACH (ifp, if_name_head, &vrf->ifaces_by_name) {
                for (ALL_LIST_ELEMENTS_RO(ifp->connected, cnode, c)) {
                        if (prefix_cmp(c->address, prefix) == 0) {
                                return ifp;
@@ -503,13 +501,11 @@ static void if_dump(const struct interface *ifp)
 void if_dump_all(void)
 {
        struct vrf *vrf;
-       struct listnode *node;
-       void *p;
+       void *ifp;
 
        RB_FOREACH (vrf, vrf_id_head, &vrfs_by_id)
-               if (vrf->iflist != NULL)
-                       for (ALL_LIST_ELEMENTS_RO(vrf->iflist, node, p))
-                               if_dump(p);
+               RB_FOREACH (ifp, if_name_head, &vrf->ifaces_by_name)
+                       if_dump(ifp);
 }
 
 DEFUN (interface_desc,
@@ -702,7 +698,6 @@ DEFUN (show_address,
 {
   int idx_vrf = 3;
   struct listnode *node;
-  struct listnode *node2;
   struct interface *ifp;
   struct connected *ifc;
   struct prefix *p;
@@ -711,9 +706,9 @@ DEFUN (show_address,
   if (argc > 2)
     VRF_GET_ID (vrf_id, argv[idx_vrf]->arg);
 
-  for (ALL_LIST_ELEMENTS_RO (vrf_iflist (vrf_id), node, ifp))
+  RB_FOREACH (ifp, if_name_head, &vrf->ifaces_by_name)
     {
-      for (ALL_LIST_ELEMENTS_RO (ifp->connected, node2, ifc))
+      for (ALL_LIST_ELEMENTS_RO (ifp->connected, node, ifc))
        {
          p = ifc->address;
 
@@ -733,21 +728,20 @@ DEFUN (show_address_vrf_all,
 {
   struct vrf *vrf;
   struct listnode *node;
-  struct listnode *node2;
   struct interface *ifp;
   struct connected *ifc;
   struct prefix *p;
 
   RB_FOREACH (vrf, vrf_name_head, &vrfs_by_name)
     {
-      if (!vrf->iflist || !listcount (vrf->iflist))
+      if (RB_EMPTY (if_name_head, &vrf->ifaces_by_name))
         continue;
 
       vty_out (vty, "\nVRF %u\n\n", vrf->vrf_id);
 
-      for (ALL_LIST_ELEMENTS_RO (vrf->iflist, node, ifp))
+      RB_FOREACH (ifp, if_name_head, &vrf->ifaces_by_name)
         {
-          for (ALL_LIST_ELEMENTS_RO (ifp->connected, node2, ifc))
+          for (ALL_LIST_ELEMENTS_RO (ifp->connected, node, ifc))
             {
               p = ifc->address;
 
@@ -1029,35 +1023,17 @@ ifaddr_ipv4_lookup (struct in_addr *addr, ifindex_t ifindex)
 }
 #endif /* ifaddr_ipv4_table */
 
-/* Initialize interface list. */
-void if_init(struct list **intf_list)
-{
-       *intf_list = list_new();
-#if 0
-  ifaddr_ipv4_table = route_table_init ();
-#endif /* ifaddr_ipv4_table */
-
-       (*intf_list)->cmp = (int (*)(void *, void *))if_cmp_func;
-}
-
-void if_terminate(struct list **intf_list)
+void if_terminate(struct vrf *vrf)
 {
-       for (;;) {
-               struct interface *ifp;
-
-               ifp = listnode_head(*intf_list);
-               if (ifp == NULL)
-                       break;
+       struct interface *ifp;
 
+       while ((ifp = RB_ROOT(if_name_head, &vrf->ifaces_by_name)) != NULL) {
                if (ifp->node) {
                        ifp->node->info = NULL;
                        route_unlock_node(ifp->node);
                }
-
                if_delete(ifp);
        }
-
-       list_delete_and_null(intf_list);
 }
 
 const char *if_link_type_str(enum zebra_link_type llt)
index caaf9aa1f0a09bf8d91c99ab117a713efd577ebd..a8058c9e9e1074dc8bec80812251a2bde33ed796 100644 (file)
--- a/lib/if.h
+++ b/lib/if.h
@@ -201,6 +201,8 @@ struct if_link_params {
 
 /* Interface structure */
 struct interface {
+       RB_ENTRY(interface) name_entry;
+
        /* Interface name.  This should probably never be changed after the
           interface is created, because the configuration info for this
           interface
@@ -282,6 +284,8 @@ struct interface {
 
        QOBJ_FIELDS
 };
+RB_HEAD(if_name_head, interface);
+RB_PROTOTYPE(if_name_head, interface, name_entry, if_cmp_func);
 DECLARE_QOBJ_TYPE(interface)
 
 /* called from the library code whenever interfaces are created/deleted
@@ -441,9 +445,9 @@ extern int if_is_loopback(struct interface *);
 extern int if_is_broadcast(struct interface *);
 extern int if_is_pointopoint(struct interface *);
 extern int if_is_multicast(struct interface *);
-extern void if_init(struct list **);
 extern void if_cmd_init(void);
-extern void if_terminate(struct list **);
+struct vrf;
+extern void if_terminate(struct vrf *vrf);
 extern void if_dump_all(void);
 extern const char *if_flag_dump(unsigned long);
 extern const char *if_link_type_str(enum zebra_link_type);
index 0a4969dfac851fb5647bb05da277b0033cece334..e303e0e1c8e7b43d2ba81787e3bc391033ec1586 100644 (file)
--- a/lib/vrf.c
+++ b/lib/vrf.c
@@ -109,7 +109,7 @@ struct vrf *vrf_get(vrf_id_t vrf_id, const char *name)
        if (vrf == NULL) {
                vrf = XCALLOC(MTYPE_VRF, sizeof(struct vrf));
                vrf->vrf_id = VRF_UNKNOWN;
-               if_init(&vrf->iflist);
+               RB_INIT(if_name_head, &vrf->ifaces_by_name);
                QOBJ_REG(vrf, vrf);
                new = 1;
 
@@ -153,7 +153,7 @@ void vrf_delete(struct vrf *vrf)
                (*vrf_master.vrf_delete_hook)(vrf);
 
        QOBJ_UNREG(vrf);
-       if_terminate(&vrf->iflist);
+       if_terminate(vrf);
 
        if (vrf->vrf_id != VRF_UNKNOWN)
                RB_REMOVE(vrf_id_head, &vrfs_by_id, vrf);
@@ -251,20 +251,6 @@ void *vrf_info_lookup(vrf_id_t vrf_id)
        return vrf ? vrf->info : NULL;
 }
 
-/* Look up the interface list in a VRF. */
-struct list *vrf_iflist(vrf_id_t vrf_id)
-{
-       struct vrf *vrf = vrf_lookup_by_id(vrf_id);
-       return vrf ? vrf->iflist : NULL;
-}
-
-/* Get the interface list of the specified VRF. Create one if not find. */
-struct list *vrf_iflist_get(vrf_id_t vrf_id)
-{
-       struct vrf *vrf = vrf_get(vrf_id, NULL);
-       return vrf->iflist;
-}
-
 /*
  * VRF bit-map
  */
index bdc0db9c90b78c809fec462f3ff2616ab5a211cd..5309100bd5ef812c4e509dbb168739dd05618f1e 100644 (file)
--- a/lib/vrf.h
+++ b/lib/vrf.h
@@ -77,8 +77,8 @@ struct vrf {
        u_char status;
 #define VRF_ACTIVE     (1 << 0)
 
-       /* Master list of interfaces belonging to this VRF */
-       struct list *iflist;
+       /* Interfaces belonging to this VRF */
+       struct if_name_head ifaces_by_name;
 
        /* User data */
        void *info;
@@ -126,15 +126,6 @@ extern void *vrf_info_get(vrf_id_t);
 /* Look up the data pointer of the specified VRF. */
 extern void *vrf_info_lookup(vrf_id_t);
 
-/*
- * Utilities to obtain the interface list
- */
-
-/* Look up the interface list of the specified VRF. */
-extern struct list *vrf_iflist(vrf_id_t);
-/* Get the interface list of the specified VRF. Create one if not find. */
-extern struct list *vrf_iflist_get(vrf_id_t);
-
 /*
  * VRF bit-map: maintaining flags, one bit per VRF ID
  */
index 0bada33502b073b4d0e66cc21c9428feb26cf608..3a4135a535c68706b7ab9d6dbc5e3904e85b8315 100644 (file)
@@ -352,13 +352,13 @@ int nhrp_nhs_free(struct nhrp_nhs *nhs)
 
 void nhrp_nhs_terminate(void)
 {
+       struct vrf *vrf = vrf_lookup_by_id(VRF_DEFAULT);
        struct interface *ifp;
        struct nhrp_interface *nifp;
        struct nhrp_nhs *nhs, *tmp;
-       struct listnode *node;
        afi_t afi;
 
-       for (ALL_LIST_ELEMENTS_RO(vrf_iflist (VRF_DEFAULT), node, ifp)) {
+       RB_FOREACH (ifp, if_name_head, &vrf->ifaces_by_name) {
                nifp = ifp->info;
                for (afi = 0; afi < AFI_MAX; afi++) {
                        list_for_each_entry_safe(nhs, tmp, &nifp->afi[afi].nhslist_head, nhslist_entry)
index bd5b1aa6f164704ee9f5f87ca8eadfd5dc8faf6a..48386c350941e2104df263f112615383d6618feb 100644 (file)
@@ -712,7 +712,7 @@ DEFUN(show_ip_nhrp, show_ip_nhrp_cmd,
        "Shortcut information\n"
        "opennhrpctl style cache dump\n")
 {
-       struct listnode *node;
+       struct vrf *vrf = vrf_lookup_by_id(VRF_DEFAULT);
        struct interface *ifp;
        struct info_ctx ctx = {
                .vty = vty,
@@ -720,17 +720,17 @@ DEFUN(show_ip_nhrp, show_ip_nhrp_cmd,
        };
 
        if (argc <= 3 || argv[3]->text[0] == 'c') {
-               for (ALL_LIST_ELEMENTS_RO(vrf_iflist(VRF_DEFAULT), node, ifp))
+               RB_FOREACH (ifp, if_name_head, &vrf->ifaces_by_name)
                        nhrp_cache_foreach(ifp, show_ip_nhrp_cache, &ctx);
        } else if (argv[3]->text[0] == 'n') {
-               for (ALL_LIST_ELEMENTS_RO(vrf_iflist(VRF_DEFAULT), node, ifp))
+               RB_FOREACH (ifp, if_name_head, &vrf->ifaces_by_name)
                        nhrp_nhs_foreach(ifp, ctx.afi, show_ip_nhrp_nhs, &ctx);
        } else if (argv[3]->text[0] == 's') {
                nhrp_shortcut_foreach(ctx.afi, show_ip_nhrp_shortcut, &ctx);
        } else {
                vty_out (vty, "Status: ok\n\n");
                ctx.count++;
-               for (ALL_LIST_ELEMENTS_RO(vrf_iflist(VRF_DEFAULT), node, ifp))
+               RB_FOREACH (ifp, if_name_head, &vrf->ifaces_by_name)
                        nhrp_cache_foreach(ifp, show_ip_opennhrp_cache, &ctx);
        }
 
@@ -796,7 +796,7 @@ DEFUN(clear_nhrp, clear_nhrp_cmd,
        "Dynamic cache entries\n"
        "Shortcut entries\n")
 {
-       struct listnode *node;
+       struct vrf *vrf = vrf_lookup_by_id(VRF_DEFAULT);
        struct interface *ifp;
        struct info_ctx ctx = {
                .vty = vty,
@@ -805,7 +805,7 @@ DEFUN(clear_nhrp, clear_nhrp_cmd,
        };
 
        if (argc <= 3 || argv[3]->text[0] == 'c') {
-               for (ALL_LIST_ELEMENTS_RO(vrf_iflist(VRF_DEFAULT), node, ifp))
+               RB_FOREACH (ifp, if_name_head, &vrf->ifaces_by_name)
                        nhrp_cache_foreach(ifp, clear_nhrp_cache, &ctx);
        } else {
                nhrp_shortcut_foreach(ctx.afi, clear_nhrp_shortcut, &ctx);
@@ -843,8 +843,8 @@ static void interface_config_write_nhrp_map(struct nhrp_cache *c, void *data)
 
 static int interface_config_write(struct vty *vty)
 {
+       struct vrf *vrf = vrf_lookup_by_id(VRF_DEFAULT);
        struct write_map_ctx mapctx;
-       struct listnode *node;
        struct interface *ifp;
        struct nhrp_interface *nifp;
        struct nhrp_nhs *nhs;
@@ -853,7 +853,7 @@ static int interface_config_write(struct vty *vty)
        char buf[SU_ADDRSTRLEN];
        int i;
 
-       for (ALL_LIST_ELEMENTS_RO(vrf_iflist(VRF_DEFAULT), node, ifp)) {
+       RB_FOREACH (ifp, if_name_head, &vrf->ifaces_by_name) {
                vty_frame(vty, "interface %s\n", ifp->name);
                if (ifp->desc)
                        vty_out (vty, " description %s\n", ifp->desc);
index fa0030b6d95dd9b1d17c256200b9a5093a5a8d60..9f5d9fbd88a9e3f1a3b5b074e8fea5c8c1a754d1 100644 (file)
@@ -141,7 +141,8 @@ static void ospf6_bfd_reg_dereg_all_nbr(struct ospf6_interface *oi, int command)
 static int ospf6_bfd_nbr_replay(int command, struct zclient *zclient,
                                zebra_size_t length, vrf_id_t vrf_id)
 {
-       struct listnode *inode, *nnode;
+       struct vrf *vrf = vrf_lookup_by_id(VRF_DEFAULT);
+       struct listnode *node;
        struct interface *ifp;
        struct ospf6_interface *oi;
        struct ospf6_neighbor *on;
@@ -154,13 +155,13 @@ static int ospf6_bfd_nbr_replay(int command, struct zclient *zclient,
        bfd_client_sendmsg(zclient, ZEBRA_BFD_CLIENT_REGISTER);
 
        /* Replay the neighbor, if BFD is enabled on the interface*/
-       for (ALL_LIST_ELEMENTS_RO(vrf_iflist(VRF_DEFAULT), inode, ifp)) {
+       RB_FOREACH (ifp, if_name_head, &vrf->ifaces_by_name) {
                oi = (struct ospf6_interface *)ifp->info;
 
                if (!oi || !oi->bfd_info)
                        continue;
 
-               for (ALL_LIST_ELEMENTS_RO(oi->neighbor_list, nnode, on)) {
+               for (ALL_LIST_ELEMENTS_RO(oi->neighbor_list, node, on)) {
                        if (on->state < OSPF6_NEIGHBOR_TWOWAY)
                                continue;
 
index 7286b3242d9ba377ea01fe160044e9743f1889b1..f8cefbf9ecc8199d0b0020c6ef71f8e555248427 100644 (file)
@@ -983,9 +983,9 @@ DEFUN (show_ipv6_ospf6_interface,
        INTERFACE_STR
        IFNAME_STR)
 {
+       struct vrf *vrf = vrf_lookup_by_id(VRF_DEFAULT);
        int idx_ifname = 4;
        struct interface *ifp;
-       struct listnode *i;
 
        if (argc == 5) {
                ifp = if_lookup_by_name(argv[idx_ifname]->arg, VRF_DEFAULT);
@@ -996,7 +996,7 @@ DEFUN (show_ipv6_ospf6_interface,
                }
                ospf6_interface_show(vty, ifp);
        } else {
-               for (ALL_LIST_ELEMENTS_RO(vrf_iflist(VRF_DEFAULT), i, ifp))
+               RB_FOREACH (ifp, if_name_head, &vrf->ifaces_by_name)
                        ospf6_interface_show(vty, ifp);
        }
 
@@ -1054,12 +1054,12 @@ DEFUN (show_ipv6_ospf6_interface_prefix,
        OSPF6_ROUTE_MATCH_STR
        "Display details of the prefixes\n")
 {
+       struct vrf *vrf = vrf_lookup_by_id(VRF_DEFAULT);
        int idx_prefix = 5;
-       struct listnode *i;
        struct ospf6_interface *oi;
        struct interface *ifp;
 
-       for (ALL_LIST_ELEMENTS_RO(vrf_iflist(VRF_DEFAULT), i, ifp)) {
+       RB_FOREACH (ifp, if_name_head, &vrf->ifaces_by_name) {
                oi = (struct ospf6_interface *)ifp->info;
                if (oi == NULL)
                        continue;
@@ -1755,11 +1755,11 @@ DEFUN (no_ipv6_ospf6_network,
 
 static int config_write_ospf6_interface(struct vty *vty)
 {
-       struct listnode *i;
+       struct vrf *vrf = vrf_lookup_by_id(VRF_DEFAULT);
        struct ospf6_interface *oi;
        struct interface *ifp;
 
-       for (ALL_LIST_ELEMENTS_RO(vrf_iflist(VRF_DEFAULT), i, ifp)) {
+       RB_FOREACH (ifp, if_name_head, &vrf->ifaces_by_name) {
                oi = (struct ospf6_interface *)ifp->info;
                if (oi == NULL)
                        continue;
@@ -1905,13 +1905,13 @@ DEFUN (clear_ipv6_ospf6_interface,
        IFNAME_STR
        )
 {
+       struct vrf *vrf = vrf_lookup_by_id(VRF_DEFAULT);
        int idx_ifname = 4;
        struct interface *ifp;
-       struct listnode *node;
 
        if (argc == 4) /* Clear all the ospfv3 interfaces. */
        {
-               for (ALL_LIST_ELEMENTS_RO(vrf_iflist(VRF_DEFAULT), node, ifp))
+               RB_FOREACH (ifp, if_name_head, &vrf->ifaces_by_name)
                        ospf6_interface_clear(vty, ifp);
        } else /* Interface name is specified. */
        {
index e582737f940e9f16c1ca2a2b702b72e7352cf5f0..2a6e56deb6cbcb80eb9ea5cb862dbc4eacd50895 100644 (file)
@@ -79,7 +79,7 @@ struct thread_master *master;
 
 static void __attribute__((noreturn)) ospf6_exit(int status)
 {
-       struct listnode *node;
+       struct vrf *vrf = vrf_lookup_by_id(VRF_DEFAULT);
        struct interface *ifp;
 
        frr_early_fini();
@@ -89,7 +89,7 @@ static void __attribute__((noreturn)) ospf6_exit(int status)
 
        bfd_gbl_exit();
 
-       for (ALL_LIST_ELEMENTS_RO(vrf_iflist(VRF_DEFAULT), node, ifp))
+       RB_FOREACH (ifp, if_name_head, &vrf->ifaces_by_name)
                if (ifp->info != NULL)
                        ospf6_interface_delete(ifp->info);
 
index 0b399bad10ca2b54bab96d62da156139fbf6867c..fb3b146e38fcd247b44c8bf89ae809f886186878 100644 (file)
@@ -837,6 +837,7 @@ static u_char *ospfv3WwLsdbEntry(struct variable *v, oid *name, size_t *length,
                                 int exact, size_t *var_len,
                                 WriteMethod **write_method)
 {
+       struct vrf *vrf = vrf_lookup_by_id(VRF_DEFAULT);
        struct ospf6_lsa *lsa = NULL;
        ifindex_t ifindex;
        uint32_t area_id, id, instid, adv_router;
@@ -955,8 +956,7 @@ static u_char *ospfv3WwLsdbEntry(struct variable *v, oid *name, size_t *length,
                        if (!ifslist)
                                return NULL;
                        ifslist->cmp = (int (*)(void *, void *))if_icmp_func;
-                       for (ALL_LIST_ELEMENTS_RO(vrf_iflist(VRF_DEFAULT), node,
-                                                 iif))
+                       RB_FOREACH (iif, if_name_head, &vrf->ifaces_by_name)
                                listnode_add_sort(ifslist, iif);
 
                        for (ALL_LIST_ELEMENTS_RO(ifslist, node, iif)) {
@@ -1092,7 +1092,7 @@ static u_char *ospfv3IfEntry(struct variable *v, oid *name, size_t *length,
                if (!ifslist)
                        return NULL;
                ifslist->cmp = (int (*)(void *, void *))if_icmp_func;
-               for (ALL_LIST_ELEMENTS_RO(vrf_iflist(VRF_DEFAULT), i, iif))
+               RB_FOREACH (iif, if_name_head, &vrf->ifaces_by_name)
                        listnode_add_sort(ifslist, iif);
 
                for (ALL_LIST_ELEMENTS_RO(ifslist, i, iif)) {
@@ -1253,7 +1253,7 @@ static u_char *ospfv3NbrEntry(struct variable *v, oid *name, size_t *length,
                if (!ifslist)
                        return NULL;
                ifslist->cmp = (int (*)(void *, void *))if_icmp_func;
-               for (ALL_LIST_ELEMENTS_RO(vrf_iflist(VRF_DEFAULT), i, iif))
+               RB_FOREACH (iif, if_name_head, &vrf->ifaces_by_name)
                        listnode_add_sort(ifslist, iif);
 
                for (ALL_LIST_ELEMENTS_RO(ifslist, i, iif)) {
index 5f300dabaec90bac42a30ec29227542166ec7984..95610e4c78b4bcf2e235d330d870830ffc1e47bd 100644 (file)
@@ -2533,9 +2533,10 @@ DEFUN (show_ip_ospf_mpls_te_link,
        "Interface information\n"
        "Interface name\n")
 {
+       struct vrf *vrf;
        int idx_interface = 5;
        struct interface *ifp;
-       struct listnode *node, *nnode, *n1;
+       struct listnode *node;
        char *vrf_name = NULL;
        bool all_vrf;
        int inst = 0;
@@ -2550,11 +2551,12 @@ DEFUN (show_ip_ospf_mpls_te_link,
        /* vrf input is provided could be all or specific vrf*/
        if (vrf_name) {
                if (all_vrf) {
-                       for (ALL_LIST_ELEMENTS_RO(om->ospf, n1, ospf)) {
+                       for (ALL_LIST_ELEMENTS_RO(om->ospf, node, ospf)) {
                                if (!ospf->oi_running)
                                        continue;
-                               for (ALL_LIST_ELEMENTS(vrf_iflist(ospf->vrf_id),
-                                                      node, nnode, ifp))
+                               vrf = vrf_lookup_by_id(ospf->vrf_id);
+                               RB_FOREACH (ifp, if_name_head,
+                                           &vrf->ifaces_by_name)
                                        show_mpls_te_link_sub(vty, ifp);
                        }
                        return CMD_SUCCESS;
@@ -2562,18 +2564,18 @@ DEFUN (show_ip_ospf_mpls_te_link,
                ospf = ospf_lookup_by_inst_name (inst, vrf_name);
                if (ospf == NULL || !ospf->oi_running)
                        return CMD_SUCCESS;
-               for (ALL_LIST_ELEMENTS(vrf_iflist(ospf->vrf_id), node,
-                                      nnode, ifp))
+               vrf = vrf_lookup_by_id(ospf->vrf_id);
+               RB_FOREACH (ifp, if_name_head, &vrf->ifaces_by_name)
                        show_mpls_te_link_sub(vty, ifp);
                return CMD_SUCCESS;
        }
        /* Show All Interfaces. */
        if (argc == 5) {
-               for (ALL_LIST_ELEMENTS_RO(om->ospf, n1, ospf)) {
+               for (ALL_LIST_ELEMENTS_RO(om->ospf, node, ospf)) {
                        if (!ospf->oi_running)
                                continue;
-                       for (ALL_LIST_ELEMENTS(vrf_iflist(ospf->vrf_id), node,
-                                              nnode, ifp))
+                       vrf = vrf_lookup_by_id(ospf->vrf_id);
+                       RB_FOREACH (ifp, if_name_head, &vrf->ifaces_by_name)
                                show_mpls_te_link_sub(vty, ifp);
                }
        }
index c12e7e035ade91bdcfbfdf225a904494d0f85e51..3c709df384caa7f6d4d591d027dd44b373d011a9 100644 (file)
@@ -333,13 +333,14 @@ DEFPY (no_ospf_router_id,
 
 static void ospf_passive_interface_default(struct ospf *ospf, u_char newval)
 {
+       struct vrf *vrf = vrf_lookup_by_id(ospf->vrf_id);
        struct listnode *ln;
        struct interface *ifp;
        struct ospf_interface *oi;
 
        ospf->passive_interface_default = newval;
 
-       for (ALL_LIST_ELEMENTS_RO(vrf_iflist(ospf->vrf_id), ln, ifp)) {
+       RB_FOREACH (ifp, if_name_head, &vrf->ifaces_by_name) {
                if (ifp && OSPF_IF_PARAM_CONFIGURED(IF_DEF_PARAMS(ifp),
                                                    passive_interface))
                        UNSET_IF_PARAM(IF_DEF_PARAMS(ifp), passive_interface);
@@ -2457,9 +2458,9 @@ DEFUN (ospf_auto_cost_reference_bandwidth,
        "The reference bandwidth in terms of Mbits per second\n")
 {
        VTY_DECLVAR_INSTANCE_CONTEXT(ospf, ospf);
+       struct vrf *vrf = vrf_lookup_by_id(ospf->vrf_id);
        int idx_number = 2;
        u_int32_t refbw;
-       struct listnode *node;
        struct interface *ifp;
 
        refbw = strtol(argv[idx_number]->arg, NULL, 10);
@@ -2473,7 +2474,7 @@ DEFUN (ospf_auto_cost_reference_bandwidth,
                return CMD_SUCCESS;
 
        ospf->ref_bandwidth = refbw;
-       for (ALL_LIST_ELEMENTS_RO(vrf_iflist(ospf->vrf_id), node, ifp))
+       RB_FOREACH (ifp, if_name_head, &vrf->ifaces_by_name)
                ospf_if_recalculate_output_cost(ifp);
 
        return CMD_SUCCESS;
@@ -2488,7 +2489,7 @@ DEFUN (no_ospf_auto_cost_reference_bandwidth,
        "The reference bandwidth in terms of Mbits per second\n")
 {
        VTY_DECLVAR_INSTANCE_CONTEXT(ospf, ospf);
-       struct listnode *node, *nnode;
+       struct vrf *vrf = vrf_lookup_by_id(ospf->vrf_id);
        struct interface *ifp;
 
        if (ospf->ref_bandwidth == OSPF_DEFAULT_REF_BANDWIDTH)
@@ -2499,7 +2500,7 @@ DEFUN (no_ospf_auto_cost_reference_bandwidth,
        vty_out(vty,
                "        Please ensure reference bandwidth is consistent across all routers\n");
 
-       for (ALL_LIST_ELEMENTS(vrf_iflist(ospf->vrf_id), node, nnode, ifp))
+       RB_FOREACH (ifp, if_name_head, &vrf->ifaces_by_name)
                ospf_if_recalculate_output_cost(ifp);
 
        return CMD_SUCCESS;
@@ -3555,7 +3556,7 @@ static int show_ip_ospf_interface_common(struct vty *vty, struct ospf *ospf,
                                         int iface_argv, u_char use_json)
 {
        struct interface *ifp;
-       struct listnode *node;
+       struct vrf *vrf = vrf_lookup_by_id(ospf->vrf_id);
        json_object *json = NULL;
        json_object *json_interface_sub = NULL;
 
@@ -3573,8 +3574,7 @@ static int show_ip_ospf_interface_common(struct vty *vty, struct ospf *ospf,
 
        if (argc == iface_argv) {
                /* Show All Interfaces.*/
-               for (ALL_LIST_ELEMENTS_RO(vrf_iflist(ospf->vrf_id),
-                                         node, ifp)) {
+               RB_FOREACH (ifp, if_name_head, &vrf->ifaces_by_name) {
                        if (ospf_oi_count(ifp)) {
                                if (use_json)
                                        json_interface_sub =
@@ -8633,14 +8633,15 @@ const char *ospf_int_type_str[] = {"unknown", /* should never be used. */
 
 static int config_write_interface_one(struct vty *vty, struct ospf *ospf)
 {
-       struct listnode *n1, *n2;
+       struct vrf *vrf = vrf_lookup_by_id(ospf->vrf_id);
+       struct listnode *node;
        struct interface *ifp;
        struct crypt_key *ck;
        struct route_node *rn = NULL;
        struct ospf_if_params *params;
        int write = 0;
 
-       for (ALL_LIST_ELEMENTS_RO(vrf_iflist(ospf->vrf_id), n1, ifp)) {
+       RB_FOREACH (ifp, if_name_head, &vrf->ifaces_by_name) {
                struct vrf *vrf = NULL;
 
                if (memcmp(ifp->name, "VLINK", 5) == 0)
@@ -8729,7 +8730,7 @@ static int config_write_interface_one(struct vty *vty, struct ospf *ospf)
                        /* Cryptographic Authentication Key print. */
                        if (params && params->auth_crypt) {
                                for (ALL_LIST_ELEMENTS_RO(params->auth_crypt,
-                                                         n2, ck)) {
+                                                         node, ck)) {
                                        vty_out(vty,
                                                " ip ospf message-digest-key %d md5 %s",
                                                ck->key_id, ck->auth_key);
@@ -9234,6 +9235,7 @@ static int config_write_ospf_distance(struct vty *vty, struct ospf *ospf)
 
 static int ospf_config_write_one(struct vty *vty, struct ospf *ospf)
 {
+       struct vrf *vrf = vrf_lookup_by_id(ospf->vrf_id);
        struct interface *ifp;
        struct ospf_interface *oi;
        struct listnode *node = NULL;
@@ -9328,7 +9330,7 @@ static int ospf_config_write_one(struct vty *vty, struct ospf *ospf)
        if (ospf->passive_interface_default == OSPF_IF_PASSIVE)
                vty_out(vty, " passive-interface default\n");
 
-       for (ALL_LIST_ELEMENTS_RO(vrf_iflist(ospf->vrf_id), node, ifp))
+       RB_FOREACH (ifp, if_name_head, &vrf->ifaces_by_name)
                if (OSPF_IF_PARAM_CONFIGURED(IF_DEF_PARAMS(ifp),
                                             passive_interface)
                    && IF_DEF_PARAMS(ifp)->passive_interface
@@ -9591,14 +9593,14 @@ DEFUN (clear_ip_ospf_interface,
 {
        int idx_ifname = 4;
        struct interface *ifp;
-       struct listnode *node, *n1;
+       struct listnode *node;
        struct ospf *ospf = NULL;
 
        if (argc == 4) /* Clear all the ospfv2 interfaces. */
        {
-               for (ALL_LIST_ELEMENTS_RO(om->ospf, n1, ospf)) {
-                       for (ALL_LIST_ELEMENTS_RO(vrf_iflist(ospf->vrf_id),
-                                                 node, ifp))
+               for (ALL_LIST_ELEMENTS_RO(om->ospf, node, ospf)) {
+                       struct vrf *vrf = vrf_lookup_by_id(ospf->vrf_id);
+                       RB_FOREACH (ifp, if_name_head, &vrf->ifaces_by_name)
                                ospf_interface_clear(ifp);
                }
        } else {
index 24d3abf2a76160282d35e354bcb2bfa4944b03c8..e6d58d7a391f99b17a3fa156ad139e4ff1b48ac0 100644 (file)
@@ -86,6 +86,7 @@ static void ospf_finish_final(struct ospf *);
 
 void ospf_router_id_update(struct ospf *ospf)
 {
+       struct vrf *vrf = vrf_lookup_by_id(ospf->vrf_id);
        struct in_addr router_id, router_id_old;
        struct ospf_interface *oi;
        struct interface *ifp;
@@ -209,7 +210,7 @@ void ospf_router_id_update(struct ospf *ospf)
                ospf_router_lsa_update(ospf);
 
                /* update ospf_interface's */
-               for (ALL_LIST_ELEMENTS_RO(vrf_iflist(ospf->vrf_id), node, ifp))
+               RB_FOREACH (ifp, if_name_head, &vrf->ifaces_by_name)
                        ospf_if_update(ospf, ifp);
        }
 }
@@ -581,6 +582,7 @@ void ospf_finish(struct ospf *ospf)
 /* Final cleanup of ospf instance */
 static void ospf_finish_final(struct ospf *ospf)
 {
+       struct vrf *vrf = vrf_lookup_by_id(ospf->vrf_id);
        struct route_node *rn;
        struct ospf_nbr_nbma *nbr_nbma;
        struct ospf_lsa *lsa;
@@ -591,7 +593,6 @@ static void ospf_finish_final(struct ospf *ospf)
        struct listnode *node, *nnode;
        int i;
        u_short instance = 0;
-       struct vrf *vrf = NULL;
 
        QOBJ_UNREG(ospf);
 
@@ -623,7 +624,7 @@ static void ospf_finish_final(struct ospf *ospf)
        list_delete_and_null(&ospf->vlinks);
 
        /* Remove any ospf interface config params */
-       for (ALL_LIST_ELEMENTS_RO(vrf_iflist(ospf->vrf_id), node, ifp)) {
+       RB_FOREACH (ifp, if_name_head, &vrf->ifaces_by_name) {
                struct ospf_if_params *params;
 
                params = IF_DEF_PARAMS(ifp);
@@ -1252,15 +1253,15 @@ static void ospf_network_run_interface(struct ospf *ospf, struct interface *ifp,
 
 static void ospf_network_run(struct prefix *p, struct ospf_area *area)
 {
+       struct vrf *vrf = vrf_lookup_by_id(area->ospf->vrf_id);
        struct interface *ifp;
-       struct listnode *node;
 
        /* Schedule Router ID Update. */
        if (area->ospf->router_id.s_addr == 0)
                ospf_router_id_update(area->ospf);
 
        /* Get target interface. */
-       for (ALL_LIST_ELEMENTS_RO(vrf_iflist(area->ospf->vrf_id), node, ifp))
+       RB_FOREACH (ifp, if_name_head, &vrf->ifaces_by_name)
                ospf_network_run_interface(area->ospf, ifp, p, area);
 }
 
index 314162c78b031f174a4461f872459fc61c7b0e27..c8d1113871cc393a917a63fd970a942582753b1a 100644 (file)
@@ -292,7 +292,6 @@ static int pim_bfd_nbr_replay(int command, struct zclient *zclient,
        struct interface *ifp = NULL;
        struct pim_interface *pim_ifp = NULL;
        struct pim_neighbor *neigh = NULL;
-       struct listnode *node;
        struct listnode *neigh_node;
        struct listnode *neigh_nextnode;
        struct vrf *vrf = NULL;
@@ -301,7 +300,7 @@ static int pim_bfd_nbr_replay(int command, struct zclient *zclient,
        bfd_client_sendmsg(zclient, ZEBRA_BFD_CLIENT_REGISTER);
 
        RB_FOREACH (vrf, vrf_name_head, &vrfs_by_name) {
-               for (ALL_LIST_ELEMENTS_RO(vrf_iflist(vrf->vrf_id), node, ifp)) {
+               RB_FOREACH (ifp, if_name_head, &vrf->ifaces_by_name) {
                        pim_ifp = ifp->info;
 
                        if (!pim_ifp)
index 7ce345d8e34131b439816cc7a65fa58588749ee8..cd55e0fa12f894f73d45036367501d6f3911d3e2 100644 (file)
@@ -214,7 +214,6 @@ static void pim_show_assert(struct pim_instance *pim, struct vty *vty)
 {
        struct pim_interface *pim_ifp;
        struct pim_ifchannel *ch;
-       struct listnode *if_node;
        struct interface *ifp;
        time_t now;
 
@@ -223,7 +222,7 @@ static void pim_show_assert(struct pim_instance *pim, struct vty *vty)
        vty_out(vty,
                "Interface Address         Source          Group           State  Winner          Uptime   Timer\n");
 
-       for (ALL_LIST_ELEMENTS_RO(vrf_iflist(pim->vrf_id), if_node, ifp)) {
+       RB_FOREACH (ifp, if_name_head, &pim->vrf->ifaces_by_name) {
                pim_ifp = ifp->info;
                if (!pim_ifp)
                        continue;
@@ -263,7 +262,6 @@ static void pim_show_assert_internal_helper(struct vty *vty,
 static void pim_show_assert_internal(struct pim_instance *pim, struct vty *vty)
 {
        struct pim_interface *pim_ifp;
-       struct listnode *if_node;
        struct pim_ifchannel *ch;
        struct interface *ifp;
 
@@ -275,7 +273,7 @@ static void pim_show_assert_internal(struct pim_instance *pim, struct vty *vty)
 
        vty_out(vty,
                "Interface Address         Source          Group           CA  eCA ATD eATD\n");
-       for (ALL_LIST_ELEMENTS_RO(vrf_iflist(pim->vrf_id), if_node, ifp)) {
+       RB_FOREACH (ifp, if_name_head, &pim->vrf->ifaces_by_name) {
                pim_ifp = ifp->info;
                if (!pim_ifp)
                        continue;
@@ -317,14 +315,13 @@ static void pim_show_assert_metric_helper(struct vty *vty,
 static void pim_show_assert_metric(struct pim_instance *pim, struct vty *vty)
 {
        struct pim_interface *pim_ifp;
-       struct listnode *if_node;
        struct pim_ifchannel *ch;
        struct interface *ifp;
 
        vty_out(vty,
                "Interface Address         Source          Group           RPT Pref Metric Address        \n");
 
-       for (ALL_LIST_ELEMENTS_RO(vrf_iflist(pim->vrf_id), if_node, ifp)) {
+       RB_FOREACH (ifp, if_name_head, &pim->vrf->ifaces_by_name) {
                pim_ifp = ifp->info;
                if (!pim_ifp)
                        continue;
@@ -379,7 +376,6 @@ static void pim_show_assert_winner_metric_helper(struct vty *vty,
 static void pim_show_assert_winner_metric(struct pim_instance *pim,
                                          struct vty *vty)
 {
-       struct listnode *if_node;
        struct pim_interface *pim_ifp;
        struct pim_ifchannel *ch;
        struct interface *ifp;
@@ -387,7 +383,7 @@ static void pim_show_assert_winner_metric(struct pim_instance *pim,
        vty_out(vty,
                "Interface Address         Source          Group           RPT Pref Metric Address        \n");
 
-       for (ALL_LIST_ELEMENTS_RO(vrf_iflist(pim->vrf_id), if_node, ifp)) {
+       RB_FOREACH (ifp, if_name_head, &pim->vrf->ifaces_by_name) {
                pim_ifp = ifp->info;
                if (!pim_ifp)
                        continue;
@@ -467,7 +463,6 @@ static void pim_show_membership_helper(struct vty *vty,
 static void pim_show_membership(struct pim_instance *pim, struct vty *vty,
                                u_char uj)
 {
-       struct listnode *if_node;
        struct pim_interface *pim_ifp;
        struct pim_ifchannel *ch;
        struct interface *ifp;
@@ -477,7 +472,7 @@ static void pim_show_membership(struct pim_instance *pim, struct vty *vty,
 
        json = json_object_new_object();
 
-       for (ALL_LIST_ELEMENTS_RO(vrf_iflist(pim->vrf_id), if_node, ifp)) {
+       RB_FOREACH (ifp, if_name_head, &pim->vrf->ifaces_by_name) {
                pim_ifp = ifp->info;
                if (!pim_ifp)
                        continue;
@@ -585,7 +580,6 @@ static void pim_print_ifp_flags(struct vty *vty, struct interface *ifp,
 static void igmp_show_interfaces(struct pim_instance *pim, struct vty *vty,
                                 u_char uj)
 {
-       struct listnode *node;
        struct interface *ifp;
        time_t now;
        json_object *json = NULL;
@@ -599,7 +593,7 @@ static void igmp_show_interfaces(struct pim_instance *pim, struct vty *vty,
                vty_out(vty,
                        "Interface  State          Address  V  Querier  Query Timer    Uptime\n");
 
-       for (ALL_LIST_ELEMENTS_RO(vrf_iflist(pim->vrf_id), node, ifp)) {
+       RB_FOREACH (ifp, if_name_head, &pim->vrf->ifaces_by_name) {
                struct pim_interface *pim_ifp;
                struct listnode *sock_node;
                struct igmp_sock *igmp;
@@ -666,7 +660,6 @@ static void igmp_show_interfaces_single(struct pim_instance *pim,
 {
        struct igmp_sock *igmp;
        struct interface *ifp;
-       struct listnode *node;
        struct listnode *sock_node;
        struct pim_interface *pim_ifp;
        char uptime[10];
@@ -690,7 +683,7 @@ static void igmp_show_interfaces_single(struct pim_instance *pim,
 
        now = pim_time_monotonic_sec();
 
-       for (ALL_LIST_ELEMENTS_RO(vrf_iflist(pim->vrf_id), node, ifp)) {
+       RB_FOREACH (ifp, if_name_head, &pim->vrf->ifaces_by_name) {
                pim_ifp = ifp->info;
 
                if (!pim_ifp)
@@ -866,7 +859,6 @@ static void igmp_show_interfaces_single(struct pim_instance *pim,
 
 static void igmp_show_interface_join(struct pim_instance *pim, struct vty *vty)
 {
-       struct listnode *node;
        struct interface *ifp;
        time_t now;
 
@@ -875,7 +867,7 @@ static void igmp_show_interface_join(struct pim_instance *pim, struct vty *vty)
        vty_out(vty,
                "Interface Address         Source          Group           Socket Uptime  \n");
 
-       for (ALL_LIST_ELEMENTS_RO(vrf_iflist(pim->vrf_id), node, ifp)) {
+       RB_FOREACH (ifp, if_name_head, &pim->vrf->ifaces_by_name) {
                struct pim_interface *pim_ifp;
                struct listnode *join_node;
                struct igmp_join *ij;
@@ -922,7 +914,6 @@ static void pim_show_interfaces_single(struct pim_instance *pim,
        struct in_addr ifaddr;
        struct interface *ifp;
        struct listnode *neighnode;
-       struct listnode *node;
        struct listnode *upnode;
        struct pim_interface *pim_ifp;
        struct pim_neighbor *neigh;
@@ -956,7 +947,7 @@ static void pim_show_interfaces_single(struct pim_instance *pim,
        if (uj)
                json = json_object_new_object();
 
-       for (ALL_LIST_ELEMENTS_RO(vrf_iflist(pim->vrf_id), node, ifp)) {
+       RB_FOREACH (ifp, if_name_head, &pim->vrf->ifaces_by_name) {
                pim_ifp = ifp->info;
 
                if (!pim_ifp)
@@ -1338,7 +1329,6 @@ static void pim_show_interfaces(struct pim_instance *pim, struct vty *vty,
                                u_char uj)
 {
        struct interface *ifp;
-       struct listnode *node;
        struct listnode *upnode;
        struct pim_interface *pim_ifp;
        struct pim_upstream *up;
@@ -1351,7 +1341,7 @@ static void pim_show_interfaces(struct pim_instance *pim, struct vty *vty,
 
        json = json_object_new_object();
 
-       for (ALL_LIST_ELEMENTS_RO(vrf_iflist(pim->vrf_id), node, ifp)) {
+       RB_FOREACH (ifp, if_name_head, &pim->vrf->ifaces_by_name) {
                pim_ifp = ifp->info;
 
                if (!pim_ifp)
@@ -1433,7 +1423,6 @@ static void pim_show_interface_traffic(struct pim_instance *pim,
 {
        struct interface *ifp = NULL;
        struct pim_interface *pim_ifp = NULL;
-       struct listnode *node = NULL;
        json_object *json = NULL;
        json_object *json_row = NULL;
 
@@ -1451,7 +1440,7 @@ static void pim_show_interface_traffic(struct pim_instance *pim,
                        "---------------------------------------------------------------------------------------------------------------\n");
        }
 
-       for (ALL_LIST_ELEMENTS_RO(vrf_iflist(pim->vrf_id), node, ifp)) {
+       RB_FOREACH (ifp, if_name_head, &pim->vrf->ifaces_by_name) {
                pim_ifp = ifp->info;
 
                if (!pim_ifp)
@@ -1514,7 +1503,6 @@ static void pim_show_interface_traffic_single(struct pim_instance *pim,
 {
        struct interface *ifp = NULL;
        struct pim_interface *pim_ifp = NULL;
-       struct listnode *node = NULL;
        json_object *json = NULL;
        json_object *json_row = NULL;
        uint8_t found_ifname = 0;
@@ -1533,7 +1521,7 @@ static void pim_show_interface_traffic_single(struct pim_instance *pim,
                        "---------------------------------------------------------------------------------------------------------------\n");
        }
 
-       for (ALL_LIST_ELEMENTS_RO(vrf_iflist(pim->vrf_id), node, ifp)) {
+       RB_FOREACH (ifp, if_name_head, &pim->vrf->ifaces_by_name) {
                if (strcmp(ifname, ifp->name))
                        continue;
 
@@ -1678,7 +1666,6 @@ static void pim_show_join_helper(struct vty *vty,
 
 static void pim_show_join(struct pim_instance *pim, struct vty *vty, u_char uj)
 {
-       struct listnode *if_node;
        struct pim_interface *pim_ifp;
        struct pim_ifchannel *ch;
        struct interface *ifp;
@@ -1693,7 +1680,7 @@ static void pim_show_join(struct pim_instance *pim, struct vty *vty, u_char uj)
                vty_out(vty,
                        "Interface Address         Source          Group           State      Uptime   Expire Prune\n");
 
-       for (ALL_LIST_ELEMENTS_RO(vrf_iflist(pim->vrf_id), if_node, ifp)) {
+       RB_FOREACH (ifp, if_name_head, &pim->vrf->ifaces_by_name) {
                pim_ifp = ifp->info;
                if (!pim_ifp)
                        continue;
@@ -1713,7 +1700,6 @@ static void pim_show_join(struct pim_instance *pim, struct vty *vty, u_char uj)
 static void pim_show_neighbors_single(struct pim_instance *pim, struct vty *vty,
                                      const char *neighbor, u_char uj)
 {
-       struct listnode *node;
        struct listnode *neighnode;
        struct interface *ifp;
        struct pim_interface *pim_ifp;
@@ -1739,7 +1725,7 @@ static void pim_show_neighbors_single(struct pim_instance *pim, struct vty *vty,
        if (uj)
                json = json_object_new_object();
 
-       for (ALL_LIST_ELEMENTS_RO(vrf_iflist(pim->vrf_id), node, ifp)) {
+       RB_FOREACH (ifp, if_name_head, &pim->vrf->ifaces_by_name) {
                pim_ifp = ifp->info;
 
                if (!pim_ifp)
@@ -2125,7 +2111,6 @@ static void pim_show_state(struct pim_instance *pim, struct vty *vty,
 static void pim_show_neighbors(struct pim_instance *pim, struct vty *vty,
                               u_char uj)
 {
-       struct listnode *node;
        struct listnode *neighnode;
        struct interface *ifp;
        struct pim_interface *pim_ifp;
@@ -2147,7 +2132,7 @@ static void pim_show_neighbors(struct pim_instance *pim, struct vty *vty,
                        "Interface         Neighbor    Uptime  Holdtime  DR Pri\n");
        }
 
-       for (ALL_LIST_ELEMENTS_RO(vrf_iflist(pim->vrf_id), node, ifp)) {
+       RB_FOREACH (ifp, if_name_head, &pim->vrf->ifaces_by_name) {
                pim_ifp = ifp->info;
 
                if (!pim_ifp)
@@ -2208,13 +2193,12 @@ static void pim_show_neighbors(struct pim_instance *pim, struct vty *vty,
 static void pim_show_neighbors_secondary(struct pim_instance *pim,
                                         struct vty *vty)
 {
-       struct listnode *node;
        struct interface *ifp;
 
        vty_out(vty,
                "Interface Address         Neighbor        Secondary      \n");
 
-       for (ALL_LIST_ELEMENTS_RO(vrf_iflist(pim->vrf_id), node, ifp)) {
+       RB_FOREACH (ifp, if_name_head, &pim->vrf->ifaces_by_name) {
                struct pim_interface *pim_ifp;
                struct in_addr ifaddr;
                struct listnode *neighnode;
@@ -2507,7 +2491,6 @@ static void pim_show_join_desired_helper(struct pim_instance *pim,
 static void pim_show_join_desired(struct pim_instance *pim, struct vty *vty,
                                  u_char uj)
 {
-       struct listnode *if_node;
        struct pim_interface *pim_ifp;
        struct pim_ifchannel *ch;
        struct interface *ifp;
@@ -2521,7 +2504,7 @@ static void pim_show_join_desired(struct pim_instance *pim, struct vty *vty,
                        "Interface Source          Group           LostAssert Joins PimInclude JoinDesired EvalJD\n");
 
        /* scan per-interface (S,G) state */
-       for (ALL_LIST_ELEMENTS_RO(vrf_iflist(pim->vrf_id), if_node, ifp)) {
+       RB_FOREACH (ifp, if_name_head, &pim->vrf->ifaces_by_name) {
                pim_ifp = ifp->info;
                if (!pim_ifp)
                        continue;
@@ -2802,7 +2785,6 @@ static void pim_show_nexthop(struct pim_instance *pim, struct vty *vty)
 static void igmp_show_groups(struct pim_instance *pim, struct vty *vty,
                             u_char uj)
 {
-       struct listnode *ifnode;
        struct interface *ifp;
        time_t now;
        json_object *json = NULL;
@@ -2818,7 +2800,7 @@ static void igmp_show_groups(struct pim_instance *pim, struct vty *vty,
                        "Interface Address         Group           Mode Timer    Srcs V Uptime  \n");
 
        /* scan interfaces */
-       for (ALL_LIST_ELEMENTS_RO(vrf_iflist(pim->vrf_id), ifnode, ifp)) {
+       RB_FOREACH (ifp, if_name_head, &pim->vrf->ifaces_by_name) {
                struct pim_interface *pim_ifp = ifp->info;
                struct listnode *sock_node;
                struct igmp_sock *igmp;
@@ -2924,14 +2906,13 @@ static void igmp_show_groups(struct pim_instance *pim, struct vty *vty,
 static void igmp_show_group_retransmission(struct pim_instance *pim,
                                           struct vty *vty)
 {
-       struct listnode *ifnode;
        struct interface *ifp;
 
        vty_out(vty,
                "Interface Address         Group           RetTimer Counter RetSrcs\n");
 
        /* scan interfaces */
-       for (ALL_LIST_ELEMENTS_RO(vrf_iflist(pim->vrf_id), ifnode, ifp)) {
+       RB_FOREACH (ifp, if_name_head, &pim->vrf->ifaces_by_name) {
                struct pim_interface *pim_ifp = ifp->info;
                struct listnode *sock_node;
                struct igmp_sock *igmp;
@@ -2989,7 +2970,6 @@ static void igmp_show_group_retransmission(struct pim_instance *pim,
 
 static void igmp_show_sources(struct pim_instance *pim, struct vty *vty)
 {
-       struct listnode *ifnode;
        struct interface *ifp;
        time_t now;
 
@@ -2999,7 +2979,7 @@ static void igmp_show_sources(struct pim_instance *pim, struct vty *vty)
                "Interface Address         Group           Source          Timer Fwd Uptime  \n");
 
        /* scan interfaces */
-       for (ALL_LIST_ELEMENTS_RO(vrf_iflist(pim->vrf_id), ifnode, ifp)) {
+       RB_FOREACH (ifp, if_name_head, &pim->vrf->ifaces_by_name) {
                struct pim_interface *pim_ifp = ifp->info;
                struct listnode *sock_node;
                struct igmp_sock *igmp;
@@ -3066,14 +3046,13 @@ static void igmp_show_sources(struct pim_instance *pim, struct vty *vty)
 static void igmp_show_source_retransmission(struct pim_instance *pim,
                                            struct vty *vty)
 {
-       struct listnode *ifnode;
        struct interface *ifp;
 
        vty_out(vty,
                "Interface Address         Group           Source          Counter\n");
 
        /* scan interfaces */
-       for (ALL_LIST_ELEMENTS_RO(vrf_iflist(pim->vrf_id), ifnode, ifp)) {
+       RB_FOREACH (ifp, if_name_head, &pim->vrf->ifaces_by_name) {
                struct pim_interface *pim_ifp = ifp->info;
                struct listnode *sock_node;
                struct igmp_sock *igmp;
@@ -3125,29 +3104,20 @@ static void igmp_show_source_retransmission(struct pim_instance *pim,
 
 static void clear_igmp_interfaces(struct pim_instance *pim)
 {
-       struct listnode *ifnode;
-       struct listnode *ifnextnode;
        struct interface *ifp;
 
-       for (ALL_LIST_ELEMENTS(vrf_iflist(pim->vrf_id), ifnode, ifnextnode,
-                              ifp)) {
+       RB_FOREACH (ifp, if_name_head, &pim->vrf->ifaces_by_name)
                pim_if_addr_del_all_igmp(ifp);
-       }
 
-       for (ALL_LIST_ELEMENTS(vrf_iflist(pim->vrf_id), ifnode, ifnextnode,
-                              ifp)) {
+       RB_FOREACH (ifp, if_name_head, &pim->vrf->ifaces_by_name)
                pim_if_addr_add_all(ifp);
-       }
 }
 
 static void clear_pim_interfaces(struct pim_instance *pim)
 {
-       struct listnode *ifnode;
-       struct listnode *ifnextnode;
        struct interface *ifp;
 
-       for (ALL_LIST_ELEMENTS(vrf_iflist(pim->vrf_id), ifnode, ifnextnode,
-                              ifp)) {
+       RB_FOREACH (ifp, if_name_head, &pim->vrf->ifaces_by_name) {
                if (ifp->info) {
                        pim_neighbor_delete_all(ifp, "interface cleared");
                }
@@ -3301,16 +3271,13 @@ DEFUN (clear_ip_pim_interface_traffic,
 {
        int idx = 2;
        struct vrf *vrf = pim_cmd_lookup_vrf(vty, argv, argc, &idx);
-       struct listnode *ifnode = NULL;
-       struct listnode *ifnextnode = NULL;
        struct interface *ifp = NULL;
        struct pim_interface *pim_ifp = NULL;
 
        if (!vrf)
                return CMD_WARNING;
 
-       for (ALL_LIST_ELEMENTS(vrf_iflist(vrf->vrf_id), ifnode, ifnextnode,
-                              ifp)) {
+       RB_FOREACH (ifp, if_name_head, &vrf->ifaces_by_name) {
                pim_ifp = ifp->info;
 
                if (!pim_ifp)
@@ -4320,7 +4287,6 @@ DEFUN (show_ip_pim_interface_traffic,
 
 static void show_multicast_interfaces(struct pim_instance *pim, struct vty *vty)
 {
-       struct listnode *node;
        struct interface *ifp;
 
        vty_out(vty, "\n");
@@ -4328,7 +4294,7 @@ static void show_multicast_interfaces(struct pim_instance *pim, struct vty *vty)
        vty_out(vty,
                "Interface Address            ifi Vif  PktsIn PktsOut    BytesIn   BytesOut\n");
 
-       for (ALL_LIST_ELEMENTS_RO(vrf_iflist(pim->vrf_id), node, ifp)) {
+       RB_FOREACH (ifp, if_name_head, &pim->vrf->ifaces_by_name) {
                struct pim_interface *pim_ifp;
                struct in_addr ifaddr;
                struct sioc_vif_req vreq;
index 01e14bec094e6408f35db927d3ac1d0604ae59a1..09b5fe2bf7fdac6b2c49c7e0b9dc1e5d2c31e5df 100644 (file)
@@ -1023,10 +1023,9 @@ int pim_if_del_vif(struct interface *ifp)
 struct interface *pim_if_find_by_vif_index(struct pim_instance *pim,
                                           ifindex_t vif_index)
 {
-       struct listnode *ifnode;
        struct interface *ifp;
 
-       for (ALL_LIST_ELEMENTS_RO(vrf_iflist(pim->vrf_id), ifnode, ifp)) {
+       RB_FOREACH (ifp, if_name_head, &pim->vrf->ifaces_by_name) {
                if (ifp->info) {
                        struct pim_interface *pim_ifp;
                        pim_ifp = ifp->info;
index 6aa5105c5fefd028f6a82e2378d69b230698abe2..71897afcea7bd12b21b662382b84cd38ea8e3600 100644 (file)
@@ -1291,10 +1291,9 @@ void pim_ifchannel_scan_forward_start(struct interface *new_ifp)
 {
        struct pim_interface *new_pim_ifp = new_ifp->info;
        struct pim_instance *pim = new_pim_ifp->pim;
-       struct listnode *ifnode;
        struct interface *ifp;
 
-       for (ALL_LIST_ELEMENTS_RO(vrf_iflist(pim->vrf_id), ifnode, ifp)) {
+       RB_FOREACH (ifp, if_name_head, &pim->vrf->ifaces_by_name) {
                struct pim_interface *loop_pim_ifp = ifp->info;
                struct pim_ifchannel *ch;
 
index 7de3e4ca6cb54f9ccfa3592789bb26211fb96cbc..3ec0a620fce843e263bc917e5adfe7a18938a11b 100644 (file)
@@ -212,12 +212,11 @@ int pim_jp_agg_is_in_list(struct list *group, struct pim_upstream *up)
 void pim_jp_agg_upstream_verification(struct pim_upstream *up, bool ignore)
 {
 #ifdef PIM_JP_AGG_DEBUG
-       struct listnode *node;
        struct interface *ifp;
        struct pim_interface *pim_ifp = up->rpf.source_nexthop.interface->info;
        struct pim_instance *pim = pim_ifp->pim;
 
-       for (ALL_LIST_ELEMENTS_RO(vrf_iflist(pim->vrf_id), node, ifp)) {
+       RB_FOREACH (ifp, if_name_head, &pim->vrf->ifaces_by_name) {
                pim_ifp = ifp->info;
                struct listnode *nnode;
 
index a1de4837dbe654a265cc0cec795ae918834b03d0..78b160f6a2aec00f1f8c713e0bfef4c3d10f5475 100644 (file)
@@ -410,12 +410,12 @@ static int pim_update_upstream_nh_helper(struct hash_backet *backet, void *arg)
 static int pim_update_upstream_nh(struct pim_instance *pim,
                                  struct pim_nexthop_cache *pnc)
 {
-       struct listnode *node, *ifnode;
+       struct listnode *node;
        struct interface *ifp;
 
        hash_walk(pnc->upstream_hash, pim_update_upstream_nh_helper, pim);
 
-       for (ALL_LIST_ELEMENTS_RO(vrf_iflist(pim->vrf_id), ifnode, ifp))
+       RB_FOREACH (ifp, if_name_head, &pim->vrf->ifaces_by_name)
                if (ifp->info) {
                        struct pim_interface *pim_ifp = ifp->info;
                        struct pim_iface_upstream_switch *us;
index cb722c17b2be4b86c9141d8388d146e8dbad4912..c1ecf687005b92127346175e64c78fd5fb14760d 100644 (file)
@@ -332,11 +332,10 @@ static int pim_rp_check_interface_addrs(struct rp_info *rp_info,
 static void pim_rp_check_interfaces(struct pim_instance *pim,
                                    struct rp_info *rp_info)
 {
-       struct listnode *node;
        struct interface *ifp;
 
        rp_info->i_am_rp = 0;
-       for (ALL_LIST_ELEMENTS_RO(vrf_iflist(pim->vrf_id), node, ifp)) {
+       RB_FOREACH (ifp, if_name_head, &pim->vrf->ifaces_by_name) {
                struct pim_interface *pim_ifp = ifp->info;
 
                if (!pim_ifp)
index ed5d1ecaa2f92109424439a857049913438b211e..47a70eb0947684603c49021d8d470553b5151c01 100644 (file)
@@ -864,12 +864,11 @@ int pim_upstream_evaluate_join_desired(struct pim_instance *pim,
                                       struct pim_upstream *up)
 {
        struct interface *ifp;
-       struct listnode *node;
        struct pim_ifchannel *ch, *starch;
        struct pim_upstream *starup = up->parent;
        int ret = 0;
 
-       for (ALL_LIST_ELEMENTS_RO(vrf_iflist(pim->vrf_id), node, ifp)) {
+       RB_FOREACH (ifp, if_name_head, &pim->vrf->ifaces_by_name) {
                if (!ifp->info)
                        continue;
 
@@ -1426,7 +1425,6 @@ int pim_upstream_inherited_olist_decide(struct pim_instance *pim,
        struct interface *ifp;
        struct pim_interface *pim_ifp = NULL;
        struct pim_ifchannel *ch, *starch;
-       struct listnode *node;
        struct pim_upstream *starup = up->parent;
        int output_intf = 0;
 
@@ -1441,7 +1439,7 @@ int pim_upstream_inherited_olist_decide(struct pim_instance *pim,
                up->channel_oil = pim_channel_oil_add(
                        pim, &up->sg, pim_ifp->mroute_vif_index);
 
-       for (ALL_LIST_ELEMENTS_RO(vrf_iflist(pim->vrf_id), node, ifp)) {
+       RB_FOREACH (ifp, if_name_head, &pim->vrf->ifaces_by_name) {
                if (!ifp->info)
                        continue;
 
index fc377b5a528747ac34430fa5d67e32bc815a08a6..9b60e284e8f54faa3306460856b8a6f7ddc8f941 100644 (file)
@@ -240,7 +240,6 @@ int pim_global_config_write(struct vty *vty)
 int pim_interface_config_write(struct vty *vty)
 {
        struct pim_instance *pim;
-       struct listnode *node;
        struct interface *ifp;
        struct vrf *vrf;
        int writes = 0;
@@ -250,8 +249,7 @@ int pim_interface_config_write(struct vty *vty)
                if (!pim)
                        continue;
 
-               for (ALL_LIST_ELEMENTS_RO(vrf_iflist(pim->vrf_id), node, ifp)) {
-
+               RB_FOREACH (ifp, if_name_head, &pim->vrf->ifaces_by_name) {
                        /* IF name */
                        if (vrf->vrf_id == VRF_DEFAULT)
                                vty_frame(vty, "interface %s\n", ifp->name);
index df70e9dd5e10de9e0ffa8fb4167218626df9608e..3424eded92526188de6eec00fdb89b1629c47791 100644 (file)
@@ -330,10 +330,10 @@ static int pim_zebra_if_address_add(int command, struct zclient *zclient,
                pim_rp_check_on_if_add(pim_ifp);
 
        if (if_is_loopback(c->ifp)) {
-               struct listnode *ifnode;
+               struct vrf *vrf = vrf_lookup_by_id(VRF_DEFAULT);
                struct interface *ifp;
 
-               for (ALL_LIST_ELEMENTS_RO(vrf_iflist(vrf_id), ifnode, ifp)) {
+               RB_FOREACH (ifp, if_name_head, &vrf->ifaces_by_name) {
                        if (!if_is_loopback(ifp) && if_is_operative(ifp))
                                pim_if_addr_add_all(ifp);
                }
@@ -392,7 +392,6 @@ static int pim_zebra_if_address_del(int command, struct zclient *client,
 static void scan_upstream_rpf_cache()
 {
        struct listnode *up_node;
-       struct listnode *ifnode;
        struct listnode *up_nextnode;
        struct listnode *node;
        struct pim_upstream *up;
@@ -501,7 +500,7 @@ static void scan_upstream_rpf_cache()
                if (!pim)
                        continue;
 
-               for (ALL_LIST_ELEMENTS_RO(vrf_iflist(pim->vrf_id), ifnode, ifp))
+               RB_FOREACH (ifp, if_name_head, &pim->vrf->ifaces_by_name)
                        if (ifp->info) {
                                struct pim_interface *pim_ifp = ifp->info;
                                struct pim_iface_upstream_switch *us;
@@ -861,7 +860,6 @@ static void igmp_source_forward_reevaluate_one(struct pim_instance *pim,
 
 void igmp_source_forward_reevaluate_all(void)
 {
-       struct listnode *ifnode;
        struct interface *ifp;
        struct vrf *vrf;
        struct pim_instance *pim;
@@ -871,8 +869,7 @@ void igmp_source_forward_reevaluate_all(void)
                if (!pim)
                        continue;
 
-               for (ALL_LIST_ELEMENTS_RO(vrf_iflist(pim->vrf_id), ifnode,
-                                         ifp)) {
+               RB_FOREACH (ifp, if_name_head, &pim->vrf->ifaces_by_name) {
                        struct pim_interface *pim_ifp = ifp->info;
                        struct listnode *sock_node;
                        struct igmp_sock *igmp;
index 1b2cbb61c32c7d0aae466a4f6423dbaf22261f6c..fe72de229f51eca11315252b8e89b86b1e1c9410 100644 (file)
@@ -336,10 +336,10 @@ static int rip_if_ipv4_address_check(struct interface *ifp)
 /* Does this address belongs to me ? */
 int if_check_address(struct in_addr addr)
 {
-       struct listnode *node;
+       struct vrf *vrf = vrf_lookup_by_id(VRF_DEFAULT);
        struct interface *ifp;
 
-       for (ALL_LIST_ELEMENTS_RO(vrf_iflist(VRF_DEFAULT), node, ifp)) {
+       RB_FOREACH (ifp, if_name_head, &vrf->ifaces_by_name) {
                struct listnode *cnode;
                struct connected *connected;
 
@@ -490,10 +490,10 @@ static void rip_interface_clean(struct rip_interface *ri)
 
 void rip_interfaces_clean(void)
 {
-       struct listnode *node;
+       struct vrf *vrf = vrf_lookup_by_id(VRF_DEFAULT);
        struct interface *ifp;
 
-       for (ALL_LIST_ELEMENTS_RO(vrf_iflist(VRF_DEFAULT), node, ifp))
+       RB_FOREACH (ifp, if_name_head, &vrf->ifaces_by_name)
                rip_interface_clean(ifp->info);
 }
 
@@ -542,10 +542,10 @@ static void rip_interface_reset(struct rip_interface *ri)
 
 void rip_interfaces_reset(void)
 {
-       struct listnode *node;
+       struct vrf *vrf = vrf_lookup_by_id(VRF_DEFAULT);
        struct interface *ifp;
 
-       for (ALL_LIST_ELEMENTS_RO(vrf_iflist(VRF_DEFAULT), node, ifp))
+       RB_FOREACH (ifp, if_name_head, &vrf->ifaces_by_name)
                rip_interface_reset(ifp->info);
 }
 
@@ -583,10 +583,10 @@ int rip_if_down(struct interface *ifp)
 /* Needed for stop RIP process. */
 void rip_if_down_all()
 {
+       struct vrf *vrf = vrf_lookup_by_id(VRF_DEFAULT);
        struct interface *ifp;
-       struct listnode *node, *nnode;
 
-       for (ALL_LIST_ELEMENTS(vrf_iflist(VRF_DEFAULT), node, nnode, ifp))
+       RB_FOREACH (ifp, if_name_head, &vrf->ifaces_by_name)
                rip_if_down(ifp);
 }
 
@@ -977,11 +977,11 @@ void rip_enable_apply(struct interface *ifp)
 /* Apply network configuration to all interface. */
 void rip_enable_apply_all()
 {
+       struct vrf *vrf = vrf_lookup_by_id(VRF_DEFAULT);
        struct interface *ifp;
-       struct listnode *node, *nnode;
 
        /* Check each interface. */
-       for (ALL_LIST_ELEMENTS(vrf_iflist(VRF_DEFAULT), node, nnode, ifp))
+       RB_FOREACH (ifp, if_name_head, &vrf->ifaces_by_name)
                rip_enable_apply(ifp);
 }
 
@@ -1091,10 +1091,10 @@ void rip_passive_interface_apply(struct interface *ifp)
 
 static void rip_passive_interface_apply_all(void)
 {
+       struct vrf *vrf = vrf_lookup_by_id(VRF_DEFAULT);
        struct interface *ifp;
-       struct listnode *node, *nnode;
 
-       for (ALL_LIST_ELEMENTS(vrf_iflist(VRF_DEFAULT), node, nnode, ifp))
+       RB_FOREACH (ifp, if_name_head, &vrf->ifaces_by_name)
                rip_passive_interface_apply(ifp);
 }
 
@@ -1728,10 +1728,10 @@ DEFUN (no_rip_passive_interface,
 /* Write rip configuration of each interface. */
 static int rip_interface_config_write(struct vty *vty)
 {
-       struct listnode *node;
+       struct vrf *vrf = vrf_lookup_by_id(VRF_DEFAULT);
        struct interface *ifp;
 
-       for (ALL_LIST_ELEMENTS_RO(vrf_iflist(VRF_DEFAULT), node, ifp)) {
+       RB_FOREACH (ifp, if_name_head, &vrf->ifaces_by_name) {
                struct rip_interface *ri;
 
                if (ifp->ifindex == IFINDEX_DELETED)
index bededba7fc65eb9973597e28a2b180b7f887e3e0..fb628001ab3944ab11353f85daa1c236a200404b 100644 (file)
@@ -372,16 +372,16 @@ static int rip_filter(int rip_distribute, struct prefix_ipv4 *p,
 /* Check nexthop address validity. */
 static int rip_nexthop_check(struct in_addr *addr)
 {
-       struct listnode *node;
-       struct listnode *cnode;
+       struct vrf *vrf = vrf_lookup_by_id(VRF_DEFAULT);
        struct interface *ifp;
+       struct listnode *cnode;
        struct connected *ifc;
        struct prefix *p;
 
        /* If nexthop address matches local configured address then it is
           invalid nexthop. */
 
-       for (ALL_LIST_ELEMENTS_RO(vrf_iflist(VRF_DEFAULT), node, ifp)) {
+       RB_FOREACH (ifp, if_name_head, &vrf->ifaces_by_name) {
                for (ALL_LIST_ELEMENTS_RO(ifp->connected, cnode, ifc)) {
                        p = ifc->address;
 
@@ -2445,7 +2445,7 @@ static void rip_update_interface(struct connected *ifc, u_char version,
 /* Update send to all interface and neighbor. */
 static void rip_update_process(int route_type)
 {
-       struct listnode *node;
+       struct vrf *vrf = vrf_lookup_by_id(VRF_DEFAULT);
        struct listnode *ifnode, *ifnnode;
        struct connected *connected;
        struct interface *ifp;
@@ -2455,7 +2455,7 @@ static void rip_update_process(int route_type)
        struct prefix *p;
 
        /* Send RIP update to each interface. */
-       for (ALL_LIST_ELEMENTS_RO(vrf_iflist(VRF_DEFAULT), node, ifp)) {
+       RB_FOREACH (ifp, if_name_head, &vrf->ifaces_by_name) {
                if (if_is_loopback(ifp))
                        continue;
 
@@ -3512,7 +3512,7 @@ DEFUN (show_ip_rip_status,
        "Show RIP routes\n"
        "IP routing protocol process parameters and statistics\n")
 {
-       struct listnode *node;
+       struct vrf *vrf = vrf_lookup_by_id(VRF_DEFAULT);
        struct interface *ifp;
        struct rip_interface *ri;
        extern const struct message ri_version_msg[];
@@ -3552,7 +3552,7 @@ DEFUN (show_ip_rip_status,
 
        vty_out(vty, "    Interface        Send  Recv   Key-chain\n");
 
-       for (ALL_LIST_ELEMENTS_RO(vrf_iflist(VRF_DEFAULT), node, ifp)) {
+       RB_FOREACH (ifp, if_name_head, &vrf->ifaces_by_name) {
                ri = ifp->info;
 
                if (!ri->running)
@@ -3586,7 +3586,7 @@ DEFUN (show_ip_rip_status,
 
        {
                int found_passive = 0;
-               for (ALL_LIST_ELEMENTS_RO(vrf_iflist(VRF_DEFAULT), node, ifp)) {
+               RB_FOREACH (ifp, if_name_head, &vrf->ifaces_by_name) {
                        ri = ifp->info;
 
                        if ((ri->enable_network || ri->enable_interface)
@@ -3771,10 +3771,10 @@ void rip_distribute_update_interface(struct interface *ifp)
 /* ARGSUSED */
 static void rip_distribute_update_all(struct prefix_list *notused)
 {
+       struct vrf *vrf = vrf_lookup_by_id(VRF_DEFAULT);
        struct interface *ifp;
-       struct listnode *node, *nnode;
 
-       for (ALL_LIST_ELEMENTS(vrf_iflist(VRF_DEFAULT), node, nnode, ifp))
+       RB_FOREACH (ifp, if_name_head, &vrf->ifaces_by_name)
                rip_distribute_update_interface(ifp);
 }
 /* ARGSUSED */
@@ -3947,10 +3947,10 @@ static void rip_routemap_update_redistribute(void)
 /* ARGSUSED */
 static void rip_routemap_update(const char *notused)
 {
+       struct vrf *vrf = vrf_lookup_by_id(VRF_DEFAULT);
        struct interface *ifp;
-       struct listnode *node, *nnode;
 
-       for (ALL_LIST_ELEMENTS(vrf_iflist(VRF_DEFAULT), node, nnode, ifp))
+       RB_FOREACH (ifp, if_name_head, &vrf->ifaces_by_name)
                rip_if_rmap_update_interface(ifp);
 
        rip_routemap_update_redistribute();
index 5c65f522ef826445e231bfba01dcb43bcedcfce4..aab2b232454e5011272d9072f6e39c9b8b02db18 100644 (file)
@@ -306,11 +306,11 @@ int ripng_interface_delete(int command, struct zclient *zclient,
 
 void ripng_interface_clean(void)
 {
-       struct listnode *node, *nnode;
+       struct vrf *vrf = vrf_lookup_by_id(VRF_DEFAULT);
        struct interface *ifp;
        struct ripng_interface *ri;
 
-       for (ALL_LIST_ELEMENTS(vrf_iflist(VRF_DEFAULT), node, nnode, ifp)) {
+       RB_FOREACH (ifp, if_name_head, &vrf->ifaces_by_name) {
                ri = ifp->info;
 
                ri->enable_network = 0;
@@ -326,11 +326,11 @@ void ripng_interface_clean(void)
 
 void ripng_interface_reset(void)
 {
-       struct listnode *node;
+       struct vrf *vrf = vrf_lookup_by_id(VRF_DEFAULT);
        struct interface *ifp;
        struct ripng_interface *ri;
 
-       for (ALL_LIST_ELEMENTS_RO(vrf_iflist(VRF_DEFAULT), node, ifp)) {
+       RB_FOREACH (ifp, if_name_head, &vrf->ifaces_by_name) {
                ri = ifp->info;
 
                ri->enable_network = 0;
@@ -760,10 +760,10 @@ void ripng_enable_apply(struct interface *ifp)
 /* Set distribute list to all interfaces. */
 static void ripng_enable_apply_all(void)
 {
+       struct vrf *vrf = vrf_lookup_by_id(VRF_DEFAULT);
        struct interface *ifp;
-       struct listnode *node;
 
-       for (ALL_LIST_ELEMENTS_RO(vrf_iflist(VRF_DEFAULT), node, ifp))
+       RB_FOREACH (ifp, if_name_head, &vrf->ifaces_by_name)
                ripng_enable_apply(ifp);
 }
 
@@ -821,10 +821,10 @@ void ripng_passive_interface_apply(struct interface *ifp)
 
 static void ripng_passive_interface_apply_all(void)
 {
+       struct vrf *vrf = vrf_lookup_by_id(VRF_DEFAULT);
        struct interface *ifp;
-       struct listnode *node;
 
-       for (ALL_LIST_ELEMENTS_RO(vrf_iflist(VRF_DEFAULT), node, ifp))
+       RB_FOREACH (ifp, if_name_head, &vrf->ifaces_by_name)
                ripng_passive_interface_apply(ifp);
 }
 
@@ -1069,12 +1069,12 @@ static int ripng_if_delete_hook(struct interface *ifp)
 /* Configuration write function for ripngd. */
 static int interface_config_write(struct vty *vty)
 {
-       struct listnode *node;
+       struct vrf *vrf = vrf_lookup_by_id(VRF_DEFAULT);
        struct interface *ifp;
        struct ripng_interface *ri;
        int write = 0;
 
-       for (ALL_LIST_ELEMENTS_RO(vrf_iflist(VRF_DEFAULT), node, ifp)) {
+       RB_FOREACH (ifp, if_name_head, &vrf->ifaces_by_name) {
                ri = ifp->info;
 
                /* Do not display the interface if there is no
index 4df1aafe5d839c04a70f64f2687d7cb9f72e380f..902b5d9862f6b8d79e4b3d8393dcfe4e55844666 100644 (file)
@@ -1377,7 +1377,7 @@ static void ripng_clear_changed_flag(void)
    enabled interface. */
 static int ripng_update(struct thread *t)
 {
-       struct listnode *node;
+       struct vrf *vrf = vrf_lookup_by_id(VRF_DEFAULT);
        struct interface *ifp;
        struct ripng_interface *ri;
 
@@ -1389,7 +1389,7 @@ static int ripng_update(struct thread *t)
                zlog_debug("RIPng update timer expired!");
 
        /* Supply routes to each interface. */
-       for (ALL_LIST_ELEMENTS_RO(vrf_iflist(VRF_DEFAULT), node, ifp)) {
+       RB_FOREACH (ifp, if_name_head, &vrf->ifaces_by_name) {
                ri = ifp->info;
 
                if (if_is_loopback(ifp) || !if_is_up(ifp))
@@ -1445,7 +1445,7 @@ static int ripng_triggered_interval(struct thread *t)
 /* Execute triggered update. */
 int ripng_triggered_update(struct thread *t)
 {
-       struct listnode *node;
+       struct vrf *vrf = vrf_lookup_by_id(VRF_DEFAULT);
        struct interface *ifp;
        struct ripng_interface *ri;
        int interval;
@@ -1465,7 +1465,7 @@ int ripng_triggered_update(struct thread *t)
 
        /* Split Horizon processing is done when generating triggered
           updates as well as normal updates (see section 2.6). */
-       for (ALL_LIST_ELEMENTS_RO(vrf_iflist(VRF_DEFAULT), node, ifp)) {
+       RB_FOREACH (ifp, if_name_head, &vrf->ifaces_by_name) {
                ri = ifp->info;
 
                if (if_is_loopback(ifp) || !if_is_up(ifp))
@@ -2058,7 +2058,7 @@ DEFUN (show_ipv6_ripng_status,
        "Show RIPng routes\n"
        "IPv6 routing protocol process parameters and statistics\n")
 {
-       struct listnode *node;
+       struct vrf *vrf = vrf_lookup_by_id(VRF_DEFAULT);
        struct interface *ifp;
 
        if (!ripng)
@@ -2091,7 +2091,7 @@ DEFUN (show_ipv6_ripng_status,
 
        vty_out(vty, "    Interface        Send  Recv\n");
 
-       for (ALL_LIST_ELEMENTS_RO(vrf_iflist(VRF_DEFAULT), node, ifp)) {
+       RB_FOREACH (ifp, if_name_head, &vrf->ifaces_by_name) {
                struct ripng_interface *ri;
 
                ri = ifp->info;
@@ -2791,10 +2791,10 @@ void ripng_distribute_update_interface(struct interface *ifp)
 /* Update all interface's distribute list. */
 static void ripng_distribute_update_all(struct prefix_list *notused)
 {
+       struct vrf *vrf = vrf_lookup_by_id(VRF_DEFAULT);
        struct interface *ifp;
-       struct listnode *node;
 
-       for (ALL_LIST_ELEMENTS_RO(vrf_iflist(VRF_DEFAULT), node, ifp))
+       RB_FOREACH (ifp, if_name_head, &vrf->ifaces_by_name)
                ripng_distribute_update_interface(ifp);
 }
 
@@ -2968,10 +2968,10 @@ static void ripng_routemap_update_redistribute(void)
 
 static void ripng_routemap_update(const char *unused)
 {
+       struct vrf *vrf = vrf_lookup_by_id(VRF_DEFAULT);
        struct interface *ifp;
-       struct listnode *node;
 
-       for (ALL_LIST_ELEMENTS_RO(vrf_iflist(VRF_DEFAULT), node, ifp))
+       RB_FOREACH (ifp, if_name_head, &vrf->ifaces_by_name)
                ripng_if_rmap_update_interface(ifp);
 
        ripng_routemap_update_redistribute();
index f31c24ada3468fb428bdb2b0f907a369a9b247a6..54dbb555db379c13c24542d39f7b478ca95d5aa1 100644 (file)
@@ -262,10 +262,10 @@ static int if_getaddrs(void)
 /* Fetch interface information via ioctl(). */
 static void interface_info_ioctl()
 {
-       struct listnode *node, *nnode;
+       struct vrf *vrf = vrf_lookup_by_id(VRF_DEFAULT);
        struct interface *ifp;
 
-       for (ALL_LIST_ELEMENTS(vrf_iflist(VRF_DEFAULT), node, nnode, ifp)) {
+       RB_FOREACH (ifp, if_name_head, &vrf->ifaces_by_name) {
                if_get_index(ifp);
 #ifdef SIOCGIFHWADDR
                if_get_hwaddr(ifp);
index a65dd21f63cfd5ca9d715802637bb89a0cc20d70..1b11357a89ac324fdc977fd7485380f8ba1a63c9 100644 (file)
@@ -1317,7 +1317,7 @@ DEFUN (show_interface,
        "Interface status and configuration\n"
        VRF_CMD_HELP_STR)
 {
-       struct listnode *node;
+       struct vrf *vrf;
        struct interface *ifp;
        vrf_id_t vrf_id = VRF_DEFAULT;
 
@@ -1327,7 +1327,8 @@ DEFUN (show_interface,
                VRF_GET_ID(vrf_id, argv[3]->arg);
 
        /* All interface print. */
-       for (ALL_LIST_ELEMENTS_RO(vrf_iflist(vrf_id), node, ifp))
+       vrf = vrf_lookup_by_id(vrf_id);
+       RB_FOREACH (ifp, if_name_head, &vrf->ifaces_by_name)
                if_dump_vty(vty, ifp);
 
        return CMD_SUCCESS;
@@ -1343,14 +1344,13 @@ DEFUN (show_interface_vrf_all,
        VRF_ALL_CMD_HELP_STR)
 {
        struct vrf *vrf;
-       struct listnode *node;
        struct interface *ifp;
 
        interface_update_stats();
 
        /* All interface print. */
        RB_FOREACH (vrf, vrf_name_head, &vrfs_by_name)
-               for (ALL_LIST_ELEMENTS_RO(vrf->iflist, node, ifp))
+               RB_FOREACH (ifp, if_name_head, &vrf->ifaces_by_name)
                        if_dump_vty(vty, ifp);
 
        return CMD_SUCCESS;
@@ -1425,11 +1425,11 @@ DEFUN (show_interface_name_vrf_all,
 
 static void if_show_description(struct vty *vty, vrf_id_t vrf_id)
 {
-       struct listnode *node;
+       struct vrf *vrf = vrf_lookup_by_id(vrf_id);
        struct interface *ifp;
 
        vty_out(vty, "Interface       Status  Protocol  Description\n");
-       for (ALL_LIST_ELEMENTS_RO(vrf_iflist(vrf_id), node, ifp)) {
+       RB_FOREACH (ifp, if_name_head, &vrf->ifaces_by_name) {
                int len;
 
                len = vty_out(vty, "%s", ifp->name);
@@ -1486,7 +1486,7 @@ DEFUN (show_interface_desc_vrf_all,
        struct vrf *vrf;
 
        RB_FOREACH (vrf, vrf_name_head, &vrfs_by_name)
-               if (!list_isempty(vrf->iflist)) {
+               if (!RB_EMPTY (if_name_head, &vrf->ifaces_by_name)) {
                        vty_out(vty, "\n\tVRF %u\n\n", vrf->vrf_id);
                        if_show_description(vty, vrf->vrf_id);
                }
@@ -2830,13 +2830,12 @@ static int 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;
 
        zebra_ptm_write(vty);
 
        RB_FOREACH (vrf, vrf_name_head, &vrfs_by_name)
-               for (ALL_LIST_ELEMENTS_RO(vrf->iflist, node, ifp)) {
+               RB_FOREACH (ifp, if_name_head, &vrf->ifaces_by_name) {
                        struct zebra_if *if_data;
                        struct listnode *addrnode;
                        struct connected *ifc;
index bc85e983e7518d7691460f166cef06d8a3fcc21a..816bc85cec1fa347f6724f48145ae0198460b12a 100644 (file)
@@ -315,7 +315,6 @@ void process_solicit(struct interface *ifp)
 static int irdp_finish(void)
 {
        struct vrf *vrf;
-       struct listnode *node, *nnode;
        struct interface *ifp;
        struct zebra_if *zi;
        struct irdp_interface *irdp;
@@ -323,7 +322,7 @@ static int irdp_finish(void)
        zlog_info("IRDP: Received shutdown notification.");
 
        RB_FOREACH (vrf, vrf_id_head, &vrfs_by_id)
-               for (ALL_LIST_ELEMENTS(vrf->iflist, node, nnode, ifp)) {
+               RB_FOREACH (ifp, if_name_head, &vrf->ifaces_by_name) {
                        zi = ifp->info;
 
                        if (!zi)
index 633604120c3a292cbf382495a62c580476550d47..c870e291615e3e99cfa83593cb90ece75ff94da8 100644 (file)
@@ -383,7 +383,6 @@ static int rtadv_timer(struct thread *thread)
 {
        struct zebra_ns *zns = THREAD_ARG(thread);
        struct vrf *vrf;
-       struct listnode *node, *nnode;
        struct interface *ifp;
        struct zebra_if *zif;
        int period;
@@ -398,7 +397,7 @@ static int rtadv_timer(struct thread *thread)
        }
 
        RB_FOREACH (vrf, vrf_id_head, &vrfs_by_id)
-               for (ALL_LIST_ELEMENTS(vrf->iflist, node, nnode, ifp)) {
+               RB_FOREACH (ifp, if_name_head, &vrf->ifaces_by_name) {
                        if (if_is_loopback(ifp)
                            || CHECK_FLAG(ifp->status,
                                          ZEBRA_INTERFACE_VRF_LOOPBACK)
index 345637c0440b1e2ce063c91fdbfd28c3e3f36e60..2ee711e1c17ef58b7453d86e3c4f5c619d74585e 100644 (file)
 static void map_slaves_to_bridge(struct interface *br_if, int link)
 {
        struct vrf *vrf;
-       struct listnode *node;
        struct interface *ifp;
 
        RB_FOREACH (vrf, vrf_name_head, &vrfs_by_name) {
-               for (ALL_LIST_ELEMENTS_RO(vrf->iflist, node, ifp)) {
+               RB_FOREACH (ifp, if_name_head, &vrf->ifaces_by_name) {
                        struct zebra_if *zif;
                        struct zebra_l2info_brslave *br_slave;
 
index a42e6680e8a2c185476baf13d27b44d1537cca58..46d16e46c52129136467af1ab3b501dff1906801 100644 (file)
@@ -257,14 +257,13 @@ DEFUN (zebra_ptm_enable,
        "Enable neighbor check with specified topology\n")
 {
        struct vrf *vrf;
-       struct listnode *i;
        struct interface *ifp;
        struct zebra_if *if_data;
 
        ptm_cb.ptm_enable = ZEBRA_IF_PTM_ENABLE_ON;
 
        RB_FOREACH (vrf, vrf_name_head, &vrfs_by_name)
-               for (ALL_LIST_ELEMENTS_RO(vrf->iflist, i, ifp))
+               RB_FOREACH (ifp, if_name_head, &vrf->ifaces_by_name)
                        if (!ifp->ptm_enable) {
                                if_data = (struct zebra_if *)ifp->info;
                                if (if_data
@@ -1088,12 +1087,11 @@ void 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;
 
        RB_FOREACH (vrf, vrf_id_head, &vrfs_by_id)
-               for (ALL_LIST_ELEMENTS_RO(vrf->iflist, i, ifp)) {
+               RB_FOREACH (ifp, if_name_head, &vrf->ifaces_by_name) {
                        send_linkup = 0;
                        if (ifp->ptm_enable) {
                                if (!if_is_operative(ifp))
index bf8a17c3ef1b1ebc0b3d080d9acc143a558a3aea..44a682957ce13b7a2bed6e26c26619100d17e9ef 100644 (file)
@@ -179,7 +179,6 @@ static int zebra_vrf_delete(struct vrf *vrf)
 
        /* uninstall everything */
        if (!CHECK_FLAG(zvrf->flags, ZEBRA_VRF_RETAIN)) {
-               struct listnode *node;
                struct interface *ifp;
 
                for (afi = AFI_IP; afi <= AFI_IP6; afi++) {
@@ -204,7 +203,7 @@ static int zebra_vrf_delete(struct vrf *vrf)
                zebra_mpls_close_tables(zvrf);
                zebra_pw_exit(zvrf);
 
-               for (ALL_LIST_ELEMENTS_RO(vrf->iflist, node, ifp))
+               RB_FOREACH (ifp, if_name_head, &vrf->ifaces_by_name)
                        if_nbr_ipv6ll_to_ipv4ll_neigh_del_all(ifp);
        }
 
index bd7b3cb8d0550cf6fb6e2ba7bec7cb1df89cf538..6066980b271ff9c8b626ee9121f27811dd97f867 100644 (file)
@@ -1211,12 +1211,11 @@ struct interface *zebra_get_vrr_intf_for_svi(struct interface *ifp)
        struct zebra_vrf *zvrf = NULL;
        struct interface *tmp_if = NULL;
        struct zebra_if *zif = NULL;
-       struct listnode *node;
 
        zvrf = vrf_info_lookup(ifp->vrf_id);
        assert(zvrf);
 
-       for (ALL_LIST_ELEMENTS_RO(vrf_iflist(zvrf_id(zvrf)), node, tmp_if)) {
+       RB_FOREACH (tmp_if, if_name_head, &zvrf->vrf->ifaces_by_name) {
                zif = tmp_if->info;
                if (!zif)
                        continue;
index fd2c5dd97cd5d946260f76a1d8b37d16e86c9dd1..2a08a556d5224ce2b9c15d9df23459d2d7e9ba8f 100644 (file)
@@ -998,14 +998,13 @@ static int zread_interface_add(struct zserv *client, u_short length,
                               struct zebra_vrf *zvrf)
 {
        struct vrf *vrf;
-       struct listnode *ifnode, *ifnnode;
        struct interface *ifp;
 
        /* Interface information is needed. */
        vrf_bitmap_set(client->ifinfo, zvrf_id(zvrf));
 
        RB_FOREACH (vrf, vrf_id_head, &vrfs_by_id) {
-               for (ALL_LIST_ELEMENTS(vrf->iflist, ifnode, ifnnode, ifp)) {
+               RB_FOREACH (ifp, if_name_head, &vrf->ifaces_by_name) {
                        /* Skip pseudo interface. */
                        if (!CHECK_FLAG(ifp->status, ZEBRA_INTERFACE_ACTIVE))
                                continue;