]> git.proxmox.com Git - mirror_frr.git/blobdiff - bgpd/bgp_vty.c
bgpd: Allow shortened 'no set large-community' and 'no set large-comm-list'
[mirror_frr.git] / bgpd / bgp_vty.c
index d8c34d2d31493de2aabdfb28463dfe2cb66270ba..2a4421aa54d30089d77699025c5100ec70f8075e 100644 (file)
@@ -602,7 +602,7 @@ static int bgp_clear(struct vty *vty, struct bgp *bgp, afi_t afi, safi_t safi,
                        bgp->update_delay_over = 0;
 
                if (!found)
-                       vty_out(vty, "%%BGP: No %s peer configured",
+                       vty_out(vty, "%%BGP: No %s peer configured\n",
                                afi_safi_print(afi, safi));
 
                return CMD_SUCCESS;
@@ -7213,7 +7213,9 @@ static int bgp_clear_prefix(struct vty *vty, const char *view_name,
                        if (prd && memcmp(rn->p.u.val, prd->val, 8) != 0)
                                continue;
 
-                       if ((table = rn->info) != NULL) {
+                       table = bgp_node_get_bgp_table_info(rn);
+                       if (table != NULL) {
+
                                if ((rm = bgp_node_match(table, &match))
                                    != NULL) {
                                        if (rm->p.prefixlen
@@ -9722,7 +9724,7 @@ static void bgp_show_peer(struct vty *vty, struct peer *p, bool use_json,
                                                                json_object_string_add(
                                                                        json_nxt,
                                                                        print_store,
-                                                                       "received");
+                                                                       "recieved"); /* misspelled for compatibility */
                                                        }
                                                }
                                                json_object_object_add(
@@ -10916,7 +10918,6 @@ static int bgp_show_neighbor(struct vty *vty, struct bgp *bgp,
        if (use_json) {
                vty_out(vty, "%s\n", json_object_to_json_string_ext(
                                             json, JSON_C_TO_STRING_PRETTY));
-               json_object_free(json);
        } else {
                vty_out(vty, "\n");
        }
@@ -10991,8 +10992,10 @@ static void bgp_show_all_instances_neighbors_vty(struct vty *vty,
                }
        }
 
-       if (use_json)
+       if (use_json) {
                vty_out(vty, "}\n");
+               json_object_free(json);
+       }
        else if (!nbr_output)
                vty_out(vty, "%% BGP instance not found\n");
 }
@@ -13990,6 +13993,7 @@ DEFUN (no_community_list_standard_all,
        COMMUNITY_VAL_STR)
 {
        char *cl_name_or_number = NULL;
+       char *str = NULL;
        int direct = 0;
        int style = COMMUNITY_LIST_STANDARD;
 
@@ -14002,13 +14006,23 @@ DEFUN (no_community_list_standard_all,
                zlog_warn("Deprecated option: 'no ip community-list <(1-99)|(100-500)|standard|expanded> <deny|permit> |AA:NN' being used");
        }
 
+       argv_find(argv, argc, "permit", &idx);
+       argv_find(argv, argc, "deny", &idx);
+
+       if (idx) {
+               direct = argv_find(argv, argc, "permit", &idx)
+                                ? COMMUNITY_PERMIT
+                                : COMMUNITY_DENY;
+
+               idx = 0;
+               argv_find(argv, argc, "AA:NN", &idx);
+               str = argv_concat(argv, argc, idx);
+       }
+
+       idx = 0;
        argv_find(argv, argc, "(1-99)", &idx);
        argv_find(argv, argc, "WORD", &idx);
        cl_name_or_number = argv[idx]->arg;
-       direct = argv_find(argv, argc, "permit", &idx) ? COMMUNITY_PERMIT
-                                                      : COMMUNITY_DENY;
-       argv_find(argv, argc, "AA:NN", &idx);
-       char *str = argv_concat(argv, argc, idx);
 
        int ret = community_list_unset(bgp_clist, cl_name_or_number, str,
                                       direct, style);
@@ -14035,6 +14049,20 @@ ALIAS (no_community_list_standard_all,
        "Specify community to accept\n"
        COMMUNITY_VAL_STR)
 
+ALIAS(no_community_list_standard_all, no_bgp_community_list_standard_all_list_cmd,
+      "no bgp community-list <(1-99)|standard WORD>",
+      NO_STR BGP_STR COMMUNITY_LIST_STR
+      "Community list number (standard)\n"
+      "Add an standard community-list entry\n"
+      "Community list name\n")
+
+ALIAS(no_community_list_standard_all, no_ip_community_list_standard_all_list_cmd,
+      "no ip community-list <(1-99)|standard WORD>",
+      NO_STR BGP_STR COMMUNITY_LIST_STR
+      "Community list number (standard)\n"
+      "Add an standard community-list entry\n"
+      "Community list name\n")
+
 /*community-list expanded */
 DEFUN (community_list_expanded_all,
        bgp_community_list_expanded_all_cmd,
@@ -14107,6 +14135,7 @@ DEFUN (no_community_list_expanded_all,
        COMMUNITY_VAL_STR)
 {
        char *cl_name_or_number = NULL;
+       char *str = NULL;
        int direct = 0;
        int style = COMMUNITY_LIST_EXPANDED;
 
@@ -14114,16 +14143,28 @@ DEFUN (no_community_list_expanded_all,
        if (argv_find(argv, argc, "ip", &idx)) {
                vty_out(vty, "This config option is deprecated, and is scheduled for removal.\n");
                vty_out(vty, "if you are using this please migrate to the below command.\n");
-               vty_out(vty, "'no community-list <(1-99)|(100-500)|standard|expanded> <deny|permit> AA:NN'\n");
-               zlog_warn("Deprecated option: 'no community-list <(1-99)|(100-500)|standard|expanded> <deny|permit> AA:NN' being used");
+               vty_out(vty, "'no bgp community-list <(1-99)|(100-500)|standard|expanded> <deny|permit> AA:NN'\n");
+               zlog_warn("Deprecated option: 'no ip community-list <(1-99)|(100-500)|standard|expanded> <deny|permit> AA:NN' being used");
+       }
+
+       idx = 0;
+       argv_find(argv, argc, "permit", &idx);
+       argv_find(argv, argc, "deny", &idx);
+
+       if (idx) {
+               direct = argv_find(argv, argc, "permit", &idx)
+                                ? COMMUNITY_PERMIT
+                                : COMMUNITY_DENY;
+
+               idx = 0;
+               argv_find(argv, argc, "AA:NN", &idx);
+               str = argv_concat(argv, argc, idx);
        }
+
+       idx = 0;
        argv_find(argv, argc, "(100-500)", &idx);
        argv_find(argv, argc, "WORD", &idx);
        cl_name_or_number = argv[idx]->arg;
-       direct = argv_find(argv, argc, "permit", &idx) ? COMMUNITY_PERMIT
-                                                      : COMMUNITY_DENY;
-       argv_find(argv, argc, "AA:NN", &idx);
-       char *str = argv_concat(argv, argc, idx);
 
        int ret = community_list_unset(bgp_clist, cl_name_or_number, str,
                                       direct, style);
@@ -14151,6 +14192,20 @@ ALIAS (no_community_list_expanded_all,
        "Specify community to accept\n"
        COMMUNITY_VAL_STR)
 
+ALIAS(no_community_list_expanded_all, no_bgp_community_list_expanded_all_list_cmd,
+      "no bgp community-list <(100-500)|expanded WORD>",
+      NO_STR IP_STR COMMUNITY_LIST_STR
+      "Community list number (expanded)\n"
+      "Add an expanded community-list entry\n"
+      "Community list name\n")
+
+ALIAS(no_community_list_expanded_all, no_ip_community_list_expanded_all_list_cmd,
+      "no ip community-list <(100-500)|expanded WORD>",
+      NO_STR IP_STR COMMUNITY_LIST_STR
+      "Community list number (expanded)\n"
+      "Add an expanded community-list entry\n"
+      "Community list name\n")
+
 /* Return configuration string of community-list entry.  */
 static const char *community_list_config_str(struct community_entry *entry)
 {
@@ -14936,6 +14991,7 @@ DEFUN (no_extcommunity_list_standard_all,
        int style = EXTCOMMUNITY_LIST_STANDARD;
        int direct = 0;
        char *cl_number_or_name = NULL;
+       char *str = NULL;
 
        int idx = 0;
        if (argv_find(argv, argc, "ip", &idx)) {
@@ -14944,13 +15000,25 @@ DEFUN (no_extcommunity_list_standard_all,
                vty_out(vty, "'no bgp extcommunity-list <(1-99)|(100-500)|standard|expanded> <deny|permit> <LINE|AA:NN>'\n");
                zlog_warn("Deprecated option: ‘no ip extcommunity-list <(1-99)|(100-500)|standard|expanded> <deny|permit> <LINE|AA:NN>' being used");
        }
+
+       idx = 0;
+       argv_find(argv, argc, "permit", &idx);
+       argv_find(argv, argc, "deny", &idx);
+
+       if (idx) {
+               direct = argv_find(argv, argc, "permit", &idx)
+                                ? COMMUNITY_PERMIT
+                                : COMMUNITY_DENY;
+
+               idx = 0;
+               argv_find(argv, argc, "AA:NN", &idx);
+               str = argv_concat(argv, argc, idx);
+       }
+
+       idx = 0;
        argv_find(argv, argc, "(1-99)", &idx);
        argv_find(argv, argc, "WORD", &idx);
        cl_number_or_name = argv[idx]->arg;
-       direct = argv_find(argv, argc, "permit", &idx) ? COMMUNITY_PERMIT
-                                                      : COMMUNITY_DENY;
-       argv_find(argv, argc, "AA:NN", &idx);
-       char *str = argv_concat(argv, argc, idx);
 
        int ret = extcommunity_list_unset(bgp_clist, cl_number_or_name, str,
                                          direct, style);
@@ -14978,6 +15046,22 @@ ALIAS (no_extcommunity_list_standard_all,
        "Specify community to accept\n"
        EXTCOMMUNITY_VAL_STR)
 
+ALIAS(no_extcommunity_list_standard_all,
+      no_bgp_extcommunity_list_standard_all_list_cmd,
+      "no bgp extcommunity-list <(1-99)|standard WORD>",
+      NO_STR IP_STR EXTCOMMUNITY_LIST_STR
+      "Extended Community list number (standard)\n"
+      "Specify standard extcommunity-list\n"
+      "Community list name\n")
+
+ALIAS(no_extcommunity_list_standard_all,
+      no_ip_extcommunity_list_standard_all_list_cmd,
+      "no ip extcommunity-list <(1-99)|standard WORD>",
+      NO_STR IP_STR EXTCOMMUNITY_LIST_STR
+      "Extended Community list number (standard)\n"
+      "Specify standard extcommunity-list\n"
+      "Community list name\n")
+
 DEFUN (no_extcommunity_list_expanded_all,
        no_bgp_extcommunity_list_expanded_all_cmd,
        "no bgp extcommunity-list <(100-500)|expanded WORD> <deny|permit> LINE...",
@@ -14994,6 +15078,7 @@ DEFUN (no_extcommunity_list_expanded_all,
        int style = EXTCOMMUNITY_LIST_EXPANDED;
        int direct = 0;
        char *cl_number_or_name = NULL;
+       char *str = NULL;
 
        int idx = 0;
        if (argv_find(argv, argc, "ip", &idx)) {
@@ -15002,13 +15087,25 @@ DEFUN (no_extcommunity_list_expanded_all,
                vty_out(vty, "'no bgp extcommunity-list <(1-99)|(100-500)|standard|expanded> <deny|permit> <LINE|AA:NN>'\n");
                zlog_warn("Deprecated option: ‘no ip extcommunity-list <(1-99)|(100-500)|standard|expanded> <deny|permit> <LINE|AA:NN>' being used");
        }
+
+       idx = 0;
+       argv_find(argv, argc, "permit", &idx);
+       argv_find(argv, argc, "deny", &idx);
+
+       if (idx) {
+               direct = argv_find(argv, argc, "permit", &idx)
+                                ? COMMUNITY_PERMIT
+                                : COMMUNITY_DENY;
+
+               idx = 0;
+               argv_find(argv, argc, "LINE", &idx);
+               str = argv_concat(argv, argc, idx);
+       }
+
+       idx = 0;
        argv_find(argv, argc, "(100-500)", &idx);
        argv_find(argv, argc, "WORD", &idx);
        cl_number_or_name = argv[idx]->arg;
-       direct = argv_find(argv, argc, "permit", &idx) ? COMMUNITY_PERMIT
-                                                      : COMMUNITY_DENY;
-       argv_find(argv, argc, "LINE", &idx);
-       char *str = argv_concat(argv, argc, idx);
 
        int ret = extcommunity_list_unset(bgp_clist, cl_number_or_name, str,
                                          direct, style);
@@ -15036,6 +15133,22 @@ ALIAS (no_extcommunity_list_expanded_all,
        "Specify community to accept\n"
        "An ordered list as a regular-expression\n")
 
+ALIAS(no_extcommunity_list_expanded_all,
+      no_ip_extcommunity_list_expanded_all_list_cmd,
+      "no ip extcommunity-list <(100-500)|expanded WORD>",
+      NO_STR IP_STR EXTCOMMUNITY_LIST_STR
+      "Extended Community list number (expanded)\n"
+      "Specify expanded extcommunity-list\n"
+      "Extended Community list name\n")
+
+ALIAS(no_extcommunity_list_expanded_all,
+      no_bgp_extcommunity_list_expanded_all_list_cmd,
+      "no bgp extcommunity-list <(100-500)|expanded WORD>",
+      NO_STR IP_STR EXTCOMMUNITY_LIST_STR
+      "Extended Community list number (expanded)\n"
+      "Specify expanded extcommunity-list\n"
+      "Extended Community list name\n")
+
 static void extcommunity_list_show(struct vty *vty, struct community_list *list)
 {
        struct community_entry *entry;
@@ -15231,13 +15344,17 @@ static void community_list_vty(void)
        install_element(CONFIG_NODE, &bgp_community_list_standard_cmd);
        install_element(CONFIG_NODE, &bgp_community_list_expanded_all_cmd);
        install_element(CONFIG_NODE, &no_bgp_community_list_standard_all_cmd);
+       install_element(CONFIG_NODE, &no_bgp_community_list_standard_all_list_cmd);
        install_element(CONFIG_NODE, &no_bgp_community_list_expanded_all_cmd);
+       install_element(CONFIG_NODE, &no_bgp_community_list_expanded_all_list_cmd);
        install_element(VIEW_NODE, &show_bgp_community_list_cmd);
        install_element(VIEW_NODE, &show_bgp_community_list_arg_cmd);
        install_element(CONFIG_NODE, &ip_community_list_standard_cmd);
        install_element(CONFIG_NODE, &ip_community_list_expanded_all_cmd);
        install_element(CONFIG_NODE, &no_ip_community_list_standard_all_cmd);
+       install_element(CONFIG_NODE, &no_ip_community_list_standard_all_list_cmd);
        install_element(CONFIG_NODE, &no_ip_community_list_expanded_all_cmd);
+       install_element(CONFIG_NODE, &no_ip_community_list_expanded_all_list_cmd);
        install_element(VIEW_NODE, &show_ip_community_list_cmd);
        install_element(VIEW_NODE, &show_ip_community_list_arg_cmd);
 
@@ -15245,13 +15362,19 @@ static void community_list_vty(void)
        install_element(CONFIG_NODE, &bgp_extcommunity_list_standard_cmd);
        install_element(CONFIG_NODE, &bgp_extcommunity_list_name_expanded_cmd);
        install_element(CONFIG_NODE, &no_bgp_extcommunity_list_standard_all_cmd);
+       install_element(CONFIG_NODE,
+                       &no_bgp_extcommunity_list_standard_all_list_cmd);
        install_element(CONFIG_NODE, &no_bgp_extcommunity_list_expanded_all_cmd);
+       install_element(CONFIG_NODE,
+                       &no_bgp_extcommunity_list_expanded_all_list_cmd);
        install_element(VIEW_NODE, &show_bgp_extcommunity_list_cmd);
        install_element(VIEW_NODE, &show_bgp_extcommunity_list_arg_cmd);
        install_element(CONFIG_NODE, &ip_extcommunity_list_standard_cmd);
        install_element(CONFIG_NODE, &ip_extcommunity_list_name_expanded_cmd);
        install_element(CONFIG_NODE, &no_ip_extcommunity_list_standard_all_cmd);
+       install_element(CONFIG_NODE, &no_ip_extcommunity_list_standard_all_list_cmd);
        install_element(CONFIG_NODE, &no_ip_extcommunity_list_expanded_all_cmd);
+       install_element(CONFIG_NODE, &no_ip_extcommunity_list_expanded_all_list_cmd);
        install_element(VIEW_NODE, &show_ip_extcommunity_list_cmd);
        install_element(VIEW_NODE, &show_ip_extcommunity_list_arg_cmd);