diff options
| author | Philippe Guibert <philippe.guibert@6wind.com> | 2023-02-28 14:17:17 +0100 | 
|---|---|---|
| committer | Philippe Guibert <philippe.guibert@6wind.com> | 2023-03-22 12:06:29 +0100 | 
| commit | 4a3243116be562b5eb083b3effd62b72f29ed87a (patch) | |
| tree | 520e98937a6e1c44467a24b0c211a45de45cf0c8 /bgpd/bgp_labelpool.h | |
| parent | bb3b811305ffc3c0998438b48a003c815c859293 (diff) | |
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.h | 43 | 
1 files changed, 43 insertions, 0 deletions
diff --git a/bgpd/bgp_labelpool.h b/bgpd/bgp_labelpool.h index 182aacec73..fd3656068a 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 */  | 
