summaryrefslogtreecommitdiff
path: root/lib/if.h
diff options
context:
space:
mode:
authorRenato Westphal <renato@opensourcerouting.org>2017-10-06 15:25:58 -0300
committerRenato Westphal <renato@opensourcerouting.org>2017-10-10 09:05:46 -0300
commit451fda4f9a2fadc24328e640077780a00ffcdac2 (patch)
treee5cb1b11502a6c525698d188ccc94adfea4515a1 /lib/if.h
parenta6ba931e0bd4adddbde35dae585d2ffa5e9c78db (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.h')
-rw-r--r--lib/if.h7
1 files changed, 7 insertions, 0 deletions
diff --git a/lib/if.h b/lib/if.h
index 3e2824b6c9..eb8af2041b 100644
--- 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)