]>
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. */ |
25 | struct bgp_damp_info | |
26 | { | |
27 | /* Doubly linked list. This information must be linked to | |
28 | reuse_list or no_reuse_list. */ | |
29 | struct bgp_damp_info *next; | |
30 | struct bgp_damp_info *prev; | |
31 | ||
32 | /* Figure-of-merit. */ | |
fd79ac91 | 33 | unsigned int penalty; |
718e3744 | 34 | |
35 | /* Number of flapping. */ | |
fd79ac91 | 36 | unsigned int flap; |
718e3744 | 37 | |
38 | /* First flap time */ | |
39 | time_t start_time; | |
40 | ||
41 | /* Last time penalty was updated. */ | |
42 | time_t t_updated; | |
43 | ||
44 | /* Time of route start to be suppressed. */ | |
45 | time_t suppress_time; | |
46 | ||
47 | /* Back reference to bgp_info. */ | |
48 | struct bgp_info *binfo; | |
49 | ||
50 | /* Back reference to bgp_node. */ | |
51 | struct bgp_node *rn; | |
52 | ||
53 | /* Current index in the reuse_list. */ | |
54 | int index; | |
55 | ||
56 | /* Last time message type. */ | |
57 | u_char lastrecord; | |
fd79ac91 | 58 | #define BGP_RECORD_UPDATE 1U |
59 | #define BGP_RECORD_WITHDRAW 2U | |
718e3744 | 60 | |
61 | afi_t afi; | |
62 | safi_t safi; | |
63 | }; | |
64 | ||
65 | /* Specified parameter set configuration. */ | |
66 | struct bgp_damp_config | |
67 | { | |
68 | /* Value over which routes suppressed. */ | |
fd79ac91 | 69 | unsigned int suppress_value; |
718e3744 | 70 | |
71 | /* Value below which suppressed routes reused. */ | |
fd79ac91 | 72 | unsigned int reuse_limit; |
718e3744 | 73 | |
74 | /* Max time a route can be suppressed. */ | |
fd79ac91 | 75 | time_t max_suppress_time; |
718e3744 | 76 | |
77 | /* Time during which accumulated penalty reduces by half. */ | |
fd79ac91 | 78 | time_t half_life; |
718e3744 | 79 | |
80 | /* Non-configurable parameters but fixed at implementation time. | |
81 | * To change this values, init_bgp_damp() should be modified. | |
82 | */ | |
fd79ac91 | 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 */ | |
718e3744 | 86 | |
87 | /* Non-configurable parameters. Most of these are calculated from | |
88 | * the configurable parameters above. | |
89 | */ | |
fd79ac91 | 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 */ | |
718e3744 | 93 | double scale_factor; |
fd79ac91 | 94 | unsigned int reuse_scale_factor; |
718e3744 | 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; | |
111 | }; | |
112 | ||
113 | #define BGP_DAMP_NONE 0 | |
114 | #define BGP_DAMP_USED 1 | |
115 | #define BGP_DAMP_SUPPRESSED 2 | |
116 | ||
117 | /* Time granularity for reuse lists */ | |
118 | #define DELTA_REUSE 10 | |
119 | ||
120 | /* Time granularity for decay arrays */ | |
121 | #define DELTA_T 5 | |
122 | ||
123 | #define DEFAULT_PENALTY 1000 | |
124 | ||
125 | #define DEFAULT_HALF_LIFE 15 | |
126 | #define DEFAULT_REUSE 750 | |
127 | #define DEFAULT_SUPPRESS 2000 | |
128 | ||
129 | #define REUSE_LIST_SIZE 256 | |
130 | #define REUSE_ARRAY_SIZE 1024 | |
131 | ||
94f2b392 | 132 | extern int bgp_damp_enable (struct bgp *, afi_t, safi_t, time_t, unsigned int, |
fd79ac91 | 133 | unsigned int, time_t); |
94f2b392 | 134 | extern int bgp_damp_disable (struct bgp *, afi_t, safi_t); |
135 | extern int bgp_damp_withdraw (struct bgp_info *, struct bgp_node *, | |
718e3744 | 136 | afi_t, safi_t, int); |
94f2b392 | 137 | extern int bgp_damp_update (struct bgp_info *, struct bgp_node *, afi_t, safi_t); |
138 | extern int bgp_damp_scan (struct bgp_info *, afi_t, safi_t); | |
139 | extern void bgp_damp_info_free (struct bgp_damp_info *, int); | |
140 | extern void bgp_damp_info_clean (void); | |
94f2b392 | 141 | extern int bgp_damp_decay (time_t, int); |
f3019aff | 142 | extern void bgp_config_write_damp (struct vty *); |
b05a1c8b | 143 | extern void bgp_damp_info_vty (struct vty *, struct bgp_info *, json_object *json_path); |
50aef6f3 | 144 | extern const char * bgp_damp_reuse_time_vty (struct vty *, struct bgp_info *, |
856ca177 | 145 | char *, size_t, u_char, json_object *); |
9914e022 | 146 | extern int bgp_show_dampening_parameters (struct vty *vty, afi_t, safi_t); |
00d252cb | 147 | |
148 | #endif /* _QUAGGA_BGP_DAMP_H */ |