bgp_damp.h 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149
  1. /* BGP flap dampening
  2. Copyright (C) 2001 IP Infusion Inc.
  3. This file is part of GNU Zebra.
  4. GNU Zebra is free software; you can redistribute it and/or modify it
  5. under the terms of the GNU General Public License as published by the
  6. Free Software Foundation; either version 2, or (at your option) any
  7. later version.
  8. GNU Zebra is distributed in the hope that it will be useful, but
  9. WITHOUT ANY WARRANTY; without even the implied warranty of
  10. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  11. General Public License for more details.
  12. You should have received a copy of the GNU General Public License
  13. along with GNU Zebra; see the file COPYING. If not, write to the Free
  14. Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
  15. 02111-1307, USA. */
  16. #ifndef _QUAGGA_BGP_DAMP_H
  17. #define _QUAGGA_BGP_DAMP_H
  18. /* Structure maintained on a per-route basis. */
  19. struct bgp_damp_info
  20. {
  21. /* Doubly linked list. This information must be linked to
  22. reuse_list or no_reuse_list. */
  23. struct bgp_damp_info *next;
  24. struct bgp_damp_info *prev;
  25. /* Figure-of-merit. */
  26. unsigned int penalty;
  27. /* Number of flapping. */
  28. unsigned int flap;
  29. /* First flap time */
  30. time_t start_time;
  31. /* Last time penalty was updated. */
  32. time_t t_updated;
  33. /* Time of route start to be suppressed. */
  34. time_t suppress_time;
  35. /* Back reference to bgp_info. */
  36. struct bgp_info *binfo;
  37. /* Back reference to bgp_node. */
  38. struct bgp_node *rn;
  39. /* Current index in the reuse_list. */
  40. int index;
  41. /* Last time message type. */
  42. u_char lastrecord;
  43. #define BGP_RECORD_UPDATE 1U
  44. #define BGP_RECORD_WITHDRAW 2U
  45. afi_t afi;
  46. safi_t safi;
  47. };
  48. /* Specified parameter set configuration. */
  49. struct bgp_damp_config
  50. {
  51. /* Value over which routes suppressed. */
  52. unsigned int suppress_value;
  53. /* Value below which suppressed routes reused. */
  54. unsigned int reuse_limit;
  55. /* Max time a route can be suppressed. */
  56. time_t max_suppress_time;
  57. /* Time during which accumulated penalty reduces by half. */
  58. time_t half_life;
  59. /* Non-configurable parameters but fixed at implementation time.
  60. * To change this values, init_bgp_damp() should be modified.
  61. */
  62. time_t tmax; /* Max time previous instability retained */
  63. unsigned int reuse_list_size; /* Number of reuse lists */
  64. unsigned int reuse_index_size; /* Size of reuse index array */
  65. /* Non-configurable parameters. Most of these are calculated from
  66. * the configurable parameters above.
  67. */
  68. unsigned int ceiling; /* Max value a penalty can attain */
  69. unsigned int decay_rate_per_tick; /* Calculated from half-life */
  70. unsigned int decay_array_size; /* Calculated using config parameters */
  71. double scale_factor;
  72. unsigned int reuse_scale_factor;
  73. /* Decay array per-set based. */
  74. double *decay_array;
  75. /* Reuse index array per-set based. */
  76. int *reuse_index;
  77. /* Reuse list array per-set based. */
  78. struct bgp_damp_info **reuse_list;
  79. int reuse_offset;
  80. /* All dampening information which is not on reuse list. */
  81. struct bgp_damp_info *no_reuse_list;
  82. /* Reuse timer thread per-set base. */
  83. struct thread* t_reuse;
  84. };
  85. #define BGP_DAMP_NONE 0
  86. #define BGP_DAMP_USED 1
  87. #define BGP_DAMP_SUPPRESSED 2
  88. /* Time granularity for reuse lists */
  89. #define DELTA_REUSE 10
  90. /* Time granularity for decay arrays */
  91. #define DELTA_T 5
  92. #define DEFAULT_PENALTY 1000
  93. #define DEFAULT_HALF_LIFE 15
  94. #define DEFAULT_REUSE 750
  95. #define DEFAULT_SUPPRESS 2000
  96. #define REUSE_LIST_SIZE 256
  97. #define REUSE_ARRAY_SIZE 1024
  98. extern int bgp_damp_enable (struct bgp *, afi_t, safi_t, time_t, unsigned int,
  99. unsigned int, time_t);
  100. extern int bgp_damp_disable (struct bgp *, afi_t, safi_t);
  101. extern int bgp_damp_withdraw (struct bgp_info *, struct bgp_node *,
  102. afi_t, safi_t, int);
  103. extern int bgp_damp_update (struct bgp_info *, struct bgp_node *, afi_t, safi_t);
  104. extern int bgp_damp_scan (struct bgp_info *, afi_t, safi_t);
  105. extern void bgp_damp_info_free (struct bgp_damp_info *, int);
  106. extern void bgp_damp_info_clean (void);
  107. extern int bgp_damp_decay (time_t, int);
  108. extern void bgp_config_write_damp (struct vty *);
  109. extern void bgp_damp_info_vty (struct vty *, struct bgp_info *);
  110. extern const char * bgp_damp_reuse_time_vty (struct vty *, struct bgp_info *,
  111. char *, size_t);
  112. extern int bgp_show_dampening_parameters (struct vty *vty, afi_t, safi_t);
  113. #endif /* _QUAGGA_BGP_DAMP_H */