diff options
| author | Renato Westphal <renato@opensourcerouting.org> | 2017-10-06 15:25:58 -0300 |
|---|---|---|
| committer | Renato Westphal <renato@opensourcerouting.org> | 2017-10-10 09:05:46 -0300 |
| commit | 451fda4f9a2fadc24328e640077780a00ffcdac2 (patch) | |
| tree | e5cb1b11502a6c525698d188ccc94adfea4515a1 /lib/if.c | |
| parent | a6ba931e0bd4adddbde35dae585d2ffa5e9c78db (diff) | |
*: 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>
Diffstat (limited to 'lib/if.c')
| -rw-r--r-- | lib/if.c | 14 |
1 files changed, 7 insertions, 7 deletions
@@ -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)) { |
