--- embedaddon/quagga/bgpd/bgp_damp.c 2012/10/09 09:22:28 1.1.1.2 +++ embedaddon/quagga/bgpd/bgp_damp.c 2016/11/02 10:09:10 1.1.1.3 @@ -26,6 +26,7 @@ Software Foundation, Inc., 59 Temple Place - Suite 330 #include "command.h" #include "log.h" #include "thread.h" +#include "filter.h" #include "bgpd/bgpd.h" #include "bgpd/bgp_damp.h" @@ -42,7 +43,7 @@ static struct bgp_damp_config *damp = &bgp_damp_cfg; used list. */ #define BGP_DAMP_LIST_ADD(N,A) BGP_INFO_ADD(N,A,no_reuse_list) #define BGP_DAMP_LIST_DEL(N,A) BGP_INFO_DEL(N,A,no_reuse_list) - + /* Calculate reuse list index by penalty value. */ static int bgp_reuse_index (int penalty) @@ -86,7 +87,7 @@ bgp_reuse_list_delete (struct bgp_damp_info *bdi) else damp->reuse_list[bdi->index] = bdi->next; } - + /* Return decayed penalty value. */ int bgp_damp_decay (time_t tdiff, int penalty) @@ -115,7 +116,7 @@ bgp_reuse_timer (struct thread *t) damp->t_reuse = NULL; damp->t_reuse = - thread_add_timer (master, bgp_reuse_timer, NULL, DELTA_REUSE); + thread_add_timer (bm->master, bgp_reuse_timer, NULL, DELTA_REUSE); t_now = bgp_clock (); @@ -447,7 +448,7 @@ bgp_damp_enable (struct bgp *bgp, afi_t afi, safi_t sa /* Register reuse timer. */ if (! damp->t_reuse) damp->t_reuse = - thread_add_timer (master, bgp_reuse_timer, NULL, DELTA_REUSE); + thread_add_timer (bm->master, bgp_reuse_timer, NULL, DELTA_REUSE); return 0; } @@ -529,15 +530,15 @@ bgp_config_write_damp (struct vty *vty) && bgp_damp_cfg.reuse_limit == DEFAULT_REUSE && bgp_damp_cfg.suppress_value == DEFAULT_SUPPRESS && bgp_damp_cfg.max_suppress_time == bgp_damp_cfg.half_life*4) - vty_out (vty, " bgp dampening %ld%s", - bgp_damp_cfg.half_life/60, + vty_out (vty, " bgp dampening %lld%s", + bgp_damp_cfg.half_life/60LL, VTY_NEWLINE); else - vty_out (vty, " bgp dampening %ld %d %d %ld%s", - bgp_damp_cfg.half_life/60, + vty_out (vty, " bgp dampening %lld %d %d %lld%s", + bgp_damp_cfg.half_life/60LL, bgp_damp_cfg.reuse_limit, bgp_damp_cfg.suppress_value, - bgp_damp_cfg.max_suppress_time/60, + bgp_damp_cfg.max_suppress_time/60LL, VTY_NEWLINE); } @@ -638,4 +639,37 @@ bgp_damp_reuse_time_vty (struct vty *vty, struct bgp_i penalty = bgp_damp_decay (t_diff, bdi->penalty); return bgp_get_reuse_time (penalty, timebuf, len); +} + +int +bgp_show_dampening_parameters (struct vty *vty, afi_t afi, safi_t safi) +{ + struct bgp *bgp; + bgp = bgp_get_default(); + + if (bgp == NULL) + { + vty_out (vty, "No BGP process is configured%s", VTY_NEWLINE); + return CMD_WARNING; + } + + if (CHECK_FLAG (bgp->af_flags[afi][safi], BGP_CONFIG_DAMPENING)) + { + vty_out (vty, "Half-life time: %ld min%s", + damp->half_life / 60, VTY_NEWLINE); + vty_out (vty, "Reuse penalty: %d%s", + damp->reuse_limit, VTY_NEWLINE); + vty_out (vty, "Suppress penalty: %d%s", + damp->suppress_value, VTY_NEWLINE); + vty_out (vty, "Max suppress time: %ld min%s", + damp->max_suppress_time / 60, VTY_NEWLINE); + vty_out (vty, "Max supress penalty: %u%s", + damp->ceiling, VTY_NEWLINE); + vty_out (vty, "%s", VTY_NEWLINE); + } + else + vty_out (vty, "dampening not enabled for %s%s", + afi == AFI_IP ? "IPv4" : "IPv6", VTY_NEWLINE); + + return CMD_SUCCESS; }