]>
git.proxmox.com Git - mirror_frr.git/blob - bgpd/bgp_damp.h
1 // SPDX-License-Identifier: GPL-2.0-or-later
3 * Copyright (C) 2001 IP Infusion Inc.
6 #ifndef _QUAGGA_BGP_DAMP_H
7 #define _QUAGGA_BGP_DAMP_H
9 #include "bgpd/bgp_table.h"
11 /* Structure maintained on a per-route basis. */
12 struct bgp_damp_info
{
13 /* Doubly linked list. This information must be linked to
14 reuse_list or no_reuse_list. */
15 struct bgp_damp_info
*next
;
16 struct bgp_damp_info
*prev
;
18 /* Figure-of-merit. */
21 /* Number of flapping. */
27 /* Last time penalty was updated. */
30 /* Time of route start to be suppressed. */
33 /* Back reference to bgp_path_info. */
34 struct bgp_path_info
*path
;
36 /* Back reference to bgp_node. */
37 struct bgp_dest
*dest
;
39 /* Current index in the reuse_list. */
42 /* Last time message type. */
44 #define BGP_RECORD_UPDATE 1U
45 #define BGP_RECORD_WITHDRAW 2U
51 /* Specified parameter set configuration. */
52 struct bgp_damp_config
{
53 /* Value over which routes suppressed. */
54 unsigned int suppress_value
;
56 /* Value below which suppressed routes reused. */
57 unsigned int reuse_limit
;
59 /* Max time a route can be suppressed. */
60 time_t max_suppress_time
;
62 /* Time during which accumulated penalty reduces by half. */
65 /* Non-configurable parameters but fixed at implementation time.
66 * To change this values, init_bgp_damp() should be modified.
68 time_t tmax
; /* Max time previous instability retained */
69 unsigned int reuse_list_size
; /* Number of reuse lists */
70 unsigned int reuse_index_size
; /* Size of reuse index array */
72 /* Non-configurable parameters. Most of these are calculated from
73 * the configurable parameters above.
75 unsigned int ceiling
; /* Max value a penalty can attain */
76 unsigned int decay_rate_per_tick
; /* Calculated from half-life */
77 unsigned int decay_array_size
; /* Calculated using config parameters */
79 unsigned int reuse_scale_factor
;
81 /* Decay array per-set based. */
84 /* Reuse index array per-set based. */
87 /* Reuse list array per-set based. */
88 struct bgp_damp_info
**reuse_list
;
91 /* All dampening information which is not on reuse list. */
92 struct bgp_damp_info
*no_reuse_list
;
94 /* Reuse timer thread per-set base. */
95 struct thread
*t_reuse
;
101 #define BGP_DAMP_NONE 0
102 #define BGP_DAMP_USED 1
103 #define BGP_DAMP_SUPPRESSED 2
105 /* Time granularity for reuse lists */
106 #define DELTA_REUSE 10
108 /* Time granularity for decay arrays */
111 #define DEFAULT_PENALTY 1000
113 #define DEFAULT_HALF_LIFE 15
114 #define DEFAULT_REUSE 750
115 #define DEFAULT_SUPPRESS 2000
117 #define REUSE_LIST_SIZE 256
118 #define REUSE_ARRAY_SIZE 1024
120 extern int bgp_damp_enable(struct bgp
*bgp
, afi_t afi
, safi_t safi
, time_t half
,
121 unsigned int reuse
, unsigned int suppress
,
123 extern int bgp_damp_disable(struct bgp
*bgp
, afi_t afi
, safi_t safi
);
124 extern int bgp_damp_withdraw(struct bgp_path_info
*path
, struct bgp_dest
*dest
,
125 afi_t afi
, safi_t safi
, int attr_change
);
126 extern int bgp_damp_update(struct bgp_path_info
*path
, struct bgp_dest
*dest
,
127 afi_t afi
, safi_t saff
);
128 extern void bgp_damp_info_free(struct bgp_damp_info
*path
, int withdraw
,
129 afi_t afi
, safi_t safi
);
130 extern void bgp_damp_info_clean(afi_t afi
, safi_t safi
);
131 extern int bgp_damp_decay(time_t tdiff
, int penalty
,
132 struct bgp_damp_config
*damp
);
133 extern void bgp_config_write_damp(struct vty
*vty
, afi_t afi
, safi_t safi
);
134 extern void bgp_damp_info_vty(struct vty
*vty
, struct bgp_path_info
*path
,
135 afi_t afi
, safi_t safi
, json_object
*json_path
);
136 extern const char *bgp_damp_reuse_time_vty(struct vty
*vty
,
137 struct bgp_path_info
*path
,
138 char *timebuf
, size_t len
, afi_t afi
,
139 safi_t safi
, bool use_json
,
141 extern int bgp_show_dampening_parameters(struct vty
*vty
, afi_t afi
,
142 safi_t safi
, uint16_t show_flags
);
144 #endif /* _QUAGGA_BGP_DAMP_H */