summaryrefslogtreecommitdiff
path: root/zebra/zebra_ns.h
diff options
context:
space:
mode:
authorMark Stapp <mjs@cisco.com>2024-10-22 15:20:54 -0700
committerMark Stapp <mjs@cisco.com>2024-10-28 14:54:06 -0400
commit5af72e95b01b1ffc76c4ef8095f70cd9b7f55c3c (patch)
tree0b973522ba3c810b357e398494a2bb45bb7b1f4d /zebra/zebra_ns.h
parent1f8d81335d177580147e778c70e5e84b2544359a (diff)
zebra: add new per-NS tree of interfaces
Add new per-NS interface typerb tree, using external linkage, to replace the use of the if_table table. Add apis to iterate the per-NS collection - which is not public. Signed-off-by: Mark Stapp <mjs@cisco.com>
Diffstat (limited to 'zebra/zebra_ns.h')
-rw-r--r--zebra/zebra_ns.h34
1 files changed, 34 insertions, 0 deletions
diff --git a/zebra/zebra_ns.h b/zebra/zebra_ns.h
index d5fd5869bc..10e414dac3 100644
--- a/zebra/zebra_ns.h
+++ b/zebra/zebra_ns.h
@@ -32,6 +32,20 @@ struct nlsock {
};
#endif
+/* Tree of interfaces: external linkage struct, and rbtree */
+PREDECL_RBTREE_UNIQ(ifp_tree);
+
+struct ifp_tree_link {
+ struct ifp_tree_item link;
+
+ ifindex_t ifindex;
+
+ struct interface *ifp;
+
+ /* Backpointer */
+ struct zebra_ns *zns;
+};
+
struct zebra_ns {
/* net-ns name. */
char name[VRF_NAMSIZ];
@@ -55,12 +69,32 @@ struct zebra_ns {
struct route_table *if_table;
+ /* Tree of interfaces in this ns */
+ struct ifp_tree_head ifp_tree;
+
/* Back pointer */
struct ns *ns;
};
struct zebra_ns *zebra_ns_lookup(ns_id_t ns_id);
+/* Manage collection of ifps per-NS */
+void zebra_ns_link_ifp(struct zebra_ns *zns, struct interface *ifp);
+void zebra_ns_unlink_ifp(struct interface *ifp);
+struct interface *zebra_ns_lookup_ifp(struct zebra_ns *zns, uint32_t ifindex);
+struct interface *zebra_ns_lookup_ifp_name(struct zebra_ns *zns, const char *ifname);
+
+/* Iterate collection of ifps, calling application's callback. Callback uses
+ * return semantics from lib/ns.h: return NS_WALK_STOP to stop the iteration.
+ * Caller's 'arg' is included in each callback.
+ * The iterator returns STOP or CONTINUE also.
+ */
+int zebra_ns_ifp_walk(struct zebra_ns *zns,
+ int (*func)(struct interface *ifp, void *arg), void *arg);
+
+/* Walk all NSes, and all ifps for each NS. */
+void zebra_ns_ifp_walk_all(int (*func)(struct interface *ifp, void *arg), void *arg);
+
int zebra_ns_init(void);
int zebra_ns_enable(ns_id_t ns_id, void **info);
int zebra_ns_disabled(struct ns *ns);