]> git.proxmox.com Git - mirror_frr.git/blobdiff - bgpd/bgp_vty.c
doc: update workflow.rst
[mirror_frr.git] / bgpd / bgp_vty.c
index b8c81232bb24147f22fa57e57455132f3370bc9f..c1851a3e026ffe134dbb1f6fedd496177254ca78 100644 (file)
@@ -553,39 +553,46 @@ static int bgp_clear(struct vty *vty, struct bgp *bgp, afi_t afi, safi_t safi,
                     const char *arg)
 {
        int ret;
+       bool found = false;
        struct peer *peer;
        struct listnode *node, *nnode;
 
        /* Clear all neighbors. */
        /*
         * Pass along pointer to next node to peer_clear() when walking all
-        * nodes
-        * on the BGP instance as that may get freed if it is a doppelganger
+        * nodes on the BGP instance as that may get freed if it is a
+        * doppelganger
         */
        if (sort == clear_all) {
                for (ALL_LIST_ELEMENTS(bgp->peer, node, nnode, peer)) {
+                       if (!peer->afc[afi][safi])
+                               continue;
+
                        if (stype == BGP_CLEAR_SOFT_NONE)
                                ret = peer_clear(peer, &nnode);
-                       else if (peer->afc[afi][safi])
-                               ret = peer_clear_soft(peer, afi, safi, stype);
                        else
-                               ret = 0;
+                               ret = peer_clear_soft(peer, afi, safi, stype);
 
                        if (ret < 0)
                                bgp_clear_vty_error(vty, peer, afi, safi, ret);
+                       else
+                               found = true;
                }
 
                /* This is to apply read-only mode on this clear. */
                if (stype == BGP_CLEAR_SOFT_NONE)
                        bgp->update_delay_over = 0;
 
+               if (!found)
+                       vty_out(vty, "%%BGP: No %s peer configured",
+                               afi_safi_print(afi, safi));
+
                return CMD_SUCCESS;
        }
 
-       /* Clear specified neighbors. */
+       /* Clear specified neighbor. */
        if (sort == clear_peer) {
                union sockunion su;
-               int ret;
 
                /* Make sockunion for lookup. */
                ret = str2sockunion(arg, &su);
@@ -610,7 +617,9 @@ static int bgp_clear(struct vty *vty, struct bgp *bgp, afi_t afi, safi_t safi,
                        }
                }
 
-               if (stype == BGP_CLEAR_SOFT_NONE)
+               if (!peer->afc[afi][safi])
+                       ret = BGP_ERR_AF_UNCONFIGURED;
+               else if (stype == BGP_CLEAR_SOFT_NONE)
                        ret = peer_clear(peer, NULL);
                else
                        ret = peer_clear_soft(peer, afi, safi, stype);
@@ -621,7 +630,7 @@ static int bgp_clear(struct vty *vty, struct bgp *bgp, afi_t afi, safi_t safi,
                return CMD_SUCCESS;
        }
 
-       /* Clear all peer-group members. */
+       /* Clear all neighbors belonging to a specific peer-group. */
        if (sort == clear_group) {
                struct peer_group *group;
 
@@ -632,27 +641,37 @@ static int bgp_clear(struct vty *vty, struct bgp *bgp, afi_t afi, safi_t safi,
                }
 
                for (ALL_LIST_ELEMENTS(group->peer, node, nnode, peer)) {
-                       if (stype == BGP_CLEAR_SOFT_NONE) {
-                               peer_clear(peer, NULL);
-                               continue;
-                       }
-
                        if (!peer->afc[afi][safi])
                                continue;
 
-                       ret = peer_clear_soft(peer, afi, safi, stype);
+                       if (stype == BGP_CLEAR_SOFT_NONE)
+                               ret = peer_clear(peer, NULL);
+                       else
+                               ret = peer_clear_soft(peer, afi, safi, stype);
 
                        if (ret < 0)
                                bgp_clear_vty_error(vty, peer, afi, safi, ret);
+                       else
+                               found = true;
                }
+
+               if (!found)
+                       vty_out(vty,
+                               "%%BGP: No %s peer belonging to peer-group %s is configured\n",
+                               afi_safi_print(afi, safi), arg);
+
                return CMD_SUCCESS;
        }
 
+       /* Clear all external (eBGP) neighbors. */
        if (sort == clear_external) {
                for (ALL_LIST_ELEMENTS(bgp->peer, node, nnode, peer)) {
                        if (peer->sort == BGP_PEER_IBGP)
                                continue;
 
+                       if (!peer->afc[afi][safi])
+                               continue;
+
                        if (stype == BGP_CLEAR_SOFT_NONE)
                                ret = peer_clear(peer, &nnode);
                        else
@@ -660,33 +679,44 @@ static int bgp_clear(struct vty *vty, struct bgp *bgp, afi_t afi, safi_t safi,
 
                        if (ret < 0)
                                bgp_clear_vty_error(vty, peer, afi, safi, ret);
+                       else
+                               found = true;
                }
+
+               if (!found)
+                       vty_out(vty,
+                               "%%BGP: No external %s peer is configured\n",
+                               afi_safi_print(afi, safi));
+
                return CMD_SUCCESS;
        }
 
+       /* Clear all neighbors belonging to a specific AS. */
        if (sort == clear_as) {
-               as_t as;
-               int find = 0;
-
-               as = strtoul(arg, NULL, 10);
+               as_t as = strtoul(arg, NULL, 10);
 
                for (ALL_LIST_ELEMENTS(bgp->peer, node, nnode, peer)) {
                        if (peer->as != as)
                                continue;
 
-                       find = 1;
-                       if (stype == BGP_CLEAR_SOFT_NONE)
+                       if (!peer->afc[afi][safi])
+                               ret = BGP_ERR_AF_UNCONFIGURED;
+                       else if (stype == BGP_CLEAR_SOFT_NONE)
                                ret = peer_clear(peer, &nnode);
                        else
                                ret = peer_clear_soft(peer, afi, safi, stype);
 
                        if (ret < 0)
                                bgp_clear_vty_error(vty, peer, afi, safi, ret);
+                       else
+                               found = true;
                }
-               if (!find)
+
+               if (!found)
                        vty_out(vty,
-                               "%%BGP: No peer is configured with AS %s\n",
-                               arg);
+                               "%%BGP: No %s peer is configured with AS %s\n",
+                               afi_safi_print(afi, safi), arg);
+
                return CMD_SUCCESS;
        }
 
@@ -741,18 +771,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
@@ -761,6 +794,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");
@@ -769,31 +805,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;
@@ -1961,7 +2004,11 @@ DEFUN (no_bgp_fast_external_failover,
 }
 
 /* "bgp enforce-first-as" configuration. */
-DEFUN (bgp_enforce_first_as,
+#if defined(VERSION_TYPE_DEV) && CONFDATE > 20180517
+CPP_NOTICE("bgpd: remove deprecated '[no] bgp enforce-first-as' commands")
+#endif
+
+DEFUN_DEPRECATED (bgp_enforce_first_as,
        bgp_enforce_first_as_cmd,
        "bgp enforce-first-as",
        BGP_STR
@@ -1969,12 +2016,11 @@ DEFUN (bgp_enforce_first_as,
 {
        VTY_DECLVAR_CONTEXT(bgp, bgp);
        bgp_flag_set(bgp, BGP_FLAG_ENFORCE_FIRST_AS);
-       bgp_clear_star_soft_in(vty, bgp->name);
 
        return CMD_SUCCESS;
 }
 
-DEFUN (no_bgp_enforce_first_as,
+DEFUN_DEPRECATED (no_bgp_enforce_first_as,
        no_bgp_enforce_first_as_cmd,
        "no bgp enforce-first-as",
        NO_STR
@@ -1983,7 +2029,6 @@ DEFUN (no_bgp_enforce_first_as,
 {
        VTY_DECLVAR_CONTEXT(bgp, bgp);
        bgp_flag_unset(bgp, BGP_FLAG_ENFORCE_FIRST_AS);
-       bgp_clear_star_soft_in(vty, bgp->name);
 
        return CMD_SUCCESS;
 }
@@ -3419,7 +3464,7 @@ ALIAS_HIDDEN(no_neighbor_set_peer_group, no_neighbor_set_peer_group_hidden_cmd,
             "Peer-group name\n")
 
 static int peer_flag_modify_vty(struct vty *vty, const char *ip_str,
-                               uint16_t flag, int set)
+                               uint32_t flag, int set)
 {
        int ret;
        struct peer *peer;
@@ -3451,13 +3496,13 @@ static int peer_flag_modify_vty(struct vty *vty, const char *ip_str,
        return bgp_vty_return(vty, ret);
 }
 
-static int peer_flag_set_vty(struct vty *vty, const char *ip_str, uint16_t flag)
+static int peer_flag_set_vty(struct vty *vty, const char *ip_str, uint32_t flag)
 {
        return peer_flag_modify_vty(vty, ip_str, flag, 1);
 }
 
 static int peer_flag_unset_vty(struct vty *vty, const char *ip_str,
-                              uint16_t flag)
+                              uint32_t flag)
 {
        return peer_flag_modify_vty(vty, ip_str, flag, 0);
 }
@@ -4043,6 +4088,7 @@ DEFUN (neighbor_send_community,
        "Send Community attribute to this neighbor\n")
 {
        int idx_peer = 1;
+
        return peer_af_flag_set_vty(vty, argv[idx_peer]->arg, bgp_node_afi(vty),
                                    bgp_node_safi(vty),
                                    PEER_FLAG_SEND_COMMUNITY);
@@ -4062,6 +4108,7 @@ DEFUN (no_neighbor_send_community,
        "Send Community attribute to this neighbor\n")
 {
        int idx_peer = 2;
+
        return peer_af_flag_unset_vty(vty, argv[idx_peer]->arg,
                                      bgp_node_afi(vty), bgp_node_safi(vty),
                                      PEER_FLAG_SEND_COMMUNITY);
@@ -4085,27 +4132,26 @@ DEFUN (neighbor_send_community_type,
        "Send Standard Community attributes\n"
        "Send Large Community attributes\n")
 {
-       int idx = 0;
+       int idx_peer = 1;
        uint32_t flag = 0;
+       const char *type = argv[argc - 1]->text;
 
-       char *peer = argv[1]->arg;
-
-       if (argv_find(argv, argc, "standard", &idx))
+       if (strmatch(type, "standard")) {
                SET_FLAG(flag, PEER_FLAG_SEND_COMMUNITY);
-       else if (argv_find(argv, argc, "extended", &idx))
+       } else if (strmatch(type, "extended")) {
                SET_FLAG(flag, PEER_FLAG_SEND_EXT_COMMUNITY);
-       else if (argv_find(argv, argc, "large", &idx))
+       } else if (strmatch(type, "large")) {
                SET_FLAG(flag, PEER_FLAG_SEND_LARGE_COMMUNITY);
-       else if (argv_find(argv, argc, "both", &idx)) {
+       } else if (strmatch(type, "both")) {
                SET_FLAG(flag, PEER_FLAG_SEND_COMMUNITY);
                SET_FLAG(flag, PEER_FLAG_SEND_EXT_COMMUNITY);
-       } else {
+       } else { /* if (strmatch(type, "all")) */
                SET_FLAG(flag, PEER_FLAG_SEND_COMMUNITY);
                SET_FLAG(flag, PEER_FLAG_SEND_EXT_COMMUNITY);
                SET_FLAG(flag, PEER_FLAG_SEND_LARGE_COMMUNITY);
        }
 
-       return peer_af_flag_set_vty(vty, peer, bgp_node_afi(vty),
+       return peer_af_flag_set_vty(vty, argv[idx_peer]->arg, bgp_node_afi(vty),
                                    bgp_node_safi(vty), flag);
 }
 
@@ -4134,33 +4180,27 @@ DEFUN (no_neighbor_send_community_type,
        "Send Large Community attributes\n")
 {
        int idx_peer = 2;
-
+       uint32_t flag = 0;
        const char *type = argv[argc - 1]->text;
 
-       if (strmatch(type, "standard"))
-               return peer_af_flag_unset_vty(
-                       vty, argv[idx_peer]->arg, bgp_node_afi(vty),
-                       bgp_node_safi(vty), PEER_FLAG_SEND_COMMUNITY);
-       if (strmatch(type, "extended"))
-               return peer_af_flag_unset_vty(
-                       vty, argv[idx_peer]->arg, bgp_node_afi(vty),
-                       bgp_node_safi(vty), PEER_FLAG_SEND_EXT_COMMUNITY);
-       if (strmatch(type, "large"))
-               return peer_af_flag_unset_vty(
-                       vty, argv[idx_peer]->arg, bgp_node_afi(vty),
-                       bgp_node_safi(vty), PEER_FLAG_SEND_LARGE_COMMUNITY);
-       if (strmatch(type, "both"))
-               return peer_af_flag_unset_vty(
-                       vty, argv[idx_peer]->arg, bgp_node_afi(vty),
-                       bgp_node_safi(vty),
-                       PEER_FLAG_SEND_COMMUNITY
-                               | PEER_FLAG_SEND_EXT_COMMUNITY);
-
-       /* if (strmatch (type, "all")) */
-       return peer_af_flag_unset_vty(
-               vty, argv[idx_peer]->arg, bgp_node_afi(vty), bgp_node_safi(vty),
-               (PEER_FLAG_SEND_COMMUNITY | PEER_FLAG_SEND_EXT_COMMUNITY
-                | PEER_FLAG_SEND_LARGE_COMMUNITY));
+       if (strmatch(type, "standard")) {
+               SET_FLAG(flag, PEER_FLAG_SEND_COMMUNITY);
+       } else if (strmatch(type, "extended")) {
+               SET_FLAG(flag, PEER_FLAG_SEND_EXT_COMMUNITY);
+       } else if (strmatch(type, "large")) {
+               SET_FLAG(flag, PEER_FLAG_SEND_LARGE_COMMUNITY);
+       } else if (strmatch(type, "both")) {
+               SET_FLAG(flag, PEER_FLAG_SEND_COMMUNITY);
+               SET_FLAG(flag, PEER_FLAG_SEND_EXT_COMMUNITY);
+       } else { /* if (strmatch(type, "all")) */
+               SET_FLAG(flag, PEER_FLAG_SEND_COMMUNITY);
+               SET_FLAG(flag, PEER_FLAG_SEND_EXT_COMMUNITY);
+               SET_FLAG(flag, PEER_FLAG_SEND_LARGE_COMMUNITY);
+       }
+
+       return peer_af_flag_unset_vty(vty, argv[idx_peer]->arg,
+                                     bgp_node_afi(vty), bgp_node_safi(vty),
+                                     flag);
 }
 
 ALIAS_HIDDEN(
@@ -4554,6 +4594,36 @@ DEFUN (no_neighbor_disable_connected_check,
                                   PEER_FLAG_DISABLE_CONNECTED_CHECK);
 }
 
+
+/* enforce-first-as */
+DEFUN (neighbor_enforce_first_as,
+       neighbor_enforce_first_as_cmd,
+       "neighbor <A.B.C.D|X:X::X:X|WORD> enforce-first-as",
+       NEIGHBOR_STR
+       NEIGHBOR_ADDR_STR2
+       "Enforce the first AS for EBGP routes\n")
+{
+       int idx_peer = 1;
+
+       return peer_flag_set_vty(vty, argv[idx_peer]->arg,
+                                PEER_FLAG_ENFORCE_FIRST_AS);
+}
+
+DEFUN (no_neighbor_enforce_first_as,
+       no_neighbor_enforce_first_as_cmd,
+       "no neighbor <A.B.C.D|X:X::X:X|WORD> enforce-first-as",
+       NO_STR
+       NEIGHBOR_STR
+       NEIGHBOR_ADDR_STR2
+       "Enforce the first AS for EBGP routes\n")
+{
+       int idx_peer = 2;
+
+       return peer_flag_unset_vty(vty, argv[idx_peer]->arg,
+                                  PEER_FLAG_ENFORCE_FIRST_AS);
+}
+
+
 DEFUN (neighbor_description,
        neighbor_description_cmd,
        "neighbor <A.B.C.D|X:X::X:X|WORD> description LINE...",
@@ -5300,8 +5370,8 @@ static int peer_prefix_list_set_vty(struct vty *vty, const char *ip_str,
                                    const char *direct_str)
 {
        int ret;
-       struct peer *peer;
        int direct = FILTER_IN;
+       struct peer *peer;
 
        peer = peer_and_group_lookup_vty(vty, ip_str);
        if (!peer)
@@ -6281,6 +6351,10 @@ DEFPY (af_label_vpn_export,
        if (argv_find(argv, argc, "no", &idx))
                yes = 0;
 
+       /* If "no ...", squash trailing parameter */
+       if (!yes)
+               label_auto = NULL;
+
        if (yes) {
                if (!label_auto)
                        label = label_val; /* parser should force unsigned */
@@ -7905,7 +7979,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]);
@@ -7942,16 +8016,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);
@@ -10625,7 +10694,7 @@ static int bgp_show_neighbor(struct vty *vty, struct bgp *bgp,
                if (use_json)
                        json_object_boolean_true_add(json, "bgpNoSuchNeighbor");
                else
-                       vty_out(vty, "%% No such neighbor\n");
+                       vty_out(vty, "%% No such neighbor in this view/vrf\n");
        }
 
        if (use_json) {
@@ -10859,7 +10928,7 @@ static void lcommunity_show_all_iterator(struct hash_backet *backet,
 
        lcom = (struct lcommunity *)backet->data;
        vty_out(vty, "[%p] (%ld) %s\n", (void *)lcom, lcom->refcnt,
-               lcommunity_str(lcom));
+               lcommunity_str(lcom, false));
 }
 
 /* Show BGP's community internal data. */
@@ -12950,6 +13019,10 @@ void bgp_vty_init(void)
        install_element(BGP_NODE, &neighbor_disable_connected_check_cmd);
        install_element(BGP_NODE, &no_neighbor_disable_connected_check_cmd);
 
+       /* "neighbor enforce-first-as" commands. */
+       install_element(BGP_NODE, &neighbor_enforce_first_as_cmd);
+       install_element(BGP_NODE, &no_neighbor_enforce_first_as_cmd);
+
        /* "neighbor description" commands. */
        install_element(BGP_NODE, &neighbor_description_cmd);
        install_element(BGP_NODE, &no_neighbor_description_cmd);
@@ -13606,6 +13679,24 @@ DEFUN (no_ip_community_list_expanded_all,
        return CMD_SUCCESS;
 }
 
+/* Return configuration string of community-list entry.  */
+static const char *community_list_config_str(struct community_entry *entry)
+{
+       const char *str;
+
+       if (entry->any)
+               str = "";
+       else {
+               if (entry->style == COMMUNITY_LIST_STANDARD)
+                       str = community_str(entry->u.com, false);
+               else if (entry->style == LARGE_COMMUNITY_LIST_STANDARD)
+                       str = lcommunity_str(entry->u.lcom, false);
+               else
+                       str = entry->config;
+       }
+       return str;
+}
+
 static void community_list_show(struct vty *vty, struct community_list *list)
 {
        struct community_entry *entry;
@@ -13631,9 +13722,7 @@ static void community_list_show(struct vty *vty, struct community_list *list)
                else
                        vty_out(vty, "    %s %s\n",
                                community_direct_str(entry->direct),
-                               entry->style == COMMUNITY_LIST_STANDARD
-                                       ? community_str(entry->u.com, false)
-                                       : entry->config);
+                               community_list_config_str(entry));
        }
 }
 
@@ -13985,9 +14074,7 @@ static void lcommunity_list_show(struct vty *vty, struct community_list *list)
                else
                        vty_out(vty, "    %s %s\n",
                                community_direct_str(entry->direct),
-                               entry->style == EXTCOMMUNITY_LIST_STANDARD
-                                       ? entry->u.ecom->str
-                                       : entry->config);
+                               community_list_config_str(entry));
        }
 }
 
@@ -14222,9 +14309,7 @@ static void extcommunity_list_show(struct vty *vty, struct community_list *list)
                else
                        vty_out(vty, "    %s %s\n",
                                community_direct_str(entry->direct),
-                               entry->style == EXTCOMMUNITY_LIST_STANDARD
-                                       ? entry->u.ecom->str
-                                       : entry->config);
+                               community_list_config_str(entry));
        }
 }
 
@@ -14275,22 +14360,6 @@ DEFUN (show_ip_extcommunity_list_arg,
        return CMD_SUCCESS;
 }
 
-/* Return configuration string of community-list entry.  */
-static const char *community_list_config_str(struct community_entry *entry)
-{
-       const char *str;
-
-       if (entry->any)
-               str = "";
-       else {
-               if (entry->style == COMMUNITY_LIST_STANDARD)
-                       str = community_str(entry->u.com, false);
-               else
-                       str = entry->config;
-       }
-       return str;
-}
-
 /* Display community-list and extcommunity-list configuration.  */
 static int community_list_config_write(struct vty *vty)
 {