summaryrefslogtreecommitdiffstats
path: root/lib/ns.h
diff options
context:
space:
mode:
authorRenato Westphal <renato@opensourcerouting.org>2016-10-29 03:03:35 +0200
committerRenato Westphal <renato@opensourcerouting.org>2016-11-28 19:18:35 +0100
commitc7fdd84f36a262d062a10c1439121df361ab78d3 (patch)
tree31751b0f29e4c778abd74aafab19807dffff86e9 /lib/ns.h
parentzebra: nuke zvrf_list and always use vrf_list instead (diff)
downloadfrr-c7fdd84f36a262d062a10c1439121df361ab78d3.tar.xz
frr-c7fdd84f36a262d062a10c1439121df361ab78d3.zip
lib: convert namespace code to use red-black trees
We definitely need to stop abusing the route table data structure when it's not necessary. Convert the namespace code to use red-black trees instead. This greatly improves code readability. Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
Diffstat (limited to 'lib/ns.h')
-rw-r--r--lib/ns.h9
1 files changed, 9 insertions, 0 deletions
diff --git a/lib/ns.h b/lib/ns.h
index 74616cd62..2a7be1ef8 100644
--- a/lib/ns.h
+++ b/lib/ns.h
@@ -23,6 +23,7 @@
#ifndef _ZEBRA_NS_H
#define _ZEBRA_NS_H
+#include "openbsd-tree.h"
#include "linklist.h"
typedef u_int16_t ns_id_t;
@@ -35,10 +36,14 @@ typedef u_int16_t ns_id_t;
struct ns
{
+ RB_ENTRY(ns) entry;
+
/* Identifier, same as the vector index */
ns_id_t ns_id;
+
/* Name */
char *name;
+
/* File descriptor */
int fd;
@@ -48,6 +53,10 @@ struct ns
/* User data */
void *info;
};
+RB_HEAD (ns_head, ns);
+RB_PROTOTYPE (ns_head, ns, entry, ns_compare)
+
+extern struct ns_head ns_tree;
/*
* NS hooks