+// SPDX-License-Identifier: GPL-2.0-or-later
/* BGP flap dampening
* Copyright (C) 2001 IP Infusion Inc.
- *
- * This file is part of GNU Zebra.
- *
- * GNU Zebra is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License as published by the
- * Free Software Foundation; either version 2, or (at your option) any
- * later version.
- *
- * GNU Zebra is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License along
- * with this program; see the file COPYING; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
#ifndef _QUAGGA_BGP_DAMP_H
/* 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;
/* 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;
/* 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;
safi_t safi;
};
-struct reuselist_node {
- SLIST_ENTRY(reuselist_node) entry;
- struct bgp_damp_info *info;
-};
-
-SLIST_HEAD(reuselist, reuselist_node);
-
/* Specified parameter set configuration. */
struct bgp_damp_config {
/* Value over which routes suppressed. */
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;
#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_enable(struct bgp *bgp, afi_t afi, safi_t safi, time_t half,
+ unsigned int reuse, unsigned int suppress,
+ time_t max);
+extern int bgp_damp_disable(struct bgp *bgp, afi_t afi, safi_t safi);
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,
- struct bgp_damp_config *bdc, int withdraw,
+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(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 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_damp_info_clean(afi_t afi, safi_t safi);
+extern int bgp_damp_decay(time_t tdiff, int penalty,
+ struct bgp_damp_config *damp);
+extern void bgp_config_write_damp(struct vty *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,
- uint16_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);
+extern int bgp_show_dampening_parameters(struct vty *vty, afi_t afi,
+ safi_t safi, uint16_t show_flags);
#endif /* _QUAGGA_BGP_DAMP_H */