diff options
author | Renato Westphal <renato@opensourcerouting.org> | 2017-10-06 20:25:58 +0200 |
---|---|---|
committer | Renato Westphal <renato@opensourcerouting.org> | 2017-10-10 14:05:46 +0200 |
commit | 451fda4f9a2fadc24328e640077780a00ffcdac2 (patch) | |
tree | e5cb1b11502a6c525698d188ccc94adfea4515a1 | |
parent | ospf6d: Add missing vrf lookup (diff) | |
download | frr-451fda4f9a2fadc24328e640077780a00ffcdac2.tar.xz frr-451fda4f9a2fadc24328e640077780a00ffcdac2.zip |
*: use the FOR_ALL_INTERFACES abstraction from babeld
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, 133 insertions, 136 deletions
diff --git a/.clang-format b/.clang-format index 2710d844e..21fe9d7c5 100644 --- a/.clang-format +++ b/.clang-format @@ -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 diff --git a/babeld/babel_interface.c b/babeld/babel_interface.c index 5bc48e8a2..d4958ddf2 100644 --- a/babeld/babel_interface.c +++ b/babeld/babel_interface.c @@ -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); diff --git a/babeld/babel_interface.h b/babeld/babel_interface.h index ce14e5906..e9567ab4f 100644 --- a/babeld/babel_interface.h +++ b/babeld/babel_interface.h @@ -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); diff --git a/babeld/babeld.c b/babeld/babeld.c index b66844465..00367612c 100644 --- a/babeld/babeld.c +++ b/babeld/babeld.c @@ -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); } diff --git a/bgpd/bgp_zebra.c b/bgpd/bgp_zebra.c index aff88694e..53c5762ce 100644 --- a/bgpd/bgp_zebra.c +++ b/bgpd/bgp_zebra.c @@ -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; diff --git a/bgpd/bgpd.c b/bgpd/bgpd.c index d8a4852ff..d223cecc5 100644 --- a/bgpd/bgpd.c +++ b/bgpd/bgpd.c @@ -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; diff --git a/eigrpd/eigrp_filter.c b/eigrpd/eigrp_filter.c index fd2e71466..7a8fd027c 100644 --- a/eigrpd/eigrp_filter.c +++ b/eigrpd/eigrp_filter.c @@ -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); } diff --git a/eigrpd/eigrp_network.c b/eigrpd/eigrp_network.c index 56b63597e..56327f120 100644 --- a/eigrpd/eigrp_network.c +++ b/eigrpd/eigrp_network.c @@ -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); } diff --git a/eigrpd/eigrp_vty.c b/eigrpd/eigrp_vty.c index 5ca3a3bef..d93abbb8b 100644 --- a/eigrpd/eigrp_vty.c +++ b/eigrpd/eigrp_vty.c @@ -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; diff --git a/eigrpd/eigrpd.c b/eigrpd/eigrpd.c index 1f2c59271..a8173f4ef 100644 --- a/eigrpd/eigrpd.c +++ b/eigrpd/eigrpd.c @@ -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); } } diff --git a/isisd/isis_circuit.c b/isisd/isis_circuit.c index 939dc71be..5e4090fac 100644 --- a/isisd/isis_circuit.c +++ b/isisd/isis_circuit.c @@ -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++; diff --git a/isisd/isis_te.c b/isisd/isis_te.c index dda5781c2..104a0fd4b 100644 --- a/isisd/isis_te.c +++ b/isisd/isis_te.c @@ -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. */ diff --git a/ldpd/ldp_zebra.c b/ldpd/ldp_zebra.c index f6dfe96dc..7f68f0b69 100644 --- a/ldpd/ldp_zebra.c +++ b/ldpd/ldp_zebra.c @@ -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; @@ -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)) { @@ -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) diff --git a/nhrpd/nhrp_nhs.c b/nhrpd/nhrp_nhs.c index 3a4135a53..6fbd6ca22 100644 --- a/nhrpd/nhrp_nhs.c +++ b/nhrpd/nhrp_nhs.c @@ -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) diff --git a/nhrpd/nhrp_vty.c b/nhrpd/nhrp_vty.c index 48386c350..ab052ac04 100644 --- a/nhrpd/nhrp_vty.c +++ b/nhrpd/nhrp_vty.c @@ -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); diff --git a/ospf6d/ospf6_bfd.c b/ospf6d/ospf6_bfd.c index 9f5d9fbd8..e28af9d06 100644 --- a/ospf6d/ospf6_bfd.c +++ b/ospf6d/ospf6_bfd.c @@ -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) diff --git a/ospf6d/ospf6_interface.c b/ospf6d/ospf6_interface.c index f8cefbf9e..f237e4bef 100644 --- a/ospf6d/ospf6_interface.c +++ b/ospf6d/ospf6_interface.c @@ -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. */ { diff --git a/ospf6d/ospf6_main.c b/ospf6d/ospf6_main.c index 2a6e56deb..4641f41c3 100644 --- a/ospf6d/ospf6_main.c +++ b/ospf6d/ospf6_main.c @@ -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); diff --git a/ospf6d/ospf6_snmp.c b/ospf6d/ospf6_snmp.c index dfe69aa0e..c14810744 100644 --- a/ospf6d/ospf6_snmp.c +++ b/ospf6d/ospf6_snmp.c @@ -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)) { diff --git a/ospfd/ospf_te.c b/ospfd/ospf_te.c index 95610e4c7..86f7e7a53 100644 --- a/ospfd/ospf_te.c +++ b/ospfd/ospf_te.c @@ -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); } } diff --git a/ospfd/ospf_vty.c b/ospfd/ospf_vty.c index a755bb7e6..087cb6f89 100644 --- a/ospfd/ospf_vty.c +++ b/ospfd/ospf_vty.c @@ -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 { diff --git a/ospfd/ospfd.c b/ospfd/ospfd.c index e6d58d7a3..25a1ea2c8 100644 --- a/ospfd/ospfd.c +++ b/ospfd/ospfd.c @@ -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); } diff --git a/pimd/pim_bfd.c b/pimd/pim_bfd.c index c8d111387..f8903d71e 100644 --- a/pimd/pim_bfd.c +++ b/pimd/pim_bfd.c @@ -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) diff --git a/pimd/pim_cmd.c b/pimd/pim_cmd.c index cd55e0fa1..e3fc0b431 100644 --- a/pimd/pim_cmd.c +++ b/pimd/pim_cmd.c @@ -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; diff --git a/pimd/pim_iface.c b/pimd/pim_iface.c index 09b5fe2bf..5dc64a1b3 100644 --- a/pimd/pim_iface.c +++ b/pimd/pim_iface.c @@ -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; diff --git a/pimd/pim_ifchannel.c b/pimd/pim_ifchannel.c index 71897afce..5f597b17b 100644 --- a/pimd/pim_ifchannel.c +++ b/pimd/pim_ifchannel.c @@ -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; diff --git a/pimd/pim_jp_agg.c b/pimd/pim_jp_agg.c index 3ec0a620f..e87dfbca9 100644 --- a/pimd/pim_jp_agg.c +++ b/pimd/pim_jp_agg.c @@ -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; diff --git a/pimd/pim_nht.c b/pimd/pim_nht.c index 78b160f6a..8f9058d99 100644 --- a/pimd/pim_nht.c +++ b/pimd/pim_nht.c @@ -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; diff --git a/pimd/pim_rp.c b/pimd/pim_rp.c index c1ecf6870..d961aa4c4 100644 --- a/pimd/pim_rp.c +++ b/pimd/pim_rp.c @@ -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) diff --git a/pimd/pim_upstream.c b/pimd/pim_upstream.c index 47a70eb09..fdd37f2b9 100644 --- a/pimd/pim_upstream.c +++ b/pimd/pim_upstream.c @@ -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; diff --git a/pimd/pim_vty.c b/pimd/pim_vty.c index 9b60e284e..450faf75b 100644 --- a/pimd/pim_vty.c +++ b/pimd/pim_vty.c @@ -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); diff --git a/pimd/pim_zebra.c b/pimd/pim_zebra.c index 3424eded9..db11e5f17 100644 --- a/pimd/pim_zebra.c +++ b/pimd/pim_zebra.c @@ -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; diff --git a/ripd/rip_interface.c b/ripd/rip_interface.c index 21950c9f2..9282896c2 100644 --- a/ripd/rip_interface.c +++ b/ripd/rip_interface.c @@ -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; diff --git a/ripd/ripd.c b/ripd/ripd.c index fb628001a..a4b56d9fb 100644 --- a/ripd/ripd.c +++ b/ripd/ripd.c @@ -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(); diff --git a/ripngd/ripng_interface.c b/ripngd/ripng_interface.c index 7203c906e..d450d5a7f 100644 --- a/ripngd/ripng_interface.c +++ b/ripngd/ripng_interface.c @@ -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 diff --git a/ripngd/ripngd.c b/ripngd/ripngd.c index 902b5d986..933cb2962 100644 --- a/ripngd/ripngd.c +++ b/ripngd/ripngd.c @@ -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(); diff --git a/zebra/if_ioctl.c b/zebra/if_ioctl.c index 33e53551b..1d108886d 100644 --- a/zebra/if_ioctl.c +++ b/zebra/if_ioctl.c @@ -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); diff --git a/zebra/interface.c b/zebra/interface.c index fe7241964..e912b2dcf 100644 --- a/zebra/interface.c +++ b/zebra/interface.c @@ -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; diff --git a/zebra/irdp_main.c b/zebra/irdp_main.c index 816bc85ce..5567d53c3 100644 --- a/zebra/irdp_main.c +++ b/zebra/irdp_main.c @@ -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) diff --git a/zebra/rtadv.c b/zebra/rtadv.c index c870e2916..6a8e2ac59 100644 --- a/zebra/rtadv.c +++ b/zebra/rtadv.c @@ -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) diff --git a/zebra/zebra_l2.c b/zebra/zebra_l2.c index 2ee711e1c..529fc48ed 100644 --- a/zebra/zebra_l2.c +++ b/zebra/zebra_l2.c @@ -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; diff --git a/zebra/zebra_ptm.c b/zebra/zebra_ptm.c index 46d16e46c..93b0723d8 100644 --- a/zebra/zebra_ptm.c +++ b/zebra/zebra_ptm.c @@ -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)) diff --git a/zebra/zebra_vrf.c b/zebra/zebra_vrf.c index 44a682957..0d0a8dd74 100644 --- a/zebra/zebra_vrf.c +++ b/zebra/zebra_vrf.c @@ -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); } diff --git a/zebra/zebra_vxlan.c b/zebra/zebra_vxlan.c index 6066980b2..c0b5f9d10 100644 --- a/zebra/zebra_vxlan.c +++ b/zebra/zebra_vxlan.c @@ -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; diff --git a/zebra/zserv.c b/zebra/zserv.c index 2a08a556d..390ff62b1 100644 --- a/zebra/zserv.c +++ b/zebra/zserv.c @@ -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; |