bgp_mpath.h 3.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. /* $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. #ifndef _QUAGGA_BGP_MPATH_H
  24. #define _QUAGGA_BGP_MPATH_H
  25. /* BGP default maximum-paths */
  26. #define BGP_DEFAULT_MAXPATHS 1
  27. /* Supplemental information linked to bgp_info for keeping track of
  28. * multipath selections, lazily allocated to save memory
  29. */
  30. struct bgp_info_mpath
  31. {
  32. /* Points to the first multipath (on bestpath) or the next multipath */
  33. struct bgp_info_mpath *mp_next;
  34. /* Points to the previous multipath or NULL on bestpath */
  35. struct bgp_info_mpath *mp_prev;
  36. /* Points to bgp_info associated with this multipath info */
  37. struct bgp_info *mp_info;
  38. /* When attached to best path, the number of selected multipaths */
  39. u_int32_t mp_count;
  40. /* Aggregated attribute for advertising multipath route */
  41. struct attr *mp_attr;
  42. };
  43. /* Functions to support maximum-paths configuration */
  44. extern int bgp_maximum_paths_set (struct bgp *, afi_t, safi_t, int, u_int16_t);
  45. extern int bgp_maximum_paths_unset (struct bgp *, afi_t, safi_t, int);
  46. bool bgp_mpath_is_configured_sort (struct bgp *, bgp_peer_sort_t, afi_t, safi_t);
  47. bool bgp_mpath_is_configured (struct bgp *, afi_t, safi_t);
  48. /* Functions used by bgp_best_selection to record current
  49. * multipath selections
  50. */
  51. extern void bgp_mp_list_init (struct list *);
  52. extern void bgp_mp_list_clear (struct list *);
  53. extern void bgp_mp_list_add (struct list *, struct bgp_info *);
  54. extern void bgp_mp_dmed_deselect (struct bgp_info *);
  55. extern void bgp_info_mpath_update (struct bgp_node *, struct bgp_info *,
  56. struct bgp_info *, struct list *,
  57. afi_t, safi_t);
  58. extern void bgp_info_mpath_aggregate_update (struct bgp_info *,
  59. struct bgp_info *);
  60. /* Unlink and free multipath information associated with a bgp_info */
  61. extern void bgp_info_mpath_dequeue (struct bgp_info *);
  62. extern void bgp_info_mpath_free (struct bgp_info_mpath **);
  63. /* Walk list of multipaths associated with a best path */
  64. extern struct bgp_info *bgp_info_mpath_first (struct bgp_info *);
  65. extern struct bgp_info *bgp_info_mpath_next (struct bgp_info *);
  66. /* Accessors for multipath information */
  67. extern u_int32_t bgp_info_mpath_count (struct bgp_info *);
  68. extern struct attr *bgp_info_mpath_attr (struct bgp_info *);
  69. #endif /* _QUAGGA_BGP_MPATH_H */