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