]> git.proxmox.com Git - mirror_frr.git/blobdiff - bgpd/bgp_vty.c
bgpd: Adding BGP GR Global & Per Neighbour FSM changes
[mirror_frr.git] / bgpd / bgp_vty.c
index 0ff64c527bfe1a5ec0dcb22e7e21ea684e5ca0dc..9dc6549d9c40c8df295bd0dccc37f733d5cdbf5e 100644 (file)
@@ -2691,8 +2691,8 @@ DEFUN (bgp_listen_limit,
        bgp_listen_limit_cmd,
        "bgp listen limit (1-5000)",
        "BGP specific commands\n"
-       "Configure BGP defaults\n"
-       "maximum number of BGP Dynamic Neighbors that can be created\n"
+       "BGP Dynamic Neighbors listen commands\n"
+       "Maximum number of BGP Dynamic Neighbors that can be created\n"
        "Configure Dynamic Neighbors listen limit value\n")
 {
        VTY_DECLVAR_CONTEXT(bgp, bgp);
@@ -2709,10 +2709,10 @@ DEFUN (bgp_listen_limit,
 DEFUN (no_bgp_listen_limit,
        no_bgp_listen_limit_cmd,
        "no bgp listen limit [(1-5000)]",
+       NO_STR
        "BGP specific commands\n"
-       "Configure BGP defaults\n"
-       "unset maximum number of BGP Dynamic Neighbors that can be created\n"
-       "Configure Dynamic Neighbors listen limit value to default\n"
+       "BGP Dynamic Neighbors listen commands\n"
+       "Maximum number of BGP Dynamic Neighbors that can be created\n"
        "Configure Dynamic Neighbors listen limit value\n")
 {
        VTY_DECLVAR_CONTEXT(bgp, bgp);
@@ -2843,7 +2843,7 @@ DEFUN (no_bgp_listen_range,
        argv_find(argv, argc, "A.B.C.D/M", &idx);
        argv_find(argv, argc, "X:X::X:X/M", &idx);
        char *prefix = argv[idx]->arg;
-       argv_find(argv, argc, "WORD", &idx);
+       argv_find(argv, argc, "PGNAME", &idx);
        char *peergroup = argv[idx]->arg;
 
        /* Convert IP prefix string to struct prefix. */
@@ -6058,6 +6058,56 @@ static int peer_maximum_prefix_unset_vty(struct vty *vty, const char *ip_str,
        return bgp_vty_return(vty, ret);
 }
 
+/* Maximum number of prefix to be sent to the neighbor. */
+DEFUN(neighbor_maximum_prefix_out,
+      neighbor_maximum_prefix_out_cmd,
+      "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix-out (1-4294967295)",
+      NEIGHBOR_STR
+      NEIGHBOR_ADDR_STR2
+      "Maximum number of prefixes to be sent to this peer\n"
+      "Maximum no. of prefix limit\n")
+{
+       int idx_peer = 1;
+       int idx_number = 3;
+       struct peer *peer;
+       uint32_t max;
+       afi_t afi = bgp_node_afi(vty);
+       safi_t safi = bgp_node_safi(vty);
+
+       peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg);
+       if (!peer)
+               return CMD_WARNING_CONFIG_FAILED;
+
+       max = strtoul(argv[idx_number]->arg, NULL, 10);
+
+       SET_FLAG(peer->af_flags[afi][safi], PEER_FLAG_MAX_PREFIX_OUT);
+       peer->pmax_out[afi][safi] = max;
+
+       return CMD_SUCCESS;
+}
+
+DEFUN(no_neighbor_maximum_prefix_out,
+      no_neighbor_maximum_prefix_out_cmd,
+      "no neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix-out",
+      NO_STR
+      NEIGHBOR_STR
+      NEIGHBOR_ADDR_STR2
+      "Maximum number of prefixes to be sent to this peer\n")
+{
+       int idx_peer = 2;
+       struct peer *peer;
+       afi_t afi = bgp_node_afi(vty);
+       safi_t safi = bgp_node_safi(vty);
+
+       peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg);
+       if (!peer)
+               return CMD_WARNING_CONFIG_FAILED;
+
+       peer->pmax_out[afi][safi] = 0;
+
+       return CMD_SUCCESS;
+}
+
 /* Maximum number of prefix configuration.  prefix count is different
    for each peer configuration.  So this configuration can be set for
    each peer configuration. */
@@ -7693,7 +7743,7 @@ DEFUN (show_bgp_vrfs,
                if (!uj && count == 1) {
                        vty_out(vty,
                                "%4s  %-5s  %-16s  %9s  %10s  %-37s\n",
-                               "Type", "Id", "routerId", "#PeersVfg",
+                               "Type", "Id", "routerId", "#PeersCfg",
                                "#PeersEstb", "Name");
                        vty_out(vty, "%11s  %-16s  %-21s  %-6s\n", " ",
                                "L3-VNI", "RouterMAC", "Interface");
@@ -9190,6 +9240,11 @@ static void bgp_show_peer_afi(struct vty *vty, struct peer *p, afi_t afi,
                        json_object_int_add(json_addr, "sentPrefixCounter",
                                                (PAF_SUBGRP(paf))->scount);
 
+               /* Maximum prefix */
+               if (CHECK_FLAG(p->af_flags[afi][safi], PEER_FLAG_MAX_PREFIX_OUT))
+                       json_object_int_add(json_addr, "prefixOutAllowedMax",
+                                           p->pmax_out[afi][safi]);
+
                /* Maximum prefix */
                if (CHECK_FLAG(p->af_flags[afi][safi], PEER_FLAG_MAX_PREFIX)) {
                        json_object_int_add(json_addr, "prefixAllowedMax",
@@ -9476,6 +9531,13 @@ static void bgp_show_peer_afi(struct vty *vty, struct peer *p, afi_t afi,
                vty_out(vty, "  %" PRIu32 " accepted prefixes\n",
                        p->pcount[afi][safi]);
 
+               /* maximum-prefix-out */
+               if (CHECK_FLAG(p->af_flags[afi][safi],
+                              PEER_FLAG_MAX_PREFIX_OUT))
+                       vty_out(vty,
+                               "  Maximum allowed prefixes sent %" PRIu32 "\n",
+                               p->pmax_out[afi][safi]);
+
                /* Maximum prefix */
                if (CHECK_FLAG(p->af_flags[afi][safi], PEER_FLAG_MAX_PREFIX)) {
                        vty_out(vty,
@@ -9711,23 +9773,6 @@ static void bgp_show_peer(struct vty *vty, struct peer *p, bool use_json,
                        uptime -= p->uptime;
                        epoch_tbuf = time(NULL) - uptime;
 
-#if CONFDATE > 20200101
-                       CPP_NOTICE(
-                               "bgpTimerUp should be deprecated and can be removed now");
-#endif
-                       /*
-                        * bgpTimerUp was miliseconds that was accurate
-                        * up to 1 day, then the value returned
-                        * became garbage.  So in order to provide
-                        * some level of backwards compatability,
-                        * we still provde the data, but now
-                        * we are returning the correct value
-                        * and also adding a new bgpTimerUpMsec
-                        * which will allow us to deprecate
-                        * this eventually
-                        */
-                       json_object_int_add(json_neigh, "bgpTimerUp",
-                                           uptime * 1000);
                        json_object_int_add(json_neigh, "bgpTimerUpMsec",
                                            uptime * 1000);
                        json_object_string_add(json_neigh, "bgpTimerUpString",
@@ -13596,6 +13641,11 @@ static void bgp_config_write_peer_af(struct vty *vty, struct bgp *bgp,
                vty_out(vty, "\n");
        }
 
+       /* maximum-prefix-out */
+       if (peergroup_af_flag_check(peer, afi, safi, PEER_FLAG_MAX_PREFIX_OUT))
+               vty_out(vty, "  neighbor %s maximum-prefix-out %" PRIu32 "\n",
+                       addr, peer->pmax_out[afi][safi]);
+
        /* Route server client. */
        if (peergroup_af_flag_check(peer, afi, safi,
                                    PEER_FLAG_RSERVER_CLIENT)) {
@@ -15132,6 +15182,26 @@ void bgp_vty_init(void)
        install_element(BGP_VPNV6_NODE, &neighbor_unsuppress_map_cmd);
        install_element(BGP_VPNV6_NODE, &no_neighbor_unsuppress_map_cmd);
 
+       /* neighbor maximum-prefix-out commands. */
+       install_element(BGP_NODE, &neighbor_maximum_prefix_out_cmd);
+       install_element(BGP_NODE, &no_neighbor_maximum_prefix_out_cmd);
+       install_element(BGP_IPV4_NODE, &neighbor_maximum_prefix_out_cmd);
+       install_element(BGP_IPV4_NODE, &no_neighbor_maximum_prefix_out_cmd);
+       install_element(BGP_IPV4M_NODE, &neighbor_maximum_prefix_out_cmd);
+       install_element(BGP_IPV4M_NODE, &no_neighbor_maximum_prefix_out_cmd);
+       install_element(BGP_IPV4L_NODE, &neighbor_maximum_prefix_out_cmd);
+       install_element(BGP_IPV4L_NODE, &no_neighbor_maximum_prefix_out_cmd);
+       install_element(BGP_IPV6_NODE, &neighbor_maximum_prefix_out_cmd);
+       install_element(BGP_IPV6_NODE, &no_neighbor_maximum_prefix_out_cmd);
+       install_element(BGP_IPV6M_NODE, &neighbor_maximum_prefix_out_cmd);
+       install_element(BGP_IPV6M_NODE, &no_neighbor_maximum_prefix_out_cmd);
+       install_element(BGP_IPV6L_NODE, &neighbor_maximum_prefix_out_cmd);
+       install_element(BGP_IPV6L_NODE, &no_neighbor_maximum_prefix_out_cmd);
+       install_element(BGP_VPNV4_NODE, &neighbor_maximum_prefix_out_cmd);
+       install_element(BGP_VPNV4_NODE, &no_neighbor_maximum_prefix_out_cmd);
+       install_element(BGP_VPNV6_NODE, &neighbor_maximum_prefix_out_cmd);
+       install_element(BGP_VPNV6_NODE, &no_neighbor_maximum_prefix_out_cmd);
+
        /* "neighbor maximum-prefix" commands. */
        install_element(BGP_NODE, &neighbor_maximum_prefix_hidden_cmd);
        install_element(BGP_NODE,