]> git.proxmox.com Git - mirror_frr.git/blob - bgpd/bgp_mpath.h
Merge pull request #13649 from donaldsharp/unlock_the_node_or_else
[mirror_frr.git] / bgpd / bgp_mpath.h
1 // SPDX-License-Identifier: GPL-2.0-or-later
2 /*
3 * BGP Multipath
4 * Copyright (C) 2010 Google Inc.
5 *
6 * This file is part of Quagga
7 */
8
9 #ifndef _FRR_BGP_MPATH_H
10 #define _FRR_BGP_MPATH_H
11
12 /* Supplemental information linked to bgp_path_info for keeping track of
13 * multipath selections, lazily allocated to save memory
14 */
15 struct bgp_path_info_mpath {
16 /* Points to the first multipath (on bestpath) or the next multipath */
17 struct bgp_path_info_mpath *mp_next;
18
19 /* Points to the previous multipath or NULL on bestpath */
20 struct bgp_path_info_mpath *mp_prev;
21
22 /* Points to bgp_path_info associated with this multipath info */
23 struct bgp_path_info *mp_info;
24
25 /* When attached to best path, the number of selected multipaths */
26 uint16_t mp_count;
27
28 /* Flags - relevant as noted. */
29 uint16_t mp_flags;
30 #define BGP_MP_LB_PRESENT 0x1 /* Link-bandwidth present for >= 1 path */
31 #define BGP_MP_LB_ALL 0x2 /* Link-bandwidth present for all multipaths */
32
33 /* Aggregated attribute for advertising multipath route */
34 struct attr *mp_attr;
35
36 /* Cumulative bandiwdth of all multipaths - attached to best path. */
37 uint64_t cum_bw;
38 };
39
40 /* Functions to support maximum-paths configuration */
41 extern int bgp_maximum_paths_set(struct bgp *bgp, afi_t afi, safi_t safi,
42 int peertype, uint16_t maxpaths,
43 bool clusterlen);
44 extern int bgp_maximum_paths_unset(struct bgp *bgp, afi_t afi, safi_t safi,
45 int peertype);
46
47 /* Functions used by bgp_best_selection to record current
48 * multipath selections
49 */
50 extern int bgp_path_info_nexthop_cmp(struct bgp_path_info *bpi1,
51 struct bgp_path_info *bpi2);
52 extern void bgp_mp_list_init(struct list *mp_list);
53 extern void bgp_mp_list_clear(struct list *mp_list);
54 extern void bgp_mp_list_add(struct list *mp_list, struct bgp_path_info *mpinfo);
55 extern void bgp_mp_dmed_deselect(struct bgp_path_info *dmed_best);
56 extern void bgp_path_info_mpath_update(struct bgp *bgp, struct bgp_dest *dest,
57 struct bgp_path_info *new_best,
58 struct bgp_path_info *old_best,
59 struct list *mp_list,
60 struct bgp_maxpaths_cfg *mpath_cfg);
61 extern void
62 bgp_path_info_mpath_aggregate_update(struct bgp_path_info *new_best,
63 struct bgp_path_info *old_best);
64
65 /* Unlink and free multipath information associated with a bgp_path_info */
66 extern void bgp_path_info_mpath_dequeue(struct bgp_path_info *path);
67 extern void bgp_path_info_mpath_free(struct bgp_path_info_mpath **mpath);
68
69 /* Walk list of multipaths associated with a best path */
70 extern struct bgp_path_info *
71 bgp_path_info_mpath_first(struct bgp_path_info *path);
72 extern struct bgp_path_info *
73 bgp_path_info_mpath_next(struct bgp_path_info *path);
74
75 /* Accessors for multipath information */
76 extern uint32_t bgp_path_info_mpath_count(struct bgp_path_info *path);
77 extern struct attr *bgp_path_info_mpath_attr(struct bgp_path_info *path);
78 extern bool bgp_path_info_mpath_chkwtd(struct bgp *bgp,
79 struct bgp_path_info *path);
80 extern uint64_t bgp_path_info_mpath_cumbw(struct bgp_path_info *path);
81
82 #endif /* _FRR_BGP_MPATH_H */