Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[8.0] bgp per-peer dampening revert #9320

Merged
merged 14 commits into from
Aug 7, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
522 changes: 154 additions & 368 deletions bgpd/bgp_damp.c

Large diffs are not rendered by default.

46 changes: 14 additions & 32 deletions bgpd/bgp_damp.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,11 @@

/* Structure maintained on a per-route basis. */
struct bgp_damp_info {
/* Doubly linked list. This information must be linked to
reuse_list or no_reuse_list. */
struct bgp_damp_info *next;
struct bgp_damp_info *prev;

/* Figure-of-merit. */
unsigned int penalty;

Expand All @@ -40,9 +45,6 @@ struct bgp_damp_info {
/* Time of route start to be suppressed. */
time_t suppress_time;

/* Back reference to associated dampening configuration. */
struct bgp_damp_config *config;

/* Back reference to bgp_path_info. */
struct bgp_path_info *path;

Expand All @@ -51,8 +53,6 @@ struct bgp_damp_info {

/* Current index in the reuse_list. */
int index;
#define BGP_DAMP_NO_REUSE_LIST_INDEX \
(-1) /* index for elements on no_reuse_list */

/* Last time message type. */
uint8_t lastrecord;
Expand All @@ -61,12 +61,8 @@ struct bgp_damp_info {

afi_t afi;
safi_t safi;

SLIST_ENTRY(bgp_damp_info) entry;
};

SLIST_HEAD(reuselist, bgp_damp_info);

/* Specified parameter set configuration. */
struct bgp_damp_config {
/* Value over which routes suppressed. */
Expand Down Expand Up @@ -104,11 +100,11 @@ struct bgp_damp_config {
int *reuse_index;

/* Reuse list array per-set based. */
struct reuselist *reuse_list;
unsigned int reuse_offset;
struct bgp_damp_info **reuse_list;
int reuse_offset;

/* All dampening information which is not on reuse list. */
struct reuselist no_reuse_list;
struct bgp_damp_info *no_reuse_list;

/* Reuse timer thread per-set base. */
struct thread *t_reuse;
Expand Down Expand Up @@ -136,40 +132,26 @@ struct bgp_damp_config {
#define REUSE_LIST_SIZE 256
#define REUSE_ARRAY_SIZE 1024

extern struct bgp_damp_config *get_active_bdc_from_pi(struct bgp_path_info *pi,
afi_t afi, safi_t safi);
extern int bgp_damp_enable(struct bgp *, afi_t, safi_t, time_t, unsigned int,
unsigned int, time_t);
extern int bgp_damp_disable(struct bgp *, afi_t, safi_t);
extern int bgp_damp_withdraw(struct bgp_path_info *path, struct bgp_dest *dest,
afi_t afi, safi_t safi, int attr_change);
extern int bgp_damp_update(struct bgp_path_info *path, struct bgp_dest *dest,
afi_t afi, safi_t saff);
extern void bgp_damp_info_free(struct bgp_damp_info *bdi, int withdraw);
extern void bgp_damp_info_clean(struct bgp *bgp, struct bgp_damp_config *bdc,
afi_t afi, safi_t safi);
extern void bgp_damp_config_clean(struct bgp_damp_config *bdc);
extern void bgp_damp_info_free(struct bgp_damp_info *path, int withdraw,
afi_t afi, safi_t safi);
extern void bgp_damp_info_clean(afi_t afi, safi_t safi);
extern int bgp_damp_decay(time_t, int, struct bgp_damp_config *damp);
extern void bgp_config_write_damp(struct vty *vty, struct bgp *bgp, afi_t afi,
safi_t safi);
extern void bgp_damp_info_vty(struct vty *vty, struct bgp *bgp,
struct bgp_path_info *path, afi_t afi,
safi_t safi, json_object *json_path);
extern void bgp_config_write_damp(struct vty *, afi_t afi, safi_t safi);
extern void bgp_damp_info_vty(struct vty *vty, struct bgp_path_info *path,
afi_t afi, safi_t safi, json_object *json_path);
extern const char *bgp_damp_reuse_time_vty(struct vty *vty,
struct bgp_path_info *path,
char *timebuf, size_t len, afi_t afi,
safi_t safi, bool use_json,
json_object *json);
extern int bgp_show_dampening_parameters(struct vty *vty, afi_t, safi_t,
uint8_t);
extern void bgp_peer_damp_enable(struct peer *peer, afi_t afi, safi_t safi,
time_t half, unsigned int reuse,
unsigned int suppress, time_t max);
extern void bgp_peer_damp_disable(struct peer *peer, afi_t afi, safi_t safi);
extern void bgp_config_write_peer_damp(struct vty *vty, struct peer *peer,
afi_t afi, safi_t safi);
extern void bgp_show_peer_dampening_parameters(struct vty *vty,
struct peer *peer, afi_t afi,
safi_t safi, bool use_json);

#endif /* _QUAGGA_BGP_DAMP_H */
1 change: 0 additions & 1 deletion bgpd/bgp_memory.c
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,6 @@ DEFINE_MTYPE(BGPD, PEER_UPDATE_SOURCE, "BGP peer update interface");
DEFINE_MTYPE(BGPD, PEER_CONF_IF, "BGP peer config interface");
DEFINE_MTYPE(BGPD, BGP_DAMP_INFO, "Dampening info");
DEFINE_MTYPE(BGPD, BGP_DAMP_ARRAY, "BGP Dampening array");
DEFINE_MTYPE(BGPD, BGP_DAMP_REUSELIST, "BGP Dampening reuse list");
DEFINE_MTYPE(BGPD, BGP_REGEXP, "BGP regexp");
DEFINE_MTYPE(BGPD, BGP_AGGREGATE, "BGP aggregate");
DEFINE_MTYPE(BGPD, BGP_ADDR, "BGP own address");
Expand Down
1 change: 0 additions & 1 deletion bgpd/bgp_memory.h
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,6 @@ DECLARE_MTYPE(PEER_UPDATE_SOURCE);
DECLARE_MTYPE(PEER_CONF_IF);
DECLARE_MTYPE(BGP_DAMP_INFO);
DECLARE_MTYPE(BGP_DAMP_ARRAY);
DECLARE_MTYPE(BGP_DAMP_REUSELIST);
DECLARE_MTYPE(BGP_REGEXP);
DECLARE_MTYPE(BGP_AGGREGATE);
DECLARE_MTYPE(BGP_ADDR);
Expand Down
58 changes: 20 additions & 38 deletions bgpd/bgp_route.c
Original file line number Diff line number Diff line change
Expand Up @@ -216,11 +216,11 @@ void bgp_path_info_extra_free(struct bgp_path_info_extra **extra)
return;

e = *extra;

if (e->damp_info)
bgp_damp_info_free(e->damp_info, 0);
e->damp_info = NULL;
bgp_damp_info_free(e->damp_info, 0, e->damp_info->afi,
e->damp_info->safi);

e->damp_info = NULL;
if (e->parent) {
struct bgp_path_info *bpi = (struct bgp_path_info *)e->parent;

Expand Down Expand Up @@ -3381,16 +3381,14 @@ static void bgp_rib_withdraw(struct bgp_dest *dest, struct bgp_path_info *pi,
/* apply dampening, if result is suppressed, we'll be retaining
* the bgp_path_info in the RIB for historical reference.
*/
if (peer->sort == BGP_PEER_EBGP) {
if (get_active_bdc_from_pi(pi, afi, safi)) {
if (bgp_damp_withdraw(pi, dest, afi, safi, 0)
== BGP_DAMP_SUPPRESSED) {
bgp_aggregate_decrement(peer->bgp, p, pi, afi,
safi);
return;
}
if (CHECK_FLAG(peer->bgp->af_flags[afi][safi], BGP_CONFIG_DAMPENING)
&& peer->sort == BGP_PEER_EBGP)
if ((bgp_damp_withdraw(pi, dest, afi, safi, 0))
== BGP_DAMP_SUPPRESSED) {
bgp_aggregate_decrement(peer->bgp, p, pi, afi,
safi);
return;
}
}

#ifdef ENABLE_BGP_VNC
if (safi == SAFI_MPLS_VPN) {
Expand Down Expand Up @@ -3859,7 +3857,8 @@ int bgp_update(struct peer *peer, const struct prefix *p, uint32_t addpath_id,
&& (overlay_index_equal(
afi, pi,
evpn == NULL ? NULL : &evpn->gw_ip))) {
if (get_active_bdc_from_pi(pi, afi, safi)
if (CHECK_FLAG(bgp->af_flags[afi][safi],
BGP_CONFIG_DAMPENING)
&& peer->sort == BGP_PEER_EBGP
&& CHECK_FLAG(pi->flags, BGP_PATH_HISTORY)) {
if (bgp_debug_update(peer, p, NULL, 1)) {
Expand Down Expand Up @@ -3953,11 +3952,11 @@ int bgp_update(struct peer *peer, const struct prefix *p, uint32_t addpath_id,
bgp_aggregate_decrement(bgp, p, pi, afi, safi);

/* Update bgp route dampening information. */
if (get_active_bdc_from_pi(pi, afi, safi)
if (CHECK_FLAG(bgp->af_flags[afi][safi], BGP_CONFIG_DAMPENING)
&& peer->sort == BGP_PEER_EBGP) {
/* This is implicit withdraw so we should update
* dampening information.
*/
dampening
information. */
if (!CHECK_FLAG(pi->flags, BGP_PATH_HISTORY))
bgp_damp_withdraw(pi, dest, afi, safi, 1);
}
Expand Down Expand Up @@ -4080,7 +4079,7 @@ int bgp_update(struct peer *peer, const struct prefix *p, uint32_t addpath_id,
#endif

/* Update bgp route dampening information. */
if (get_active_bdc_from_pi(pi, afi, safi)
if (CHECK_FLAG(bgp->af_flags[afi][safi], BGP_CONFIG_DAMPENING)
&& peer->sort == BGP_PEER_EBGP) {
/* Now we do normal update dampening. */
ret = bgp_damp_update(pi, dest, afi, safi);
Expand Down Expand Up @@ -10210,7 +10209,7 @@ void route_vty_out_detail(struct vty *vty, struct bgp *bgp, struct bgp_dest *bn,
}

if (path->extra && path->extra->damp_info)
bgp_damp_info_vty(vty, bgp, path, afi, safi, json_path);
bgp_damp_info_vty(vty, path, afi, safi, json_path);

/* Remote Label */
if (path->extra && bgp_is_valid_label(&path->extra->label[0])
Expand Down Expand Up @@ -14362,7 +14361,7 @@ static int bgp_clear_damp_route(struct vty *vty, const char *view_name,
pi_temp = pi->next;
bgp_damp_info_free(
pi->extra->damp_info,
1);
1, afi, safi);
pi = pi_temp;
} else
pi = pi->next;
Expand All @@ -14382,24 +14381,9 @@ static int bgp_clear_damp_route(struct vty *vty, const char *view_name,
while (pi) {
if (pi->extra && pi->extra->damp_info) {
pi_temp = pi->next;
struct bgp_damp_info *bdi =
pi->extra->damp_info;
if (bdi->lastrecord
== BGP_RECORD_UPDATE) {
bgp_aggregate_increment(
bgp,
&bdi->dest->p,
bdi->path,
bdi->afi,
bdi->safi);
bgp_process(bgp,
bdi->dest,
bdi->afi,
bdi->safi);
}
bgp_damp_info_free(
pi->extra->damp_info,
1);
1, afi, safi);
pi = pi_temp;
} else
pi = pi->next;
Expand All @@ -14421,9 +14405,7 @@ DEFUN (clear_ip_bgp_dampening,
BGP_STR
"Clear route flap dampening information\n")
{
VTY_DECLVAR_CONTEXT(bgp, bgp);
bgp_damp_info_clean(bgp, &bgp->damp[AFI_IP][SAFI_UNICAST], AFI_IP,
SAFI_UNICAST);
bgp_damp_info_clean(AFI_IP, SAFI_UNICAST);
return CMD_SUCCESS;
}

Expand Down
109 changes: 1 addition & 108 deletions bgpd/bgp_vty.c
Original file line number Diff line number Diff line change
Expand Up @@ -7948,93 +7948,6 @@ DEFPY(
return CMD_SUCCESS;
}

DEFPY(neighbor_damp,
neighbor_damp_cmd,
"neighbor <A.B.C.D|X:X::X:X|WORD>$neighbor dampening [(1-45)$half [(1-20000)$reuse (1-20000)$suppress (1-255)$max]]",
NEIGHBOR_STR
NEIGHBOR_ADDR_STR2
"Enable neighbor route-flap dampening\n"
"Half-life time for the penalty\n"
"Value to start reusing a route\n"
"Value to start suppressing a route\n"
"Maximum duration to suppress a stable route\n")
{
struct peer *peer = peer_and_group_lookup_vty(vty, neighbor);

if (!peer)
return CMD_WARNING_CONFIG_FAILED;
if (!half)
half = DEFAULT_HALF_LIFE;
if (!reuse) {
reuse = DEFAULT_REUSE;
suppress = DEFAULT_SUPPRESS;
max = half * 4;
}
if (suppress < reuse) {
vty_out(vty,
"Suppress value cannot be less than reuse value\n");
return CMD_WARNING_CONFIG_FAILED;
}
bgp_peer_damp_enable(peer, bgp_node_afi(vty), bgp_node_safi(vty),
half * 60, reuse, suppress, max * 60);
return CMD_SUCCESS;
}

DEFPY(no_neighbor_damp,
no_neighbor_damp_cmd,
"no neighbor <A.B.C.D|X:X::X:X|WORD>$neighbor dampening [HALF [REUSE SUPPRESS MAX]]",
NO_STR
NEIGHBOR_STR
NEIGHBOR_ADDR_STR2
"Enable neighbor route-flap dampening\n"
"Half-life time for the penalty\n"
"Value to start reusing a route\n"
"Value to start suppressing a route\n"
"Maximum duration to suppress a stable route\n")
{
struct peer *peer = peer_and_group_lookup_vty(vty, neighbor);

if (!peer)
return CMD_WARNING_CONFIG_FAILED;
bgp_peer_damp_disable(peer, bgp_node_afi(vty), bgp_node_safi(vty));
return CMD_SUCCESS;
}

DEFPY (show_ip_bgp_neighbor_damp_param,
show_ip_bgp_neighbor_damp_param_cmd,
"show [ip] bgp [<ipv4|ipv6> [unicast]] neighbors <A.B.C.D|X:X::X:X|WORD>$neighbor dampening parameters [json]$json",
SHOW_STR
IP_STR
BGP_STR
BGP_AFI_HELP_STR
"Address Family modifier\n"
NEIGHBOR_STR
NEIGHBOR_ADDR_STR2
"Neighbor route-flap dampening information\n"
"Display detail of configured dampening parameters\n"
JSON_STR)
{
bool use_json = false;
int idx = 0;
afi_t afi = AFI_IP;
safi_t safi = SAFI_UNICAST;
struct peer *peer;

if (argv_find(argv, argc, "ip", &idx))
afi = AFI_IP;
if (argv_find(argv, argc, "ipv4", &idx))
afi = AFI_IP;
if (argv_find(argv, argc, "ipv6", &idx))
afi = AFI_IP6;
peer = peer_and_group_lookup_vty(vty, neighbor);
if (!peer)
return CMD_WARNING;
if (json)
use_json = true;
bgp_show_peer_dampening_parameters(vty, peer, afi, safi, use_json);
return CMD_SUCCESS;
}

static int set_ecom_list(struct vty *vty, int argc, struct cmd_token **argv,
struct ecommunity **list, bool is_rt6)
{
Expand Down Expand Up @@ -16409,9 +16322,6 @@ static void bgp_config_write_peer_af(struct vty *vty, struct bgp *bgp,
: "");
}
}

if (peer_af_flag_check(peer, afi, safi, PEER_FLAG_CONFIG_DAMPENING))
bgp_config_write_peer_damp(vty, peer, afi, safi);
}

/* Address family based peer configuration display. */
Expand Down Expand Up @@ -16464,7 +16374,7 @@ static void bgp_config_write_family(struct vty *vty, struct bgp *bgp, afi_t afi,

/* BGP flag dampening. */
if (CHECK_FLAG(bgp->af_flags[afi][safi], BGP_CONFIG_DAMPENING))
bgp_config_write_damp(vty, bgp, afi, safi);
bgp_config_write_damp(vty, afi, safi);

for (ALL_LIST_ELEMENTS(bgp->group, node, nnode, group))
bgp_config_write_peer_af(vty, bgp, group->conf, afi, safi);
Expand Down Expand Up @@ -18247,23 +18157,6 @@ void bgp_vty_init(void)
install_element(BGP_EVPN_NODE, &neighbor_allowas_in_cmd);
install_element(BGP_EVPN_NODE, &no_neighbor_allowas_in_cmd);

/* "neighbor dampening" commands. */
install_element(BGP_NODE, &neighbor_damp_cmd);
install_element(BGP_NODE, &no_neighbor_damp_cmd);
install_element(BGP_IPV4_NODE, &neighbor_damp_cmd);
install_element(BGP_IPV4_NODE, &no_neighbor_damp_cmd);
install_element(BGP_IPV4M_NODE, &neighbor_damp_cmd);
install_element(BGP_IPV4M_NODE, &no_neighbor_damp_cmd);
install_element(BGP_IPV4L_NODE, &neighbor_damp_cmd);
install_element(BGP_IPV4L_NODE, &no_neighbor_damp_cmd);
install_element(BGP_IPV6_NODE, &neighbor_damp_cmd);
install_element(BGP_IPV6_NODE, &no_neighbor_damp_cmd);
install_element(BGP_IPV6M_NODE, &neighbor_damp_cmd);
install_element(BGP_IPV6M_NODE, &no_neighbor_damp_cmd);
install_element(BGP_IPV6L_NODE, &neighbor_damp_cmd);
install_element(BGP_IPV6L_NODE, &no_neighbor_damp_cmd);
install_element(VIEW_NODE, &show_ip_bgp_neighbor_damp_param_cmd);

/* address-family commands. */
install_element(BGP_NODE, &address_family_ipv4_safi_cmd);
install_element(BGP_NODE, &address_family_ipv6_safi_cmd);
Expand Down
Loading