]> git.puffer.fish Git - matthieu/frr.git/commitdiff
*: use the FOR_ALL_INTERFACES abstraction from babeld
authorRenato Westphal <renato@opensourcerouting.org>
Fri, 6 Oct 2017 18:25:58 +0000 (15:25 -0300)
committerRenato Westphal <renato@opensourcerouting.org>
Tue, 10 Oct 2017 12:05:46 +0000 (09:05 -0300)
This improves code readability and also future-proofs our codebase
against new changes in the data structure used to store interfaces.

The FOR_ALL_INTERFACES_ADDRESSES macro was also moved to lib/ but
for now only babeld is using it.

Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
47 files changed:
.clang-format
babeld/babel_interface.c
babeld/babel_interface.h
babeld/babeld.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
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 2710d844e9c85ff1291d801fb3d978d2297419a0..21fe9d7c5e570b85d5f68d0c94f37b73f054b516 100644 (file)
@@ -41,6 +41,8 @@ ForEachMacros:
   - RB_FOREACH_REVERSE
   - RB_FOREACH_REVERSE_SAFE
   - SPLAY_FOREACH
+  - FOR_ALL_INTERFACES
+  - FOR_ALL_INTERFACES_ADDRESSES
   # zebra
   - RE_DEST_FOREACH_ROUTE
   - RE_DEST_FOREACH_ROUTE_SAFE
index 5bc48e8a258fc2fdc5bb99d92e81cb8357879ffd..d4958ddf249e35c15d56c7f108510c127492d5a8 100644 (file)
@@ -901,7 +901,7 @@ DEFUN (show_babel_interface,
 
   if (argc == 3)
   {
-    RB_FOREACH (ifp, if_name_head, &vrf->ifaces_by_name)
+    FOR_ALL_INTERFACES (vrf, ifp)
       show_babel_interface_sub (vty, ifp);
     return CMD_SUCCESS;
   }
@@ -1320,7 +1320,7 @@ interface_config_write (struct vty *vty)
     struct interface *ifp;
     int write = 0;
 
-    RB_FOREACH (ifp, if_name_head, &vrf->ifaces_by_name) {
+    FOR_ALL_INTERFACES (vrf, ifp) {
         vty_frame (vty, "interface %s\n",ifp->name);
         if (ifp->desc)
             vty_out (vty, " description %s\n",ifp->desc);
index ce14e5906009b89773b66cc8d393e618214553cb..e9567ab4f8997c3273c14fd89ab68151e8abf341 100644 (file)
@@ -103,16 +103,6 @@ if_up(struct interface *ifp)
             (babel_get_if_nfo(ifp)->flags & BABEL_IF_IS_UP));
 }
 
-/* types:
- 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 */
-#define FOR_ALL_INTERFACES_ADDRESSES(ifp, _connected, _node)                   \
-    for(ALL_LIST_ELEMENTS_RO(ifp->connected, _node, _connected))
-
 struct buffered_update {
     unsigned char id[8];
     unsigned char prefix[16];
@@ -120,7 +110,6 @@ struct buffered_update {
     unsigned char pad[3];
 };
 
-
 /* init function */
 void babel_if_init(void);
 
index b668444656c76cd3d1bec4b1ebefb0686682d45b..00367612c624d94d97e9b6be14d3fe1ecb84c527 100644 (file)
@@ -581,7 +581,7 @@ babel_distribute_update_all (struct prefix_list *notused)
     struct vrf *vrf = vrf_lookup_by_id(VRF_DEFAULT);
     struct interface *ifp;
 
-    RB_FOREACH (ifp, if_name_head, &vrf->ifaces_by_name)
+    FOR_ALL_INTERFACES (vrf, ifp)
         babel_distribute_update_interface (ifp);
 }
 
index aff88694ef967bc0938cd36ed804a1fa937419a4..53c5762ceab153af217a37a61f0f534b5954b970 100644 (file)
@@ -606,7 +606,7 @@ struct interface *if_lookup_by_ipv4(struct in_addr *addr, vrf_id_t vrf_id)
        p.prefix = *addr;
        p.prefixlen = IPV4_MAX_BITLEN;
 
-       RB_FOREACH (ifp, if_name_head, &vrf->ifaces_by_name) {
+       FOR_ALL_INTERFACES (vrf, ifp) {
                for (ALL_LIST_ELEMENTS_RO(ifp->connected, cnode, connected)) {
                        cp = connected->address;
 
@@ -630,7 +630,7 @@ struct interface *if_lookup_by_ipv4_exact(struct in_addr *addr, vrf_id_t vrf_id)
        if (!vrf)
                return NULL;
 
-       RB_FOREACH (ifp, if_name_head, &vrf->ifaces_by_name) {
+       FOR_ALL_INTERFACES (vrf, ifp) {
                for (ALL_LIST_ELEMENTS_RO(ifp->connected, cnode, connected)) {
                        cp = connected->address;
 
@@ -660,7 +660,7 @@ struct interface *if_lookup_by_ipv6(struct in6_addr *addr, ifindex_t ifindex,
        p.prefix = *addr;
        p.prefixlen = IPV6_MAX_BITLEN;
 
-       RB_FOREACH (ifp, if_name_head, &vrf->ifaces_by_name) {
+       FOR_ALL_INTERFACES (vrf, ifp) {
                for (ALL_LIST_ELEMENTS_RO(ifp->connected, cnode, connected)) {
                        cp = connected->address;
 
@@ -691,7 +691,7 @@ struct interface *if_lookup_by_ipv6_exact(struct in6_addr *addr,
        if (!vrf)
                return NULL;
 
-       RB_FOREACH (ifp, if_name_head, &vrf->ifaces_by_name) {
+       FOR_ALL_INTERFACES (vrf, ifp) {
                for (ALL_LIST_ELEMENTS_RO(ifp->connected, cnode, connected)) {
                        cp = connected->address;
 
index d8a4852ff66f2abb1b86841e41e71fbcdb5e2093..d223cecc592ff3e76afba41cdd38318e4a9ea327 100644 (file)
@@ -7348,7 +7348,7 @@ static void bgp_if_finish(struct bgp *bgp)
        if (bgp->inst_type == BGP_INSTANCE_TYPE_VIEW || !vrf)
                return;
 
-       RB_FOREACH (ifp, if_name_head, &vrf->ifaces_by_name) {
+       FOR_ALL_INTERFACES (vrf, ifp) {
                struct listnode *c_node, *c_nnode;
                struct connected *c;
 
index fd2e71466a573245af9a3b1eb289c9a086bc5b7d..7a8fd027ca09fbb9c0e55eed67defd79d609a0ae 100644 (file)
@@ -298,7 +298,7 @@ void eigrp_distribute_update_all(struct prefix_list *notused)
        struct vrf *vrf = vrf_lookup_by_id(VRF_DEFAULT);
        struct interface *ifp;
 
-       RB_FOREACH (ifp, if_name_head, &vrf->ifaces_by_name)
+       FOR_ALL_INTERFACES (vrf, ifp)
                eigrp_distribute_update_interface(ifp);
 }
 
index 56b63597e12aaa26a04397c315794d4c81472978..56327f12051fdfb9d4f0318107084856016e7951 100644 (file)
@@ -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. */
-       RB_FOREACH (ifp, if_name_head, &vrf->ifaces_by_name) {
+       FOR_ALL_INTERFACES (vrf, ifp) {
                zlog_debug("Setting up %s", ifp->name);
                eigrp_network_run_interface(eigrp, p, ifp);
        }
index 5ca3a3bef28634693847cb0c680ff0de6fac1154..d93abbb8b7183c50283ff50971cacbbef430b10c 100644 (file)
@@ -136,7 +136,7 @@ static int eigrp_write_interface(struct vty *vty)
        struct interface *ifp;
        struct eigrp_interface *ei;
 
-       RB_FOREACH (ifp, if_name_head, &vrf->ifaces_by_name) {
+       FOR_ALL_INTERFACES (vrf, ifp) {
                ei = ifp->info;
                if (!ei)
                        continue;
index 1f2c5927163b1e7949369fa002e23a8f47875a67..a8173f4efdc21943d78c4847c92f48f162a70ece 100644 (file)
@@ -116,7 +116,7 @@ void eigrp_router_id_update(struct eigrp *eigrp)
                //        inet_ntoa(eigrp->router_id));
 
                /* update eigrp_interface's */
-               RB_FOREACH (ifp, if_name_head, &vrf->ifaces_by_name)
+               FOR_ALL_INTERFACES (vrf, ifp)
                        eigrp_if_update(ifp);
        }
 }
index 939dc71beebfc7ccc08b62ee6cb086a76400f1f1..5e4090facc4be460ad8dde9bbaaf649b74552933 100644 (file)
@@ -940,7 +940,7 @@ int isis_interface_config_write(struct vty *vty)
        struct isis_circuit *circuit;
        int i;
 
-       RB_FOREACH (ifp, if_name_head, &vrf->ifaces_by_name) {
+       FOR_ALL_INTERFACES (vrf, ifp) {
                /* IF name */
                vty_frame(vty, "interface %s\n", ifp->name);
                write++;
index dda5781c2cbc495847707951a60b937129c6705a..104a0fd4bf2bcdda62d40aa240b387589619bdce 100644 (file)
@@ -1251,7 +1251,7 @@ DEFUN (show_isis_mpls_te_interface,
 
        /* Show All Interfaces. */
        if (argc == 4) {
-               RB_FOREACH (ifp, if_name_head, &vrf->ifaces_by_name)
+               FOR_ALL_INTERFACES (vrf, ifp)
                        show_mpls_te_sub(vty, ifp);
        }
        /* Interface name is specified. */
index f6dfe96dc4e5a28b0cb7fdf649bb726fa5b21b9c..7f68f0b69438df54476d70d56f4d24fa9027226f 100644 (file)
@@ -219,7 +219,7 @@ kif_redistribute(const char *ifname)
        struct kif               kif;
        struct kaddr             ka;
 
-       RB_FOREACH (ifp, if_name_head, &vrf->ifaces_by_name) {
+       FOR_ALL_INTERFACES (vrf, ifp) {
                if (ifname && strcmp(ifname, ifp->name) != 0)
                        continue;
 
index 36fd509bcba65c9d1a01951b811abd018d770155..320dfba4b5a5be695ce91217c496dbb73567fc01 100644 (file)
--- a/lib/if.c
+++ b/lib/if.c
@@ -278,7 +278,7 @@ struct interface *if_lookup_exact_address(void *src, int family,
        struct prefix *p;
        struct connected *c;
 
-       RB_FOREACH (ifp, if_name_head, &vrf->ifaces_by_name) {
+       FOR_ALL_INTERFACES (vrf, ifp) {
                for (ALL_LIST_ELEMENTS_RO(ifp->connected, cnode, c)) {
                        p = c->address;
 
@@ -324,7 +324,7 @@ struct connected *if_lookup_address(void *matchaddr, int family,
 
        match = NULL;
 
-       RB_FOREACH (ifp, if_name_head, &vrf->ifaces_by_name) {
+       FOR_ALL_INTERFACES (vrf, ifp) {
                for (ALL_LIST_ELEMENTS_RO(ifp->connected, cnode, c)) {
                        if (c->address && (c->address->family == AF_INET)
                            && prefix_match(CONNECTED_PREFIX(c), &addr)
@@ -345,7 +345,7 @@ struct interface *if_lookup_prefix(struct prefix *prefix, vrf_id_t vrf_id)
        struct interface *ifp;
        struct connected *c;
 
-       RB_FOREACH (ifp, if_name_head, &vrf->ifaces_by_name) {
+       FOR_ALL_INTERFACES (vrf, ifp) {
                for (ALL_LIST_ELEMENTS_RO(ifp->connected, cnode, c)) {
                        if (prefix_cmp(c->address, prefix) == 0) {
                                return ifp;
@@ -528,7 +528,7 @@ void if_dump_all(void)
        void *ifp;
 
        RB_FOREACH (vrf, vrf_id_head, &vrfs_by_id)
-               RB_FOREACH (ifp, if_name_head, &vrf->ifaces_by_name)
+               FOR_ALL_INTERFACES (vrf, ifp)
                        if_dump(ifp);
 }
 
@@ -685,7 +685,7 @@ static void if_autocomplete(vector comps, struct cmd_token *token)
        struct vrf *vrf = NULL;
 
        RB_FOREACH (vrf, vrf_name_head, &vrfs_by_name) {
-               RB_FOREACH (ifp, if_name_head, &vrf->ifaces_by_name) {
+               FOR_ALL_INTERFACES (vrf, ifp) {
                        vector_set(comps, XSTRDUP(MTYPE_COMPLETION, ifp->name));
                }
        }
@@ -730,7 +730,7 @@ DEFUN (show_address,
   if (argc > 2)
     VRF_GET_ID (vrf_id, argv[idx_vrf]->arg);
 
-  RB_FOREACH (ifp, if_name_head, &vrf->ifaces_by_name)
+  FOR_ALL_INTERFACES (vrf, ifp)
     {
       for (ALL_LIST_ELEMENTS_RO (ifp->connected, node, ifc))
        {
@@ -763,7 +763,7 @@ DEFUN (show_address_vrf_all,
 
       vty_out (vty, "\nVRF %u\n\n", vrf->vrf_id);
 
-      RB_FOREACH (ifp, if_name_head, &vrf->ifaces_by_name)
+      FOR_ALL_INTERFACES (vrf, ifp)
         {
           for (ALL_LIST_ELEMENTS_RO (ifp->connected, node, ifc))
             {
index 3e2824b6c952dc6cd22d8b0becbe388df9fc235e..eb8af2041b21fdb0f8f62cde261cf2a9712c766c 100644 (file)
--- a/lib/if.h
+++ b/lib/if.h
@@ -322,6 +322,13 @@ DECLARE_QOBJ_TYPE(interface)
                        "ifindex doesn't exist in VRF %u!",                    \
                        __func__, (ifp)->ifindex, (ifp)->vrf_id);
 
+#define FOR_ALL_INTERFACES(vrf, ifp)                                           \
+       if (vrf)                                                               \
+               RB_FOREACH (ifp, if_name_head, &vrf->ifaces_by_name)
+
+#define FOR_ALL_INTERFACES_ADDRESSES(ifp, connected, node)                     \
+       for (ALL_LIST_ELEMENTS_RO(ifp->connected, node, connected))
+
 /* called from the library code whenever interfaces are created/deleted
  * note: interfaces may not be fully realized at that point; also they
  * may not exist in the system (ifindex = IFINDEX_INTERNAL)
index 3a4135a535c68706b7ab9d6dbc5e3904e85b8315..6fbd6ca2242f3502dedd1bf6f138591c7556d2f8 100644 (file)
@@ -358,7 +358,7 @@ void nhrp_nhs_terminate(void)
        struct nhrp_nhs *nhs, *tmp;
        afi_t afi;
 
-       RB_FOREACH (ifp, if_name_head, &vrf->ifaces_by_name) {
+       FOR_ALL_INTERFACES (vrf, ifp) {
                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 48386c350941e2104df263f112615383d6618feb..ab052ac04a141e4cf7156322cf2d3ea72db2fb87 100644 (file)
@@ -720,17 +720,17 @@ DEFUN(show_ip_nhrp, show_ip_nhrp_cmd,
        };
 
        if (argc <= 3 || argv[3]->text[0] == 'c') {
-               RB_FOREACH (ifp, if_name_head, &vrf->ifaces_by_name)
+               FOR_ALL_INTERFACES (vrf, ifp)
                        nhrp_cache_foreach(ifp, show_ip_nhrp_cache, &ctx);
        } else if (argv[3]->text[0] == 'n') {
-               RB_FOREACH (ifp, if_name_head, &vrf->ifaces_by_name)
+               FOR_ALL_INTERFACES (vrf, ifp)
                        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++;
-               RB_FOREACH (ifp, if_name_head, &vrf->ifaces_by_name)
+               FOR_ALL_INTERFACES (vrf, ifp)
                        nhrp_cache_foreach(ifp, show_ip_opennhrp_cache, &ctx);
        }
 
@@ -805,7 +805,7 @@ DEFUN(clear_nhrp, clear_nhrp_cmd,
        };
 
        if (argc <= 3 || argv[3]->text[0] == 'c') {
-               RB_FOREACH (ifp, if_name_head, &vrf->ifaces_by_name)
+               FOR_ALL_INTERFACES (vrf, ifp)
                        nhrp_cache_foreach(ifp, clear_nhrp_cache, &ctx);
        } else {
                nhrp_shortcut_foreach(ctx.afi, clear_nhrp_shortcut, &ctx);
@@ -853,7 +853,7 @@ static int interface_config_write(struct vty *vty)
        char buf[SU_ADDRSTRLEN];
        int i;
 
-       RB_FOREACH (ifp, if_name_head, &vrf->ifaces_by_name) {
+       FOR_ALL_INTERFACES (vrf, ifp) {
                vty_frame(vty, "interface %s\n", ifp->name);
                if (ifp->desc)
                        vty_out (vty, " description %s\n", ifp->desc);
index 9f5d9fbd88a9e3f1a3b5b074e8fea5c8c1a754d1..e28af9d06d7a7ddf35e244803bce22135f6a8c5f 100644 (file)
@@ -155,7 +155,7 @@ 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*/
-       RB_FOREACH (ifp, if_name_head, &vrf->ifaces_by_name) {
+       FOR_ALL_INTERFACES (vrf, ifp) {
                oi = (struct ospf6_interface *)ifp->info;
 
                if (!oi || !oi->bfd_info)
index f8cefbf9ecc8199d0b0020c6ef71f8e555248427..f237e4bef3ac9060db911303888786fca77174f2 100644 (file)
@@ -996,7 +996,7 @@ DEFUN (show_ipv6_ospf6_interface,
                }
                ospf6_interface_show(vty, ifp);
        } else {
-               RB_FOREACH (ifp, if_name_head, &vrf->ifaces_by_name)
+               FOR_ALL_INTERFACES (vrf, ifp)
                        ospf6_interface_show(vty, ifp);
        }
 
@@ -1059,7 +1059,7 @@ DEFUN (show_ipv6_ospf6_interface_prefix,
        struct ospf6_interface *oi;
        struct interface *ifp;
 
-       RB_FOREACH (ifp, if_name_head, &vrf->ifaces_by_name) {
+       FOR_ALL_INTERFACES (vrf, ifp) {
                oi = (struct ospf6_interface *)ifp->info;
                if (oi == NULL)
                        continue;
@@ -1759,7 +1759,7 @@ static int config_write_ospf6_interface(struct vty *vty)
        struct ospf6_interface *oi;
        struct interface *ifp;
 
-       RB_FOREACH (ifp, if_name_head, &vrf->ifaces_by_name) {
+       FOR_ALL_INTERFACES (vrf, ifp) {
                oi = (struct ospf6_interface *)ifp->info;
                if (oi == NULL)
                        continue;
@@ -1911,7 +1911,7 @@ DEFUN (clear_ipv6_ospf6_interface,
 
        if (argc == 4) /* Clear all the ospfv3 interfaces. */
        {
-               RB_FOREACH (ifp, if_name_head, &vrf->ifaces_by_name)
+               FOR_ALL_INTERFACES (vrf, ifp)
                        ospf6_interface_clear(vty, ifp);
        } else /* Interface name is specified. */
        {
index 2a6e56deb6cbcb80eb9ea5cb862dbc4eacd50895..4641f41c3380116def16348979df544fa7ec7bb6 100644 (file)
@@ -89,7 +89,7 @@ static void __attribute__((noreturn)) ospf6_exit(int status)
 
        bfd_gbl_exit();
 
-       RB_FOREACH (ifp, if_name_head, &vrf->ifaces_by_name)
+       FOR_ALL_INTERFACES (vrf, ifp)
                if (ifp->info != NULL)
                        ospf6_interface_delete(ifp->info);
 
index dfe69aa0e78020fc96aa8e62a5946627f1f075d9..c148107449a6f2f3375b8bcbe2cfa26bdee000ba 100644 (file)
@@ -956,7 +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;
-                       RB_FOREACH (iif, if_name_head, &vrf->ifaces_by_name)
+                       FOR_ALL_INTERFACES (vrf, iif)
                                listnode_add_sort(ifslist, iif);
 
                        for (ALL_LIST_ELEMENTS_RO(ifslist, node, iif)) {
@@ -1093,7 +1093,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;
-               RB_FOREACH (iif, if_name_head, &vrf->ifaces_by_name)
+               FOR_ALL_INTERFACES (vrf, iif)
                        listnode_add_sort(ifslist, iif);
 
                for (ALL_LIST_ELEMENTS_RO(ifslist, i, iif)) {
@@ -1255,7 +1255,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;
-               RB_FOREACH (iif, if_name_head, &vrf->ifaces_by_name)
+               FOR_ALL_INTERFACES (vrf, iif)
                        listnode_add_sort(ifslist, iif);
 
                for (ALL_LIST_ELEMENTS_RO(ifslist, i, iif)) {
index 95610e4c78b4bcf2e235d330d870830ffc1e47bd..86f7e7a53d1c6d17fa212ec56e04f3604f716546 100644 (file)
@@ -2555,8 +2555,7 @@ DEFUN (show_ip_ospf_mpls_te_link,
                                if (!ospf->oi_running)
                                        continue;
                                vrf = vrf_lookup_by_id(ospf->vrf_id);
-                               RB_FOREACH (ifp, if_name_head,
-                                           &vrf->ifaces_by_name)
+                               FOR_ALL_INTERFACES (vrf, ifp)
                                        show_mpls_te_link_sub(vty, ifp);
                        }
                        return CMD_SUCCESS;
@@ -2565,7 +2564,7 @@ DEFUN (show_ip_ospf_mpls_te_link,
                if (ospf == NULL || !ospf->oi_running)
                        return CMD_SUCCESS;
                vrf = vrf_lookup_by_id(ospf->vrf_id);
-               RB_FOREACH (ifp, if_name_head, &vrf->ifaces_by_name)
+               FOR_ALL_INTERFACES (vrf, ifp)
                        show_mpls_te_link_sub(vty, ifp);
                return CMD_SUCCESS;
        }
@@ -2575,7 +2574,7 @@ DEFUN (show_ip_ospf_mpls_te_link,
                        if (!ospf->oi_running)
                                continue;
                        vrf = vrf_lookup_by_id(ospf->vrf_id);
-                       RB_FOREACH (ifp, if_name_head, &vrf->ifaces_by_name)
+                       FOR_ALL_INTERFACES (vrf, ifp)
                                show_mpls_te_link_sub(vty, ifp);
                }
        }
index a755bb7e65d941679628224e201ab709863ea302..087cb6f89ea472c6cb5b8558ec6317f6c54ebe5b 100644 (file)
@@ -340,7 +340,7 @@ static void ospf_passive_interface_default(struct ospf *ospf, u_char newval)
 
        ospf->passive_interface_default = newval;
 
-       RB_FOREACH (ifp, if_name_head, &vrf->ifaces_by_name) {
+       FOR_ALL_INTERFACES (vrf, ifp) {
                if (ifp && OSPF_IF_PARAM_CONFIGURED(IF_DEF_PARAMS(ifp),
                                                    passive_interface))
                        UNSET_IF_PARAM(IF_DEF_PARAMS(ifp), passive_interface);
@@ -2474,7 +2474,7 @@ DEFUN (ospf_auto_cost_reference_bandwidth,
                return CMD_SUCCESS;
 
        ospf->ref_bandwidth = refbw;
-       RB_FOREACH (ifp, if_name_head, &vrf->ifaces_by_name)
+       FOR_ALL_INTERFACES (vrf, ifp)
                ospf_if_recalculate_output_cost(ifp);
 
        return CMD_SUCCESS;
@@ -2500,7 +2500,7 @@ DEFUN (no_ospf_auto_cost_reference_bandwidth,
        vty_out(vty,
                "        Please ensure reference bandwidth is consistent across all routers\n");
 
-       RB_FOREACH (ifp, if_name_head, &vrf->ifaces_by_name)
+       FOR_ALL_INTERFACES (vrf, ifp)
                ospf_if_recalculate_output_cost(ifp);
 
        return CMD_SUCCESS;
@@ -3574,7 +3574,7 @@ static int show_ip_ospf_interface_common(struct vty *vty, struct ospf *ospf,
 
        if (argc == iface_argv) {
                /* Show All Interfaces.*/
-               RB_FOREACH (ifp, if_name_head, &vrf->ifaces_by_name) {
+               FOR_ALL_INTERFACES (vrf, ifp) {
                        if (ospf_oi_count(ifp)) {
                                if (use_json)
                                        json_interface_sub =
@@ -8641,7 +8641,7 @@ static int config_write_interface_one(struct vty *vty, struct ospf *ospf)
        struct ospf_if_params *params;
        int write = 0;
 
-       RB_FOREACH (ifp, if_name_head, &vrf->ifaces_by_name) {
+       FOR_ALL_INTERFACES (vrf, ifp) {
                struct vrf *vrf = NULL;
 
                if (memcmp(ifp->name, "VLINK", 5) == 0)
@@ -9327,7 +9327,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");
 
-       RB_FOREACH (ifp, if_name_head, &vrf->ifaces_by_name)
+       FOR_ALL_INTERFACES (vrf, ifp)
                if (OSPF_IF_PARAM_CONFIGURED(IF_DEF_PARAMS(ifp),
                                             passive_interface)
                    && IF_DEF_PARAMS(ifp)->passive_interface
@@ -9597,7 +9597,7 @@ DEFUN (clear_ip_ospf_interface,
        {
                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)
+                       FOR_ALL_INTERFACES (vrf, ifp)
                                ospf_interface_clear(ifp);
                }
        } else {
index e6d58d7a391f99b17a3fa156ad139e4ff1b48ac0..25a1ea2c8dd60b58cbcdd7426e522fa19d68524a 100644 (file)
@@ -210,7 +210,7 @@ void ospf_router_id_update(struct ospf *ospf)
                ospf_router_lsa_update(ospf);
 
                /* update ospf_interface's */
-               RB_FOREACH (ifp, if_name_head, &vrf->ifaces_by_name)
+               FOR_ALL_INTERFACES (vrf, ifp)
                        ospf_if_update(ospf, ifp);
        }
 }
@@ -624,7 +624,7 @@ static void ospf_finish_final(struct ospf *ospf)
        list_delete_and_null(&ospf->vlinks);
 
        /* Remove any ospf interface config params */
-       RB_FOREACH (ifp, if_name_head, &vrf->ifaces_by_name) {
+       FOR_ALL_INTERFACES (vrf, ifp) {
                struct ospf_if_params *params;
 
                params = IF_DEF_PARAMS(ifp);
@@ -1261,7 +1261,7 @@ static void ospf_network_run(struct prefix *p, struct ospf_area *area)
                ospf_router_id_update(area->ospf);
 
        /* Get target interface. */
-       RB_FOREACH (ifp, if_name_head, &vrf->ifaces_by_name)
+       FOR_ALL_INTERFACES (vrf, ifp)
                ospf_network_run_interface(area->ospf, ifp, p, area);
 }
 
index c8d1113871cc393a917a63fd970a942582753b1a..f8903d71e9f7d1f56ed092677646ace3f125afb6 100644 (file)
@@ -300,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) {
-               RB_FOREACH (ifp, if_name_head, &vrf->ifaces_by_name) {
+               FOR_ALL_INTERFACES (vrf, ifp) {
                        pim_ifp = ifp->info;
 
                        if (!pim_ifp)
index cd55e0fa12f894f73d45036367501d6f3911d3e2..e3fc0b431f7ebfcc0ef2227ceb762ed04fe8cfce 100644 (file)
@@ -222,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");
 
-       RB_FOREACH (ifp, if_name_head, &pim->vrf->ifaces_by_name) {
+       FOR_ALL_INTERFACES (pim->vrf, ifp) {
                pim_ifp = ifp->info;
                if (!pim_ifp)
                        continue;
@@ -273,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");
-       RB_FOREACH (ifp, if_name_head, &pim->vrf->ifaces_by_name) {
+       FOR_ALL_INTERFACES (pim->vrf, ifp) {
                pim_ifp = ifp->info;
                if (!pim_ifp)
                        continue;
@@ -321,7 +321,7 @@ static void pim_show_assert_metric(struct pim_instance *pim, struct vty *vty)
        vty_out(vty,
                "Interface Address         Source          Group           RPT Pref Metric Address        \n");
 
-       RB_FOREACH (ifp, if_name_head, &pim->vrf->ifaces_by_name) {
+       FOR_ALL_INTERFACES (pim->vrf, ifp) {
                pim_ifp = ifp->info;
                if (!pim_ifp)
                        continue;
@@ -383,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");
 
-       RB_FOREACH (ifp, if_name_head, &pim->vrf->ifaces_by_name) {
+       FOR_ALL_INTERFACES (pim->vrf, ifp) {
                pim_ifp = ifp->info;
                if (!pim_ifp)
                        continue;
@@ -472,7 +472,7 @@ static void pim_show_membership(struct pim_instance *pim, struct vty *vty,
 
        json = json_object_new_object();
 
-       RB_FOREACH (ifp, if_name_head, &pim->vrf->ifaces_by_name) {
+       FOR_ALL_INTERFACES (pim->vrf, ifp) {
                pim_ifp = ifp->info;
                if (!pim_ifp)
                        continue;
@@ -593,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");
 
-       RB_FOREACH (ifp, if_name_head, &pim->vrf->ifaces_by_name) {
+       FOR_ALL_INTERFACES (pim->vrf, ifp) {
                struct pim_interface *pim_ifp;
                struct listnode *sock_node;
                struct igmp_sock *igmp;
@@ -683,7 +683,7 @@ static void igmp_show_interfaces_single(struct pim_instance *pim,
 
        now = pim_time_monotonic_sec();
 
-       RB_FOREACH (ifp, if_name_head, &pim->vrf->ifaces_by_name) {
+       FOR_ALL_INTERFACES (pim->vrf, ifp) {
                pim_ifp = ifp->info;
 
                if (!pim_ifp)
@@ -867,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");
 
-       RB_FOREACH (ifp, if_name_head, &pim->vrf->ifaces_by_name) {
+       FOR_ALL_INTERFACES (pim->vrf, ifp) {
                struct pim_interface *pim_ifp;
                struct listnode *join_node;
                struct igmp_join *ij;
@@ -947,7 +947,7 @@ static void pim_show_interfaces_single(struct pim_instance *pim,
        if (uj)
                json = json_object_new_object();
 
-       RB_FOREACH (ifp, if_name_head, &pim->vrf->ifaces_by_name) {
+       FOR_ALL_INTERFACES (pim->vrf, ifp) {
                pim_ifp = ifp->info;
 
                if (!pim_ifp)
@@ -1341,7 +1341,7 @@ static void pim_show_interfaces(struct pim_instance *pim, struct vty *vty,
 
        json = json_object_new_object();
 
-       RB_FOREACH (ifp, if_name_head, &pim->vrf->ifaces_by_name) {
+       FOR_ALL_INTERFACES (pim->vrf, ifp) {
                pim_ifp = ifp->info;
 
                if (!pim_ifp)
@@ -1440,7 +1440,7 @@ static void pim_show_interface_traffic(struct pim_instance *pim,
                        "---------------------------------------------------------------------------------------------------------------\n");
        }
 
-       RB_FOREACH (ifp, if_name_head, &pim->vrf->ifaces_by_name) {
+       FOR_ALL_INTERFACES (pim->vrf, ifp) {
                pim_ifp = ifp->info;
 
                if (!pim_ifp)
@@ -1521,7 +1521,7 @@ static void pim_show_interface_traffic_single(struct pim_instance *pim,
                        "---------------------------------------------------------------------------------------------------------------\n");
        }
 
-       RB_FOREACH (ifp, if_name_head, &pim->vrf->ifaces_by_name) {
+       FOR_ALL_INTERFACES (pim->vrf, ifp) {
                if (strcmp(ifname, ifp->name))
                        continue;
 
@@ -1680,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");
 
-       RB_FOREACH (ifp, if_name_head, &pim->vrf->ifaces_by_name) {
+       FOR_ALL_INTERFACES (pim->vrf, ifp) {
                pim_ifp = ifp->info;
                if (!pim_ifp)
                        continue;
@@ -1725,7 +1725,7 @@ static void pim_show_neighbors_single(struct pim_instance *pim, struct vty *vty,
        if (uj)
                json = json_object_new_object();
 
-       RB_FOREACH (ifp, if_name_head, &pim->vrf->ifaces_by_name) {
+       FOR_ALL_INTERFACES (pim->vrf, ifp) {
                pim_ifp = ifp->info;
 
                if (!pim_ifp)
@@ -2132,7 +2132,7 @@ static void pim_show_neighbors(struct pim_instance *pim, struct vty *vty,
                        "Interface         Neighbor    Uptime  Holdtime  DR Pri\n");
        }
 
-       RB_FOREACH (ifp, if_name_head, &pim->vrf->ifaces_by_name) {
+       FOR_ALL_INTERFACES (pim->vrf, ifp) {
                pim_ifp = ifp->info;
 
                if (!pim_ifp)
@@ -2198,7 +2198,7 @@ static void pim_show_neighbors_secondary(struct pim_instance *pim,
        vty_out(vty,
                "Interface Address         Neighbor        Secondary      \n");
 
-       RB_FOREACH (ifp, if_name_head, &pim->vrf->ifaces_by_name) {
+       FOR_ALL_INTERFACES (pim->vrf, ifp) {
                struct pim_interface *pim_ifp;
                struct in_addr ifaddr;
                struct listnode *neighnode;
@@ -2504,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 */
-       RB_FOREACH (ifp, if_name_head, &pim->vrf->ifaces_by_name) {
+       FOR_ALL_INTERFACES (pim->vrf, ifp) {
                pim_ifp = ifp->info;
                if (!pim_ifp)
                        continue;
@@ -2800,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 */
-       RB_FOREACH (ifp, if_name_head, &pim->vrf->ifaces_by_name) {
+       FOR_ALL_INTERFACES (pim->vrf, ifp) {
                struct pim_interface *pim_ifp = ifp->info;
                struct listnode *sock_node;
                struct igmp_sock *igmp;
@@ -2912,7 +2912,7 @@ static void igmp_show_group_retransmission(struct pim_instance *pim,
                "Interface Address         Group           RetTimer Counter RetSrcs\n");
 
        /* scan interfaces */
-       RB_FOREACH (ifp, if_name_head, &pim->vrf->ifaces_by_name) {
+       FOR_ALL_INTERFACES (pim->vrf, ifp) {
                struct pim_interface *pim_ifp = ifp->info;
                struct listnode *sock_node;
                struct igmp_sock *igmp;
@@ -2979,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 */
-       RB_FOREACH (ifp, if_name_head, &pim->vrf->ifaces_by_name) {
+       FOR_ALL_INTERFACES (pim->vrf, ifp) {
                struct pim_interface *pim_ifp = ifp->info;
                struct listnode *sock_node;
                struct igmp_sock *igmp;
@@ -3052,7 +3052,7 @@ static void igmp_show_source_retransmission(struct pim_instance *pim,
                "Interface Address         Group           Source          Counter\n");
 
        /* scan interfaces */
-       RB_FOREACH (ifp, if_name_head, &pim->vrf->ifaces_by_name) {
+       FOR_ALL_INTERFACES (pim->vrf, ifp) {
                struct pim_interface *pim_ifp = ifp->info;
                struct listnode *sock_node;
                struct igmp_sock *igmp;
@@ -3106,10 +3106,10 @@ static void clear_igmp_interfaces(struct pim_instance *pim)
 {
        struct interface *ifp;
 
-       RB_FOREACH (ifp, if_name_head, &pim->vrf->ifaces_by_name)
+       FOR_ALL_INTERFACES (pim->vrf, ifp)
                pim_if_addr_del_all_igmp(ifp);
 
-       RB_FOREACH (ifp, if_name_head, &pim->vrf->ifaces_by_name)
+       FOR_ALL_INTERFACES (pim->vrf, ifp)
                pim_if_addr_add_all(ifp);
 }
 
@@ -3117,7 +3117,7 @@ static void clear_pim_interfaces(struct pim_instance *pim)
 {
        struct interface *ifp;
 
-       RB_FOREACH (ifp, if_name_head, &pim->vrf->ifaces_by_name) {
+       FOR_ALL_INTERFACES (pim->vrf, ifp) {
                if (ifp->info) {
                        pim_neighbor_delete_all(ifp, "interface cleared");
                }
@@ -3277,7 +3277,7 @@ DEFUN (clear_ip_pim_interface_traffic,
        if (!vrf)
                return CMD_WARNING;
 
-       RB_FOREACH (ifp, if_name_head, &vrf->ifaces_by_name) {
+       FOR_ALL_INTERFACES (vrf, ifp) {
                pim_ifp = ifp->info;
 
                if (!pim_ifp)
@@ -4294,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");
 
-       RB_FOREACH (ifp, if_name_head, &pim->vrf->ifaces_by_name) {
+       FOR_ALL_INTERFACES (pim->vrf, ifp) {
                struct pim_interface *pim_ifp;
                struct in_addr ifaddr;
                struct sioc_vif_req vreq;
index 09b5fe2bf7fdac6b2c49c7e0b9dc1e5d2c31e5df..5dc64a1b3fea08201863ef25dae4b1742cda12d7 100644 (file)
@@ -1025,7 +1025,7 @@ struct interface *pim_if_find_by_vif_index(struct pim_instance *pim,
 {
        struct interface *ifp;
 
-       RB_FOREACH (ifp, if_name_head, &pim->vrf->ifaces_by_name) {
+       FOR_ALL_INTERFACES (pim->vrf, ifp) {
                if (ifp->info) {
                        struct pim_interface *pim_ifp;
                        pim_ifp = ifp->info;
index 71897afcea7bd12b21b662382b84cd38ea8e3600..5f597b17b1b0f009138644a3fb8ae2f31da7d93a 100644 (file)
@@ -1293,7 +1293,7 @@ void pim_ifchannel_scan_forward_start(struct interface *new_ifp)
        struct pim_instance *pim = new_pim_ifp->pim;
        struct interface *ifp;
 
-       RB_FOREACH (ifp, if_name_head, &pim->vrf->ifaces_by_name) {
+       FOR_ALL_INTERFACES (pim->vrf, ifp) {
                struct pim_interface *loop_pim_ifp = ifp->info;
                struct pim_ifchannel *ch;
 
index 3ec0a620fce843e263bc917e5adfe7a18938a11b..e87dfbca95b89b1e9aac68ce1668b0636ea858ff 100644 (file)
@@ -216,7 +216,7 @@ void pim_jp_agg_upstream_verification(struct pim_upstream *up, bool ignore)
        struct pim_interface *pim_ifp = up->rpf.source_nexthop.interface->info;
        struct pim_instance *pim = pim_ifp->pim;
 
-       RB_FOREACH (ifp, if_name_head, &pim->vrf->ifaces_by_name) {
+       FOR_ALL_INTERFACES (pim->vrf, ifp) {
                pim_ifp = ifp->info;
                struct listnode *nnode;
 
index 78b160f6a2aec00f1f8c713e0bfef4c3d10f5475..8f9058d99478df4be66471edd757e27031663cdb 100644 (file)
@@ -415,7 +415,7 @@ static int pim_update_upstream_nh(struct pim_instance *pim,
 
        hash_walk(pnc->upstream_hash, pim_update_upstream_nh_helper, pim);
 
-       RB_FOREACH (ifp, if_name_head, &pim->vrf->ifaces_by_name)
+       FOR_ALL_INTERFACES (pim->vrf, ifp)
                if (ifp->info) {
                        struct pim_interface *pim_ifp = ifp->info;
                        struct pim_iface_upstream_switch *us;
index c1ecf687005b92127346175e64c78fd5fb14760d..d961aa4c4970cc86cde35c4395be620f3fc2a69f 100644 (file)
@@ -335,7 +335,7 @@ static void pim_rp_check_interfaces(struct pim_instance *pim,
        struct interface *ifp;
 
        rp_info->i_am_rp = 0;
-       RB_FOREACH (ifp, if_name_head, &pim->vrf->ifaces_by_name) {
+       FOR_ALL_INTERFACES (pim->vrf, ifp) {
                struct pim_interface *pim_ifp = ifp->info;
 
                if (!pim_ifp)
index 47a70eb0947684603c49021d8d470553b5151c01..fdd37f2b91bf17c5dfab3b165572870d29f17acb 100644 (file)
@@ -868,7 +868,7 @@ int pim_upstream_evaluate_join_desired(struct pim_instance *pim,
        struct pim_upstream *starup = up->parent;
        int ret = 0;
 
-       RB_FOREACH (ifp, if_name_head, &pim->vrf->ifaces_by_name) {
+       FOR_ALL_INTERFACES (pim->vrf, ifp) {
                if (!ifp->info)
                        continue;
 
@@ -1439,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);
 
-       RB_FOREACH (ifp, if_name_head, &pim->vrf->ifaces_by_name) {
+       FOR_ALL_INTERFACES (pim->vrf, ifp) {
                if (!ifp->info)
                        continue;
 
index 9b60e284e8f54faa3306460856b8a6f7ddc8f941..450faf75bbc1138894ab49ff618e92c7f1cc17be 100644 (file)
@@ -249,7 +249,7 @@ int pim_interface_config_write(struct vty *vty)
                if (!pim)
                        continue;
 
-               RB_FOREACH (ifp, if_name_head, &pim->vrf->ifaces_by_name) {
+               FOR_ALL_INTERFACES (pim->vrf, ifp) {
                        /* IF name */
                        if (vrf->vrf_id == VRF_DEFAULT)
                                vty_frame(vty, "interface %s\n", ifp->name);
index 3424eded92526188de6eec00fdb89b1629c47791..db11e5f17119c5072aa91e2fe3301d671a824531 100644 (file)
@@ -333,7 +333,7 @@ static int pim_zebra_if_address_add(int command, struct zclient *zclient,
                struct vrf *vrf = vrf_lookup_by_id(VRF_DEFAULT);
                struct interface *ifp;
 
-               RB_FOREACH (ifp, if_name_head, &vrf->ifaces_by_name) {
+               FOR_ALL_INTERFACES (vrf, ifp) {
                        if (!if_is_loopback(ifp) && if_is_operative(ifp))
                                pim_if_addr_add_all(ifp);
                }
@@ -500,7 +500,7 @@ static void scan_upstream_rpf_cache()
                if (!pim)
                        continue;
 
-               RB_FOREACH (ifp, if_name_head, &pim->vrf->ifaces_by_name)
+               FOR_ALL_INTERFACES (pim->vrf, ifp)
                        if (ifp->info) {
                                struct pim_interface *pim_ifp = ifp->info;
                                struct pim_iface_upstream_switch *us;
@@ -869,7 +869,7 @@ void igmp_source_forward_reevaluate_all(void)
                if (!pim)
                        continue;
 
-               RB_FOREACH (ifp, if_name_head, &pim->vrf->ifaces_by_name) {
+               FOR_ALL_INTERFACES (pim->vrf, ifp) {
                        struct pim_interface *pim_ifp = ifp->info;
                        struct listnode *sock_node;
                        struct igmp_sock *igmp;
index 21950c9f2bd01c37fb7ae2d444549af0e6ea50bf..9282896c2845db2b1ffe77127033168d79069658 100644 (file)
@@ -339,7 +339,7 @@ int if_check_address(struct in_addr addr)
        struct vrf *vrf = vrf_lookup_by_id(VRF_DEFAULT);
        struct interface *ifp;
 
-       RB_FOREACH (ifp, if_name_head, &vrf->ifaces_by_name) {
+       FOR_ALL_INTERFACES (vrf, ifp) {
                struct listnode *cnode;
                struct connected *connected;
 
@@ -493,7 +493,7 @@ void rip_interfaces_clean(void)
        struct vrf *vrf = vrf_lookup_by_id(VRF_DEFAULT);
        struct interface *ifp;
 
-       RB_FOREACH (ifp, if_name_head, &vrf->ifaces_by_name)
+       FOR_ALL_INTERFACES (vrf, ifp)
                rip_interface_clean(ifp->info);
 }
 
@@ -545,7 +545,7 @@ void rip_interfaces_reset(void)
        struct vrf *vrf = vrf_lookup_by_id(VRF_DEFAULT);
        struct interface *ifp;
 
-       RB_FOREACH (ifp, if_name_head, &vrf->ifaces_by_name)
+       FOR_ALL_INTERFACES (vrf, ifp)
                rip_interface_reset(ifp->info);
 }
 
@@ -586,7 +586,7 @@ void rip_if_down_all()
        struct vrf *vrf = vrf_lookup_by_id(VRF_DEFAULT);
        struct interface *ifp;
 
-       RB_FOREACH (ifp, if_name_head, &vrf->ifaces_by_name)
+       FOR_ALL_INTERFACES (vrf, ifp)
                rip_if_down(ifp);
 }
 
@@ -981,7 +981,7 @@ void rip_enable_apply_all()
        struct interface *ifp;
 
        /* Check each interface. */
-       RB_FOREACH (ifp, if_name_head, &vrf->ifaces_by_name)
+       FOR_ALL_INTERFACES (vrf, ifp)
                rip_enable_apply(ifp);
 }
 
@@ -1094,7 +1094,7 @@ static void rip_passive_interface_apply_all(void)
        struct vrf *vrf = vrf_lookup_by_id(VRF_DEFAULT);
        struct interface *ifp;
 
-       RB_FOREACH (ifp, if_name_head, &vrf->ifaces_by_name)
+       FOR_ALL_INTERFACES (vrf, ifp)
                rip_passive_interface_apply(ifp);
 }
 
@@ -1731,7 +1731,7 @@ static int rip_interface_config_write(struct vty *vty)
        struct vrf *vrf = vrf_lookup_by_id(VRF_DEFAULT);
        struct interface *ifp;
 
-       RB_FOREACH (ifp, if_name_head, &vrf->ifaces_by_name) {
+       FOR_ALL_INTERFACES (vrf, ifp) {
                struct rip_interface *ri;
 
                ri = ifp->info;
index fb628001ab3944ab11353f85daa1c236a200404b..a4b56d9fbf40d645ac95665d5226d5f51e202988 100644 (file)
@@ -381,7 +381,7 @@ static int rip_nexthop_check(struct in_addr *addr)
        /* If nexthop address matches local configured address then it is
           invalid nexthop. */
 
-       RB_FOREACH (ifp, if_name_head, &vrf->ifaces_by_name) {
+       FOR_ALL_INTERFACES (vrf, ifp) {
                for (ALL_LIST_ELEMENTS_RO(ifp->connected, cnode, ifc)) {
                        p = ifc->address;
 
@@ -2455,7 +2455,7 @@ static void rip_update_process(int route_type)
        struct prefix *p;
 
        /* Send RIP update to each interface. */
-       RB_FOREACH (ifp, if_name_head, &vrf->ifaces_by_name) {
+       FOR_ALL_INTERFACES (vrf, ifp) {
                if (if_is_loopback(ifp))
                        continue;
 
@@ -3552,7 +3552,7 @@ DEFUN (show_ip_rip_status,
 
        vty_out(vty, "    Interface        Send  Recv   Key-chain\n");
 
-       RB_FOREACH (ifp, if_name_head, &vrf->ifaces_by_name) {
+       FOR_ALL_INTERFACES (vrf, ifp) {
                ri = ifp->info;
 
                if (!ri->running)
@@ -3586,7 +3586,7 @@ DEFUN (show_ip_rip_status,
 
        {
                int found_passive = 0;
-               RB_FOREACH (ifp, if_name_head, &vrf->ifaces_by_name) {
+               FOR_ALL_INTERFACES (vrf, ifp) {
                        ri = ifp->info;
 
                        if ((ri->enable_network || ri->enable_interface)
@@ -3774,7 +3774,7 @@ static void rip_distribute_update_all(struct prefix_list *notused)
        struct vrf *vrf = vrf_lookup_by_id(VRF_DEFAULT);
        struct interface *ifp;
 
-       RB_FOREACH (ifp, if_name_head, &vrf->ifaces_by_name)
+       FOR_ALL_INTERFACES (vrf, ifp)
                rip_distribute_update_interface(ifp);
 }
 /* ARGSUSED */
@@ -3950,7 +3950,7 @@ static void rip_routemap_update(const char *notused)
        struct vrf *vrf = vrf_lookup_by_id(VRF_DEFAULT);
        struct interface *ifp;
 
-       RB_FOREACH (ifp, if_name_head, &vrf->ifaces_by_name)
+       FOR_ALL_INTERFACES (vrf, ifp)
                rip_if_rmap_update_interface(ifp);
 
        rip_routemap_update_redistribute();
index 7203c906e19f783972026ebe2b8a3066e6df400a..d450d5a7f9806af2ebba4f0e31afdd2d51ae8055 100644 (file)
@@ -310,7 +310,7 @@ void ripng_interface_clean(void)
        struct interface *ifp;
        struct ripng_interface *ri;
 
-       RB_FOREACH (ifp, if_name_head, &vrf->ifaces_by_name) {
+       FOR_ALL_INTERFACES (vrf, ifp) {
                ri = ifp->info;
 
                ri->enable_network = 0;
@@ -330,7 +330,7 @@ void ripng_interface_reset(void)
        struct interface *ifp;
        struct ripng_interface *ri;
 
-       RB_FOREACH (ifp, if_name_head, &vrf->ifaces_by_name) {
+       FOR_ALL_INTERFACES (vrf, ifp) {
                ri = ifp->info;
 
                ri->enable_network = 0;
@@ -763,7 +763,7 @@ static void ripng_enable_apply_all(void)
        struct vrf *vrf = vrf_lookup_by_id(VRF_DEFAULT);
        struct interface *ifp;
 
-       RB_FOREACH (ifp, if_name_head, &vrf->ifaces_by_name)
+       FOR_ALL_INTERFACES (vrf, ifp)
                ripng_enable_apply(ifp);
 }
 
@@ -824,7 +824,7 @@ static void ripng_passive_interface_apply_all(void)
        struct vrf *vrf = vrf_lookup_by_id(VRF_DEFAULT);
        struct interface *ifp;
 
-       RB_FOREACH (ifp, if_name_head, &vrf->ifaces_by_name)
+       FOR_ALL_INTERFACES (vrf, ifp)
                ripng_passive_interface_apply(ifp);
 }
 
@@ -1074,7 +1074,7 @@ static int interface_config_write(struct vty *vty)
        struct ripng_interface *ri;
        int write = 0;
 
-       RB_FOREACH (ifp, if_name_head, &vrf->ifaces_by_name) {
+       FOR_ALL_INTERFACES (vrf, ifp) {
                ri = ifp->info;
 
                /* Do not display the interface if there is no
index 902b5d9862f6b8d79e4b3d8393dcfe4e55844666..933cb2962fb70a04642089904d984fd5a91dcc7a 100644 (file)
@@ -1389,7 +1389,7 @@ static int ripng_update(struct thread *t)
                zlog_debug("RIPng update timer expired!");
 
        /* Supply routes to each interface. */
-       RB_FOREACH (ifp, if_name_head, &vrf->ifaces_by_name) {
+       FOR_ALL_INTERFACES (vrf, ifp) {
                ri = ifp->info;
 
                if (if_is_loopback(ifp) || !if_is_up(ifp))
@@ -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). */
-       RB_FOREACH (ifp, if_name_head, &vrf->ifaces_by_name) {
+       FOR_ALL_INTERFACES (vrf, ifp) {
                ri = ifp->info;
 
                if (if_is_loopback(ifp) || !if_is_up(ifp))
@@ -2091,7 +2091,7 @@ DEFUN (show_ipv6_ripng_status,
 
        vty_out(vty, "    Interface        Send  Recv\n");
 
-       RB_FOREACH (ifp, if_name_head, &vrf->ifaces_by_name) {
+       FOR_ALL_INTERFACES (vrf, ifp) {
                struct ripng_interface *ri;
 
                ri = ifp->info;
@@ -2794,7 +2794,7 @@ static void ripng_distribute_update_all(struct prefix_list *notused)
        struct vrf *vrf = vrf_lookup_by_id(VRF_DEFAULT);
        struct interface *ifp;
 
-       RB_FOREACH (ifp, if_name_head, &vrf->ifaces_by_name)
+       FOR_ALL_INTERFACES (vrf, ifp)
                ripng_distribute_update_interface(ifp);
 }
 
@@ -2971,7 +2971,7 @@ static void ripng_routemap_update(const char *unused)
        struct vrf *vrf = vrf_lookup_by_id(VRF_DEFAULT);
        struct interface *ifp;
 
-       RB_FOREACH (ifp, if_name_head, &vrf->ifaces_by_name)
+       FOR_ALL_INTERFACES (vrf, ifp)
                ripng_if_rmap_update_interface(ifp);
 
        ripng_routemap_update_redistribute();
index 33e53551bf06ec6adaea343295e33aae34a69991..1d108886de669532f3f7dcbb166b30ac611c9b07 100644 (file)
@@ -265,7 +265,7 @@ static void interface_info_ioctl()
        struct vrf *vrf = vrf_lookup_by_id(VRF_DEFAULT);
        struct interface *ifp;
 
-       RB_FOREACH (ifp, if_name_head, &vrf->ifaces_by_name) {
+       FOR_ALL_INTERFACES (vrf, ifp) {
                if_get_index(ifp);
 #ifdef SIOCGIFHWADDR
                if_get_hwaddr(ifp);
index fe724196421ed2672180edd5013595fa95ded994..e912b2dcf8473b8164209e1579c58602daaf418c 100644 (file)
@@ -1328,7 +1328,7 @@ DEFUN (show_interface,
 
        /* All interface print. */
        vrf = vrf_lookup_by_id(vrf_id);
-       RB_FOREACH (ifp, if_name_head, &vrf->ifaces_by_name)
+       FOR_ALL_INTERFACES (vrf, ifp)
                if_dump_vty(vty, ifp);
 
        return CMD_SUCCESS;
@@ -1350,7 +1350,7 @@ DEFUN (show_interface_vrf_all,
 
        /* All interface print. */
        RB_FOREACH (vrf, vrf_name_head, &vrfs_by_name)
-               RB_FOREACH (ifp, if_name_head, &vrf->ifaces_by_name)
+               FOR_ALL_INTERFACES (vrf, ifp)
                        if_dump_vty(vty, ifp);
 
        return CMD_SUCCESS;
@@ -1429,7 +1429,7 @@ static void if_show_description(struct vty *vty, vrf_id_t vrf_id)
        struct interface *ifp;
 
        vty_out(vty, "Interface       Status  Protocol  Description\n");
-       RB_FOREACH (ifp, if_name_head, &vrf->ifaces_by_name) {
+       FOR_ALL_INTERFACES (vrf, ifp) {
                int len;
 
                len = vty_out(vty, "%s", ifp->name);
@@ -2835,7 +2835,7 @@ static int if_config_write(struct vty *vty)
        zebra_ptm_write(vty);
 
        RB_FOREACH (vrf, vrf_name_head, &vrfs_by_name)
-               RB_FOREACH (ifp, if_name_head, &vrf->ifaces_by_name) {
+               FOR_ALL_INTERFACES (vrf, ifp) {
                        struct zebra_if *if_data;
                        struct listnode *addrnode;
                        struct connected *ifc;
index 816bc85cec1fa347f6724f48145ae0198460b12a..5567d53c3f73c313308fc101eb5c0c00222cfffb 100644 (file)
@@ -322,7 +322,7 @@ static int irdp_finish(void)
        zlog_info("IRDP: Received shutdown notification.");
 
        RB_FOREACH (vrf, vrf_id_head, &vrfs_by_id)
-               RB_FOREACH (ifp, if_name_head, &vrf->ifaces_by_name) {
+               FOR_ALL_INTERFACES (vrf, ifp) {
                        zi = ifp->info;
 
                        if (!zi)
index c870e291615e3e99cfa83593cb90ece75ff94da8..6a8e2ac594e2ac86fd134e9bb5c1a2281f697b7d 100644 (file)
@@ -397,7 +397,7 @@ static int rtadv_timer(struct thread *thread)
        }
 
        RB_FOREACH (vrf, vrf_id_head, &vrfs_by_id)
-               RB_FOREACH (ifp, if_name_head, &vrf->ifaces_by_name) {
+               FOR_ALL_INTERFACES (vrf, ifp) {
                        if (if_is_loopback(ifp)
                            || CHECK_FLAG(ifp->status,
                                          ZEBRA_INTERFACE_VRF_LOOPBACK)
index 2ee711e1c17ef58b7453d86e3c4f5c619d74585e..529fc48edfcd21410f02d544f5b1bd1b1d19beaf 100644 (file)
@@ -55,7 +55,7 @@ static void map_slaves_to_bridge(struct interface *br_if, int link)
        struct interface *ifp;
 
        RB_FOREACH (vrf, vrf_name_head, &vrfs_by_name) {
-               RB_FOREACH (ifp, if_name_head, &vrf->ifaces_by_name) {
+               FOR_ALL_INTERFACES (vrf, ifp) {
                        struct zebra_if *zif;
                        struct zebra_l2info_brslave *br_slave;
 
index 46d16e46c52129136467af1ab3b501dff1906801..93b0723d8b8f235de6805db9ef50b87fcbcc5f2c 100644 (file)
@@ -263,7 +263,7 @@ DEFUN (zebra_ptm_enable,
        ptm_cb.ptm_enable = ZEBRA_IF_PTM_ENABLE_ON;
 
        RB_FOREACH (vrf, vrf_name_head, &vrfs_by_name)
-               RB_FOREACH (ifp, if_name_head, &vrf->ifaces_by_name)
+               FOR_ALL_INTERFACES (vrf, ifp)
                        if (!ifp->ptm_enable) {
                                if_data = (struct zebra_if *)ifp->info;
                                if (if_data
@@ -1091,7 +1091,7 @@ void zebra_ptm_reset_status(int ptm_disable)
        int send_linkup;
 
        RB_FOREACH (vrf, vrf_id_head, &vrfs_by_id)
-               RB_FOREACH (ifp, if_name_head, &vrf->ifaces_by_name) {
+               FOR_ALL_INTERFACES (vrf, ifp) {
                        send_linkup = 0;
                        if (ifp->ptm_enable) {
                                if (!if_is_operative(ifp))
index 44a682957ce13b7a2bed6e26c26619100d17e9ef..0d0a8dd747e99b54e18753c2b201611b1dc66396 100644 (file)
@@ -203,7 +203,7 @@ static int zebra_vrf_delete(struct vrf *vrf)
                zebra_mpls_close_tables(zvrf);
                zebra_pw_exit(zvrf);
 
-               RB_FOREACH (ifp, if_name_head, &vrf->ifaces_by_name)
+               FOR_ALL_INTERFACES (vrf, ifp)
                        if_nbr_ipv6ll_to_ipv4ll_neigh_del_all(ifp);
        }
 
index 6066980b271ff9c8b626ee9121f27811dd97f867..c0b5f9d10fa51839102bf91a01617b99417a629a 100644 (file)
@@ -1215,7 +1215,7 @@ struct interface *zebra_get_vrr_intf_for_svi(struct interface *ifp)
        zvrf = vrf_info_lookup(ifp->vrf_id);
        assert(zvrf);
 
-       RB_FOREACH (tmp_if, if_name_head, &zvrf->vrf->ifaces_by_name) {
+       FOR_ALL_INTERFACES (zvrf->vrf, tmp_if) {
                zif = tmp_if->info;
                if (!zif)
                        continue;
index 2a08a556d5224ce2b9c15d9df23459d2d7e9ba8f..390ff62b198d8a43e9f6797020c3a883b732369e 100644 (file)
@@ -1004,7 +1004,7 @@ static int zread_interface_add(struct zserv *client, u_short length,
        vrf_bitmap_set(client->ifinfo, zvrf_id(zvrf));
 
        RB_FOREACH (vrf, vrf_id_head, &vrfs_by_id) {
-               RB_FOREACH (ifp, if_name_head, &vrf->ifaces_by_name) {
+               FOR_ALL_INTERFACES (vrf, ifp) {
                        /* Skip pseudo interface. */
                        if (!CHECK_FLAG(ifp->status, ZEBRA_INTERFACE_ACTIVE))
                                continue;