]>
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 | ||
718e3744 | 24 | /* Structure maintained on a per-route basis. */ |
d62a17ae | 25 | struct bgp_damp_info { |
26 | /* Doubly linked list. This information must be linked to | |
27 | reuse_list or no_reuse_list. */ | |
28 | struct bgp_damp_info *next; | |
29 | struct bgp_damp_info *prev; | |
30 | ||
31 | /* Figure-of-merit. */ | |
32 | unsigned int penalty; | |
33 | ||
34 | /* Number of flapping. */ | |
35 | unsigned int flap; | |
36 | ||
37 | /* First flap time */ | |
38 | time_t start_time; | |
39 | ||
40 | /* Last time penalty was updated. */ | |
41 | time_t t_updated; | |
42 | ||
43 | /* Time of route start to be suppressed. */ | |
44 | time_t suppress_time; | |
45 | ||
18ee8310 | 46 | /* Back reference to bgp_path_info. */ |
9b6d8fcf | 47 | struct bgp_path_info *path; |
d62a17ae | 48 | |
49 | /* Back reference to bgp_node. */ | |
50 | struct bgp_node *rn; | |
51 | ||
52 | /* Current index in the reuse_list. */ | |
53 | int index; | |
54 | ||
55 | /* Last time message type. */ | |
d7c0a89a | 56 | uint8_t lastrecord; |
fd79ac91 | 57 | #define BGP_RECORD_UPDATE 1U |
58 | #define BGP_RECORD_WITHDRAW 2U | |
718e3744 | 59 | |
d62a17ae | 60 | afi_t afi; |
61 | safi_t safi; | |
718e3744 | 62 | }; |
63 | ||
64 | /* Specified parameter set configuration. */ | |
d62a17ae | 65 | struct bgp_damp_config { |
66 | /* Value over which routes suppressed. */ | |
67 | unsigned int suppress_value; | |
68 | ||
69 | /* Value below which suppressed routes reused. */ | |
70 | unsigned int reuse_limit; | |
71 | ||
72 | /* Max time a route can be suppressed. */ | |
73 | time_t max_suppress_time; | |
74 | ||
75 | /* Time during which accumulated penalty reduces by half. */ | |
76 | time_t half_life; | |
77 | ||
78 | /* Non-configurable parameters but fixed at implementation time. | |
79 | * To change this values, init_bgp_damp() should be modified. | |
80 | */ | |
81 | time_t tmax; /* Max time previous instability retained */ | |
82 | unsigned int reuse_list_size; /* Number of reuse lists */ | |
83 | unsigned int reuse_index_size; /* Size of reuse index array */ | |
84 | ||
85 | /* Non-configurable parameters. Most of these are calculated from | |
86 | * the configurable parameters above. | |
87 | */ | |
88 | unsigned int ceiling; /* Max value a penalty can attain */ | |
89 | unsigned int decay_rate_per_tick; /* Calculated from half-life */ | |
90 | unsigned int decay_array_size; /* Calculated using config parameters */ | |
91 | double scale_factor; | |
92 | unsigned int reuse_scale_factor; | |
93 | ||
94 | /* Decay array per-set based. */ | |
95 | double *decay_array; | |
96 | ||
97 | /* Reuse index array per-set based. */ | |
98 | int *reuse_index; | |
99 | ||
100 | /* Reuse list array per-set based. */ | |
101 | struct bgp_damp_info **reuse_list; | |
102 | int reuse_offset; | |
103 | ||
104 | /* All dampening information which is not on reuse list. */ | |
105 | struct bgp_damp_info *no_reuse_list; | |
106 | ||
107 | /* Reuse timer thread per-set base. */ | |
108 | struct thread *t_reuse; | |
718e3744 | 109 | }; |
110 | ||
111 | #define BGP_DAMP_NONE 0 | |
112 | #define BGP_DAMP_USED 1 | |
113 | #define BGP_DAMP_SUPPRESSED 2 | |
114 | ||
115 | /* Time granularity for reuse lists */ | |
116 | #define DELTA_REUSE 10 | |
117 | ||
118 | /* Time granularity for decay arrays */ | |
119 | #define DELTA_T 5 | |
120 | ||
121 | #define DEFAULT_PENALTY 1000 | |
122 | ||
123 | #define DEFAULT_HALF_LIFE 15 | |
124 | #define DEFAULT_REUSE 750 | |
125 | #define DEFAULT_SUPPRESS 2000 | |
126 | ||
127 | #define REUSE_LIST_SIZE 256 | |
128 | #define REUSE_ARRAY_SIZE 1024 | |
129 | ||
d62a17ae | 130 | extern int bgp_damp_enable(struct bgp *, afi_t, safi_t, time_t, unsigned int, |
131 | unsigned int, time_t); | |
132 | extern int bgp_damp_disable(struct bgp *, afi_t, safi_t); | |
4b7e6066 DS |
133 | extern int bgp_damp_withdraw(struct bgp_path_info *path, struct bgp_node *rn, |
134 | afi_t afi, safi_t safi, int attr_change); | |
135 | extern int bgp_damp_update(struct bgp_path_info *path, struct bgp_node *rn, | |
136 | afi_t afi, safi_t saff); | |
137 | extern int bgp_damp_scan(struct bgp_path_info *path, afi_t afi, safi_t safi); | |
138 | extern void bgp_damp_info_free(struct bgp_damp_info *path, int withdraw); | |
d62a17ae | 139 | extern void bgp_damp_info_clean(void); |
140 | extern int bgp_damp_decay(time_t, int); | |
141 | extern void bgp_config_write_damp(struct vty *); | |
4b7e6066 | 142 | extern void bgp_damp_info_vty(struct vty *vty, struct bgp_path_info *path, |
d62a17ae | 143 | json_object *json_path); |
94d4c685 | 144 | extern const char *bgp_damp_reuse_time_vty(struct vty *vty, |
9b6d8fcf | 145 | struct bgp_path_info *path, |
94d4c685 DS |
146 | char *timebuf, size_t len, |
147 | bool use_json, json_object *json); | |
d62a17ae | 148 | extern int bgp_show_dampening_parameters(struct vty *vty, afi_t, safi_t); |
00d252cb | 149 | |
150 | #endif /* _QUAGGA_BGP_DAMP_H */ |