#include "bgpd/bgp_bfd.h"
#include "bgpd/bgp_io.h"
#include "bgpd/bgp_evpn.h"
+#include "bgpd/bgp_addpath.h"
static struct peer_group *listen_range_exists(struct bgp *bgp,
struct prefix *range, int exact);
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;
int idx_asn = 2;
int idx_view_vrf = 3;
int idx_vrf = 4;
+ int is_new_bgp = 0;
int ret;
as_t as;
struct bgp *bgp;
inst_type = BGP_INSTANCE_TYPE_VIEW;
}
+ if (inst_type == BGP_INSTANCE_TYPE_DEFAULT)
+ is_new_bgp = (bgp_lookup(as, name) == NULL);
+
ret = bgp_get(&bgp, &as, name, inst_type);
switch (ret) {
case BGP_ERR_MULTIPLE_INSTANCE_NOT_SET:
* any pending VRF-VPN leaking that was configured via
* earlier "router bgp X vrf FOO" blocks.
*/
- if (inst_type == BGP_INSTANCE_TYPE_DEFAULT)
+ if (is_new_bgp && inst_type == BGP_INSTANCE_TYPE_DEFAULT)
vpn_leak_postchange_all();
/* Pending: handle when user tries to change a view to vrf n vv.
for (ALL_LIST_ELEMENTS(bgp->peer, node, nnode, peer)) {
FOREACH_AFI_SAFI (afi, safi)
- if (CHECK_FLAG(
- peer->af_flags[afi][safi],
- PEER_FLAG_ADDPATH_TX_BESTPATH_PER_AS)) {
+ if (bgp_addpath_dmed_required(
+ peer->addpath_type[afi][safi])) {
bestpath_per_as_used = 1;
break;
}
if (!peer)
return CMD_WARNING_CONFIG_FAILED;
- return peer_af_flag_set_vty(vty, argv[idx_peer]->arg, bgp_node_afi(vty),
- bgp_node_safi(vty),
- PEER_FLAG_ADDPATH_TX_ALL_PATHS);
+ bgp_addpath_set_peer_type(peer, bgp_node_afi(vty), bgp_node_safi(vty),
+ BGP_ADDPATH_ALL);
+ return CMD_SUCCESS;
}
ALIAS_HIDDEN(neighbor_addpath_tx_all_paths,
"Use addpath to advertise all paths to a 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_ADDPATH_TX_ALL_PATHS);
+ struct peer *peer;
+
+ peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg);
+ if (!peer)
+ return CMD_WARNING_CONFIG_FAILED;
+
+ if (peer->addpath_type[bgp_node_afi(vty)][bgp_node_safi(vty)]
+ != BGP_ADDPATH_ALL) {
+ vty_out(vty,
+ "%% Peer not currently configured to transmit all paths.");
+ return CMD_WARNING_CONFIG_FAILED;
+ }
+
+ bgp_addpath_set_peer_type(peer, bgp_node_afi(vty), bgp_node_safi(vty),
+ BGP_ADDPATH_NONE);
+
+ return CMD_SUCCESS;
}
ALIAS_HIDDEN(no_neighbor_addpath_tx_all_paths,
if (!peer)
return CMD_WARNING_CONFIG_FAILED;
- return peer_af_flag_set_vty(vty, argv[idx_peer]->arg, bgp_node_afi(vty),
- bgp_node_safi(vty),
- PEER_FLAG_ADDPATH_TX_BESTPATH_PER_AS);
+ bgp_addpath_set_peer_type(peer, bgp_node_afi(vty), bgp_node_safi(vty),
+ BGP_ADDPATH_BEST_PER_AS);
+
+ return CMD_SUCCESS;
}
ALIAS_HIDDEN(neighbor_addpath_tx_bestpath_per_as,
"Use addpath to advertise the bestpath per each neighboring AS\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_ADDPATH_TX_BESTPATH_PER_AS);
+ struct peer *peer;
+
+ peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg);
+ if (!peer)
+ return CMD_WARNING_CONFIG_FAILED;
+
+ if (peer->addpath_type[bgp_node_afi(vty)][bgp_node_safi(vty)]
+ != BGP_ADDPATH_BEST_PER_AS) {
+ vty_out(vty,
+ "%% Peer not currently configured to transmit all best path per as.");
+ return CMD_WARNING_CONFIG_FAILED;
+ }
+
+ bgp_addpath_set_peer_type(peer, bgp_node_afi(vty), bgp_node_safi(vty),
+ BGP_ADDPATH_NONE);
+
+ return CMD_SUCCESS;
}
ALIAS_HIDDEN(no_neighbor_addpath_tx_bestpath_per_as,
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
json_addr,
"privateAsNumsRemovedInUpdatesToNbr");
- if (CHECK_FLAG(p->af_flags[afi][safi],
- PEER_FLAG_ADDPATH_TX_ALL_PATHS))
- json_object_boolean_true_add(json_addr,
- "addpathTxAllPaths");
-
- if (CHECK_FLAG(p->af_flags[afi][safi],
- PEER_FLAG_ADDPATH_TX_BESTPATH_PER_AS))
- json_object_boolean_true_add(json_addr,
- "addpathTxBestpathPerAS");
+ if (p->addpath_type[afi][safi] != BGP_ADDPATH_NONE)
+ json_object_boolean_true_add(
+ json_addr,
+ bgp_addpath_names(p->addpath_type[afi][safi])
+ ->type_json_name);
if (CHECK_FLAG(p->af_flags[afi][safi], PEER_FLAG_AS_OVERRIDE))
json_object_string_add(json_addr,
vty_out(vty,
" Private AS numbers removed in updates to this neighbor\n");
- if (CHECK_FLAG(p->af_flags[afi][safi],
- PEER_FLAG_ADDPATH_TX_ALL_PATHS))
- vty_out(vty, " Advertise all paths via addpath\n");
-
- if (CHECK_FLAG(p->af_flags[afi][safi],
- PEER_FLAG_ADDPATH_TX_BESTPATH_PER_AS))
- vty_out(vty,
- " Advertise bestpath per AS via addpath\n");
+ if (p->addpath_type[afi][safi] != BGP_ADDPATH_NONE)
+ vty_out(vty, " %s\n",
+ bgp_addpath_names(p->addpath_type[afi][safi])
+ ->human_description);
if (CHECK_FLAG(p->af_flags[afi][safi], PEER_FLAG_AS_OVERRIDE))
vty_out(vty,
json_object_string_add(
json_nxt,
print_store,
- "received");
+ "recieved"); /* misspelled for compatibility */
}
}
json_object_object_add(
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");
}
}
}
- 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");
}
COMMUNITY_VAL_STR)
{
char *cl_name_or_number = NULL;
+ char *str = NULL;
int direct = 0;
int style = COMMUNITY_LIST_STANDARD;
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);
"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,
COMMUNITY_VAL_STR)
{
char *cl_name_or_number = NULL;
+ char *str = NULL;
int direct = 0;
int style = COMMUNITY_LIST_EXPANDED;
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);
"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)
{
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)) {
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);
"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...",
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)) {
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);
"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;
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);
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);