]> git.proxmox.com Git - mirror_frr.git/blobdiff - bgpd/bgp_vty.c
Merge pull request #2501 from pacovn/infer_unused1
[mirror_frr.git] / bgpd / bgp_vty.c
index 6209c1be201767771759c0f0e08529cd443f853c..d98104a9faa819d906682dc8c63551e4ae54e484 100644 (file)
@@ -34,6 +34,7 @@
 #include "hash.h"
 #include "queue.h"
 #include "filter.h"
+#include "frrstr.h"
 
 #include "bgpd/bgpd.h"
 #include "bgpd/bgp_advertise.h"
@@ -771,18 +772,21 @@ static void bgp_clear_star_soft_out(struct vty *vty, const char *name)
 #endif
 
 /* BGP global configuration.  */
-
-DEFUN (bgp_multiple_instance_func,
-       bgp_multiple_instance_cmd,
-       "bgp multiple-instance",
-       BGP_STR
-       "Enable bgp multiple instance\n")
+#if defined(VERSION_TYPE_DEV) && (CONFDATE > 20190601)
+CPP_NOTICE("bgpd: time to remove deprecated bgp multiple-instance")
+CPP_NOTICE("This includes BGP_OPT_MULTIPLE_INSTANCE")
+#endif
+DEFUN_HIDDEN (bgp_multiple_instance_func,
+             bgp_multiple_instance_cmd,
+             "bgp multiple-instance",
+             BGP_STR
+             "Enable bgp multiple instance\n")
 {
        bgp_option_set(BGP_OPT_MULTIPLE_INSTANCE);
        return CMD_SUCCESS;
 }
 
-DEFUN (no_bgp_multiple_instance,
+DEFUN_HIDDEN (no_bgp_multiple_instance,
        no_bgp_multiple_instance_cmd,
        "no bgp multiple-instance",
        NO_STR
@@ -791,6 +795,9 @@ DEFUN (no_bgp_multiple_instance,
 {
        int ret;
 
+       vty_out(vty, "This config option is deprecated, and is scheduled for removal.\n");
+       vty_out(vty, "if you are using this please let the developers know\n");
+       zlog_warn("Deprecated option: `bgp multiple-instance` being used");
        ret = bgp_option_unset(BGP_OPT_MULTIPLE_INSTANCE);
        if (ret < 0) {
                vty_out(vty, "%% There are more than two BGP instances\n");
@@ -799,31 +806,38 @@ DEFUN (no_bgp_multiple_instance,
        return CMD_SUCCESS;
 }
 
-DEFUN (bgp_config_type,
-       bgp_config_type_cmd,
-       "bgp config-type <cisco|zebra>",
-       BGP_STR
-       "Configuration type\n"
-       "cisco\n"
-       "zebra\n")
+#if defined(VERSION_TYPE_DEV) && (CONFDATE > 20190601)
+CPP_NOTICE("bgpd: time to remove deprecated cli bgp config-type cisco")
+CPP_NOTICE("This includes BGP_OPT_CISCO_CONFIG")
+#endif
+DEFUN_HIDDEN (bgp_config_type,
+             bgp_config_type_cmd,
+             "bgp config-type <cisco|zebra>",
+             BGP_STR
+             "Configuration type\n"
+             "cisco\n"
+             "zebra\n")
 {
        int idx = 0;
-       if (argv_find(argv, argc, "cisco", &idx))
+       if (argv_find(argv, argc, "cisco", &idx)) {
+               vty_out(vty, "This config option is deprecated, and is scheduled for removal.\n");
+               vty_out(vty, "if you are using this please let the developers know!\n");
+               zlog_warn("Deprecated option: `bgp config-type cisco` being used");
                bgp_option_set(BGP_OPT_CONFIG_CISCO);
-       else
+       else
                bgp_option_unset(BGP_OPT_CONFIG_CISCO);
 
        return CMD_SUCCESS;
 }
 
-DEFUN (no_bgp_config_type,
-       no_bgp_config_type_cmd,
-       "no bgp config-type [<cisco|zebra>]",
-       NO_STR
-       BGP_STR
-       "Display configuration type\n"
-       "cisco\n"
-       "zebra\n")
+DEFUN_HIDDEN (no_bgp_config_type,
+             no_bgp_config_type_cmd,
+             "no bgp config-type [<cisco|zebra>]",
+             NO_STR
+             BGP_STR
+             "Display configuration type\n"
+             "cisco\n"
+             "zebra\n")
 {
        bgp_option_unset(BGP_OPT_CONFIG_CISCO);
        return CMD_SUCCESS;
@@ -2819,7 +2833,7 @@ static int peer_conf_interface_get(struct vty *vty, const char *conf_if,
                }
 
                if (v6only)
-                       SET_FLAG(peer->flags, PEER_FLAG_IFPEER_V6ONLY);
+                       peer_flag_set(peer, PEER_FLAG_IFPEER_V6ONLY);
 
                /* Request zebra to initiate IPv6 RAs on this interface. We do
                 * this
@@ -2836,9 +2850,9 @@ static int peer_conf_interface_get(struct vty *vty, const char *conf_if,
        if ((v6only && !CHECK_FLAG(peer->flags, PEER_FLAG_IFPEER_V6ONLY))
            || (!v6only && CHECK_FLAG(peer->flags, PEER_FLAG_IFPEER_V6ONLY))) {
                if (v6only)
-                       SET_FLAG(peer->flags, PEER_FLAG_IFPEER_V6ONLY);
+                       peer_flag_set(peer, PEER_FLAG_IFPEER_V6ONLY);
                else
-                       UNSET_FLAG(peer->flags, PEER_FLAG_IFPEER_V6ONLY);
+                       peer_flag_unset(peer, PEER_FLAG_IFPEER_V6ONLY);
 
                /* v6only flag changed. Reset bgp seesion */
                if (BGP_IS_VALID_STATE_FOR_NOTIF(peer->status)) {
@@ -2849,8 +2863,11 @@ static int peer_conf_interface_get(struct vty *vty, const char *conf_if,
                        bgp_session_reset(peer);
        }
 
-       if (!CHECK_FLAG(peer->flags, PEER_FLAG_CAPABILITY_ENHE))
-               peer_flag_set(peer, PEER_FLAG_CAPABILITY_ENHE);
+       if (!CHECK_FLAG(peer->flags_invert, PEER_FLAG_CAPABILITY_ENHE)) {
+               SET_FLAG(peer->flags, PEER_FLAG_CAPABILITY_ENHE);
+               SET_FLAG(peer->flags_invert, PEER_FLAG_CAPABILITY_ENHE);
+               UNSET_FLAG(peer->flags_override, PEER_FLAG_CAPABILITY_ENHE);
+       }
 
        if (peer_group_name) {
                group = peer_group_lookup(bgp, peer_group_name);
@@ -4639,12 +4656,11 @@ DEFUN (neighbor_description,
 
 DEFUN (no_neighbor_description,
        no_neighbor_description_cmd,
-       "no neighbor <A.B.C.D|X:X::X:X|WORD> description [LINE]",
+       "no neighbor <A.B.C.D|X:X::X:X|WORD> description",
        NO_STR
        NEIGHBOR_STR
        NEIGHBOR_ADDR_STR2
-       "Neighbor specific description\n"
-       "Up to 80 characters describing this neighbor\n")
+       "Neighbor specific description\n")
 {
        int idx_peer = 2;
        struct peer *peer;
@@ -4658,6 +4674,11 @@ DEFUN (no_neighbor_description,
        return CMD_SUCCESS;
 }
 
+ALIAS(no_neighbor_description, no_neighbor_description_comment_cmd,
+      "no neighbor <A.B.C.D|X:X::X:X|WORD> description LINE...",
+      NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
+      "Neighbor specific description\n"
+      "Up to 80 characters describing this neighbor\n")
 
 /* Neighbor update-source. */
 static int peer_update_source_vty(struct vty *vty, const char *peer_str,
@@ -4665,6 +4686,7 @@ static int peer_update_source_vty(struct vty *vty, const char *peer_str,
 {
        struct peer *peer;
        struct prefix p;
+       union sockunion su;
 
        peer = peer_and_group_lookup_vty(vty, peer_str);
        if (!peer)
@@ -4674,10 +4696,7 @@ static int peer_update_source_vty(struct vty *vty, const char *peer_str,
                return CMD_WARNING;
 
        if (source_str) {
-               union sockunion su;
-               int ret = str2sockunion(source_str, &su);
-
-               if (ret == 0)
+               if (str2sockunion(source_str, &su) == 0)
                        peer_update_source_addr_set(peer, &su);
                else {
                        if (str2prefix(source_str, &p)) {
@@ -4967,26 +4986,28 @@ DEFUN (no_neighbor_override_capability,
 
 DEFUN (neighbor_strict_capability,
        neighbor_strict_capability_cmd,
-       "neighbor <A.B.C.D|X:X::X:X> strict-capability-match",
+       "neighbor <A.B.C.D|X:X::X:X|WORD> strict-capability-match",
        NEIGHBOR_STR
-       NEIGHBOR_ADDR_STR
+       NEIGHBOR_ADDR_STR2
        "Strict capability negotiation match\n")
 {
-       int idx_ip = 1;
-       return peer_flag_set_vty(vty, argv[idx_ip]->arg,
+       int idx_peer = 1;
+
+       return peer_flag_set_vty(vty, argv[idx_peer]->arg,
                                 PEER_FLAG_STRICT_CAP_MATCH);
 }
 
 DEFUN (no_neighbor_strict_capability,
        no_neighbor_strict_capability_cmd,
-       "no neighbor <A.B.C.D|X:X::X:X> strict-capability-match",
+       "no neighbor <A.B.C.D|X:X::X:X|WORD> strict-capability-match",
        NO_STR
        NEIGHBOR_STR
-       NEIGHBOR_ADDR_STR
+       NEIGHBOR_ADDR_STR2
        "Strict capability negotiation match\n")
 {
-       int idx_ip = 2;
-       return peer_flag_unset_vty(vty, argv[idx_ip]->arg,
+       int idx_peer = 2;
+
+       return peer_flag_unset_vty(vty, argv[idx_peer]->arg,
                                   PEER_FLAG_STRICT_CAP_MATCH);
 }
 
@@ -7966,7 +7987,7 @@ static int bgp_show_summary(struct vty *vty, struct bgp *bgp, int afi, int safi,
                                            BGP_UPTIME_LEN, 0, NULL));
 
                        if (peer->status == Established)
-                               if (peer->afc_recv[afi][pfx_rcd_safi])
+                               if (peer->afc_recv[afi][safi])
                                        vty_out(vty, " %12ld",
                                                peer->pcount[afi]
                                                            [pfx_rcd_safi]);
@@ -8003,16 +8024,11 @@ static int bgp_show_summary(struct vty *vty, struct bgp *bgp, int afi, int safi,
                if (count)
                        vty_out(vty, "\nTotal number of neighbors %d\n", count);
                else {
-                       if (use_json)
-                               vty_out(vty,
-                                       "{\"error\": {\"message\": \"No %s neighbor configured\"}}\n",
-                                       afi_safi_print(afi, safi));
-                       else
-                               vty_out(vty, "No %s neighbor is configured\n",
-                                       afi_safi_print(afi, safi));
+                       vty_out(vty, "No %s neighbor is configured\n",
+                               afi_safi_print(afi, safi));
                }
 
-               if (dn_count && !use_json) {
+               if (dn_count) {
                        vty_out(vty, "* - dynamic neighbor\n");
                        vty_out(vty, "%d dynamic neighbor(s), limit %d\n",
                                dn_count, bgp->dynamic_neighbors_limit);
@@ -9178,8 +9194,7 @@ static void bgp_show_peer(struct vty *vty, struct peer *p, uint8_t use_json,
                json_object_int_add(json_neigh,
                                    "bgpTimerKeepAliveIntervalMsecs",
                                    p->v_keepalive * 1000);
-
-               if (PEER_OR_GROUP_TIMER_SET(p)) {
+               if (CHECK_FLAG(p->flags, PEER_FLAG_TIMER)) {
                        json_object_int_add(json_neigh,
                                            "bgpTimerConfiguredHoldTimeMsecs",
                                            p->holdtime * 1000);
@@ -9243,7 +9258,7 @@ static void bgp_show_peer(struct vty *vty, struct peer *p, uint8_t use_json,
                vty_out(vty,
                        "  Hold time is %d, keepalive interval is %d seconds\n",
                        p->v_holdtime, p->v_keepalive);
-               if (PEER_OR_GROUP_TIMER_SET(p)) {
+               if (CHECK_FLAG(p->flags, PEER_FLAG_TIMER)) {
                        vty_out(vty, "  Configured hold time is %d",
                                p->holdtime);
                        vty_out(vty, ", keepalive interval is %d seconds\n",
@@ -11394,7 +11409,6 @@ DEFUN (show_ip_bgp_peer_groups,
        "Peer group name\n")
 {
        char *vrf, *pg;
-       vrf = pg = NULL;
        int idx = 0;
 
        vrf = argv_find(argv, argc, "VIEWVRFNAME", &idx) ? argv[idx]->arg
@@ -13018,6 +13032,7 @@ void bgp_vty_init(void)
        /* "neighbor description" commands. */
        install_element(BGP_NODE, &neighbor_description_cmd);
        install_element(BGP_NODE, &no_neighbor_description_cmd);
+       install_element(BGP_NODE, &no_neighbor_description_comment_cmd);
 
        /* "neighbor update-source" commands. "*/
        install_element(BGP_NODE, &neighbor_update_source_cmd);