]> git.proxmox.com Git - mirror_frr.git/blob - bgpd/bgp_mpath.h
Merge pull request #6150 from ton31337/feature/black_topotests_developer_guide
[mirror_frr.git] / bgpd / bgp_mpath.h
1 /*
2 * BGP Multipath
3 * Copyright (C) 2010 Google Inc.
4 *
5 * This file is part of Quagga
6 *
7 * Quagga is free software; you can redistribute it and/or modify it
8 * under the terms of the GNU General Public License as published by the
9 * Free Software Foundation; either version 2, or (at your option) any
10 * later version.
11 *
12 * Quagga is distributed in the hope that it will be useful, but
13 * WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License along
18 * with this program; see the file COPYING; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
20 */
21
22 #ifndef _QUAGGA_BGP_MPATH_H
23 #define _QUAGGA_BGP_MPATH_H
24
25 /* Supplemental information linked to bgp_path_info for keeping track of
26 * multipath selections, lazily allocated to save memory
27 */
28 struct bgp_path_info_mpath {
29 /* Points to the first multipath (on bestpath) or the next multipath */
30 struct bgp_path_info_mpath *mp_next;
31
32 /* Points to the previous multipath or NULL on bestpath */
33 struct bgp_path_info_mpath *mp_prev;
34
35 /* Points to bgp_path_info associated with this multipath info */
36 struct bgp_path_info *mp_info;
37
38 /* When attached to best path, the number of selected multipaths */
39 uint16_t mp_count;
40
41 /* Flags - relevant as noted. */
42 uint16_t mp_flags;
43 #define BGP_MP_LB_PRESENT 0x1 /* Link-bandwidth present for >= 1 path */
44 #define BGP_MP_LB_ALL 0x2 /* Link-bandwidth present for all multipaths */
45
46 /* Aggregated attribute for advertising multipath route */
47 struct attr *mp_attr;
48
49 /* Cumulative bandiwdth of all multipaths - attached to best path. */
50 uint64_t cum_bw;
51 };
52
53 /* Functions to support maximum-paths configuration */
54 extern int bgp_maximum_paths_set(struct bgp *, afi_t, safi_t, int, uint16_t,
55 uint16_t);
56 extern int bgp_maximum_paths_unset(struct bgp *, afi_t, safi_t, int);
57
58 /* Functions used by bgp_best_selection to record current
59 * multipath selections
60 */
61 extern int bgp_path_info_nexthop_cmp(struct bgp_path_info *bpi1,
62 struct bgp_path_info *bpi2);
63 extern void bgp_mp_list_init(struct list *);
64 extern void bgp_mp_list_clear(struct list *);
65 extern void bgp_mp_list_add(struct list *mp_list, struct bgp_path_info *mpinfo);
66 extern void bgp_mp_dmed_deselect(struct bgp_path_info *dmed_best);
67 extern void bgp_path_info_mpath_update(struct bgp_node *rn,
68 struct bgp_path_info *new_best,
69 struct bgp_path_info *old_best,
70 struct list *mp_list,
71 struct bgp_maxpaths_cfg *mpath_cfg);
72 extern void
73 bgp_path_info_mpath_aggregate_update(struct bgp_path_info *new_best,
74 struct bgp_path_info *old_best);
75
76 /* Unlink and free multipath information associated with a bgp_path_info */
77 extern void bgp_path_info_mpath_dequeue(struct bgp_path_info *path);
78 extern void bgp_path_info_mpath_free(struct bgp_path_info_mpath **mpath);
79
80 /* Walk list of multipaths associated with a best path */
81 extern struct bgp_path_info *
82 bgp_path_info_mpath_first(struct bgp_path_info *path);
83 extern struct bgp_path_info *
84 bgp_path_info_mpath_next(struct bgp_path_info *path);
85
86 /* Accessors for multipath information */
87 extern uint32_t bgp_path_info_mpath_count(struct bgp_path_info *path);
88 extern struct attr *bgp_path_info_mpath_attr(struct bgp_path_info *path);
89 extern bool bgp_path_info_mpath_chkwtd(struct bgp *bgp,
90 struct bgp_path_info *path);
91 extern uint64_t bgp_path_info_mpath_cumbw(struct bgp_path_info *path);
92
93 #endif /* _QUAGGA_BGP_MPATH_H */