blob: 2a84d5e1e21bb86888b37162b4d9840bc1603ce5 [file] [log] [blame]
Josh Bailey165b5ff2011-07-20 20:43:22 -07001/* $QuaggaId: Format:%an, %ai, %h$ $
2 *
3 * BGP Multipath
4 * Copyright (C) 2010 Google Inc.
5 *
6 * This file is part of Quagga
7 *
8 * Quagga is free software; you can redistribute it and/or modify it
9 * under the terms of the GNU General Public License as published by the
10 * Free Software Foundation; either version 2, or (at your option) any
11 * later version.
12 *
13 * Quagga is distributed in the hope that it will be useful, but
14 * WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 * General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with Quagga; see the file COPYING. If not, write to the Free
20 * Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
21 * 02111-1307, USA.
22 */
23
24#ifndef _QUAGGA_BGP_MPATH_H
25#define _QUAGGA_BGP_MPATH_H
26
27/* BGP default maximum-paths */
28#define BGP_DEFAULT_MAXPATHS 1
29
Josh Baileyde8d5df2011-07-20 20:46:01 -070030/* Supplemental information linked to bgp_info for keeping track of
31 * multipath selections, lazily allocated to save memory
32 */
33struct bgp_info_mpath
34{
35 /* Points to the first multipath (on bestpath) or the next multipath */
36 struct bgp_info_mpath *mp_next;
37
38 /* Points to the previous multipath or NULL on bestpath */
39 struct bgp_info_mpath *mp_prev;
40
41 /* Points to bgp_info associated with this multipath info */
42 struct bgp_info *mp_info;
43
44 /* When attached to best path, the number of selected multipaths */
45 u_int32_t mp_count;
Josh Bailey0b597ef2011-07-20 20:49:11 -070046
47 /* Aggregated attribute for advertising multipath route */
48 struct attr *mp_attr;
Josh Baileyde8d5df2011-07-20 20:46:01 -070049};
50
Josh Bailey165b5ff2011-07-20 20:43:22 -070051/* Functions to support maximum-paths configuration */
52extern int bgp_maximum_paths_set (struct bgp *, afi_t, safi_t, int, u_int16_t);
53extern int bgp_maximum_paths_unset (struct bgp *, afi_t, safi_t, int);
Paul Jakma6d4742b2015-11-25 17:14:37 +000054bool bgp_mpath_is_configured_sort (struct bgp *, bgp_peer_sort_t, afi_t, safi_t);
55bool bgp_mpath_is_configured (struct bgp *, afi_t, safi_t);
Josh Bailey165b5ff2011-07-20 20:43:22 -070056
Josh Bailey96450fa2011-07-20 20:45:12 -070057/* Functions used by bgp_best_selection to record current
58 * multipath selections
59 */
60extern void bgp_mp_list_init (struct list *);
61extern void bgp_mp_list_clear (struct list *);
62extern void bgp_mp_list_add (struct list *, struct bgp_info *);
Josh Bailey6918e742011-07-20 20:48:20 -070063extern void bgp_mp_dmed_deselect (struct bgp_info *);
Josh Baileyde8d5df2011-07-20 20:46:01 -070064extern void bgp_info_mpath_update (struct bgp_node *, struct bgp_info *,
65 struct bgp_info *, struct list *,
Paul Jakma6d4742b2015-11-25 17:14:37 +000066 afi_t, safi_t);
Josh Bailey0b597ef2011-07-20 20:49:11 -070067extern void bgp_info_mpath_aggregate_update (struct bgp_info *,
68 struct bgp_info *);
Josh Baileyde8d5df2011-07-20 20:46:01 -070069
70/* Unlink and free multipath information associated with a bgp_info */
71extern void bgp_info_mpath_dequeue (struct bgp_info *);
72extern void bgp_info_mpath_free (struct bgp_info_mpath **);
73
74/* Walk list of multipaths associated with a best path */
75extern struct bgp_info *bgp_info_mpath_first (struct bgp_info *);
76extern struct bgp_info *bgp_info_mpath_next (struct bgp_info *);
77
78/* Accessors for multipath information */
79extern u_int32_t bgp_info_mpath_count (struct bgp_info *);
Josh Bailey0b597ef2011-07-20 20:49:11 -070080extern struct attr *bgp_info_mpath_attr (struct bgp_info *);
Josh Bailey96450fa2011-07-20 20:45:12 -070081
Josh Bailey165b5ff2011-07-20 20:43:22 -070082#endif /* _QUAGGA_BGP_MPATH_H */