]> git.proxmox.com Git - mirror_frr.git/blobdiff - bgpd/bgp_labelpool.h
Merge pull request #13649 from donaldsharp/unlock_the_node_or_else
[mirror_frr.git] / bgpd / bgp_labelpool.h
index 2f3ffe437fa6ca4e2ee298fa42e969945bafd372..b33527186e0a10b876494ec4a9db104a48352c36 100644 (file)
@@ -1,21 +1,8 @@
+// SPDX-License-Identifier: GPL-2.0-or-later
 /*
  * BGP Label Pool - Manage label chunk allocations from zebra asynchronously
  *
  * Copyright (C) 2018 LabN Consulting, L.L.C.
- *
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License as published by the Free
- * Software Foundation; either version 2 of the License, or (at your option)
- * any later version.
- *
- * This program is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
- * more details.
- *
- * You should have received a copy of the GNU General Public License along
- * with this program; see the file COPYING; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
  */
 
 #ifndef _FRR_BGP_LABELPOOL_H
@@ -30,6 +17,7 @@
  */
 #define LP_TYPE_VRF    0x00000001
 #define LP_TYPE_BGP_LU 0x00000002
+#define LP_TYPE_NEXTHOP 0x00000003
 
 PREDECL_LIST(lp_fifo);
 
@@ -44,7 +32,7 @@ struct labelpool {
        uint32_t next_chunksize;                /* request this many labels */
 };
 
-extern void bgp_lp_init(struct thread_master *master, struct labelpool *pool);
+extern void bgp_lp_init(struct event_loop *master, struct labelpool *pool);
 extern void bgp_lp_finish(void);
 extern void bgp_lp_get(int type, void *labelid,
        int (*cbfunc)(mpls_label_t label, void *labelid, bool allocated));
@@ -54,4 +42,55 @@ 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;
+
+       /* copy a nexthop resolution from bgp nexthop tracking
+        * used to extract the interface nexthop
+        */
+       struct nexthop *nh;
+
+       /* list of path_vrfs using it */
+       LIST_HEAD(path_lists, bgp_path_info) paths;
+
+       time_t last_update;
+
+       /* 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);
+void bgp_label_per_nexthop_init(void);
 #endif /* _FRR_BGP_LABELPOOL_H */