From 0a486e5fcb1b8dac7d8b4cf6ed93e82b8b72fed6 Mon Sep 17 00:00:00 2001 From: hasso Date: Tue, 1 Feb 2005 20:57:17 +0000 Subject: * bgpd.[ch], bgp_vty.c, bgp_route.c: "Restart session after maximum-prefix limit" feature support. [merge from GNU Zebra] --- bgpd/bgp_vty.c | 164 +++++++++++++++++++++++++++++++++++++++++++++++---------- 1 file changed, 135 insertions(+), 29 deletions(-) (limited to 'bgpd/bgp_vty.c') 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); -- cgit v1.2.1