]>
Commit | Line | Data |
---|---|---|
acddc0ed | 1 | // SPDX-License-Identifier: GPL-2.0-or-later |
955bfd98 PZ |
2 | /* |
3 | * BGP Label Pool - Manage label chunk allocations from zebra asynchronously | |
4 | * | |
5 | * Copyright (C) 2018 LabN Consulting, L.L.C. | |
955bfd98 PZ |
6 | */ |
7 | ||
8 | #ifndef _FRR_BGP_LABELPOOL_H | |
9 | #define _FRR_BGP_LABELPOOL_H | |
10 | ||
11 | #include <zebra.h> | |
12 | ||
13 | #include "mpls.h" | |
14 | ||
15 | /* | |
16 | * Types used in bgp_lp_get for debug tracking; add more as needed | |
17 | */ | |
18 | #define LP_TYPE_VRF 0x00000001 | |
57592a53 | 19 | #define LP_TYPE_BGP_LU 0x00000002 |
bb3b8113 | 20 | #define LP_TYPE_NEXTHOP 0x00000003 |
955bfd98 | 21 | |
960b9a53 | 22 | PREDECL_LIST(lp_fifo); |
41397f2e | 23 | |
955bfd98 PZ |
24 | struct labelpool { |
25 | struct skiplist *ledger; /* all requests */ | |
26 | struct skiplist *inuse; /* individual labels */ | |
27 | struct list *chunks; /* granted by zebra */ | |
41397f2e | 28 | struct lp_fifo_head requests; /* blocked on zebra */ |
955bfd98 PZ |
29 | struct work_queue *callback_q; |
30 | uint32_t pending_count; /* requested from zebra */ | |
e3ea6503 | 31 | uint32_t reconnect_count; /* zebra reconnections */ |
80853c2e | 32 | uint32_t next_chunksize; /* request this many labels */ |
955bfd98 PZ |
33 | }; |
34 | ||
35 | extern void bgp_lp_init(struct thread_master *master, struct labelpool *pool); | |
36 | extern void bgp_lp_finish(void); | |
37 | extern void bgp_lp_get(int type, void *labelid, | |
38 | int (*cbfunc)(mpls_label_t label, void *labelid, bool allocated)); | |
39 | extern void bgp_lp_release(int type, void *labelid, mpls_label_t label); | |
40 | extern void bgp_lp_event_chunk(uint8_t keep, uint32_t first, uint32_t last); | |
41 | extern void bgp_lp_event_zebra_down(void); | |
42 | extern void bgp_lp_event_zebra_up(void); | |
e3ea6503 | 43 | extern void bgp_lp_vty_init(void); |
955bfd98 | 44 | |
4a324311 PG |
45 | struct bgp_label_per_nexthop_cache; |
46 | PREDECL_RBTREE_UNIQ(bgp_label_per_nexthop_cache); | |
47 | ||
48 | extern int | |
49 | bgp_label_per_nexthop_cache_cmp(const struct bgp_label_per_nexthop_cache *a, | |
50 | const struct bgp_label_per_nexthop_cache *b); | |
51 | ||
52 | struct bgp_label_per_nexthop_cache { | |
53 | ||
54 | /* RB-tree entry. */ | |
55 | struct bgp_label_per_nexthop_cache_item entry; | |
56 | ||
57 | /* the nexthop is the key of the list */ | |
58 | struct prefix nexthop; | |
59 | ||
60 | /* calculated label */ | |
61 | mpls_label_t label; | |
62 | ||
63 | /* number of path_vrfs */ | |
64 | unsigned int path_count; | |
65 | ||
66 | /* back pointer to bgp instance */ | |
67 | struct bgp *to_bgp; | |
68 | ||
aa274376 PG |
69 | /* copy a nexthop resolution from bgp nexthop tracking |
70 | * used to extract the interface nexthop | |
71 | */ | |
72 | struct nexthop *nh; | |
73 | ||
4a324311 PG |
74 | /* list of path_vrfs using it */ |
75 | LIST_HEAD(path_lists, bgp_path_info) paths; | |
76 | ||
b314ae7e PG |
77 | time_t last_update; |
78 | ||
4a324311 PG |
79 | /* Back pointer to the cache tree this entry belongs to. */ |
80 | struct bgp_label_per_nexthop_cache_head *tree; | |
81 | }; | |
82 | ||
83 | DECLARE_RBTREE_UNIQ(bgp_label_per_nexthop_cache, | |
84 | struct bgp_label_per_nexthop_cache, entry, | |
85 | bgp_label_per_nexthop_cache_cmp); | |
86 | ||
87 | void bgp_label_per_nexthop_free(struct bgp_label_per_nexthop_cache *blnc); | |
88 | ||
89 | struct bgp_label_per_nexthop_cache * | |
90 | bgp_label_per_nexthop_new(struct bgp_label_per_nexthop_cache_head *tree, | |
91 | struct prefix *nexthop); | |
92 | struct bgp_label_per_nexthop_cache * | |
93 | bgp_label_per_nexthop_find(struct bgp_label_per_nexthop_cache_head *tree, | |
94 | struct prefix *nexthop); | |
955bfd98 | 95 | #endif /* _FRR_BGP_LABELPOOL_H */ |