diff options
Diffstat (limited to 'bgpd')
-rw-r--r-- | bgpd/ChangeLog | 5 | ||||
-rw-r--r-- | bgpd/bgp_route.c | 44 | ||||
-rw-r--r-- | bgpd/bgp_vty.c | 164 | ||||
-rw-r--r-- | bgpd/bgpd.c | 52 | ||||
-rw-r--r-- | bgpd/bgpd.h | 11 |
5 files changed, 228 insertions, 48 deletions
diff --git a/bgpd/ChangeLog b/bgpd/ChangeLog index 269c5524..00072cca 100644 --- a/bgpd/ChangeLog +++ b/bgpd/ChangeLog @@ -1,5 +1,10 @@ 2005-02-01 Akihiro Mizutani <mizutani@net-chef.net> + * bgpd.[ch], bgp_vty.c, bgp_route.c: "Restart session after + maximum-prefix limit" feature support. + +2005-02-01 Akihiro Mizutani <mizutani@net-chef.net> + * bgp_nexthop.c: Improve debug. * bgpd.[ch], bgp_nexthop.c, bgp_snmp.c: Remove useless bgp_get_master() function. diff --git a/bgpd/bgp_route.c b/bgpd/bgp_route.c index 40a61b61..2e7f7b31 100644 --- a/bgpd/bgp_route.c +++ b/bgpd/bgp_route.c @@ -52,6 +52,7 @@ Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA #include "bgpd/bgp_damp.h" #include "bgpd/bgp_advertise.h" #include "bgpd/bgp_zebra.h" +#include "bgpd/bgp_vty.h" /* Extern from bgp_dump.c */ extern char *bgp_origin_str[]; @@ -1267,7 +1268,24 @@ bgp_process (struct bgp *bgp, struct bgp_node *rn, afi_t afi, safi_t safi) } return 0; } - + +int +bgp_maximum_prefix_restart_timer (struct thread *thread) +{ + struct peer *peer; + + peer = THREAD_ARG (thread); + peer->t_pmax_restart = NULL; + + if (BGP_DEBUG (events, EVENTS)) + zlog_debug ("%s Maximum-prefix restart timer expired, restore peering", + peer->host); + + peer_clear (peer); + + return 0; +} + int bgp_maximum_prefix_overflow (struct peer *peer, afi_t afi, safi_t safi, int always) @@ -1282,8 +1300,9 @@ bgp_maximum_prefix_overflow (struct peer *peer, afi_t afi, return 0; zlog (peer->log, LOG_INFO, - "%%MAXPFXEXCEED: No. of prefix received from %s (afi %d): %ld exceed limit %ld", - peer->host, afi, peer->pcount[afi][safi], peer->pmax[afi][safi]); + "%%MAXPFXEXCEED: No. of %s prefix received from %s %ld exceed, " + "limit %ld", afi_safi_print (afi, safi), peer->host, + peer->pcount[afi][safi], peer->pmax[afi][safi]); SET_FLAG (peer->af_sflags[afi][safi], PEER_STATUS_PREFIX_LIMIT); if (CHECK_FLAG (peer->af_flags[afi][safi], PEER_FLAG_MAX_PREFIX_WARNING)) @@ -1307,6 +1326,20 @@ bgp_maximum_prefix_overflow (struct peer *peer, afi_t afi, bgp_notify_send_with_data (peer, BGP_NOTIFY_CEASE, BGP_NOTIFY_CEASE_MAX_PREFIX, ndata, 7); } + + /* restart timer start */ + if (peer->pmax_restart[afi][safi]) + { + peer->v_pmax_restart = peer->pmax_restart[afi][safi] * 60; + + if (BGP_DEBUG (events, EVENTS)) + zlog_debug ("%s Maximum-prefix restart timer started for %d secs", + peer->host, peer->v_pmax_restart); + + BGP_TIMER_ON (peer->t_pmax_restart, bgp_maximum_prefix_restart_timer, + peer->v_pmax_restart); + } + return 1; } else @@ -1319,8 +1352,9 @@ bgp_maximum_prefix_overflow (struct peer *peer, afi_t afi, return 0; zlog (peer->log, LOG_INFO, - "%%MAXPFX: No. of prefix received from %s (afi %d) reaches %ld, max %ld", - peer->host, afi, peer->pcount[afi][safi], peer->pmax[afi][safi]); + "%%MAXPFX: No. of %s prefix received from %s reaches %ld, max %ld", + afi_safi_print (afi, safi), peer->host, peer->pcount[afi][safi], + peer->pmax[afi][safi]); SET_FLAG (peer->af_sflags[afi][safi], PEER_STATUS_PREFIX_THRESHOLD); } else diff --git a/bgpd/bgp_vty.c b/bgpd/bgp_vty.c index b94e66b0..02f8e4cf 100644 --- a/bgpd/bgp_vty.c +++ b/bgpd/bgp_vty.c @@ -3569,12 +3569,14 @@ DEFUN (no_neighbor_unsuppress_map, int peer_maximum_prefix_set_vty (struct vty *vty, const char *ip_str, afi_t afi, safi_t safi, const char *num_str, - const char *threshold_str, int warning) + const char *threshold_str, int warning, + const char *restart_str) { int ret; struct peer *peer; u_int32_t max; u_char threshold; + u_int16_t restart; peer = peer_and_group_lookup_vty (vty, ip_str); if (! peer) @@ -3586,7 +3588,12 @@ peer_maximum_prefix_set_vty (struct vty *vty, const char *ip_str, afi_t afi, else threshold = MAXIMUM_PREFIX_THRESHOLD_DEFAULT; - ret = peer_maximum_prefix_set (peer, afi, safi, max, threshold, warning); + if (restart_str) + restart = atoi (restart_str); + else + restart = 0; + + ret = peer_maximum_prefix_set (peer, afi, safi, max, threshold, warning, restart); return bgp_vty_return (vty, ret); } @@ -3619,7 +3626,8 @@ DEFUN (neighbor_maximum_prefix, "maximum no. of prefix limit\n") { return peer_maximum_prefix_set_vty (vty, argv[0], bgp_node_afi (vty), - bgp_node_safi (vty), argv[1], NULL, 0); + bgp_node_safi (vty), argv[1], NULL, 0, + NULL); } DEFUN (neighbor_maximum_prefix_threshold, @@ -3632,8 +3640,9 @@ DEFUN (neighbor_maximum_prefix_threshold, "Threshold value (%) at which to generate a warning msg\n") { return peer_maximum_prefix_set_vty (vty, argv[0], bgp_node_afi (vty), - bgp_node_safi (vty), argv[1], argv[2], 0); - } + bgp_node_safi (vty), argv[1], argv[2], 0, + NULL); +} DEFUN (neighbor_maximum_prefix_warning, neighbor_maximum_prefix_warning_cmd, @@ -3645,7 +3654,8 @@ DEFUN (neighbor_maximum_prefix_warning, "Only give warning message when limit is exceeded\n") { return peer_maximum_prefix_set_vty (vty, argv[0], bgp_node_afi (vty), - bgp_node_safi (vty), argv[1], NULL, 1); + bgp_node_safi (vty), argv[1], NULL, 1, + NULL); } DEFUN (neighbor_maximum_prefix_threshold_warning, @@ -3659,8 +3669,37 @@ DEFUN (neighbor_maximum_prefix_threshold_warning, "Only give warning message when limit is exceeded\n") { return peer_maximum_prefix_set_vty (vty, argv[0], bgp_node_afi (vty), - bgp_node_safi (vty), argv[1], argv[2], 1); - } + bgp_node_safi (vty), argv[1], argv[2], 1, NULL); +} + +DEFUN (neighbor_maximum_prefix_restart, + neighbor_maximum_prefix_restart_cmd, + NEIGHBOR_CMD2 "maximum-prefix <1-4294967295> restart <1-65535>", + NEIGHBOR_STR + NEIGHBOR_ADDR_STR2 + "Maximum number of prefix accept from this peer\n" + "maximum no. of prefix limit\n" + "Restart bgp connection after limit is exceeded\n" + "Restart interval in minutes") +{ + return peer_maximum_prefix_set_vty (vty, argv[0], bgp_node_afi (vty), + bgp_node_safi (vty), argv[1], NULL, 0, argv[2]); +} + +DEFUN (neighbor_maximum_prefix_threshold_restart, + neighbor_maximum_prefix_threshold_restart_cmd, + NEIGHBOR_CMD2 "maximum-prefix <1-4294967295> <1-100> restart <1-65535>", + NEIGHBOR_STR + NEIGHBOR_ADDR_STR2 + "Maximum number of prefix accept from this peer\n" + "maximum no. of prefix limit\n" + "Threshold value (%) at which to generate a warning msg\n" + "Restart bgp connection after limit is exceeded\n" + "Restart interval in minutes") +{ + return peer_maximum_prefix_set_vty (vty, argv[0], bgp_node_afi (vty), + bgp_node_safi (vty), argv[1], argv[2], 0, argv[3]); +} DEFUN (no_neighbor_maximum_prefix, no_neighbor_maximum_prefix_cmd, @@ -3684,7 +3723,27 @@ ALIAS (no_neighbor_maximum_prefix, "maximum no. of prefix limit\n") ALIAS (no_neighbor_maximum_prefix, - no_neighbor_maximum_prefix_val2_cmd, + no_neighbor_maximum_prefix_threshold_cmd, + NO_NEIGHBOR_CMD2 "maximum-prefix <1-4294967295> warning-only", + NO_STR + NEIGHBOR_STR + NEIGHBOR_ADDR_STR2 + "Maximum number of prefix accept from this peer\n" + "maximum no. of prefix limit\n" + "Threshold value (%) at which to generate a warning msg\n") + +ALIAS (no_neighbor_maximum_prefix, + no_neighbor_maximum_prefix_warning_cmd, + NO_NEIGHBOR_CMD2 "maximum-prefix <1-4294967295> warning-only", + NO_STR + NEIGHBOR_STR + NEIGHBOR_ADDR_STR2 + "Maximum number of prefix accept from this peer\n" + "maximum no. of prefix limit\n" + "Only give warning message when limit is exceeded\n"); + +ALIAS (no_neighbor_maximum_prefix, + no_neighbor_maximum_prefix_threshold_warning_cmd, NO_NEIGHBOR_CMD2 "maximum-prefix <1-4294967295> <1-100> warning-only", NO_STR NEIGHBOR_STR @@ -3692,17 +3751,30 @@ ALIAS (no_neighbor_maximum_prefix, "Maximum number of prefix accept from this peer\n" "maximum no. of prefix limit\n" "Threshold value (%) at which to generate a warning msg\n" - "Only give warning message when limit is exceeded\n") + "Only give warning message when limit is exceeded\n"); ALIAS (no_neighbor_maximum_prefix, - no_neighbor_maximum_prefix_val3_cmd, - NO_NEIGHBOR_CMD2 "maximum-prefix <1-4294967295> warning-only", + no_neighbor_maximum_prefix_restart_cmd, + NO_NEIGHBOR_CMD2 "maximum-prefix <1-4294967295> restart <1-65535>", NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 "Maximum number of prefix accept from this peer\n" "maximum no. of prefix limit\n" - "Only give warning message when limit is exceeded\n") + "Restart bgp connection after limit is exceeded\n" + "Restart interval in minutes") + +ALIAS (no_neighbor_maximum_prefix, + no_neighbor_maximum_prefix_threshold_restart_cmd, + NO_NEIGHBOR_CMD2 "maximum-prefix <1-4294967295> <1-100> restart <1-65535>", + NO_STR + NEIGHBOR_STR + NEIGHBOR_ADDR_STR2 + "Maximum number of prefix accept from this peer\n" + "maximum no. of prefix limit\n" + "Threshold value (%) at which to generate a warning msg\n" + "Restart bgp connection after limit is exceeded\n" + "Restart interval in minutes") /* "neighbor allowas-in" */ DEFUN (neighbor_allowas_in, @@ -6860,11 +6932,14 @@ bgp_show_peer_afi (struct vty *vty, struct peer *p, afi_t afi, safi_t safi) /* Maximum prefix */ if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_MAX_PREFIX)) { - vty_out (vty, " maximum limit %ld%s%s", p->pmax[afi][safi], + vty_out (vty, " Maximum prefixes allowed %ld%s%s", p->pmax[afi][safi], CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_MAX_PREFIX_WARNING) - ? " (warning-only)" : "", VTY_NEWLINE); - vty_out (vty, " Threshold for warning message %d%%%s", p->pmax_threshold [afi][safi], - VTY_NEWLINE); + ? " (warning-only)" : "", VTY_NEWLINE); + vty_out (vty, " Threshold for warning message %d%%", + p->pmax_threshold[afi][safi]); + if (p->pmax_restart[afi][safi]) + vty_out (vty, ", restart interval %d min", p->pmax_restart[afi][safi]); + vty_out (vty, "%s", VTY_NEWLINE); } vty_out (vty, "%s", VTY_NEWLINE); @@ -7092,8 +7167,14 @@ bgp_show_peer (struct vty *vty, struct peer *p) if (CHECK_FLAG (p->sflags, PEER_STATUS_PREFIX_OVERFLOW)) { vty_out (vty, " Peer had exceeded the max. no. of prefixes configured.%s", VTY_NEWLINE); - vty_out (vty, " Reduce the no. of prefix and clear ip bgp %s to restore peering%s", - p->host, VTY_NEWLINE); + + if (p->t_pmax_restart) + vty_out (vty, " Reduce the no. of prefix from %s, will restart in %ld seconds%s", + p->host, thread_timer_remain_second (p->t_pmax_restart), + VTY_NEWLINE); + else + vty_out (vty, " Reduce the no. of prefix and clear ip bgp %s to restore peering%s", + p->host, VTY_NEWLINE); } /* EBGP Multihop */ @@ -8923,42 +9004,67 @@ bgp_vty_init () install_element (BGP_NODE, &neighbor_maximum_prefix_threshold_cmd); install_element (BGP_NODE, &neighbor_maximum_prefix_warning_cmd); install_element (BGP_NODE, &neighbor_maximum_prefix_threshold_warning_cmd); + install_element (BGP_NODE, &neighbor_maximum_prefix_restart_cmd); + install_element (BGP_NODE, &neighbor_maximum_prefix_threshold_restart_cmd); install_element (BGP_NODE, &no_neighbor_maximum_prefix_cmd); install_element (BGP_NODE, &no_neighbor_maximum_prefix_val_cmd); - install_element (BGP_NODE, &no_neighbor_maximum_prefix_val2_cmd); - install_element (BGP_NODE, &no_neighbor_maximum_prefix_val3_cmd); + install_element (BGP_NODE, &no_neighbor_maximum_prefix_threshold_cmd); + install_element (BGP_NODE, &no_neighbor_maximum_prefix_warning_cmd); + install_element (BGP_NODE, &no_neighbor_maximum_prefix_threshold_warning_cmd); + install_element (BGP_NODE, &no_neighbor_maximum_prefix_restart_cmd); + install_element (BGP_NODE, &no_neighbor_maximum_prefix_threshold_restart_cmd); install_element (BGP_IPV4_NODE, &neighbor_maximum_prefix_cmd); install_element (BGP_IPV4_NODE, &neighbor_maximum_prefix_threshold_cmd); install_element (BGP_IPV4_NODE, &neighbor_maximum_prefix_warning_cmd); install_element (BGP_IPV4_NODE, &neighbor_maximum_prefix_threshold_warning_cmd); + install_element (BGP_IPV4_NODE, &neighbor_maximum_prefix_restart_cmd); + install_element (BGP_IPV4_NODE, &neighbor_maximum_prefix_threshold_restart_cmd); install_element (BGP_IPV4_NODE, &no_neighbor_maximum_prefix_cmd); install_element (BGP_IPV4_NODE, &no_neighbor_maximum_prefix_val_cmd); - install_element (BGP_IPV4_NODE, &no_neighbor_maximum_prefix_val2_cmd); - install_element (BGP_IPV4_NODE, &no_neighbor_maximum_prefix_val3_cmd); + install_element (BGP_IPV4_NODE, &no_neighbor_maximum_prefix_threshold_cmd); + install_element (BGP_IPV4_NODE, &no_neighbor_maximum_prefix_warning_cmd); + install_element (BGP_IPV4_NODE, &no_neighbor_maximum_prefix_threshold_warning_cmd); + install_element (BGP_IPV4_NODE, &no_neighbor_maximum_prefix_restart_cmd); + install_element (BGP_IPV4_NODE, &no_neighbor_maximum_prefix_threshold_restart_cmd); install_element (BGP_IPV4M_NODE, &neighbor_maximum_prefix_cmd); install_element (BGP_IPV4M_NODE, &neighbor_maximum_prefix_threshold_cmd); install_element (BGP_IPV4M_NODE, &neighbor_maximum_prefix_warning_cmd); install_element (BGP_IPV4M_NODE, &neighbor_maximum_prefix_threshold_warning_cmd); + install_element (BGP_IPV4M_NODE, &neighbor_maximum_prefix_restart_cmd); + install_element (BGP_IPV4M_NODE, &neighbor_maximum_prefix_threshold_restart_cmd); install_element (BGP_IPV4M_NODE, &no_neighbor_maximum_prefix_cmd); install_element (BGP_IPV4M_NODE, &no_neighbor_maximum_prefix_val_cmd); - install_element (BGP_IPV4M_NODE, &no_neighbor_maximum_prefix_val2_cmd); - install_element (BGP_IPV4M_NODE, &no_neighbor_maximum_prefix_val3_cmd); + install_element (BGP_IPV4M_NODE, &no_neighbor_maximum_prefix_threshold_cmd); + install_element (BGP_IPV4M_NODE, &no_neighbor_maximum_prefix_warning_cmd); + install_element (BGP_IPV4M_NODE, &no_neighbor_maximum_prefix_threshold_warning_cmd); + install_element (BGP_IPV4M_NODE, &no_neighbor_maximum_prefix_restart_cmd); + install_element (BGP_IPV4M_NODE, &no_neighbor_maximum_prefix_threshold_restart_cmd); install_element (BGP_IPV6_NODE, &neighbor_maximum_prefix_cmd); install_element (BGP_IPV6_NODE, &neighbor_maximum_prefix_threshold_cmd); install_element (BGP_IPV6_NODE, &neighbor_maximum_prefix_warning_cmd); install_element (BGP_IPV6_NODE, &neighbor_maximum_prefix_threshold_warning_cmd); + install_element (BGP_IPV6_NODE, &neighbor_maximum_prefix_restart_cmd); + install_element (BGP_IPV6_NODE, &neighbor_maximum_prefix_threshold_restart_cmd); install_element (BGP_IPV6_NODE, &no_neighbor_maximum_prefix_cmd); install_element (BGP_IPV6_NODE, &no_neighbor_maximum_prefix_val_cmd); - install_element (BGP_IPV6_NODE, &no_neighbor_maximum_prefix_val2_cmd); - install_element (BGP_IPV6_NODE, &no_neighbor_maximum_prefix_val3_cmd); + install_element (BGP_IPV6_NODE, &no_neighbor_maximum_prefix_threshold_cmd); + install_element (BGP_IPV6_NODE, &no_neighbor_maximum_prefix_warning_cmd); + install_element (BGP_IPV6_NODE, &no_neighbor_maximum_prefix_threshold_warning_cmd); + install_element (BGP_IPV6_NODE, &no_neighbor_maximum_prefix_restart_cmd); + install_element (BGP_IPV6_NODE, &no_neighbor_maximum_prefix_threshold_restart_cmd); install_element (BGP_VPNV4_NODE, &neighbor_maximum_prefix_cmd); install_element (BGP_VPNV4_NODE, &neighbor_maximum_prefix_threshold_cmd); install_element (BGP_VPNV4_NODE, &neighbor_maximum_prefix_warning_cmd); install_element (BGP_VPNV4_NODE, &neighbor_maximum_prefix_threshold_warning_cmd); + install_element (BGP_VPNV4_NODE, &neighbor_maximum_prefix_restart_cmd); + install_element (BGP_VPNV4_NODE, &neighbor_maximum_prefix_threshold_restart_cmd); install_element (BGP_VPNV4_NODE, &no_neighbor_maximum_prefix_cmd); install_element (BGP_VPNV4_NODE, &no_neighbor_maximum_prefix_val_cmd); - install_element (BGP_VPNV4_NODE, &no_neighbor_maximum_prefix_val2_cmd); - install_element (BGP_VPNV4_NODE, &no_neighbor_maximum_prefix_val3_cmd); + install_element (BGP_VPNV4_NODE, &no_neighbor_maximum_prefix_threshold_cmd); + install_element (BGP_VPNV4_NODE, &no_neighbor_maximum_prefix_warning_cmd); + install_element (BGP_VPNV4_NODE, &no_neighbor_maximum_prefix_threshold_warning_cmd); + install_element (BGP_VPNV4_NODE, &no_neighbor_maximum_prefix_restart_cmd); + install_element (BGP_VPNV4_NODE, &no_neighbor_maximum_prefix_threshold_restart_cmd); /* "neighbor allowas-in" */ install_element (BGP_NODE, &neighbor_allowas_in_cmd); diff --git a/bgpd/bgpd.c b/bgpd/bgpd.c index cb760d90..097b235c 100644 --- a/bgpd/bgpd.c +++ b/bgpd/bgpd.c @@ -1075,6 +1075,7 @@ peer_delete (struct peer *peer) BGP_TIMER_OFF (peer->t_keepalive); BGP_TIMER_OFF (peer->t_asorig); BGP_TIMER_OFF (peer->t_routeadv); + BGP_TIMER_OFF (peer->t_pmax_restart); /* Delete from all peer list. */ if (! CHECK_FLAG (peer->sflags, PEER_STATUS_GROUP)) @@ -1296,6 +1297,7 @@ peer_group2peer_config_copy (struct peer_group *group, struct peer *peer, /* maximum-prefix */ peer->pmax[afi][safi] = conf->pmax[afi][safi]; peer->pmax_threshold[afi][safi] = conf->pmax_threshold[afi][safi]; + peer->pmax_restart[afi][safi] = conf->pmax_restart[afi][safi]; /* allowas-in */ peer->allowas_in[afi][safi] = conf->allowas_in[afi][safi]; @@ -2148,6 +2150,15 @@ peer_flag_modify_action (struct peer *peer, u_int32_t flag) { if (CHECK_FLAG (peer->flags, flag)) { + UNSET_FLAG (peer->sflags, PEER_STATUS_PREFIX_OVERFLOW); + if (peer->t_pmax_restart) + { + BGP_TIMER_OFF (peer->t_pmax_restart); + if (BGP_DEBUG (events, EVENTS)) + zlog_debug ("%s Maximum-prefix restart timer canceled", + peer->host); + } + if (peer->status == Established) bgp_notify_send (peer, BGP_NOTIFY_CEASE, BGP_NOTIFY_CEASE_ADMIN_SHUTDOWN); @@ -3923,7 +3934,8 @@ peer_unsuppress_map_unset (struct peer *peer, afi_t afi, safi_t safi) int peer_maximum_prefix_set (struct peer *peer, afi_t afi, safi_t safi, - u_int32_t max, u_char threshold, int warning) + u_int32_t max, u_char threshold, + int warning, u_int16_t restart) { struct peer_group *group; struct listnode *nn; @@ -3934,6 +3946,7 @@ peer_maximum_prefix_set (struct peer *peer, afi_t afi, safi_t safi, SET_FLAG (peer->af_flags[afi][safi], PEER_FLAG_MAX_PREFIX); peer->pmax[afi][safi] = max; peer->pmax_threshold[afi][safi] = threshold; + peer->pmax_restart[afi][safi] = restart; if (warning) SET_FLAG (peer->af_flags[afi][safi], PEER_FLAG_MAX_PREFIX_WARNING); else @@ -3951,6 +3964,7 @@ peer_maximum_prefix_set (struct peer *peer, afi_t afi, safi_t safi, SET_FLAG (peer->af_flags[afi][safi], PEER_FLAG_MAX_PREFIX); peer->pmax[afi][safi] = max; peer->pmax_threshold[afi][safi] = threshold; + peer->pmax_restart[afi][safi] = restart; if (warning) SET_FLAG (peer->af_flags[afi][safi], PEER_FLAG_MAX_PREFIX_WARNING); else @@ -3985,13 +3999,15 @@ peer_maximum_prefix_unset (struct peer *peer, afi_t afi, safi_t safi) peer->pmax[afi][safi] = peer->group->conf->pmax[afi][safi]; peer->pmax_threshold[afi][safi] = peer->group->conf->pmax_threshold[afi][safi]; + peer->pmax_restart[afi][safi] = peer->group->conf->pmax_restart[afi][safi]; return 0; } UNSET_FLAG (peer->af_flags[afi][safi], PEER_FLAG_MAX_PREFIX); UNSET_FLAG (peer->af_flags[afi][safi], PEER_FLAG_MAX_PREFIX_WARNING); peer->pmax[afi][safi] = 0; - peer->pmax_threshold[afi][safi] = MAXIMUM_PREFIX_THRESHOLD_DEFAULT; + peer->pmax_threshold[afi][safi] = 0; + peer->pmax_restart[afi][safi] = 0; if (! CHECK_FLAG (peer->sflags, PEER_STATUS_GROUP)) return 0; @@ -4005,7 +4021,8 @@ peer_maximum_prefix_unset (struct peer *peer, afi_t afi, safi_t safi) UNSET_FLAG (peer->af_flags[afi][safi], PEER_FLAG_MAX_PREFIX); UNSET_FLAG (peer->af_flags[afi][safi], PEER_FLAG_MAX_PREFIX_WARNING); peer->pmax[afi][safi] = 0; - peer->pmax_threshold[afi][safi] = MAXIMUM_PREFIX_THRESHOLD_DEFAULT; + peer->pmax_threshold[afi][safi] = 0; + peer->pmax_restart[afi][safi] = 0; } return 0; } @@ -4015,7 +4032,20 @@ peer_clear (struct peer *peer) { if (! CHECK_FLAG (peer->flags, PEER_FLAG_SHUTDOWN)) { - UNSET_FLAG (peer->sflags, PEER_STATUS_PREFIX_OVERFLOW); + if (CHECK_FLAG (peer->sflags, PEER_STATUS_PREFIX_OVERFLOW)) + { + UNSET_FLAG (peer->sflags, PEER_STATUS_PREFIX_OVERFLOW); + if (peer->t_pmax_restart) + { + BGP_TIMER_OFF (peer->t_pmax_restart); + if (BGP_DEBUG (events, EVENTS)) + zlog_debug ("%s Maximum-prefix restart timer canceled", + peer->host); + } + BGP_EVENT_ADD (peer, BGP_Start); + return 0; + } + peer->v_start = BGP_INIT_START_TIMER; if (peer->status == Established) bgp_notify_send (peer, BGP_NOTIFY_CEASE, @@ -4499,12 +4529,14 @@ bgp_config_write_peer (struct vty *vty, struct bgp *bgp, || CHECK_FLAG (g_peer->af_flags[afi][safi], PEER_FLAG_MAX_PREFIX_WARNING) != CHECK_FLAG (peer->af_flags[afi][safi], PEER_FLAG_MAX_PREFIX_WARNING)) { - vty_out (vty, " neighbor %s maximum-prefix %ld", addr, peer->pmax[afi][safi]); - if (peer->pmax_threshold[afi][safi] != MAXIMUM_PREFIX_THRESHOLD_DEFAULT) - vty_out (vty, " %d", peer->pmax_threshold[afi][safi]); - if (CHECK_FLAG (peer->af_flags[afi][safi], PEER_FLAG_MAX_PREFIX_WARNING)) - vty_out (vty, " warning-only"); - vty_out (vty, "%s", VTY_NEWLINE); + vty_out (vty, " neighbor %s maximum-prefix %ld", addr, peer->pmax[afi][safi]); + if (peer->pmax_threshold[afi][safi] != MAXIMUM_PREFIX_THRESHOLD_DEFAULT) + vty_out (vty, " %d", peer->pmax_threshold[afi][safi]); + if (CHECK_FLAG (peer->af_flags[afi][safi], PEER_FLAG_MAX_PREFIX_WARNING)) + vty_out (vty, " warning-only"); + if (peer->pmax_restart[afi][safi]) + vty_out (vty, " restart %d", peer->pmax_restart[afi][safi]); + vty_out (vty, "%s", VTY_NEWLINE); } /* Route server client. */ diff --git a/bgpd/bgpd.h b/bgpd/bgpd.h index 42c3ceaa..7a0707c0 100644 --- a/bgpd/bgpd.h +++ b/bgpd/bgpd.h @@ -301,7 +301,7 @@ struct peer u_char afc_adv[AFI_MAX][SAFI_MAX]; u_char afc_recv[AFI_MAX][SAFI_MAX]; - /* Capability Flags.*/ + /* Capability flags (reset in bgp_stop) */ u_char cap; #define PEER_CAP_REFRESH_ADV (1 << 0) /* refresh advertised */ #define PEER_CAP_REFRESH_OLD_RCV (1 << 1) /* refresh old received */ @@ -311,7 +311,7 @@ struct peer #define PEER_CAP_RESTART_ADV (1 << 5) /* restart advertised */ #define PEER_CAP_RESTART_RCV (1 << 6) /* restart received */ - /* Capability Flags.*/ + /* Capability flags (reset in bgp_stop) */ u_int16_t af_cap[AFI_MAX][SAFI_MAX]; #define PEER_CAP_ORF_PREFIX_SM_ADV (1 << 0) /* send-mode advertised */ #define PEER_CAP_ORF_PREFIX_RM_ADV (1 << 1) /* receive-mode advertised */ @@ -371,7 +371,7 @@ struct peer #define PEER_STATUS_HAVE_ACCEPT (1 << 3) /* accept peer's parent */ #define PEER_STATUS_GROUP (1 << 4) /* peer-group conf */ - /* Peer status af flags. */ + /* Peer status af flags (reset in bgp_stop) */ u_int16_t af_sflags[AFI_MAX][SAFI_MAX]; #define PEER_STATUS_ORF_PREFIX_SEND (1 << 0) /* prefix-list send peer */ #define PEER_STATUS_ORF_WAIT_REFRESH (1 << 1) /* wait refresh received peer */ @@ -399,6 +399,7 @@ struct peer u_int32_t v_keepalive; u_int32_t v_asorig; u_int32_t v_routeadv; + u_int32_t v_pmax_restart; /* Threads. */ struct thread *t_read; @@ -409,6 +410,7 @@ struct peer struct thread *t_keepalive; struct thread *t_asorig; struct thread *t_routeadv; + struct thread *t_pmax_restart; /* Statistics field */ u_int32_t open_in; /* Open message input count */ @@ -457,6 +459,7 @@ struct peer /* Max prefix count. */ unsigned long pmax[AFI_MAX][SAFI_MAX]; u_char pmax_threshold[AFI_MAX][SAFI_MAX]; + u_int16_t pmax_restart[AFI_MAX][SAFI_MAX]; #define MAXIMUM_PREFIX_THRESHOLD_DEFAULT 75 /* allowas-in. */ @@ -891,7 +894,7 @@ int peer_route_map_unset (struct peer *, afi_t, safi_t, int); int peer_unsuppress_map_set (struct peer *, afi_t, safi_t, const char *); int peer_unsuppress_map_unset (struct peer *, afi_t, safi_t); -int peer_maximum_prefix_set (struct peer *, afi_t, safi_t, u_int32_t, u_char, int); +int peer_maximum_prefix_set (struct peer *, afi_t, safi_t, u_int32_t, u_char, int, u_int16_t); int peer_maximum_prefix_unset (struct peer *, afi_t, safi_t); int peer_clear (struct peer *); |