diff options
author | Stephen Worley <sworley@cumulusnetworks.com> | 2019-07-24 18:27:40 +0200 |
---|---|---|
committer | Stephen Worley <sworley@cumulusnetworks.com> | 2019-10-25 17:13:41 +0200 |
commit | 37c6708b93af52a4f0e271d217ba973a683ed71f (patch) | |
tree | 207244b4d094243fcf8244b027d88a5bde8bcf76 /zebra/zebra_nhg.h | |
parent | zebra: Remove some extraneous zebra_nhg logging (diff) | |
download | frr-37c6708b93af52a4f0e271d217ba973a683ed71f.tar.xz frr-37c6708b93af52a4f0e271d217ba973a683ed71f.zip |
zebra: Switch nhg_connected to use new RB tree
Switch the nhg_connected tree structures to use the new
RB tree API in `lib/typerb.h`. We were using the openbsd-tree
implementation before.
Signed-off-by: Stephen Worley <sworley@cumulusnetworks.com>
Diffstat (limited to 'zebra/zebra_nhg.h')
-rw-r--r-- | zebra/zebra_nhg.h | 33 |
1 files changed, 20 insertions, 13 deletions
diff --git a/zebra/zebra_nhg.h b/zebra/zebra_nhg.h index ff2c73433..0be821267 100644 --- a/zebra/zebra_nhg.h +++ b/zebra/zebra_nhg.h @@ -39,6 +39,7 @@ struct nh_grp { uint8_t weight; }; +PREDECL_RBTREE_UNIQ(nhg_connected_tree); struct nhg_hash_entry { uint32_t id; @@ -69,7 +70,7 @@ struct nhg_hash_entry { * Using a rb tree here to make lookups * faster with ID's. */ - RB_HEAD(nhg_connected_head, nhg_connected) nhg_depends, nhg_dependents; + struct nhg_connected_tree_head nhg_depends, nhg_dependents; /* * Is this nexthop group valid, ie all nexthops are fully resolved. * What is fully resolved? It's a nexthop that is either self contained @@ -96,11 +97,18 @@ struct nhg_hash_entry { /* Abstraction for connected trees */ struct nhg_connected { - RB_ENTRY(nhg_connected) nhg_entry; + struct nhg_connected_tree_item tree_item; struct nhg_hash_entry *nhe; }; -RB_PROTOTYPE(nhg_connected_head, nhg_connected, nhg_entry, nhg_connected_cmp); +static int nhg_connected_cmp(const struct nhg_connected *con1, + const struct nhg_connected *con2) +{ + return (con1->nhe->id - con2->nhe->id); +} + +DECLARE_RBTREE_UNIQ(nhg_connected_tree, struct nhg_connected, tree_item, + nhg_connected_cmp); enum nhg_ctx_op_e { @@ -150,17 +158,16 @@ extern void nhg_connected_free(struct nhg_connected *dep); extern struct nhg_connected *nhg_connected_new(struct nhg_hash_entry *nhe); /* nhg connected tree direct access functions */ -extern void nhg_connected_head_init(struct nhg_connected_head *head); -extern unsigned int -nhg_connected_head_count(const struct nhg_connected_head *head); -extern void nhg_connected_head_free(struct nhg_connected_head *head); -extern bool nhg_connected_head_is_empty(const struct nhg_connected_head *head); +extern void nhg_connected_tree_init(struct nhg_connected_tree_head *head); +extern void nhg_connected_tree_free(struct nhg_connected_tree_head *head); +extern bool +nhg_connected_tree_is_empty(const struct nhg_connected_tree_head *head); extern struct nhg_connected * -nhg_connected_head_root(const struct nhg_connected_head *head); -extern void nhg_connected_head_del(struct nhg_connected_head *head, - struct nhg_hash_entry *nhe); -extern void nhg_connected_head_add(struct nhg_connected_head *head, - struct nhg_hash_entry *nhe); +nhg_connected_tree_root(struct nhg_connected_tree_head *head); +extern void nhg_connected_tree_del_nhe(struct nhg_connected_tree_head *head, + struct nhg_hash_entry *nhe); +extern void nhg_connected_tree_add_nhe(struct nhg_connected_tree_head *head, + struct nhg_hash_entry *nhe); /** * NHE abstracted tree functions. |