]>
Commit | Line | Data |
---|---|---|
718e3744 | 1 | /* BGP flap dampening |
896014f4 DL |
2 | * Copyright (C) 2001 IP Infusion Inc. |
3 | * | |
4 | * This file is part of GNU Zebra. | |
5 | * | |
6 | * GNU Zebra is free software; you can redistribute it and/or modify it | |
7 | * under the terms of the GNU General Public License as published by the | |
8 | * Free Software Foundation; either version 2, or (at your option) any | |
9 | * later version. | |
10 | * | |
11 | * GNU Zebra is distributed in the hope that it will be useful, but | |
12 | * WITHOUT ANY WARRANTY; without even the implied warranty of | |
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
14 | * General Public License for more details. | |
15 | * | |
16 | * You should have received a copy of the GNU General Public License along | |
17 | * with this program; see the file COPYING; if not, write to the Free Software | |
18 | * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA | |
19 | */ | |
718e3744 | 20 | |
00d252cb | 21 | #ifndef _QUAGGA_BGP_DAMP_H |
22 | #define _QUAGGA_BGP_DAMP_H | |
23 | ||
9bcb3eef DS |
24 | #include "bgpd/bgp_table.h" |
25 | ||
718e3744 | 26 | /* Structure maintained on a per-route basis. */ |
d62a17ae | 27 | struct bgp_damp_info { |
28 | /* Doubly linked list. This information must be linked to | |
29 | reuse_list or no_reuse_list. */ | |
30 | struct bgp_damp_info *next; | |
31 | struct bgp_damp_info *prev; | |
32 | ||
33 | /* Figure-of-merit. */ | |
34 | unsigned int penalty; | |
35 | ||
36 | /* Number of flapping. */ | |
37 | unsigned int flap; | |
38 | ||
39 | /* First flap time */ | |
40 | time_t start_time; | |
41 | ||
42 | /* Last time penalty was updated. */ | |
43 | time_t t_updated; | |
44 | ||
45 | /* Time of route start to be suppressed. */ | |
46 | time_t suppress_time; | |
47 | ||
18ee8310 | 48 | /* Back reference to bgp_path_info. */ |
9b6d8fcf | 49 | struct bgp_path_info *path; |
d62a17ae | 50 | |
51 | /* Back reference to bgp_node. */ | |
9bcb3eef | 52 | struct bgp_dest *dest; |
d62a17ae | 53 | |
54 | /* Current index in the reuse_list. */ | |
55 | int index; | |
56 | ||
57 | /* Last time message type. */ | |
d7c0a89a | 58 | uint8_t lastrecord; |
fd79ac91 | 59 | #define BGP_RECORD_UPDATE 1U |
60 | #define BGP_RECORD_WITHDRAW 2U | |
718e3744 | 61 | |
d62a17ae | 62 | afi_t afi; |
63 | safi_t safi; | |
718e3744 | 64 | }; |
65 | ||
66 | /* Specified parameter set configuration. */ | |
d62a17ae | 67 | struct bgp_damp_config { |
68 | /* Value over which routes suppressed. */ | |
69 | unsigned int suppress_value; | |
70 | ||
71 | /* Value below which suppressed routes reused. */ | |
72 | unsigned int reuse_limit; | |
73 | ||
74 | /* Max time a route can be suppressed. */ | |
75 | time_t max_suppress_time; | |
76 | ||
77 | /* Time during which accumulated penalty reduces by half. */ | |
78 | time_t half_life; | |
79 | ||
80 | /* Non-configurable parameters but fixed at implementation time. | |
81 | * To change this values, init_bgp_damp() should be modified. | |
82 | */ | |
83 | time_t tmax; /* Max time previous instability retained */ | |
84 | unsigned int reuse_list_size; /* Number of reuse lists */ | |
85 | unsigned int reuse_index_size; /* Size of reuse index array */ | |
86 | ||
87 | /* Non-configurable parameters. Most of these are calculated from | |
88 | * the configurable parameters above. | |
89 | */ | |
90 | unsigned int ceiling; /* Max value a penalty can attain */ | |
91 | unsigned int decay_rate_per_tick; /* Calculated from half-life */ | |
92 | unsigned int decay_array_size; /* Calculated using config parameters */ | |
93 | double scale_factor; | |
94 | unsigned int reuse_scale_factor; | |
95 | ||
96 | /* Decay array per-set based. */ | |
97 | double *decay_array; | |
98 | ||
99 | /* Reuse index array per-set based. */ | |
100 | int *reuse_index; | |
101 | ||
102 | /* Reuse list array per-set based. */ | |
103 | struct bgp_damp_info **reuse_list; | |
104 | int reuse_offset; | |
105 | ||
106 | /* All dampening information which is not on reuse list. */ | |
107 | struct bgp_damp_info *no_reuse_list; | |
108 | ||
109 | /* Reuse timer thread per-set base. */ | |
110 | struct thread *t_reuse; | |
a935f597 DA |
111 | |
112 | afi_t afi; | |
113 | safi_t safi; | |
718e3744 | 114 | }; |
115 | ||
116 | #define BGP_DAMP_NONE 0 | |
117 | #define BGP_DAMP_USED 1 | |
118 | #define BGP_DAMP_SUPPRESSED 2 | |
119 | ||
120 | /* Time granularity for reuse lists */ | |
121 | #define DELTA_REUSE 10 | |
122 | ||
123 | /* Time granularity for decay arrays */ | |
124 | #define DELTA_T 5 | |
125 | ||
126 | #define DEFAULT_PENALTY 1000 | |
127 | ||
128 | #define DEFAULT_HALF_LIFE 15 | |
129 | #define DEFAULT_REUSE 750 | |
130 | #define DEFAULT_SUPPRESS 2000 | |
131 | ||
132 | #define REUSE_LIST_SIZE 256 | |
133 | #define REUSE_ARRAY_SIZE 1024 | |
134 | ||
d62a17ae | 135 | extern int bgp_damp_enable(struct bgp *, afi_t, safi_t, time_t, unsigned int, |
136 | unsigned int, time_t); | |
137 | extern int bgp_damp_disable(struct bgp *, afi_t, safi_t); | |
9bcb3eef | 138 | extern int bgp_damp_withdraw(struct bgp_path_info *path, struct bgp_dest *dest, |
4b7e6066 | 139 | afi_t afi, safi_t safi, int attr_change); |
9bcb3eef | 140 | extern int bgp_damp_update(struct bgp_path_info *path, struct bgp_dest *dest, |
4b7e6066 | 141 | afi_t afi, safi_t saff); |
a935f597 DA |
142 | extern void bgp_damp_info_free(struct bgp_damp_info *path, int withdraw, |
143 | afi_t afi, safi_t safi); | |
144 | extern void bgp_damp_info_clean(afi_t afi, safi_t safi); | |
145 | extern int bgp_damp_decay(time_t, int, struct bgp_damp_config *damp); | |
146 | extern void bgp_config_write_damp(struct vty *, afi_t afi, safi_t safi); | |
4b7e6066 | 147 | extern void bgp_damp_info_vty(struct vty *vty, struct bgp_path_info *path, |
a935f597 | 148 | afi_t afi, safi_t safi, json_object *json_path); |
94d4c685 | 149 | extern const char *bgp_damp_reuse_time_vty(struct vty *vty, |
9b6d8fcf | 150 | struct bgp_path_info *path, |
a935f597 DA |
151 | char *timebuf, size_t len, afi_t afi, |
152 | safi_t safi, bool use_json, | |
153 | json_object *json); | |
96f3485c MK |
154 | extern int bgp_show_dampening_parameters(struct vty *vty, afi_t, safi_t, |
155 | uint8_t); | |
00d252cb | 156 | |
157 | #endif /* _QUAGGA_BGP_DAMP_H */ |