summaryrefslogtreecommitdiffstats
path: root/bgpd/bgp_labelpool.h
diff options
context:
space:
mode:
authorPhilippe Guibert <philippe.guibert@6wind.com>2023-02-28 14:17:17 +0100
committerPhilippe Guibert <philippe.guibert@6wind.com>2023-05-09 21:00:57 +0200
commit546d58702e2836743b25ed416f6b089009056d2e (patch)
treed8e4e3b724d39c779e11a4e21611b8cd02e676da /bgpd/bgp_labelpool.h
parentbgpd: introduce LP_TYPE_NEXTHOP label type (diff)
downloadfrr-546d58702e2836743b25ed416f6b089009056d2e.tar.xz
frr-546d58702e2836743b25ed416f6b089009056d2e.zip
bgpd: add the bgp_label_per_nexthop_cache struct and apis
This commit introduces the necessary structs and apis to create the cache entries that store the label information associated to a given nexthop. A hash table is created in each BGP instance for all the AFIs: IPv4 and IPv6. That hash table is initialised. An API to look and/or create an entry based on a given nexthop. Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
Diffstat (limited to 'bgpd/bgp_labelpool.h')
-rw-r--r--bgpd/bgp_labelpool.h43
1 files changed, 43 insertions, 0 deletions
diff --git a/bgpd/bgp_labelpool.h b/bgpd/bgp_labelpool.h
index 649195498..0e965f3b9 100644
--- a/bgpd/bgp_labelpool.h
+++ b/bgpd/bgp_labelpool.h
@@ -42,4 +42,47 @@ extern void bgp_lp_event_zebra_down(void);
extern void bgp_lp_event_zebra_up(void);
extern void bgp_lp_vty_init(void);
+struct bgp_label_per_nexthop_cache;
+PREDECL_RBTREE_UNIQ(bgp_label_per_nexthop_cache);
+
+extern int
+bgp_label_per_nexthop_cache_cmp(const struct bgp_label_per_nexthop_cache *a,
+ const struct bgp_label_per_nexthop_cache *b);
+
+struct bgp_label_per_nexthop_cache {
+
+ /* RB-tree entry. */
+ struct bgp_label_per_nexthop_cache_item entry;
+
+ /* the nexthop is the key of the list */
+ struct prefix nexthop;
+
+ /* calculated label */
+ mpls_label_t label;
+
+ /* number of path_vrfs */
+ unsigned int path_count;
+
+ /* back pointer to bgp instance */
+ struct bgp *to_bgp;
+
+ /* list of path_vrfs using it */
+ LIST_HEAD(path_lists, bgp_path_info) paths;
+
+ /* Back pointer to the cache tree this entry belongs to. */
+ struct bgp_label_per_nexthop_cache_head *tree;
+};
+
+DECLARE_RBTREE_UNIQ(bgp_label_per_nexthop_cache,
+ struct bgp_label_per_nexthop_cache, entry,
+ bgp_label_per_nexthop_cache_cmp);
+
+void bgp_label_per_nexthop_free(struct bgp_label_per_nexthop_cache *blnc);
+
+struct bgp_label_per_nexthop_cache *
+bgp_label_per_nexthop_new(struct bgp_label_per_nexthop_cache_head *tree,
+ struct prefix *nexthop);
+struct bgp_label_per_nexthop_cache *
+bgp_label_per_nexthop_find(struct bgp_label_per_nexthop_cache_head *tree,
+ struct prefix *nexthop);
#endif /* _FRR_BGP_LABELPOOL_H */