]> git.proxmox.com Git - mirror_frr.git/blame - bgpd/bgp_damp.h
Merge pull request #13649 from donaldsharp/unlock_the_node_or_else
[mirror_frr.git] / bgpd / bgp_damp.h
CommitLineData
acddc0ed 1// SPDX-License-Identifier: GPL-2.0-or-later
718e3744 2/* BGP flap dampening
896014f4 3 * Copyright (C) 2001 IP Infusion Inc.
896014f4 4 */
718e3744 5
00d252cb 6#ifndef _QUAGGA_BGP_DAMP_H
7#define _QUAGGA_BGP_DAMP_H
8
9bcb3eef
DS
9#include "bgpd/bgp_table.h"
10
718e3744 11/* Structure maintained on a per-route basis. */
d62a17ae 12struct bgp_damp_info {
b4f7f45b
IR
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;
17
d62a17ae 18 /* Figure-of-merit. */
19 unsigned int penalty;
20
21 /* Number of flapping. */
22 unsigned int flap;
23
24 /* First flap time */
25 time_t start_time;
26
27 /* Last time penalty was updated. */
28 time_t t_updated;
29
30 /* Time of route start to be suppressed. */
31 time_t suppress_time;
32
18ee8310 33 /* Back reference to bgp_path_info. */
9b6d8fcf 34 struct bgp_path_info *path;
d62a17ae 35
36 /* Back reference to bgp_node. */
9bcb3eef 37 struct bgp_dest *dest;
d62a17ae 38
39 /* Current index in the reuse_list. */
40 int index;
41
42 /* Last time message type. */
d7c0a89a 43 uint8_t lastrecord;
fd79ac91 44#define BGP_RECORD_UPDATE 1U
45#define BGP_RECORD_WITHDRAW 2U
718e3744 46
d62a17ae 47 afi_t afi;
48 safi_t safi;
aa95cf73 49};
718e3744 50
51/* Specified parameter set configuration. */
d62a17ae 52struct bgp_damp_config {
53 /* Value over which routes suppressed. */
54 unsigned int suppress_value;
55
56 /* Value below which suppressed routes reused. */
57 unsigned int reuse_limit;
58
59 /* Max time a route can be suppressed. */
60 time_t max_suppress_time;
61
62 /* Time during which accumulated penalty reduces by half. */
63 time_t half_life;
64
65 /* Non-configurable parameters but fixed at implementation time.
66 * To change this values, init_bgp_damp() should be modified.
67 */
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 */
71
72 /* Non-configurable parameters. Most of these are calculated from
73 * the configurable parameters above.
74 */
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 */
78 double scale_factor;
79 unsigned int reuse_scale_factor;
80
81 /* Decay array per-set based. */
82 double *decay_array;
83
84 /* Reuse index array per-set based. */
85 int *reuse_index;
86
87 /* Reuse list array per-set based. */
b4f7f45b
IR
88 struct bgp_damp_info **reuse_list;
89 int reuse_offset;
d62a17ae 90
91 /* All dampening information which is not on reuse list. */
b4f7f45b 92 struct bgp_damp_info *no_reuse_list;
d62a17ae 93
94 /* Reuse timer thread per-set base. */
e6685141 95 struct event *t_reuse;
a935f597
DA
96
97 afi_t afi;
98 safi_t safi;
718e3744 99};
100
101#define BGP_DAMP_NONE 0
102#define BGP_DAMP_USED 1
103#define BGP_DAMP_SUPPRESSED 2
104
105/* Time granularity for reuse lists */
106#define DELTA_REUSE 10
107
108/* Time granularity for decay arrays */
109#define DELTA_T 5
110
111#define DEFAULT_PENALTY 1000
112
113#define DEFAULT_HALF_LIFE 15
114#define DEFAULT_REUSE 750
115#define DEFAULT_SUPPRESS 2000
116
117#define REUSE_LIST_SIZE 256
118#define REUSE_ARRAY_SIZE 1024
119
c0f0ec64
DS
120extern int bgp_damp_enable(struct bgp *bgp, afi_t afi, safi_t safi, time_t half,
121 unsigned int reuse, unsigned int suppress,
122 time_t max);
123extern int bgp_damp_disable(struct bgp *bgp, afi_t afi, safi_t safi);
9bcb3eef 124extern int bgp_damp_withdraw(struct bgp_path_info *path, struct bgp_dest *dest,
4b7e6066 125 afi_t afi, safi_t safi, int attr_change);
9bcb3eef 126extern int bgp_damp_update(struct bgp_path_info *path, struct bgp_dest *dest,
4b7e6066 127 afi_t afi, safi_t saff);
b4f7f45b 128extern void bgp_damp_info_free(struct bgp_damp_info *path, int withdraw,
5c8846f6 129 afi_t afi, safi_t safi);
b4f7f45b 130extern void bgp_damp_info_clean(afi_t afi, safi_t safi);
c0f0ec64
DS
131extern int bgp_damp_decay(time_t tdiff, int penalty,
132 struct bgp_damp_config *damp);
133extern void bgp_config_write_damp(struct vty *vty, afi_t afi, safi_t safi);
b4f7f45b
IR
134extern void bgp_damp_info_vty(struct vty *vty, struct bgp_path_info *path,
135 afi_t afi, safi_t safi, json_object *json_path);
94d4c685 136extern const char *bgp_damp_reuse_time_vty(struct vty *vty,
9b6d8fcf 137 struct bgp_path_info *path,
a935f597
DA
138 char *timebuf, size_t len, afi_t afi,
139 safi_t safi, bool use_json,
140 json_object *json);
c0f0ec64
DS
141extern int bgp_show_dampening_parameters(struct vty *vty, afi_t afi,
142 safi_t safi, uint16_t show_flags);
00d252cb 143
144#endif /* _QUAGGA_BGP_DAMP_H */