]> git.proxmox.com Git - mirror_frr.git/blobdiff - bgpd/bgp_vty.c
yang: change EIGRP authentication enum name
[mirror_frr.git] / bgpd / bgp_vty.c
index a18a3bb952e69e96d2e0c059b6887f8984ddf11e..27042017dd7ff343562e9ff46216e6aef692905d 100644 (file)
@@ -624,18 +624,12 @@ 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;
                }
 
                /* 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\n",
-                               afi_safi_print(afi, safi));
-
                return CMD_SUCCESS;
        }
 
@@ -925,7 +919,7 @@ DEFUN (no_auto_summary,
 /* "router bgp" commands. */
 DEFUN_NOSH (router_bgp,
        router_bgp_cmd,
-       "router bgp [(1-4294967295) [<view|vrf> VIEWVRFNAME]]",
+       "router bgp [(1-4294967295)$instasn [<view|vrf> VIEWVRFNAME]]",
        ROUTER_STR
        BGP_STR
        AS_STR
@@ -979,10 +973,6 @@ DEFUN_NOSH (router_bgp,
 
                ret = bgp_get(&bgp, &as, name, inst_type);
                switch (ret) {
-               case BGP_ERR_MULTIPLE_INSTANCE_NOT_SET:
-                       vty_out(vty,
-                               "Please specify 'bgp multiple-instance' first\n");
-                       return CMD_WARNING_CONFIG_FAILED;
                case BGP_ERR_AS_MISMATCH:
                        vty_out(vty, "BGP is already running; AS is %u\n", as);
                        return CMD_WARNING_CONFIG_FAILED;
@@ -1003,6 +993,8 @@ DEFUN_NOSH (router_bgp,
                if (is_new_bgp && inst_type == BGP_INSTANCE_TYPE_DEFAULT)
                        vpn_leak_postchange_all();
 
+               if (inst_type == BGP_INSTANCE_TYPE_VRF)
+                       bgp_vpn_leak_export(bgp);
                /* Pending: handle when user tries to change a view to vrf n vv.
                 */
        }
@@ -1017,7 +1009,7 @@ DEFUN_NOSH (router_bgp,
 /* "no router bgp" commands. */
 DEFUN (no_router_bgp,
        no_router_bgp_cmd,
-       "no router bgp [(1-4294967295) [<view|vrf> VIEWVRFNAME]]",
+       "no router bgp [(1-4294967295)$instasn [<view|vrf> VIEWVRFNAME]]",
        NO_STR
        ROUTER_STR
        BGP_STR
@@ -1085,6 +1077,9 @@ DEFUN (no_router_bgp,
                }
        }
 
+       if (bgp_vpn_leak_unimport(bgp, vty))
+               return CMD_WARNING_CONFIG_FAILED;
+
        bgp_delete(bgp);
 
        return CMD_SUCCESS;
@@ -4825,14 +4820,15 @@ static int peer_default_originate_set_vty(struct vty *vty, const char *peer_str,
 {
        int ret;
        struct peer *peer;
-       struct route_map *route_map;
+       struct route_map *route_map = NULL;
 
        peer = peer_and_group_lookup_vty(vty, peer_str);
        if (!peer)
                return CMD_WARNING_CONFIG_FAILED;
 
        if (set) {
-               route_map = route_map_lookup_warn_noexist(vty, rmap);
+               if (rmap)
+                       route_map = route_map_lookup_warn_noexist(vty, rmap);
                ret = peer_default_originate_set(peer, afi, safi,
                                                 rmap, route_map);
        } else
@@ -7285,6 +7281,9 @@ DEFUN (clear_ip_bgp_all,
        } else if (argv_find(argv, argc, "PGNAME", &idx)) {
                clr_sort = clear_peer;
                clr_arg = argv[idx]->arg;
+       } else if (argv_find(argv, argc, "WORD", &idx)) {
+               clr_sort = clear_peer;
+               clr_arg = argv[idx]->arg;
        } else if (argv_find(argv, argc, "(1-4294967295)", &idx)) {
                clr_sort = clear_as;
                clr_arg = argv[idx]->arg;
@@ -7726,14 +7725,6 @@ DEFUN (show_bgp_memory,
                                     count * sizeof(struct peer_group)));
 
        /* Other */
-       if ((count = mtype_stats_alloc(MTYPE_HASH)))
-               vty_out(vty, "%ld hash tables, using %s of memory\n", count,
-                       mtype_memstr(memstrbuf, sizeof(memstrbuf),
-                                    count * sizeof(struct hash)));
-       if ((count = mtype_stats_alloc(MTYPE_HASH_BACKET)))
-               vty_out(vty, "%ld hash buckets, using %s of memory\n", count,
-                       mtype_memstr(memstrbuf, sizeof(memstrbuf),
-                                    count * sizeof(struct hash_bucket)));
        if ((count = mtype_stats_alloc(MTYPE_BGP_REGEXP)))
                vty_out(vty, "%ld compiled regexes, using %s of memory\n",
                        count, mtype_memstr(memstrbuf, sizeof(memstrbuf),
@@ -11324,15 +11315,19 @@ static int bgp_show_route_leak_vty(struct vty *vty, const char *name,
                                json_object_array_add(json_import_vrfs,
                                                json_object_new_string(vname));
 
+                       json_object_object_add(json, "importFromVrfs",
+                                                      json_import_vrfs);
                        dir = BGP_VPN_POLICY_DIR_FROMVPN;
-                       ecom_str = ecommunity_ecom2str(
+                       if (bgp->vpn_policy[afi].rtlist[dir]) {
+                               ecom_str = ecommunity_ecom2str(
                                        bgp->vpn_policy[afi].rtlist[dir],
                                        ECOMMUNITY_FORMAT_ROUTE_MAP, 0);
-                       json_object_object_add(json, "importFromVrfs",
-                                              json_import_vrfs);
-                       json_object_string_add(json, "importRts", ecom_str);
-
-                       XFREE(MTYPE_ECOMMUNITY_STR, ecom_str);
+                               json_object_string_add(json, "importRts",
+                                                      ecom_str);
+                               XFREE(MTYPE_ECOMMUNITY_STR, ecom_str);
+                       } else
+                               json_object_string_add(json, "importRts",
+                                                      "none");
                }
 
                if (!CHECK_FLAG(bgp->af_flags[afi][safi],
@@ -11356,12 +11351,16 @@ static int bgp_show_route_leak_vty(struct vty *vty, const char *name,
                                                 buf1, RD_ADDRSTRLEN));
 
                        dir = BGP_VPN_POLICY_DIR_TOVPN;
-                       ecom_str = ecommunity_ecom2str(
+                       if (bgp->vpn_policy[afi].rtlist[dir]) {
+                               ecom_str = ecommunity_ecom2str(
                                               bgp->vpn_policy[afi].rtlist[dir],
                                               ECOMMUNITY_FORMAT_ROUTE_MAP, 0);
-                       json_object_string_add(json, "exportRts", ecom_str);
-
-                       XFREE(MTYPE_ECOMMUNITY_STR, ecom_str);
+                               json_object_string_add(json, "exportRts",
+                                                      ecom_str);
+                               XFREE(MTYPE_ECOMMUNITY_STR, ecom_str);
+                       } else
+                               json_object_string_add(json, "exportRts",
+                                                      "none");
                }
 
                if (use_json) {
@@ -11394,12 +11393,16 @@ static int bgp_show_route_leak_vty(struct vty *vty, const char *name,
                                vty_out(vty, "  %s\n", vname);
 
                        dir = BGP_VPN_POLICY_DIR_FROMVPN;
-                       ecom_str = ecommunity_ecom2str(
+                       ecom_str = NULL;
+                       if (bgp->vpn_policy[afi].rtlist[dir]) {
+                               ecom_str = ecommunity_ecom2str(
                                               bgp->vpn_policy[afi].rtlist[dir],
                                               ECOMMUNITY_FORMAT_ROUTE_MAP, 0);
-                       vty_out(vty, "Import RT(s): %s\n", ecom_str);
+                               vty_out(vty, "Import RT(s): %s\n", ecom_str);
 
-                       XFREE(MTYPE_ECOMMUNITY_STR, ecom_str);
+                               XFREE(MTYPE_ECOMMUNITY_STR, ecom_str);
+                       } else
+                               vty_out(vty, "Import RT(s):\n");
                }
 
                if (!CHECK_FLAG(bgp->af_flags[afi][safi],
@@ -11422,11 +11425,14 @@ static int bgp_show_route_leak_vty(struct vty *vty, const char *name,
                                              buf1, RD_ADDRSTRLEN));
 
                        dir = BGP_VPN_POLICY_DIR_TOVPN;
-                       ecom_str = ecommunity_ecom2str(
+                       if (bgp->vpn_policy[afi].rtlist[dir]) {
+                               ecom_str = ecommunity_ecom2str(
                                        bgp->vpn_policy[afi].rtlist[dir],
                                        ECOMMUNITY_FORMAT_ROUTE_MAP, 0);
-                       vty_out(vty, "Export RT: %s\n", ecom_str);
-                       XFREE(MTYPE_ECOMMUNITY_STR, ecom_str);
+                               vty_out(vty, "Export RT: %s\n", ecom_str);
+                               XFREE(MTYPE_ECOMMUNITY_STR, ecom_str);
+                       } else
+                               vty_out(vty, "Import RT(s):\n");
                }
        }
 
@@ -12309,7 +12315,7 @@ ALIAS_HIDDEN(
 
 DEFUN (no_bgp_redistribute_ipv4_ospf,
        no_bgp_redistribute_ipv4_ospf_cmd,
-       "no redistribute <ospf|table> (1-65535) [metric (0-4294967295)] [route-map WORD]",
+       "no redistribute <ospf|table> (1-65535) [{metric (0-4294967295)|route-map WORD}]",
        NO_STR
        "Redistribute information from another routing protocol\n"
        "Open Shortest Path First (OSPFv2)\n"
@@ -12337,7 +12343,7 @@ DEFUN (no_bgp_redistribute_ipv4_ospf,
 
 ALIAS_HIDDEN(
        no_bgp_redistribute_ipv4_ospf, no_bgp_redistribute_ipv4_ospf_hidden_cmd,
-       "no redistribute <ospf|table> (1-65535) [metric (0-4294967295)] [route-map WORD]",
+       "no redistribute <ospf|table> (1-65535) [{metric (0-4294967295)|route-map WORD}]",
        NO_STR
        "Redistribute information from another routing protocol\n"
        "Open Shortest Path First (OSPFv2)\n"
@@ -12350,7 +12356,7 @@ ALIAS_HIDDEN(
 
 DEFUN (no_bgp_redistribute_ipv4,
        no_bgp_redistribute_ipv4_cmd,
-       "no redistribute " FRR_IP_REDIST_STR_BGPD " [metric (0-4294967295)] [route-map WORD]",
+       "no redistribute " FRR_IP_REDIST_STR_BGPD " [{metric (0-4294967295)|route-map WORD}]",
        NO_STR
        "Redistribute information from another routing protocol\n"
        FRR_IP_REDIST_HELP_STR_BGPD
@@ -12374,7 +12380,7 @@ DEFUN (no_bgp_redistribute_ipv4,
 ALIAS_HIDDEN(
        no_bgp_redistribute_ipv4, no_bgp_redistribute_ipv4_hidden_cmd,
        "no redistribute " FRR_IP_REDIST_STR_BGPD
-       " [metric (0-4294967295)] [route-map WORD]",
+       " [{metric (0-4294967295)|route-map WORD}]",
        NO_STR
        "Redistribute information from another routing protocol\n" FRR_IP_REDIST_HELP_STR_BGPD
        "Metric for redistributed routes\n"
@@ -12533,7 +12539,7 @@ DEFUN (bgp_redistribute_ipv6_metric_rmap,
 
 DEFUN (no_bgp_redistribute_ipv6,
        no_bgp_redistribute_ipv6_cmd,
-       "no redistribute " FRR_IP6_REDIST_STR_BGPD " [metric (0-4294967295)] [route-map WORD]",
+       "no redistribute " FRR_IP6_REDIST_STR_BGPD " [{metric (0-4294967295)|route-map WORD}]",
        NO_STR
        "Redistribute information from another routing protocol\n"
        FRR_IP6_REDIST_HELP_STR_BGPD
@@ -13190,20 +13196,44 @@ void bgp_vty_init(void)
        install_element(BGP_NODE, &no_neighbor_nexthop_self_all_hidden_cmd);
        install_element(BGP_IPV4_NODE, &neighbor_nexthop_self_force_cmd);
        install_element(BGP_IPV4_NODE, &no_neighbor_nexthop_self_force_cmd);
+       install_element(BGP_IPV4_NODE, &neighbor_nexthop_self_all_hidden_cmd);
+       install_element(BGP_IPV4_NODE,
+                       &no_neighbor_nexthop_self_all_hidden_cmd);
        install_element(BGP_IPV4M_NODE, &neighbor_nexthop_self_force_cmd);
        install_element(BGP_IPV4M_NODE, &no_neighbor_nexthop_self_force_cmd);
+       install_element(BGP_IPV4M_NODE, &neighbor_nexthop_self_all_hidden_cmd);
+       install_element(BGP_IPV4M_NODE,
+                       &no_neighbor_nexthop_self_all_hidden_cmd);
        install_element(BGP_IPV4L_NODE, &neighbor_nexthop_self_force_cmd);
        install_element(BGP_IPV4L_NODE, &no_neighbor_nexthop_self_force_cmd);
+       install_element(BGP_IPV4L_NODE, &neighbor_nexthop_self_all_hidden_cmd);
+       install_element(BGP_IPV4L_NODE,
+                       &no_neighbor_nexthop_self_all_hidden_cmd);
        install_element(BGP_IPV6_NODE, &neighbor_nexthop_self_force_cmd);
        install_element(BGP_IPV6_NODE, &no_neighbor_nexthop_self_force_cmd);
+       install_element(BGP_IPV6_NODE, &neighbor_nexthop_self_all_hidden_cmd);
+       install_element(BGP_IPV6_NODE,
+                       &no_neighbor_nexthop_self_all_hidden_cmd);
        install_element(BGP_IPV6M_NODE, &neighbor_nexthop_self_force_cmd);
        install_element(BGP_IPV6M_NODE, &no_neighbor_nexthop_self_force_cmd);
+       install_element(BGP_IPV6M_NODE, &neighbor_nexthop_self_all_hidden_cmd);
+       install_element(BGP_IPV6M_NODE,
+                       &no_neighbor_nexthop_self_all_hidden_cmd);
        install_element(BGP_IPV6L_NODE, &neighbor_nexthop_self_force_cmd);
        install_element(BGP_IPV6L_NODE, &no_neighbor_nexthop_self_force_cmd);
+       install_element(BGP_IPV6L_NODE, &neighbor_nexthop_self_all_hidden_cmd);
+       install_element(BGP_IPV6L_NODE,
+                       &no_neighbor_nexthop_self_all_hidden_cmd);
        install_element(BGP_VPNV4_NODE, &neighbor_nexthop_self_force_cmd);
        install_element(BGP_VPNV4_NODE, &no_neighbor_nexthop_self_force_cmd);
+       install_element(BGP_VPNV4_NODE, &neighbor_nexthop_self_all_hidden_cmd);
+       install_element(BGP_VPNV4_NODE,
+                       &no_neighbor_nexthop_self_all_hidden_cmd);
        install_element(BGP_VPNV6_NODE, &neighbor_nexthop_self_force_cmd);
        install_element(BGP_VPNV6_NODE, &no_neighbor_nexthop_self_force_cmd);
+       install_element(BGP_VPNV6_NODE, &neighbor_nexthop_self_all_hidden_cmd);
+       install_element(BGP_VPNV6_NODE,
+                       &no_neighbor_nexthop_self_all_hidden_cmd);
 
        /* "neighbor as-override" commands. */
        install_element(BGP_NODE, &neighbor_as_override_hidden_cmd);