diff options
Diffstat (limited to 'bgpd/bgp_vty.c')
| -rw-r--r-- | bgpd/bgp_vty.c | 1165 | 
1 files changed, 804 insertions, 361 deletions
diff --git a/bgpd/bgp_vty.c b/bgpd/bgp_vty.c index 7ef9db9f0d..9b4d893682 100644 --- a/bgpd/bgp_vty.c +++ b/bgpd/bgp_vty.c @@ -118,6 +118,10 @@ FRR_CFG_DEFAULT_BOOL(BGP_HARD_ADMIN_RESET,  	{ .val_bool = false, .match_version = "< 8.3", },  	{ .val_bool = true },  ); +FRR_CFG_DEFAULT_BOOL(BGP_SOFT_VERSION_CAPABILITY, +	{ .val_bool = true, .match_profile = "datacenter", }, +	{ .val_bool = false }, +);  DEFINE_HOOK(bgp_inst_config_write,  		(struct bgp *bgp, struct vty *vty), @@ -164,6 +168,8 @@ static enum node_type bgp_node_type(afi_t afi, safi_t safi)  			return BGP_VPNV4_NODE;  		case SAFI_FLOWSPEC:  			return BGP_FLOWSPECV4_NODE; +		case SAFI_LINKSTATE: +		case SAFI_LINKSTATE_VPN:  		case SAFI_UNSPEC:  		case SAFI_ENCAP:  		case SAFI_EVPN: @@ -184,6 +190,8 @@ static enum node_type bgp_node_type(afi_t afi, safi_t safi)  			return BGP_VPNV6_NODE;  		case SAFI_FLOWSPEC:  			return BGP_FLOWSPECV6_NODE; +		case SAFI_LINKSTATE: +		case SAFI_LINKSTATE_VPN:  		case SAFI_UNSPEC:  		case SAFI_ENCAP:  		case SAFI_EVPN: @@ -194,6 +202,23 @@ static enum node_type bgp_node_type(afi_t afi, safi_t safi)  		break;  	case AFI_L2VPN:  		return BGP_EVPN_NODE; +	case AFI_LINKSTATE: +		switch (safi) { +		case SAFI_LINKSTATE: +			return BGP_LS_NODE; +		case SAFI_LINKSTATE_VPN: /* Not yet supported */ +		case SAFI_UNICAST: +		case SAFI_MULTICAST: +		case SAFI_LABELED_UNICAST: +		case SAFI_MPLS_VPN: +		case SAFI_FLOWSPEC: +		case SAFI_UNSPEC: +		case SAFI_ENCAP: +		case SAFI_EVPN: +		case SAFI_MAX: +			return BGP_IPV4_NODE; +		} +		break;  	case AFI_UNSPEC:  	case AFI_MAX:  		// We should never be here but to clarify the switch statement.. @@ -235,6 +260,11 @@ static const char *get_afi_safi_vty_str(afi_t afi, safi_t safi)  	} else if (afi == AFI_L2VPN) {  		if (safi == SAFI_EVPN)  			return "L2VPN EVPN"; +	} else if (afi == AFI_LINKSTATE) { +		if (safi == SAFI_LINKSTATE) +			return "Link State"; +		if (safi == SAFI_LINKSTATE_VPN) +			return "Link State VPN";  	}  	return "Unknown"; @@ -277,6 +307,11 @@ static const char *get_afi_safi_json_str(afi_t afi, safi_t safi)  	} else if (afi == AFI_L2VPN) {  		if (safi == SAFI_EVPN)  			return "l2VpnEvpn"; +	} else if (afi == AFI_LINKSTATE) { +		if (safi == SAFI_LINKSTATE) +			return "linkState"; +		if (safi == SAFI_LINKSTATE_VPN) +			return "linkStateVPN";  	}  	return "Unknown"; @@ -367,6 +402,9 @@ afi_t bgp_node_afi(struct vty *vty)  	case BGP_EVPN_NODE:  		afi = AFI_L2VPN;  		break; +	case BGP_LS_NODE: +		afi = AFI_LINKSTATE; +		break;  	default:  		afi = AFI_IP;  		break; @@ -399,6 +437,9 @@ safi_t bgp_node_safi(struct vty *vty)  	case BGP_FLOWSPECV6_NODE:  		safi = SAFI_FLOWSPEC;  		break; +	case BGP_LS_NODE: +		safi = SAFI_LINKSTATE; +		break;  	default:  		safi = SAFI_UNICAST;  		break; @@ -424,6 +465,8 @@ afi_t bgp_vty_afi_from_str(const char *afi_str)  		afi = AFI_IP6;  	else if (strmatch(afi_str, "l2vpn"))  		afi = AFI_L2VPN; +	else if (strmatch(afi_str, "link-state")) +		afi = AFI_LINKSTATE;  	return afi;  } @@ -443,6 +486,10 @@ int argv_find_and_parse_afi(struct cmd_token **argv, int argc, int *index,  		ret = 1;  		if (afi)  			*afi = AFI_L2VPN; +	} else if (argv_find(argv, argc, "link-state", index)) { +		ret = 1; +		if (afi) +			*afi = AFI_LINKSTATE;  	}  	return ret;  } @@ -463,6 +510,10 @@ safi_t bgp_vty_safi_from_str(const char *safi_str)  		safi = SAFI_LABELED_UNICAST;  	else if (strmatch(safi_str, "flowspec"))  		safi = SAFI_FLOWSPEC; +	else if (strmatch(safi_str, "link-state")) +		safi = SAFI_LINKSTATE; +	else if (strmatch(safi_str, "link-state-vpn")) +		safi = SAFI_LINKSTATE_VPN;  	return safi;  } @@ -494,6 +545,10 @@ int argv_find_and_parse_safi(struct cmd_token **argv, int argc, int *index,  		ret = 1;  		if (safi)  			*safi = SAFI_FLOWSPEC; +	} else if (argv_find(argv, argc, "link-state", index)) { +		ret = 1; +		if (safi) +			*safi = SAFI_LINKSTATE;  	}  	return ret;  } @@ -530,6 +585,8 @@ static const char *get_bgp_default_af_flag(afi_t afi, safi_t safi)  		case SAFI_FLOWSPEC:  			return "ipv4-flowspec";  		case SAFI_UNSPEC: +		case SAFI_LINKSTATE: +		case SAFI_LINKSTATE_VPN:  		case SAFI_EVPN:  		case SAFI_MAX:  			return "unknown-afi/safi"; @@ -549,6 +606,8 @@ static const char *get_bgp_default_af_flag(afi_t afi, safi_t safi)  			return "ipv6-labeled-unicast";  		case SAFI_FLOWSPEC:  			return "ipv6-flowspec"; +		case SAFI_LINKSTATE: +		case SAFI_LINKSTATE_VPN:  		case SAFI_UNSPEC:  		case SAFI_EVPN:  		case SAFI_MAX: @@ -564,9 +623,30 @@ static const char *get_bgp_default_af_flag(afi_t afi, safi_t safi)  		case SAFI_MPLS_VPN:  		case SAFI_ENCAP:  		case SAFI_LABELED_UNICAST: +		case SAFI_LINKSTATE: +		case SAFI_LINKSTATE_VPN: +		case SAFI_FLOWSPEC: +		case SAFI_UNSPEC: +		case SAFI_MAX: +			return "unknown-afi/safi"; +		} +		break; +	case AFI_LINKSTATE: +		switch (safi) { +		case SAFI_EVPN: +		case SAFI_UNICAST: +		case SAFI_MULTICAST: +		case SAFI_MPLS_VPN: +		case SAFI_ENCAP: +		case SAFI_LABELED_UNICAST:  		case SAFI_FLOWSPEC:  		case SAFI_UNSPEC:  		case SAFI_MAX: +		case SAFI_LINKSTATE: +			return "link-state"; +		case SAFI_LINKSTATE_VPN: +			return "link-state-vpn"; +		default:  			return "unknown-afi/safi";  		}  		break; @@ -586,7 +666,7 @@ int bgp_get_vty(struct bgp **bgp, as_t *as, const char *name,  	int ret = bgp_get(bgp, as, name, inst_type, as_pretty, asnotation);  	if (ret == BGP_CREATED) { -		bgp_timers_set(*bgp, DFLT_BGP_KEEPALIVE, DFLT_BGP_HOLDTIME, +		bgp_timers_set(NULL, *bgp, DFLT_BGP_KEEPALIVE, DFLT_BGP_HOLDTIME,  			       DFLT_BGP_CONNECT_RETRY, BGP_DEFAULT_DELAYOPEN);  		if (DFLT_BGP_IMPORT_CHECK) @@ -607,6 +687,9 @@ int bgp_get_vty(struct bgp **bgp, as_t *as, const char *name,  			SET_FLAG((*bgp)->flags, BGP_FLAG_GRACEFUL_NOTIFICATION);  		if (DFLT_BGP_HARD_ADMIN_RESET)  			SET_FLAG((*bgp)->flags, BGP_FLAG_HARD_ADMIN_RESET); +		if (DFLT_BGP_SOFT_VERSION_CAPABILITY) +			SET_FLAG((*bgp)->flags, +				 BGP_FLAG_SOFT_VERSION_CAPABILITY);  		ret = BGP_SUCCESS;  	} @@ -1994,8 +2077,8 @@ DEFUN (bgp_confederation_identifier,         "bgp confederation identifier ASNUM",         BGP_STR         "AS confederation parameters\n" -       AS_STR -       "Set routing domain confederation AS\n") +       "Set routing domain confederation AS\n" +       AS_STR)  {  	VTY_DECLVAR_CONTEXT(bgp, bgp);  	int idx_number = 3; @@ -2017,8 +2100,8 @@ DEFUN (no_bgp_confederation_identifier,         NO_STR         BGP_STR         "AS confederation parameters\n" -       AS_STR -       "Set routing domain confederation AS\n") +       "Set routing domain confederation AS\n" +       AS_STR)  {  	VTY_DECLVAR_CONTEXT(bgp, bgp);  	bgp_confederation_id_unset(bgp); @@ -2654,7 +2737,7 @@ DEFUN (bgp_timers,  		return CMD_WARNING_CONFIG_FAILED;  	} -	bgp_timers_set(bgp, keepalive, holdtime, DFLT_BGP_CONNECT_RETRY, +	bgp_timers_set(vty, bgp, keepalive, holdtime, DFLT_BGP_CONNECT_RETRY,  		       BGP_DEFAULT_DELAYOPEN);  	return CMD_SUCCESS; @@ -2670,7 +2753,7 @@ DEFUN (no_bgp_timers,         "Holdtime\n")  {  	VTY_DECLVAR_CONTEXT(bgp, bgp); -	bgp_timers_set(bgp, DFLT_BGP_KEEPALIVE, DFLT_BGP_HOLDTIME, +	bgp_timers_set(vty, bgp, DFLT_BGP_KEEPALIVE, DFLT_BGP_HOLDTIME,  		       DFLT_BGP_CONNECT_RETRY, BGP_DEFAULT_DELAYOPEN);  	return CMD_SUCCESS; @@ -2881,9 +2964,9 @@ DEFUN(bgp_reject_as_sets, bgp_reject_as_sets_cmd,  	 * with aspath containing AS_SET or AS_CONFED_SET.  	 */  	for (ALL_LIST_ELEMENTS(bgp->peer, node, nnode, peer)) { -		if (BGP_IS_VALID_STATE_FOR_NOTIF(peer->status)) { +		if (BGP_IS_VALID_STATE_FOR_NOTIF(peer->connection->status)) {  			peer->last_reset = PEER_DOWN_AS_SETS_REJECT; -			bgp_notify_send(peer, BGP_NOTIFY_CEASE, +			bgp_notify_send(peer->connection, BGP_NOTIFY_CEASE,  					BGP_NOTIFY_CEASE_CONFIG_CHANGE);  		}  	} @@ -2907,9 +2990,9 @@ DEFUN(no_bgp_reject_as_sets, no_bgp_reject_as_sets_cmd,  	 * with aspath containing AS_SET or AS_CONFED_SET.  	 */  	for (ALL_LIST_ELEMENTS(bgp->peer, node, nnode, peer)) { -		if (BGP_IS_VALID_STATE_FOR_NOTIF(peer->status)) { +		if (BGP_IS_VALID_STATE_FOR_NOTIF(peer->connection->status)) {  			peer->last_reset = PEER_DOWN_AS_SETS_REJECT; -			bgp_notify_send(peer, BGP_NOTIFY_CEASE, +			bgp_notify_send(peer->connection, BGP_NOTIFY_CEASE,  					BGP_NOTIFY_CEASE_CONFIG_CHANGE);  		}  	} @@ -3059,9 +3142,17 @@ DEFUN (bgp_graceful_restart_restart_time,  	VTY_DECLVAR_CONTEXT(bgp, bgp);  	int idx_number = 3;  	uint32_t restart; +	struct listnode *node, *nnode; +	struct peer *peer;  	restart = strtoul(argv[idx_number]->arg, NULL, 10);  	bgp->restart_time = restart; + +	for (ALL_LIST_ELEMENTS(bgp->peer, node, nnode, peer)) +		bgp_capability_send(peer, AFI_IP, SAFI_UNICAST, +				    CAPABILITY_CODE_RESTART, +				    CAPABILITY_ACTION_SET); +  	return CMD_SUCCESS;  } @@ -3112,8 +3203,16 @@ DEFUN (no_bgp_graceful_restart_restart_time,  	"Delay value (seconds)\n")  {  	VTY_DECLVAR_CONTEXT(bgp, bgp); +	struct listnode *node, *nnode; +	struct peer *peer;  	bgp->restart_time = BGP_DEFAULT_RESTART_TIME; + +	for (ALL_LIST_ELEMENTS(bgp->peer, node, nnode, peer)) +		bgp_capability_send(peer, AFI_IP, SAFI_UNICAST, +				    CAPABILITY_CODE_RESTART, +				    CAPABILITY_ACTION_UNSET); +  	return CMD_SUCCESS;  } @@ -3168,12 +3267,19 @@ DEFPY (bgp_graceful_restart_notification,  	"Indicate Graceful Restart support for BGP NOTIFICATION messages\n")  {  	VTY_DECLVAR_CONTEXT(bgp, bgp); +	struct listnode *node, *nnode; +	struct peer *peer;  	if (no)  		UNSET_FLAG(bgp->flags, BGP_FLAG_GRACEFUL_NOTIFICATION);  	else  		SET_FLAG(bgp->flags, BGP_FLAG_GRACEFUL_NOTIFICATION); +	for (ALL_LIST_ELEMENTS(bgp->peer, node, nnode, peer)) +		bgp_capability_send(peer, AFI_IP, SAFI_UNICAST, +				    CAPABILITY_CODE_RESTART, +				    CAPABILITY_ACTION_SET); +  	return CMD_SUCCESS;  } @@ -3589,10 +3695,16 @@ DEFUN(bgp_llgr_stalepath_time, bgp_llgr_stalepath_time_cmd,  	VTY_DECLVAR_CONTEXT(bgp, bgp);  	uint32_t llgr_stale_time; +	struct listnode *node, *nnode; +	struct peer *peer;  	llgr_stale_time = strtoul(argv[3]->arg, NULL, 10);  	bgp->llgr_stale_time = llgr_stale_time; +	for (ALL_LIST_ELEMENTS(bgp->peer, node, nnode, peer)) +		bgp_capability_send(peer, AFI_IP, SAFI_UNICAST, +				    CAPABILITY_CODE_LLGR, CAPABILITY_ACTION_SET); +  	return CMD_SUCCESS;  } @@ -3604,9 +3716,16 @@ DEFUN(no_bgp_llgr_stalepath_time, no_bgp_llgr_stalepath_time_cmd,        "Stale time value (seconds)\n")  {  	VTY_DECLVAR_CONTEXT(bgp, bgp); +	struct listnode *node, *nnode; +	struct peer *peer;  	bgp->llgr_stale_time = BGP_DEFAULT_LLGR_STALE_TIME; +	for (ALL_LIST_ELEMENTS(bgp->peer, node, nnode, peer)) +		bgp_capability_send(peer, AFI_IP, SAFI_UNICAST, +				    CAPABILITY_CODE_LLGR, +				    CAPABILITY_ACTION_UNSET); +  	return CMD_SUCCESS;  } @@ -4093,6 +4212,7 @@ DEFPY(bgp_default_afi_safi, bgp_default_afi_safi_cmd,        "ipv6-vpn|"        "ipv6-labeled-unicast|"        "ipv6-flowspec|" +      "link-state|"        "l2vpn-evpn>$afi_safi",        NO_STR        BGP_STR @@ -4107,6 +4227,7 @@ DEFPY(bgp_default_afi_safi, bgp_default_afi_safi_cmd,        "Activate ipv6-vpn for a peer by default\n"        "Activate ipv6-labeled-unicast for a peer by default\n"        "Activate ipv6-flowspec for a peer by default\n" +      "Activate link-state for a peer by default\n"        "Activate l2vpn-evpn for a peer by default\n")  {  	VTY_DECLVAR_CONTEXT(bgp, bgp); @@ -4116,9 +4237,14 @@ DEFPY(bgp_default_afi_safi, bgp_default_afi_safi_cmd,  	strlcpy(afi_safi_str, afi_safi, sizeof(afi_safi_str));  	char *afi_str = strtok_r(afi_safi_str, "-", &afi_safi_str_tok);  	char *safi_str = strtok_r(NULL, "-", &afi_safi_str_tok); -	afi_t afi = bgp_vty_afi_from_str(afi_str); +	afi_t afi;  	safi_t safi; +	if (strmatch(afi_safi, "link-state")) +		afi = bgp_vty_afi_from_str("link-state"); +	else +		afi = bgp_vty_afi_from_str(afi_str); +  	/*  	 * Impossible situation but making coverity happy  	 */ @@ -4126,6 +4252,8 @@ DEFPY(bgp_default_afi_safi, bgp_default_afi_safi_cmd,  	if (strmatch(safi_str, "labeled"))  		safi = bgp_vty_safi_from_str("labeled-unicast"); +	else if (strmatch(afi_safi, "link-state")) +		safi = bgp_vty_safi_from_str("link-state");  	else  		safi = bgp_vty_safi_from_str(safi_str); @@ -4197,6 +4325,24 @@ DEFUN (no_bgp_default_show_nexthop_hostname,  	return CMD_SUCCESS;  } +DEFPY (bgp_default_software_version_capability, +       bgp_default_software_version_capability_cmd, +       "[no] bgp default software-version-capability", +       NO_STR +       BGP_STR +       "Configure BGP defaults\n" +       "Advertise software version capability for all neighbors\n") +{ +	VTY_DECLVAR_CONTEXT(bgp, bgp); + +	if (no) +		UNSET_FLAG(bgp->flags, BGP_FLAG_SOFT_VERSION_CAPABILITY); +	else +		SET_FLAG(bgp->flags, BGP_FLAG_SOFT_VERSION_CAPABILITY); + +	return CMD_SUCCESS; +} +  /* "bgp network import-check" configuration.  */  DEFUN (bgp_network_import_check,         bgp_network_import_check_cmd, @@ -4826,9 +4972,9 @@ static int peer_conf_interface_get(struct vty *vty, const char *conf_if,  			peer_flag_unset(peer, PEER_FLAG_IFPEER_V6ONLY);  		/* v6only flag changed. Reset bgp seesion */ -		if (BGP_IS_VALID_STATE_FOR_NOTIF(peer->status)) { +		if (BGP_IS_VALID_STATE_FOR_NOTIF(peer->connection->status)) {  			peer->last_reset = PEER_DOWN_V6ONLY_CHANGE; -			bgp_notify_send(peer, BGP_NOTIFY_CEASE, +			bgp_notify_send(peer->connection, BGP_NOTIFY_CEASE,  					BGP_NOTIFY_CEASE_CONFIG_CHANGE);  		} else  			bgp_session_reset(peer); @@ -5015,7 +5161,7 @@ DEFUN (no_neighbor,  			peer_notify_unconfig(peer);  			peer_delete(peer); -			if (other && other->status != Deleted) { +			if (other && other->connection->status != Deleted) {  				peer_notify_unconfig(other);  				peer_delete(other);  			} @@ -5700,17 +5846,25 @@ DEFPY(neighbor_capability_software_version,        "Advertise Software Version capability to the peer\n")  {  	struct peer *peer; +	int ret;  	peer = peer_and_group_lookup_vty(vty, neighbor); -	if (peer && peer->conf_if) -		return CMD_SUCCESS; +	if (!peer) +		return CMD_WARNING_CONFIG_FAILED;  	if (no) -		return peer_flag_unset_vty(vty, neighbor, -					   PEER_FLAG_CAPABILITY_SOFT_VERSION); +		ret = peer_flag_unset_vty(vty, neighbor, +					  PEER_FLAG_CAPABILITY_SOFT_VERSION);  	else -		return peer_flag_set_vty(vty, neighbor, -					 PEER_FLAG_CAPABILITY_SOFT_VERSION); +		ret = peer_flag_set_vty(vty, neighbor, +					PEER_FLAG_CAPABILITY_SOFT_VERSION); + +	bgp_capability_send(peer, AFI_IP, SAFI_UNICAST, +			    CAPABILITY_CODE_SOFT_VERSION, +			    no ? CAPABILITY_ACTION_UNSET +			       : CAPABILITY_ACTION_SET); + +	return ret;  }  static int peer_af_flag_modify_vty(struct vty *vty, const char *peer_str, @@ -6749,14 +6903,9 @@ static uint8_t get_role_by_name(const char *role_str)  	return ROLE_UNDEFINED;  } -static int peer_role_set_vty(struct vty *vty, const char *ip_str, +static int peer_role_set_vty(struct vty *vty, struct peer *peer,  			     const char *role_str, bool strict_mode)  { -	struct peer *peer; - -	peer = peer_and_group_lookup_vty(vty, ip_str); -	if (!peer) -		return CMD_WARNING_CONFIG_FAILED;  	uint8_t role = get_role_by_name(role_str);  	if (role == ROLE_UNDEFINED) @@ -6764,50 +6913,56 @@ static int peer_role_set_vty(struct vty *vty, const char *ip_str,  	return bgp_vty_return(vty, peer_role_set(peer, role, strict_mode));  } -static int peer_role_unset_vty(struct vty *vty, const char *ip_str) -{ -	struct peer *peer; - -	peer = peer_and_group_lookup_vty(vty, ip_str); -	if (!peer) -		return CMD_WARNING_CONFIG_FAILED; -	return bgp_vty_return(vty, peer_role_unset(peer)); -} -  DEFPY(neighbor_role,        neighbor_role_cmd, -      "neighbor <A.B.C.D|X:X::X:X|WORD> local-role <provider|rs-server|rs-client|customer|peer>", +      "neighbor <A.B.C.D|X:X::X:X|WORD>$neighbor local-role <provider|rs-server|rs-client|customer|peer>$role",        NEIGHBOR_STR        NEIGHBOR_ADDR_STR2        "Set session role\n"        ROLE_STR)  { -	int idx_peer = 1; -	int idx_role = 3; +	int ret; +	struct peer *peer; -	return peer_role_set_vty(vty, argv[idx_peer]->arg, argv[idx_role]->arg, -				 false); +	peer = peer_and_group_lookup_vty(vty, neighbor); +	if (!peer) +		return CMD_WARNING_CONFIG_FAILED; + +	ret = peer_role_set_vty(vty, peer, role, false); + +	bgp_capability_send(peer, AFI_IP, SAFI_UNICAST, CAPABILITY_CODE_ROLE, +			    CAPABILITY_ACTION_SET); + +	return ret;  }  DEFPY(neighbor_role_strict,        neighbor_role_strict_cmd, -      "neighbor <A.B.C.D|X:X::X:X|WORD> local-role <provider|rs-server|rs-client|customer|peer> strict-mode", +      "neighbor <A.B.C.D|X:X::X:X|WORD>$neighbor local-role <provider|rs-server|rs-client|customer|peer>$role strict-mode",        NEIGHBOR_STR        NEIGHBOR_ADDR_STR2        "Set session role\n"        ROLE_STR        "Use additional restriction on peer\n")  { -	int idx_peer = 1; -	int idx_role = 3; +	int ret; +	struct peer *peer; + +	peer = peer_and_group_lookup_vty(vty, neighbor); +	if (!peer) +		return CMD_WARNING_CONFIG_FAILED; + +	ret = peer_role_set_vty(vty, peer, role, true); -	return peer_role_set_vty(vty, argv[idx_peer]->arg, argv[idx_role]->arg, -				 true); +	bgp_capability_send(peer, AFI_IP, SAFI_UNICAST, CAPABILITY_CODE_ROLE, +			    CAPABILITY_ACTION_SET); + +	return ret;  }  DEFPY(no_neighbor_role,        no_neighbor_role_cmd, -      "no neighbor <A.B.C.D|X:X::X:X|WORD> local-role <provider|rs-server|rs-client|customer|peer> [strict-mode]", +      "no neighbor <A.B.C.D|X:X::X:X|WORD>$neighbor local-role <provider|rs-server|rs-client|customer|peer> [strict-mode]",        NO_STR        NEIGHBOR_STR        NEIGHBOR_ADDR_STR2 @@ -6815,9 +6970,19 @@ DEFPY(no_neighbor_role,        ROLE_STR        "Use additional restriction on peer\n")  { -	int idx_peer = 2; +	int ret; +	struct peer *peer; + +	peer = peer_and_group_lookup_vty(vty, neighbor); +	if (!peer) +		return CMD_WARNING_CONFIG_FAILED; -	return peer_role_unset_vty(vty, argv[idx_peer]->arg); +	ret = bgp_vty_return(vty, peer_role_unset(peer)); + +	bgp_capability_send(peer, AFI_IP, SAFI_UNICAST, CAPABILITY_CODE_ROLE, +			    CAPABILITY_ACTION_UNSET); + +	return ret;  }  /* disable-connected-check */ @@ -7563,7 +7728,7 @@ DEFUN (bgp_set_route_map_delay_timer,  		if (!rmap_delay_timer && bm->t_rmap_update) {  			EVENT_OFF(bm->t_rmap_update);  			event_execute(bm->master, bgp_route_map_update_timer, -				      NULL, 0); +				      NULL, 0, NULL);  		}  		return CMD_SUCCESS;  	} else { @@ -7959,6 +8124,26 @@ DEFPY (bgp_condadv_period,  	return CMD_SUCCESS;  } +DEFPY (bgp_def_originate_eval, +       bgp_def_originate_eval_cmd, +       "[no$no] bgp default-originate timer (0-3600)$timer", +       NO_STR +       BGP_STR +       "Control default-originate\n" +       "Set period to rescan BGP table to check if default-originate condition is met\n" +       "Period between BGP table scans, in seconds; default 5\n") +{ +	VTY_DECLVAR_CONTEXT(bgp, bgp); + +	bgp->rmap_def_originate_eval_timer = +		no ? RMAP_DEFAULT_ORIGINATE_EVAL_TIMER : timer; + +	if (bgp->t_rmap_def_originate_eval) +		EVENT_OFF(bgp->t_rmap_def_originate_eval); + +	return CMD_SUCCESS; +} +  DEFPY (neighbor_advertise_map,         neighbor_advertise_map_cmd,         "[no$no] neighbor <A.B.C.D|X:X::X:X|WORD>$neighbor advertise-map RMAP_NAME$advertise_str <exist-map|non-exist-map>$exist RMAP_NAME$condition_str", @@ -8567,6 +8752,8 @@ DEFPY (neighbor_soo,  		ecommunity_free(&peer->soo[afi][safi]);  		peer->soo[afi][safi] = ecomm_soo;  		peer_af_flag_unset(peer, afi, safi, PEER_FLAG_SOO); +	} else { +		ecommunity_free(&ecomm_soo);  	}  	return bgp_vty_return(vty, @@ -8783,7 +8970,7 @@ DEFUN (neighbor_addpath_tx_all_paths,  		return CMD_WARNING_CONFIG_FAILED;  	bgp_addpath_set_peer_type(peer, bgp_node_afi(vty), bgp_node_safi(vty), -				 BGP_ADDPATH_ALL); +				  BGP_ADDPATH_ALL, 0);  	return CMD_SUCCESS;  } @@ -8816,7 +9003,7 @@ DEFUN (no_neighbor_addpath_tx_all_paths,  	}  	bgp_addpath_set_peer_type(peer, bgp_node_afi(vty), bgp_node_safi(vty), -				 BGP_ADDPATH_NONE); +				  BGP_ADDPATH_NONE, 0);  	return CMD_SUCCESS;  } @@ -8827,6 +9014,45 @@ ALIAS_HIDDEN(no_neighbor_addpath_tx_all_paths,  	     NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2  	     "Use addpath to advertise all paths to a neighbor\n") +DEFPY (neighbor_addpath_tx_best_selected_paths, +       neighbor_addpath_tx_best_selected_paths_cmd, +       "neighbor <A.B.C.D|X:X::X:X|WORD>$neighbor addpath-tx-best-selected (1-6)$paths", +       NEIGHBOR_STR +       NEIGHBOR_ADDR_STR2 +       "Use addpath to advertise best selected paths to a neighbor\n" +       "The number of best paths\n") +{ +	struct peer *peer; + +	peer = peer_and_group_lookup_vty(vty, neighbor); +	if (!peer) +		return CMD_WARNING_CONFIG_FAILED; + +	bgp_addpath_set_peer_type(peer, bgp_node_afi(vty), bgp_node_safi(vty), +				  BGP_ADDPATH_BEST_SELECTED, paths); +	return CMD_SUCCESS; +} + +DEFPY (no_neighbor_addpath_tx_best_selected_paths, +       no_neighbor_addpath_tx_best_selected_paths_cmd, +       "no neighbor <A.B.C.D|X:X::X:X|WORD>$neighbor addpath-tx-best-selected [(1-6)]", +       NO_STR +       NEIGHBOR_STR +       NEIGHBOR_ADDR_STR2 +       "Use addpath to advertise best selected paths to a neighbor\n" +       "The number of best paths\n") +{ +	struct peer *peer; + +	peer = peer_and_group_lookup_vty(vty, neighbor); +	if (!peer) +		return CMD_WARNING_CONFIG_FAILED; + +	bgp_addpath_set_peer_type(peer, bgp_node_afi(vty), bgp_node_safi(vty), +				  BGP_ADDPATH_BEST_SELECTED, 0); +	return CMD_SUCCESS; +} +  DEFUN (neighbor_addpath_tx_bestpath_per_as,         neighbor_addpath_tx_bestpath_per_as_cmd,         "neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-bestpath-per-AS", @@ -8842,7 +9068,7 @@ DEFUN (neighbor_addpath_tx_bestpath_per_as,  		return CMD_WARNING_CONFIG_FAILED;  	bgp_addpath_set_peer_type(peer, bgp_node_afi(vty), bgp_node_safi(vty), -				 BGP_ADDPATH_BEST_PER_AS); +				  BGP_ADDPATH_BEST_PER_AS, 0);  	return CMD_SUCCESS;  } @@ -8876,7 +9102,7 @@ DEFUN (no_neighbor_addpath_tx_bestpath_per_as,  	}  	bgp_addpath_set_peer_type(peer, bgp_node_afi(vty), bgp_node_safi(vty), -				 BGP_ADDPATH_NONE); +				  BGP_ADDPATH_NONE, 0);  	return CMD_SUCCESS;  } @@ -9199,6 +9425,8 @@ DEFPY(af_label_vpn_export_allocation_mode,  	bool old_per_nexthop, new_per_nexthop;  	afi = vpn_policy_getafi(vty, bgp, false); +	if (afi == AFI_MAX) +		return CMD_WARNING_CONFIG_FAILED;  	old_per_nexthop = !!CHECK_FLAG(bgp->vpn_policy[afi].flags,  				       BGP_VPN_POLICY_TOVPN_LABEL_PER_NEXTHOP); @@ -9932,6 +10160,7 @@ DEFPY (bgp_imexport_vpn,  	bool yes = true;  	int flag;  	enum vpn_policy_direction dir; +	struct bgp *bgp_default = bgp_get_default();  	if (argv_find(argv, argc, "no", &idx))  		yes = false; @@ -9967,14 +10196,18 @@ DEFPY (bgp_imexport_vpn,  		SET_FLAG(bgp->af_flags[afi][safi], flag);  		if (!previous_state) {  			/* trigger export current vrf */ -			vpn_leak_postchange(dir, afi, bgp_get_default(), bgp); +			vpn_leak_postchange(dir, afi, bgp_default, bgp);  		}  	} else {  		if (previous_state) {  			/* trigger un-export current vrf */ -			vpn_leak_prechange(dir, afi, bgp_get_default(), bgp); +			vpn_leak_prechange(dir, afi, bgp_default, bgp);  		}  		UNSET_FLAG(bgp->af_flags[afi][safi], flag); +		if (previous_state && bgp_default && +		    !CHECK_FLAG(bgp_default->af_flags[afi][SAFI_MPLS_VPN], +				BGP_VPNVX_RETAIN_ROUTE_TARGET_ALL)) +			vpn_leak_no_retain(bgp, bgp_default, afi);  	}  	hook_call(bgp_snmp_init_stats, bgp); @@ -10130,6 +10363,15 @@ DEFUN_NOSH (address_family_evpn,  	return CMD_SUCCESS;  } +DEFUN_NOSH(address_family_linkstate, address_family_linkstate_cmd, +	   "address-family link-state link-state", +	   "Enter Address Family command mode\n" BGP_AF_STR BGP_AF_MODIFIER_STR) +{ +	VTY_DECLVAR_CONTEXT(bgp, bgp); +	vty->node = BGP_LS_NODE; +	return CMD_SUCCESS; +} +  DEFUN_NOSH (bgp_segment_routing_srv6,              bgp_segment_routing_srv6_cmd,              "segment-routing srv6", @@ -10270,7 +10512,8 @@ DEFUN_NOSH (exit_address_family,  	    || vty->node == BGP_IPV6L_NODE || vty->node == BGP_VPNV6_NODE  	    || vty->node == BGP_EVPN_NODE  	    || vty->node == BGP_FLOWSPECV4_NODE -	    || vty->node == BGP_FLOWSPECV6_NODE) +	    || vty->node == BGP_FLOWSPECV6_NODE +		|| vty->node == BGP_LS_NODE)  		vty->node = BGP_NODE;  	return CMD_SUCCESS;  } @@ -10587,7 +10830,7 @@ static inline void calc_peers_cfgd_estbd(struct bgp *bgp, int *peers_cfgd,  		if (!CHECK_FLAG(peer->flags, PEER_FLAG_CONFIG_NODE))  			continue;  		(*peers_cfgd)++; -		if (peer_established(peer)) +		if (peer_established(peer->connection))  			(*peers_estbd)++;  	}  } @@ -10866,6 +11109,29 @@ DEFUN (show_bgp_memory,  				memstrbuf, sizeof(memstrbuf),  				count * sizeof(struct bgp_path_info_extra))); +	count = mtype_stats_alloc(MTYPE_BGP_ROUTE_EXTRA_EVPN); +	if (count) +		vty_out(vty, "%ld BGP extra info for EVPN, using %s of memory\n", +			count, +			mtype_memstr(memstrbuf, sizeof(memstrbuf), +				     count * sizeof(struct bgp_path_info_extra_evpn))); + +	count = mtype_stats_alloc(MTYPE_BGP_ROUTE_EXTRA_FS); +	if (count) +		vty_out(vty, +			"%ld BGP extra info for flowspec, using %s of memory\n", +			count, +			mtype_memstr(memstrbuf, sizeof(memstrbuf), +				     count * sizeof(struct bgp_path_info_extra_fs))); + +	count = mtype_stats_alloc(MTYPE_BGP_ROUTE_EXTRA_VRFLEAK); +	if (count) +		vty_out(vty, +			"%ld BGP extra info for vrf leaking, using %s of memory\n", +			count, +			mtype_memstr(memstrbuf, sizeof(memstrbuf), +				     count * sizeof(struct bgp_path_info_extra_vrfleak))); +  	if ((count = mtype_stats_alloc(MTYPE_BGP_STATIC)))  		vty_out(vty, "%ld Static routes, using %s of memory\n", count,  			mtype_memstr(memstrbuf, sizeof(memstrbuf), @@ -11044,11 +11310,9 @@ static void bgp_show_peer_reset(struct vty * vty, struct peer *peer,  					     msgbuf, sizeof(msgbuf),  					     (uint8_t *)peer->notify.data,  					     peer->notify.length); -				if (msg_str) -					json_object_string_add( -					   json_peer, -					   "lastShutdownDescription", -					   msg_str); +				json_object_string_add(json_peer, +				   "lastShutdownDescription", +				   msg_str);  			}  		} @@ -11088,7 +11352,8 @@ static void bgp_show_peer_reset(struct vty * vty, struct peer *peer,  static inline bool bgp_has_peer_failed(struct peer *peer, afi_t afi,  				       safi_t safi)  { -	return ((!peer_established(peer)) || !peer->afc_recv[afi][safi]); +	return ((!peer_established(peer->connection)) || +		!peer->afc_recv[afi][safi]);  }  static void bgp_show_failed_summary(struct vty *vty, struct bgp *bgp, @@ -11115,7 +11380,7 @@ static void bgp_show_failed_summary(struct vty *vty, struct bgp *bgp,  				    peer->dropped);  		peer_uptime(peer->uptime, timebuf, BGP_UPTIME_LEN,  			    use_json, json_peer); -		if (peer_established(peer)) +		if (peer_established(peer->connection))  			json_object_string_add(json_peer, "lastResetDueTo",  					       "AFI/SAFI Not Negotiated");  		else @@ -11138,7 +11403,7 @@ static void bgp_show_failed_summary(struct vty *vty, struct bgp *bgp,  			peer->dropped,  			peer_uptime(peer->uptime, timebuf,  				    BGP_UPTIME_LEN, 0, NULL)); -		if (peer_established(peer)) +		if (peer_established(peer->connection))  			vty_out(vty, "  AFI/SAFI Not Negotiated\n");  		else  			bgp_show_peer_reset(vty, peer, NULL, @@ -11613,12 +11878,16 @@ static int bgp_show_summary(struct vty *vty, struct bgp *bgp, int afi, int safi,  						    PEER_TOTAL_TX(peer));  				atomic_size_t outq_count, inq_count; -				outq_count = atomic_load_explicit( -					&peer->obuf->count, -					memory_order_relaxed); -				inq_count = atomic_load_explicit( -					&peer->ibuf->count, -					memory_order_relaxed); +				outq_count = +					atomic_load_explicit(&peer->connection +								      ->obuf +								      ->count, +							     memory_order_relaxed); +				inq_count = +					atomic_load_explicit(&peer->connection +								      ->ibuf +								      ->count, +							     memory_order_relaxed);  				json_object_int_add(  					json_peer, "tableVersion", @@ -11654,7 +11923,8 @@ static int bgp_show_summary(struct vty *vty, struct bgp *bgp, int afi, int safi,  					json_object_string_add(  						json_peer, "state",  						lookup_msg(bgp_status_msg, -							   peer->status, NULL)); +							   peer->connection->status, +							   NULL));  				else if (CHECK_FLAG(  						 peer->sflags,  						 PEER_STATUS_PREFIX_OVERFLOW)) @@ -11665,7 +11935,8 @@ static int bgp_show_summary(struct vty *vty, struct bgp *bgp, int afi, int safi,  					json_object_string_add(  						json_peer, "state",  						lookup_msg(bgp_status_msg, -							   peer->status, NULL)); +							   peer->connection->status, +							   NULL));  				/* BGP peer state */  				if (CHECK_FLAG(peer->flags, PEER_FLAG_SHUTDOWN) @@ -11719,10 +11990,10 @@ static int bgp_show_summary(struct vty *vty, struct bgp *bgp, int afi, int safi,  			if (peer->conf_if)  				json_object_string_add(json_peer, "idType",  						       "interface"); -			else if (peer->su.sa.sa_family == AF_INET) +			else if (peer->connection->su.sa.sa_family == AF_INET)  				json_object_string_add(json_peer, "idType",  						       "ipv4"); -			else if (peer->su.sa.sa_family == AF_INET6) +			else if (peer->connection->su.sa.sa_family == AF_INET6)  				json_object_string_add(json_peer, "idType",  						       "ipv6");  			json_object_object_add(json_peers, peer->host, @@ -11781,14 +12052,18 @@ static int bgp_show_summary(struct vty *vty, struct bgp *bgp, int afi, int safi,  						" ");  				atomic_size_t outq_count, inq_count; -				outq_count = atomic_load_explicit( -					&peer->obuf->count, -					memory_order_relaxed); -				inq_count = atomic_load_explicit( -					&peer->ibuf->count, -					memory_order_relaxed); - -				vty_out(vty, "4 "); +				outq_count = +					atomic_load_explicit(&peer->connection +								      ->obuf +								      ->count, +							     memory_order_relaxed); +				inq_count = +					atomic_load_explicit(&peer->connection +								      ->ibuf +								      ->count, +							     memory_order_relaxed); + +				vty_out(vty, "4");  				vty_out(vty, ASN_FORMAT_SPACE(bgp->asnotation),  					&peer->as);  				if (show_wide) @@ -11809,7 +12084,7 @@ static int bgp_show_summary(struct vty *vty, struct bgp *bgp, int afi, int safi,  					peer_uptime(peer->uptime, timebuf,  						    BGP_UPTIME_LEN, 0, NULL)); -				if (peer_established(peer)) { +				if (peer_established(peer->connection)) {  					if (peer->afc_recv[afi][safi]) {  						if (CHECK_FLAG(  							    bgp->flags, @@ -11858,20 +12133,31 @@ static int bgp_show_summary(struct vty *vty, struct bgp *bgp, int afi, int safi,  					else  						vty_out(vty, " %12s",  							lookup_msg(bgp_status_msg, -								   peer->status, NULL)); +								   peer->connection +									   ->status, +								   NULL));  					vty_out(vty, " %8u", 0);  				}  				/* Make sure `Desc` column is the lastest in  				 * the output. +				 * If the description is not set, try +				 * to print the software version if the +				 * capability is enabled and received.  				 */  				if (peer->desc)  					vty_out(vty, " %s",  						bgp_peer_description_stripped(  							peer->desc,  							show_wide ? 64 : 20)); -				else +				else if (peer->soft_version) { +					vty_out(vty, " %s", +						bgp_peer_description_stripped( +							peer->soft_version, +							show_wide ? 64 : 20)); +				} else {  					vty_out(vty, " N/A"); +				}  				vty_out(vty, "\n");  			} @@ -12099,11 +12385,11 @@ int bgp_show_summary_vty(struct vty *vty, const char *name, afi_t afi,  /* `show [ip] bgp summary' commands. */  DEFPY(show_ip_bgp_summary, show_ip_bgp_summary_cmd, -      "show [ip] bgp [<view|vrf> VIEWVRFNAME] [" BGP_AFI_CMD_STR -      " [" BGP_SAFI_WITH_LABEL_CMD_STR +      "show [ip] bgp [<view|vrf> VIEWVRFNAME] [" BGP_AFI_WITH_LS_CMD_STR +      " [" BGP_SAFI_WITH_LABEL_LS_CMD_STR        "]] [all$all] summary [established|failed] [<neighbor <A.B.C.D|X:X::X:X|WORD>|remote-as <ASNUM|internal|external>>] [terse] [wide] [json$uj]", -      SHOW_STR IP_STR BGP_STR BGP_INSTANCE_HELP_STR BGP_AFI_HELP_STR -	      BGP_SAFI_WITH_LABEL_HELP_STR +      SHOW_STR IP_STR BGP_STR BGP_INSTANCE_HELP_STR BGP_AFI_WITH_LS_HELP_STR +	      BGP_SAFI_WITH_LABEL_LS_HELP_STR        "Display the entries for all address families\n"        "Summary of BGP neighbor status\n"        "Show only sessions in Established state\n" @@ -12254,9 +12540,9 @@ static void bgp_show_neighnor_graceful_restart_flags(struct vty *vty,  	bool rbit = false;  	bool nbit = false; -	if (CHECK_FLAG(p->cap, PEER_CAP_RESTART_ADV) -	    && (CHECK_FLAG(p->cap, PEER_CAP_RESTART_RCV)) -	    && (peer_established(p))) { +	if (CHECK_FLAG(p->cap, PEER_CAP_RESTART_ADV) && +	    (CHECK_FLAG(p->cap, PEER_CAP_RESTART_RCV)) && +	    (peer_established(p->connection))) {  		rbit = CHECK_FLAG(p->cap, PEER_CAP_GRACEFUL_RESTART_R_BIT_RCV);  		nbit = CHECK_FLAG(p->cap, PEER_CAP_GRACEFUL_RESTART_N_BIT_RCV);  	} @@ -12279,9 +12565,8 @@ static void bgp_show_neighbor_graceful_restart_remote_mode(struct vty *vty,  	if (!json)  		vty_out(vty, "\n    Remote GR Mode: "); -	if (CHECK_FLAG(peer->cap, PEER_CAP_RESTART_ADV) -	    && (peer_established(peer))) { - +	if (CHECK_FLAG(peer->cap, PEER_CAP_RESTART_ADV) && +	    (peer_established(peer->connection))) {  		if ((peer->nsf_af_count == 0)  		    && !CHECK_FLAG(peer->cap, PEER_CAP_RESTART_RCV)) { @@ -12443,12 +12728,15 @@ static void bgp_show_neighbor_graceful_restart_capability_per_afi_safi(  		if (json) {  			json_object_int_add(json_timer, "stalePathTimer",  					    peer->bgp->stalepath_time); +			json_object_int_add(json_timer, "llgrStaleTime", +					    peer->llgr[afi][safi].stale_time); -			if (peer->t_gr_stale != NULL) { +			if (peer->connection->t_gr_stale != NULL) {  				json_object_int_add(json_timer,  						    "stalePathTimerRemaining",  						    event_timer_remain_second( -							    peer->t_gr_stale)); +							    peer->connection +								    ->t_gr_stale));  			}  			/* Display Configured Selection @@ -12478,11 +12766,11 @@ static void bgp_show_neighbor_graceful_restart_capability_per_afi_safi(  				"        Configured Stale Path Time(sec): %u\n",  				peer->bgp->stalepath_time); -			if (peer->t_gr_stale != NULL) +			if (peer->connection->t_gr_stale != NULL)  				vty_out(vty,  					"      Stale Path Remaining(sec): %ld\n",  					event_timer_remain_second( -						peer->t_gr_stale)); +						peer->connection->t_gr_stale));  			/* Display Configured Selection  			 * Deferral only when when  			 * Gr mode is enabled. @@ -12492,6 +12780,9 @@ static void bgp_show_neighbor_graceful_restart_capability_per_afi_safi(  					"        Configured Selection Deferral Time(sec): %u\n",  					peer->bgp->select_defer_time); +			vty_out(vty, "        LLGR Stale Path Time(sec): %u\n", +				peer->llgr[afi][safi].stale_time); +  			if (peer->bgp->gr_info[afi][safi].t_select_deferral !=  			    NULL)  				vty_out(vty, @@ -12523,14 +12814,16 @@ static void bgp_show_neighbor_graceful_restart_time(struct vty *vty,  		json_object_int_add(json_timer, "configuredRestartTimer",  				    p->bgp->restart_time); +		json_object_int_add(json_timer, "configuredLlgrStaleTime", +				    p->bgp->llgr_stale_time);  		json_object_int_add(json_timer, "receivedRestartTimer",  				    p->v_gr_restart); -		if (p->t_gr_restart != NULL) -			json_object_int_add( -				json_timer, "restartTimerRemaining", -				event_timer_remain_second(p->t_gr_restart)); +		if (p->connection->t_gr_restart != NULL) +			json_object_int_add(json_timer, "restartTimerRemaining", +					    event_timer_remain_second( +						    p->connection->t_gr_restart));  		json_object_object_add(json, "timers", json_timer);  	} else { @@ -12541,12 +12834,16 @@ static void bgp_show_neighbor_graceful_restart_time(struct vty *vty,  		vty_out(vty, "      Received Restart Time(sec): %u\n",  			p->v_gr_restart); -		if (p->t_gr_restart != NULL) +		vty_out(vty, "      Configured LLGR Stale Path Time(sec): %u\n", +			p->bgp->llgr_stale_time); +		if (p->connection->t_gr_restart != NULL)  			vty_out(vty, "      Restart Time Remaining(sec): %ld\n", -				event_timer_remain_second(p->t_gr_restart)); -		if (p->t_gr_restart != NULL) { +				event_timer_remain_second( +					p->connection->t_gr_restart)); +		if (p->connection->t_gr_restart != NULL) {  			vty_out(vty, "      Restart Time Remaining(sec): %ld\n", -				event_timer_remain_second(p->t_gr_restart)); +				event_timer_remain_second( +					p->connection->t_gr_restart));  		}  	}  } @@ -12564,10 +12861,10 @@ static void bgp_show_peer_gr_status(struct vty *vty, struct peer *p,  	if (p->conf_if) {  		if (json)  			json_object_string_addf(json, "neighborAddr", "%pSU", -						&p->su); +						&p->connection->su);  		else  			vty_out(vty, "BGP neighbor on %s: %pSU\n", p->conf_if, -				&p->su); +				&p->connection->su);  	} else {  		snprintf(neighborAddr, sizeof(neighborAddr), "%s%s", dn_flag,  			 p->host); @@ -12593,7 +12890,6 @@ static void bgp_show_peer_afi(struct vty *vty, struct peer *p, afi_t afi,  	int orf_pfx_count;  	json_object *json_af = NULL;  	json_object *json_prefA = NULL; -	json_object *json_prefB = NULL;  	json_object *json_addr = NULL;  	json_object *json_advmap = NULL; @@ -12636,37 +12932,13 @@ static void bgp_show_peer_afi(struct vty *vty, struct peer *p, afi_t afi,  					       json_prefA);  		} -		if (CHECK_FLAG(p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_SM_ADV) -		    || CHECK_FLAG(p->af_cap[afi][safi], -				  PEER_CAP_ORF_PREFIX_SM_OLD_RCV) -		    || CHECK_FLAG(p->af_cap[afi][safi], -				  PEER_CAP_ORF_PREFIX_RM_ADV) -		    || CHECK_FLAG(p->af_cap[afi][safi], -				  PEER_CAP_ORF_PREFIX_RM_OLD_RCV)) { -			json_object_int_add(json_af, "orfOldType", -					    ORF_TYPE_PREFIX_OLD); -			json_prefB = json_object_new_object(); -			bgp_show_peer_afi_orf_cap( -				vty, p, afi, safi, PEER_CAP_ORF_PREFIX_SM_ADV, -				PEER_CAP_ORF_PREFIX_RM_ADV, -				PEER_CAP_ORF_PREFIX_SM_OLD_RCV, -				PEER_CAP_ORF_PREFIX_RM_OLD_RCV, use_json, -				json_prefB); -			json_object_object_add(json_af, "orfOldPrefixList", -					       json_prefB); -		} - -		if (CHECK_FLAG(p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_SM_ADV) -		    || CHECK_FLAG(p->af_cap[afi][safi], -				  PEER_CAP_ORF_PREFIX_SM_RCV) -		    || CHECK_FLAG(p->af_cap[afi][safi], -				  PEER_CAP_ORF_PREFIX_SM_OLD_RCV) -		    || CHECK_FLAG(p->af_cap[afi][safi], -				  PEER_CAP_ORF_PREFIX_RM_ADV) -		    || CHECK_FLAG(p->af_cap[afi][safi], -				  PEER_CAP_ORF_PREFIX_RM_RCV) -		    || CHECK_FLAG(p->af_cap[afi][safi], -				  PEER_CAP_ORF_PREFIX_RM_OLD_RCV)) +		if (CHECK_FLAG(p->af_cap[afi][safi], +			       PEER_CAP_ORF_PREFIX_SM_ADV) || +		    CHECK_FLAG(p->af_cap[afi][safi], +			       PEER_CAP_ORF_PREFIX_SM_RCV) || +		    CHECK_FLAG(p->af_cap[afi][safi], +			       PEER_CAP_ORF_PREFIX_RM_ADV) || +		    CHECK_FLAG(p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_RM_RCV))  			json_object_object_add(json_addr, "afDependentCap",  					       json_af);  		else @@ -12953,17 +13225,13 @@ static void bgp_show_peer_afi(struct vty *vty, struct peer *p, afi_t afi,  		} else {  			vty_out(vty, "  Not part of any update group\n");  		} -		if (CHECK_FLAG(p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_SM_ADV) -		    || CHECK_FLAG(p->af_cap[afi][safi], -				  PEER_CAP_ORF_PREFIX_SM_RCV) -		    || CHECK_FLAG(p->af_cap[afi][safi], -				  PEER_CAP_ORF_PREFIX_SM_OLD_RCV) -		    || CHECK_FLAG(p->af_cap[afi][safi], -				  PEER_CAP_ORF_PREFIX_RM_ADV) -		    || CHECK_FLAG(p->af_cap[afi][safi], -				  PEER_CAP_ORF_PREFIX_RM_RCV) -		    || CHECK_FLAG(p->af_cap[afi][safi], -				  PEER_CAP_ORF_PREFIX_RM_OLD_RCV)) +		if (CHECK_FLAG(p->af_cap[afi][safi], +			       PEER_CAP_ORF_PREFIX_SM_ADV) || +		    CHECK_FLAG(p->af_cap[afi][safi], +			       PEER_CAP_ORF_PREFIX_SM_RCV) || +		    CHECK_FLAG(p->af_cap[afi][safi], +			       PEER_CAP_ORF_PREFIX_RM_ADV) || +		    CHECK_FLAG(p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_RM_RCV))  			vty_out(vty, "  AF-dependant capabilities:\n");  		if (CHECK_FLAG(p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_SM_ADV) @@ -12982,22 +13250,6 @@ static void bgp_show_peer_afi(struct vty *vty, struct peer *p, afi_t afi,  				PEER_CAP_ORF_PREFIX_SM_RCV,  				PEER_CAP_ORF_PREFIX_RM_RCV, use_json, NULL);  		} -		if (CHECK_FLAG(p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_SM_ADV) -		    || CHECK_FLAG(p->af_cap[afi][safi], -				  PEER_CAP_ORF_PREFIX_SM_OLD_RCV) -		    || CHECK_FLAG(p->af_cap[afi][safi], -				  PEER_CAP_ORF_PREFIX_RM_ADV) -		    || CHECK_FLAG(p->af_cap[afi][safi], -				  PEER_CAP_ORF_PREFIX_RM_OLD_RCV)) { -			vty_out(vty, -				"    Outbound Route Filter (ORF) type (%d) Prefix-list:\n", -				ORF_TYPE_PREFIX_OLD); -			bgp_show_peer_afi_orf_cap( -				vty, p, afi, safi, PEER_CAP_ORF_PREFIX_SM_ADV, -				PEER_CAP_ORF_PREFIX_RM_ADV, -				PEER_CAP_ORF_PREFIX_SM_OLD_RCV, -				PEER_CAP_ORF_PREFIX_RM_OLD_RCV, use_json, NULL); -		}  		snprintf(orf_pfx_name, sizeof(orf_pfx_name), "%s.%d.%d",  			 p->host, afi, safi); @@ -13280,19 +13532,19 @@ static void bgp_show_peer(struct vty *vty, struct peer *p, bool use_json,  	if (!use_json) {  		if (p->conf_if) /* Configured interface name. */  			vty_out(vty, "BGP neighbor on %s: %pSU, ", p->conf_if, -				&p->su); +				&p->connection->su);  		else /* Configured IP address. */  			vty_out(vty, "BGP neighbor is %s%s, ", dn_flag,  				p->host);  	}  	if (use_json) { -		if (p->conf_if && BGP_PEER_SU_UNSPEC(p)) +		if (p->conf_if && BGP_CONNECTION_SU_UNSPEC(p->connection))  			json_object_string_add(json_neigh, "bgpNeighborAddr",  					       "none"); -		else if (p->conf_if && !BGP_PEER_SU_UNSPEC(p)) +		else if (p->conf_if && !BGP_CONNECTION_SU_UNSPEC(p->connection))  			json_object_string_addf(json_neigh, "bgpNeighborAddr", -						"%pSU", &p->su); +						"%pSU", &p->connection->su);  		asn_asn2json(json_neigh, "remoteAs", p->as, bgp->asnotation); @@ -13421,7 +13673,8 @@ static void bgp_show_peer(struct vty *vty, struct peer *p, bool use_json,  			if (dn_flag[0]) {  				struct prefix prefix, *range = NULL; -				if (sockunion2hostprefix(&(p->su), &prefix)) +				if (sockunion2hostprefix(&p->connection->su, +							 &prefix))  					range = peer_group_lookup_dynamic_neighbor_range(  						p->group, &prefix); @@ -13440,7 +13693,8 @@ static void bgp_show_peer(struct vty *vty, struct peer *p, bool use_json,  			if (dn_flag[0]) {  				struct prefix prefix, *range = NULL; -				if (sockunion2hostprefix(&(p->su), &prefix)) +				if (sockunion2hostprefix(&p->connection->su, +							 &prefix))  					range = peer_group_lookup_dynamic_neighbor_range(  						p->group, &prefix); @@ -13474,11 +13728,11 @@ static void bgp_show_peer(struct vty *vty, struct peer *p, bool use_json,  						     "nbrCommonAdmin");  		/* Status. */ -		json_object_string_add( -			json_neigh, "bgpState", -			lookup_msg(bgp_status_msg, p->status, NULL)); +		json_object_string_add(json_neigh, "bgpState", +				       lookup_msg(bgp_status_msg, +						  p->connection->status, NULL)); -		if (peer_established(p)) { +		if (peer_established(p->connection)) {  			time_t uptime;  			uptime = monotime(NULL); @@ -13494,9 +13748,7 @@ static void bgp_show_peer(struct vty *vty, struct peer *p, bool use_json,  			json_object_int_add(json_neigh,  					    "bgpTimerUpEstablishedEpoch",  					    epoch_tbuf); -		} - -		else if (p->status == Active) { +		} else if (p->connection->status == Active) {  			if (CHECK_FLAG(p->flags, PEER_FLAG_PASSIVE))  				json_object_string_add(json_neigh, "bgpStateIs",  						       "passive"); @@ -13556,13 +13808,10 @@ static void bgp_show_peer(struct vty *vty, struct peer *p, bool use_json,  		}  		/* Configured and Synced tcp-mss value for peer */ -		if (CHECK_FLAG(p->flags, PEER_FLAG_TCP_MSS)) { -			sync_tcp_mss = sockopt_tcp_mss_get(p->fd); -			json_object_int_add(json_neigh, "bgpTcpMssConfigured", -					    p->tcp_mss); -			json_object_int_add(json_neigh, "bgpTcpMssSynced", -					    sync_tcp_mss); -		} +		sync_tcp_mss = sockopt_tcp_mss_get(p->connection->fd); +		json_object_int_add(json_neigh, "bgpTcpMssConfigured", +				    p->tcp_mss); +		json_object_int_add(json_neigh, "bgpTcpMssSynced", sync_tcp_mss);  		/* Extended Optional Parameters Length for BGP OPEN Message */  		if (BGP_OPEN_EXT_OPT_PARAMS_CAPABLE(p)) @@ -13602,14 +13851,13 @@ static void bgp_show_peer(struct vty *vty, struct peer *p, bool use_json,  		/* Status. */  		vty_out(vty, "  BGP state = %s", -			lookup_msg(bgp_status_msg, p->status, NULL)); +			lookup_msg(bgp_status_msg, p->connection->status, NULL)); -		if (peer_established(p)) +		if (peer_established(p->connection))  			vty_out(vty, ", up for %8s",  				peer_uptime(p->uptime, timebuf, BGP_UPTIME_LEN,  					    0, NULL)); - -		else if (p->status == Active) { +		else if (p->connection->status == Active) {  			if (CHECK_FLAG(p->flags, PEER_FLAG_PASSIVE))  				vty_out(vty, " (passive)");  			else if (CHECK_FLAG(p->sflags, PEER_STATUS_NSF_WAIT)) @@ -13643,11 +13891,9 @@ static void bgp_show_peer(struct vty *vty, struct peer *p, bool use_json,  				p->delayopen);  		/* Configured and synced tcp-mss value for peer */ -		if (CHECK_FLAG(p->flags, PEER_FLAG_TCP_MSS)) { -			sync_tcp_mss = sockopt_tcp_mss_get(p->fd); -			vty_out(vty, "  Configured tcp-mss is %d", p->tcp_mss); -			vty_out(vty, ", synced tcp-mss is %d\n", sync_tcp_mss); -		} +		sync_tcp_mss = sockopt_tcp_mss_get(p->connection->fd); +		vty_out(vty, "  Configured tcp-mss is %d", p->tcp_mss); +		vty_out(vty, ", synced tcp-mss is %d\n", sync_tcp_mss);  		/* Extended Optional Parameters Length for BGP OPEN Message */  		if (BGP_OPEN_EXT_OPT_PARAMS_CAPABLE(p)) @@ -13665,7 +13911,7 @@ static void bgp_show_peer(struct vty *vty, struct peer *p, bool use_json,  					bgp->t_condition_check));  	}  	/* Capability. */ -	if (peer_established(p) && +	if (peer_established(p->connection) &&  	    (p->cap || peer_afc_advertised(p) || peer_afc_received(p))) {  		if (use_json) {  			json_object *json_cap = NULL; @@ -13949,46 +14195,19 @@ static void bgp_show_peer(struct vty *vty, struct peer *p, bool use_json,  			/* Route Refresh */  			if (CHECK_FLAG(p->cap, PEER_CAP_REFRESH_ADV) || -			    CHECK_FLAG(p->cap, PEER_CAP_REFRESH_NEW_RCV) || -			    CHECK_FLAG(p->cap, PEER_CAP_REFRESH_OLD_RCV)) { +			    CHECK_FLAG(p->cap, PEER_CAP_REFRESH_RCV)) {  				if (CHECK_FLAG(p->cap, PEER_CAP_REFRESH_ADV) && -				    (CHECK_FLAG(p->cap, -						PEER_CAP_REFRESH_NEW_RCV) || -				     CHECK_FLAG(p->cap, -						PEER_CAP_REFRESH_OLD_RCV))) { -					if (CHECK_FLAG( -						    p->cap, -						    PEER_CAP_REFRESH_OLD_RCV) && -					    CHECK_FLAG( -						    p->cap, -						    PEER_CAP_REFRESH_NEW_RCV)) -						json_object_string_add( -							json_cap, -							"routeRefresh", -							"advertisedAndReceivedOldNew"); -					else { -						if (CHECK_FLAG( -							    p->cap, -							    PEER_CAP_REFRESH_OLD_RCV)) -							json_object_string_add( -								json_cap, -								"routeRefresh", -								"advertisedAndReceivedOld"); -						else -							json_object_string_add( -								json_cap, -								"routeRefresh", -								"advertisedAndReceivedNew"); -					} -				} else if (CHECK_FLAG(p->cap, -						      PEER_CAP_REFRESH_ADV)) +				    CHECK_FLAG(p->cap, PEER_CAP_REFRESH_RCV)) +					json_object_string_add(json_cap, +							       "routeRefresh", +							       "advertisedAndReceived"); +				else if (CHECK_FLAG(p->cap, +						    PEER_CAP_REFRESH_ADV))  					json_object_string_add(json_cap,  							       "routeRefresh",  							       "advertised");  				else if (CHECK_FLAG(p->cap, -						    PEER_CAP_REFRESH_NEW_RCV) || -					 CHECK_FLAG(p->cap, -						    PEER_CAP_REFRESH_OLD_RCV)) +						    PEER_CAP_REFRESH_RCV))  					json_object_string_add(json_cap,  							       "routeRefresh",  							       "received"); @@ -14390,33 +14609,16 @@ static void bgp_show_peer(struct vty *vty, struct peer *p, bool use_json,  			/* Route Refresh */  			if (CHECK_FLAG(p->cap, PEER_CAP_REFRESH_ADV) || -			    CHECK_FLAG(p->cap, PEER_CAP_REFRESH_NEW_RCV) || -			    CHECK_FLAG(p->cap, PEER_CAP_REFRESH_OLD_RCV)) { +			    CHECK_FLAG(p->cap, PEER_CAP_REFRESH_RCV)) {  				vty_out(vty, "    Route refresh:");  				if (CHECK_FLAG(p->cap, PEER_CAP_REFRESH_ADV))  					vty_out(vty, " advertised"); -				if (CHECK_FLAG(p->cap, -					       PEER_CAP_REFRESH_NEW_RCV) || -				    CHECK_FLAG(p->cap, -					       PEER_CAP_REFRESH_OLD_RCV)) -					vty_out(vty, " %sreceived(%s)", +				if (CHECK_FLAG(p->cap, PEER_CAP_REFRESH_RCV)) +					vty_out(vty, " %sreceived",  						CHECK_FLAG(p->cap,  							   PEER_CAP_REFRESH_ADV)  							? "and " -							: "", -						(CHECK_FLAG( -							 p->cap, -							 PEER_CAP_REFRESH_OLD_RCV) && -						 CHECK_FLAG( -							 p->cap, -							 PEER_CAP_REFRESH_NEW_RCV)) -							? "old & new" -							: CHECK_FLAG( -								  p->cap, -								  PEER_CAP_REFRESH_OLD_RCV) -								  ? "old" -								  : "new"); - +							: "");  				vty_out(vty, "\n");  			} @@ -14566,7 +14768,7 @@ static void bgp_show_peer(struct vty *vty, struct peer *p, bool use_json,  		json_grace_send = json_object_new_object();  		json_grace_recv = json_object_new_object(); -		if ((peer_established(p)) && +		if ((peer_established(p->connection)) &&  		    CHECK_FLAG(p->cap, PEER_CAP_RESTART_RCV)) {  			FOREACH_AFI_SAFI (afi, safi) {  				if (CHECK_FLAG(p->af_sflags[afi][safi], @@ -14595,26 +14797,27 @@ static void bgp_show_peer(struct vty *vty, struct peer *p, bool use_json,  				       json_grace_recv); -		if (p->t_gr_restart) -			json_object_int_add( -				json_grace, "gracefulRestartTimerMsecs", -				event_timer_remain_second(p->t_gr_restart) * -					1000); +		if (p->connection->t_gr_restart) +			json_object_int_add(json_grace, +					    "gracefulRestartTimerMsecs", +					    event_timer_remain_second( +						    p->connection->t_gr_restart) * +						    1000); -		if (p->t_gr_stale) -			json_object_int_add( -				json_grace, "gracefulStalepathTimerMsecs", -				event_timer_remain_second(p->t_gr_stale) * -					1000); +		if (p->connection->t_gr_stale) +			json_object_int_add(json_grace, +					    "gracefulStalepathTimerMsecs", +					    event_timer_remain_second( +						    p->connection->t_gr_stale) * +						    1000);  		/* more gr info in new format */  		BGP_SHOW_PEER_GR_CAPABILITY(vty, p, json_grace);  		json_object_object_add(json_neigh, "gracefulRestartInfo",  				       json_grace);  	} else {  		vty_out(vty, "  Graceful restart information:\n"); -		if ((peer_established(p)) && +		if ((peer_established(p->connection)) &&  		    CHECK_FLAG(p->cap, PEER_CAP_RESTART_RCV)) { -  			vty_out(vty, "    End-of-RIB send: ");  			FOREACH_AFI_SAFI (afi, safi) {  				if (CHECK_FLAG(p->af_sflags[afi][safi], @@ -14642,15 +14845,17 @@ static void bgp_show_peer(struct vty *vty, struct peer *p, bool use_json,  			vty_out(vty, "\n");  		} -		if (p->t_gr_restart) +		if (p->connection->t_gr_restart)  			vty_out(vty,  				"    The remaining time of restart timer is %ld\n", -				event_timer_remain_second(p->t_gr_restart)); +				event_timer_remain_second( +					p->connection->t_gr_restart)); -		if (p->t_gr_stale) +		if (p->connection->t_gr_stale)  			vty_out(vty,  				"    The remaining time of stalepath timer is %ld\n", -				event_timer_remain_second(p->t_gr_stale)); +				event_timer_remain_second( +					p->connection->t_gr_stale));  		/* more gr info in new format */  		BGP_SHOW_PEER_GR_CAPABILITY(vty, p, NULL); @@ -14662,9 +14867,9 @@ static void bgp_show_peer(struct vty *vty, struct peer *p, bool use_json,  		/* Packet counts. */  		atomic_size_t outq_count, inq_count; -		outq_count = atomic_load_explicit(&p->obuf->count, +		outq_count = atomic_load_explicit(&p->connection->obuf->count,  						  memory_order_relaxed); -		inq_count = atomic_load_explicit(&p->ibuf->count, +		inq_count = atomic_load_explicit(&p->connection->ibuf->count,  						 memory_order_relaxed);  		json_object_int_add(json_stat, "depthInq", @@ -14715,9 +14920,9 @@ static void bgp_show_peer(struct vty *vty, struct peer *p, bool use_json,  			notify_out, notify_in, update_out, update_in,  			keepalive_out, keepalive_in, refresh_out, refresh_in,  			dynamic_cap_out, dynamic_cap_in; -		outq_count = atomic_load_explicit(&p->obuf->count, +		outq_count = atomic_load_explicit(&p->connection->obuf->count,  						  memory_order_relaxed); -		inq_count = atomic_load_explicit(&p->ibuf->count, +		inq_count = atomic_load_explicit(&p->connection->ibuf->count,  						 memory_order_relaxed);  		open_out = atomic_load_explicit(&p->open_out,  						memory_order_relaxed); @@ -14849,15 +15054,15 @@ static void bgp_show_peer(struct vty *vty, struct peer *p, bool use_json,  					    BGP_UPTIME_LEN, 0, NULL));  			bgp_show_peer_reset(vty, p, NULL, false); -			if (p->last_reset_cause_size) { -				msg = p->last_reset_cause; +			if (p->last_reset_cause) { +				msg = p->last_reset_cause->data;  				vty_out(vty,  					"  Message received that caused BGP to send a NOTIFICATION:\n    "); -				for (i = 1; i <= p->last_reset_cause_size; +				for (i = 1; i <= p->last_reset_cause->size;  				     i++) {  					vty_out(vty, "%02X", *msg++); -					if (i != p->last_reset_cause_size) { +					if (i != p->last_reset_cause->size) {  						if (i % 16 == 0) {  							vty_out(vty, "\n    ");  						} else if (i % 4 == 0) { @@ -14878,21 +15083,22 @@ static void bgp_show_peer(struct vty *vty, struct peer *p, bool use_json,  			vty_out(vty,  				"  Peer had exceeded the max. no. of prefixes configured.\n"); -		if (p->t_pmax_restart) { +		if (p->connection->t_pmax_restart) {  			if (use_json) {  				json_object_boolean_true_add(  					json_neigh, "reducePrefixNumFrom");  				json_object_int_add(json_neigh,  						    "restartInTimerMsec",  						    event_timer_remain_second( -							    p->t_pmax_restart) * +							    p->connection +								    ->t_pmax_restart) *  							    1000);  			} else  				vty_out(vty,  					"  Reduce the no. of prefix from %s, will restart in %ld seconds\n",  					p->host,  					event_timer_remain_second( -						p->t_pmax_restart)); +						p->connection->t_pmax_restart));  		} else {  			if (use_json)  				json_object_boolean_true_add( @@ -15029,7 +15235,7 @@ static void bgp_show_peer(struct vty *vty, struct peer *p, bool use_json,  	if (use_json) {  		json_object_int_add(json_neigh, "connectRetryTimer",  				    p->v_connect); -		if (peer_established(p)) { +		if (peer_established(p->connection)) {  			json_object_int_add(json_neigh, "estimatedRttInMsecs",  					    p->rtt);  			if (CHECK_FLAG(p->flags, PEER_FLAG_RTT_SHUTDOWN)) { @@ -15041,32 +15247,37 @@ static void bgp_show_peer(struct vty *vty, struct peer *p, bool use_json,  						    p->rtt_keepalive_rcv);  			}  		} -		if (p->t_start) -			json_object_int_add( -				json_neigh, "nextStartTimerDueInMsecs", -				event_timer_remain_second(p->t_start) * 1000); -		if (p->t_connect) -			json_object_int_add( -				json_neigh, "nextConnectTimerDueInMsecs", -				event_timer_remain_second(p->t_connect) * 1000); -		if (p->t_routeadv) { +		if (p->connection->t_start) +			json_object_int_add(json_neigh, +					    "nextStartTimerDueInMsecs", +					    event_timer_remain_second( +						    p->connection->t_start) * +						    1000); +		if (p->connection->t_connect) +			json_object_int_add(json_neigh, +					    "nextConnectTimerDueInMsecs", +					    event_timer_remain_second( +						    p->connection->t_connect) * +						    1000); +		if (p->connection->t_routeadv) {  			json_object_int_add(json_neigh, "mraiInterval",  					    p->v_routeadv); -			json_object_int_add( -				json_neigh, "mraiTimerExpireInMsecs", -				event_timer_remain_second(p->t_routeadv) * -					1000); +			json_object_int_add(json_neigh, "mraiTimerExpireInMsecs", +					    event_timer_remain_second( +						    p->connection->t_routeadv) * +						    1000);  		}  		if (p->password)  			json_object_int_add(json_neigh, "authenticationEnabled",  					    1); -		if (p->t_read) +		if (p->connection->t_read)  			json_object_string_add(json_neigh, "readThread", "on");  		else  			json_object_string_add(json_neigh, "readThread", "off"); -		if (CHECK_FLAG(p->thread_flags, PEER_THREAD_WRITES_ON)) +		if (CHECK_FLAG(p->connection->thread_flags, +			       PEER_THREAD_WRITES_ON))  			json_object_string_add(json_neigh, "writeThread", "on");  		else  			json_object_string_add(json_neigh, "writeThread", @@ -15074,7 +15285,7 @@ static void bgp_show_peer(struct vty *vty, struct peer *p, bool use_json,  	} else {  		vty_out(vty, "BGP Connect Retry Timer in Seconds: %d\n",  			p->v_connect); -		if (peer_established(p)) { +		if (peer_established(p->connection)) {  			vty_out(vty, "Estimated round trip time: %d ms\n",  				p->rtt);  			if (CHECK_FLAG(p->flags, PEER_FLAG_RTT_SHUTDOWN)) @@ -15082,25 +15293,30 @@ static void bgp_show_peer(struct vty *vty, struct peer *p, bool use_json,  					"Shutdown when RTT > %dms, count > %u\n",  					p->rtt_expected, p->rtt_keepalive_rcv);  		} -		if (p->t_start) +		if (p->connection->t_start)  			vty_out(vty, "Next start timer due in %ld seconds\n", -				event_timer_remain_second(p->t_start)); -		if (p->t_connect) +				event_timer_remain_second( +					p->connection->t_start)); +		if (p->connection->t_connect)  			vty_out(vty, "Next connect timer due in %ld seconds\n", -				event_timer_remain_second(p->t_connect)); -		if (p->t_routeadv) +				event_timer_remain_second( +					p->connection->t_connect)); +		if (p->connection->t_routeadv)  			vty_out(vty,  				"MRAI (interval %u) timer expires in %ld seconds\n",  				p->v_routeadv, -				event_timer_remain_second(p->t_routeadv)); +				event_timer_remain_second( +					p->connection->t_routeadv));  		if (p->password)  			vty_out(vty, "Peer Authentication Enabled\n");  		vty_out(vty, "Read thread: %s  Write thread: %s  FD used: %d\n", -			p->t_read ? "on" : "off", -			CHECK_FLAG(p->thread_flags, PEER_THREAD_WRITES_ON) +			p->connection->t_read ? "on" : "off", +			CHECK_FLAG(p->connection->thread_flags, +				   PEER_THREAD_WRITES_ON)  				? "on" -				: "off", p->fd); +				: "off", +			p->connection->fd);  	}  	if (p->notify.code == BGP_NOTIFY_OPEN_ERR @@ -15163,7 +15379,7 @@ static int bgp_show_neighbor_graceful_restart(struct vty *vty, struct bgp *bgp,  								json_neighbor);  				}  			} else { -				if (sockunion_same(&peer->su, su)) { +				if (sockunion_same(&peer->connection->su, su)) {  					found = true;  					bgp_show_peer_gr_status(vty, peer,  								json_neighbor); @@ -15233,7 +15449,7 @@ static int bgp_show_neighbor(struct vty *vty, struct bgp *bgp,  						      json);  				}  			} else { -				if (sockunion_same(&peer->su, su)) { +				if (sockunion_same(&peer->connection->su, su)) {  					find = 1;  					bgp_show_peer(vty, peer, use_json,  						      json); @@ -15255,7 +15471,9 @@ static int bgp_show_neighbor(struct vty *vty, struct bgp *bgp,  							break;  						}  					} else { -						if (sockunion_same(&peer->su, su)) { +						if (sockunion_same(&peer->connection +									    ->su, +								   su)) {  							find = 1;  							bgp_show_peer(vty, peer, use_json,  								      json); @@ -16364,8 +16582,10 @@ static int bgp_show_one_peer_group(struct vty *vty, struct peer_group *group,  					    PEER_STATUS_PREFIX_OVERFLOW))  				peer_status = "Idle (PfxCt)";  			else -				peer_status = lookup_msg(bgp_status_msg, -							 peer->status, NULL); +				peer_status = +					lookup_msg(bgp_status_msg, +						   peer->connection->status, +						   NULL);  			dynamic = peer_dynamic_neighbor(peer); @@ -16671,8 +16891,15 @@ DEFUN (bgp_redistribute_ipv4_ospf,  	if (strncmp(argv[idx_ospf_table]->arg, "o", 1) == 0)  		protocol = ZEBRA_ROUTE_OSPF; -	else +	else { +		if (bgp->vrf_id != VRF_DEFAULT) { +			vty_out(vty, +				"%% Only default BGP instance can use '%s'\n", +				argv[idx_ospf_table]->arg); +			return CMD_WARNING_CONFIG_FAILED; +		}  		protocol = ZEBRA_ROUTE_TABLE; +	}  	bgp_redist_add(bgp, AFI_IP, protocol, instance);  	return bgp_redistribute_set(bgp, AFI_IP, protocol, instance, false); @@ -16708,8 +16935,15 @@ DEFUN (bgp_redistribute_ipv4_ospf_rmap,  	if (strncmp(argv[idx_ospf_table]->arg, "o", 1) == 0)  		protocol = ZEBRA_ROUTE_OSPF; -	else +	else { +		if (bgp->vrf_id != VRF_DEFAULT) { +			vty_out(vty, +				"%% Only default BGP instance can use '%s'\n", +				argv[idx_ospf_table]->arg); +			return CMD_WARNING_CONFIG_FAILED; +		}  		protocol = ZEBRA_ROUTE_TABLE; +	}  	instance = strtoul(argv[idx_number]->arg, NULL, 10);  	red = bgp_redist_add(bgp, AFI_IP, protocol, instance); @@ -16750,8 +16984,15 @@ DEFUN (bgp_redistribute_ipv4_ospf_metric,  	if (strncmp(argv[idx_ospf_table]->arg, "o", 1) == 0)  		protocol = ZEBRA_ROUTE_OSPF; -	else +	else { +		if (bgp->vrf_id != VRF_DEFAULT) { +			vty_out(vty, +				"%% Only default BGP instance can use '%s'\n", +				argv[idx_ospf_table]->arg); +			return CMD_WARNING_CONFIG_FAILED; +		}  		protocol = ZEBRA_ROUTE_TABLE; +	}  	instance = strtoul(argv[idx_number]->arg, NULL, 10);  	metric = strtoul(argv[idx_number_2]->arg, NULL, 10); @@ -16799,8 +17040,15 @@ DEFUN (bgp_redistribute_ipv4_ospf_rmap_metric,  	if (strncmp(argv[idx_ospf_table]->arg, "o", 1) == 0)  		protocol = ZEBRA_ROUTE_OSPF; -	else +	else { +		if (bgp->vrf_id != VRF_DEFAULT) { +			vty_out(vty, +				"%% Only default BGP instance can use '%s'\n", +				argv[idx_ospf_table]->arg); +			return CMD_WARNING_CONFIG_FAILED; +		}  		protocol = ZEBRA_ROUTE_TABLE; +	}  	instance = strtoul(argv[idx_number]->arg, NULL, 10);  	metric = strtoul(argv[idx_number_2]->arg, NULL, 10); @@ -16853,8 +17101,15 @@ DEFUN (bgp_redistribute_ipv4_ospf_metric_rmap,  	if (strncmp(argv[idx_ospf_table]->arg, "o", 1) == 0)  		protocol = ZEBRA_ROUTE_OSPF; -	else +	else { +		if (bgp->vrf_id != VRF_DEFAULT) { +			vty_out(vty, +				"%% Only default BGP instance can use '%s'\n", +				argv[idx_ospf_table]->arg); +			return CMD_WARNING_CONFIG_FAILED; +		}  		protocol = ZEBRA_ROUTE_TABLE; +	}  	instance = strtoul(argv[idx_number]->arg, NULL, 10);  	metric = strtoul(argv[idx_number_2]->arg, NULL, 10); @@ -16901,11 +17156,19 @@ DEFUN (no_bgp_redistribute_ipv4_ospf,  	if (strncmp(argv[idx_ospf_table]->arg, "o", 1) == 0)  		protocol = ZEBRA_ROUTE_OSPF; -	else +	else { +		if (bgp->vrf_id != VRF_DEFAULT) { +			vty_out(vty, +				"%% Only default BGP instance can use '%s'\n", +				argv[idx_ospf_table]->arg); +			return CMD_WARNING_CONFIG_FAILED; +		}  		protocol = ZEBRA_ROUTE_TABLE; +	}  	instance = strtoul(argv[idx_number]->arg, NULL, 10); -	return bgp_redistribute_unset(bgp, AFI_IP, protocol, instance); +	bgp_redistribute_unset(bgp, AFI_IP, protocol, instance); +	return CMD_SUCCESS;  }  ALIAS_HIDDEN( @@ -16941,7 +17204,8 @@ DEFUN (no_bgp_redistribute_ipv4,  		vty_out(vty, "%% Invalid route type\n");  		return CMD_WARNING_CONFIG_FAILED;  	} -	return bgp_redistribute_unset(bgp, AFI_IP, type, 0); +	bgp_redistribute_unset(bgp, AFI_IP, type, 0); +	return CMD_SUCCESS;  }  ALIAS_HIDDEN( @@ -17125,7 +17389,8 @@ DEFUN (no_bgp_redistribute_ipv6,  		return CMD_WARNING_CONFIG_FAILED;  	} -	return bgp_redistribute_unset(bgp, AFI_IP6, type, 0); +	bgp_redistribute_unset(bgp, AFI_IP6, type, 0); +	return CMD_SUCCESS;  }  /* Neighbor update tcp-mss. */ @@ -17680,8 +17945,12 @@ static void bgp_config_write_peer_global(struct vty *vty, struct bgp *bgp,  	    && !(peer->gtsm_hops != BGP_GTSM_HOPS_DISABLED  		 && peer->ttl == MAXTTL)) {  		if (!peer_group_active(peer) || g_peer->ttl != peer->ttl) { -			vty_out(vty, " neighbor %s ebgp-multihop %d\n", addr, -				peer->ttl); +			if (peer->ttl != MAXTTL) +				vty_out(vty, " neighbor %s ebgp-multihop %d\n", +					addr, peer->ttl); +			else +				vty_out(vty, " neighbor %s ebgp-multihop\n", +					addr);  		}  	} @@ -17915,6 +18184,13 @@ static void bgp_config_write_peer_af(struct vty *vty, struct bgp *bgp,  				"  neighbor %s addpath-tx-bestpath-per-AS\n",  				addr);  			break; +		case BGP_ADDPATH_BEST_SELECTED: +			if (peer->addpath_best_selected[afi][safi]) +				vty_out(vty, +					"  neighbor %s addpath-tx-best-selected %u\n", +					addr, +					peer->addpath_best_selected[afi][safi]); +			break;  		case BGP_ADDPATH_MAX:  		case BGP_ADDPATH_NONE:  			break; @@ -18182,6 +18458,11 @@ static void bgp_config_write_family(struct vty *vty, struct bgp *bgp, afi_t afi,  	} else if (afi == AFI_L2VPN) {  		if (safi == SAFI_EVPN)  			vty_frame(vty, "l2vpn evpn"); +	} else if (afi == AFI_LINKSTATE) { +		if (safi == SAFI_LINKSTATE) +			vty_frame(vty, "link-state link-state"); +		else if (safi == SAFI_LINKSTATE_VPN) +			vty_frame(vty, "link-state link-state-vpn");  	}  	vty_frame(vty, "\n"); @@ -18413,6 +18694,15 @@ int bgp_config_write(struct vty *vty)  					? ""  					: "no "); +		if (!!CHECK_FLAG(bgp->flags, BGP_FLAG_SOFT_VERSION_CAPABILITY) != +		    SAVE_BGP_SOFT_VERSION_CAPABILITY) +			vty_out(vty, +				" %sbgp default software-version-capability\n", +				CHECK_FLAG(bgp->flags, +					   BGP_FLAG_SOFT_VERSION_CAPABILITY) +					? "" +					: "no "); +  		/* BGP default subgroup-pkt-queue-max. */  		if (bgp->default_subgroup_pkt_queue_max  		    != BGP_DEFAULT_SUBGROUP_PKT_QUEUE_MAX) @@ -18620,6 +18910,12 @@ int bgp_config_write(struct vty *vty)  				" bgp conditional-advertisement timer %u\n",  				bgp->condition_check_period); +		/* default-originate timer configuration */ +		if (bgp->rmap_def_originate_eval_timer != +		    RMAP_DEFAULT_ORIGINATE_EVAL_TIMER) +			vty_out(vty, " bgp default-originate timer %u\n", +				bgp->rmap_def_originate_eval_timer); +  		/* peer-group */  		for (ALL_LIST_ELEMENTS(bgp->group, node, nnode, group)) {  			bgp_config_write_peer_global(vty, bgp, group->conf); @@ -18710,6 +19006,11 @@ int bgp_config_write(struct vty *vty)  		/* EVPN configuration.  */  		bgp_config_write_family(vty, bgp, AFI_L2VPN, SAFI_EVPN); +		bgp_config_write_family(vty, bgp, AFI_LINKSTATE, +					SAFI_LINKSTATE); +		bgp_config_write_family(vty, bgp, AFI_LINKSTATE, +					SAFI_LINKSTATE_VPN); +  		hook_call(bgp_inst_config_write, bgp, vty);  #ifdef ENABLE_BGP_VNC @@ -18834,6 +19135,13 @@ static struct cmd_node bgp_srv6_node = {  	.prompt = "%s(config-router-srv6)# ",  }; +static struct cmd_node bgp_ls_node = { +	.name = "bgp link-state", +	.node = BGP_LS_NODE, +	.parent_node = BGP_NODE, +	.prompt = "%s(config-router-af-ls)# ", +}; +  static void community_list_vty(void);  static void bgp_ac_peergroup(vector comps, struct cmd_token *token) @@ -18906,6 +19214,9 @@ bool bgp_config_inprocess(void)  	return event_is_scheduled(t_bgp_cfg);  } +/* Max wait time for config to load before post-config processing */ +#define BGP_PRE_CONFIG_MAX_WAIT_SECONDS 600 +  static void bgp_config_finish(struct event *t)  {  	struct listnode *node; @@ -18915,11 +19226,17 @@ static void bgp_config_finish(struct event *t)  		hook_call(bgp_config_end, bgp);  } +static void bgp_config_end_timeout(struct event *t) +{ +	zlog_err("BGP configuration end timer expired after %d seconds.", +		 BGP_PRE_CONFIG_MAX_WAIT_SECONDS); +	bgp_config_finish(t); +} +  static void bgp_config_start(void)  { -#define BGP_PRE_CONFIG_MAX_WAIT_SECONDS 600  	EVENT_OFF(t_bgp_cfg); -	event_add_timer(bm->master, bgp_config_finish, NULL, +	event_add_timer(bm->master, bgp_config_end_timeout, NULL,  			BGP_PRE_CONFIG_MAX_WAIT_SECONDS, &t_bgp_cfg);  } @@ -18969,6 +19286,12 @@ static int config_write_interface_one(struct vty *vty, struct vrf *vrf)  			vty_out(vty, " mpls bgp forwarding\n");  			write++;  		} +		if (CHECK_FLAG(iifp->flags, +			       BGP_INTERFACE_MPLS_L3VPN_SWITCHING)) { +			vty_out(vty, +				" mpls bgp l3vpn-multi-domain-switching\n"); +			write++; +		}  		if_vty_config_end(vty);  	} @@ -19019,6 +19342,35 @@ DEFPY(mpls_bgp_forwarding, mpls_bgp_forwarding_cmd,  	return CMD_SUCCESS;  } +DEFPY(mpls_bgp_l3vpn_multi_domain_switching, +      mpls_bgp_l3vpn_multi_domain_switching_cmd, +      "[no$no] mpls bgp l3vpn-multi-domain-switching", +      NO_STR MPLS_STR BGP_STR +      "Bind a local MPLS label to incoming L3VPN updates\n") +{ +	bool check; +	struct bgp_interface *iifp; + +	VTY_DECLVAR_CONTEXT(interface, ifp); +	iifp = ifp->info; +	if (!iifp) { +		vty_out(vty, "Interface %s not available\n", ifp->name); +		return CMD_WARNING_CONFIG_FAILED; +	} +	check = CHECK_FLAG(iifp->flags, BGP_INTERFACE_MPLS_L3VPN_SWITCHING); +	if (check == !no) +		return CMD_SUCCESS; +	if (no) +		UNSET_FLAG(iifp->flags, BGP_INTERFACE_MPLS_L3VPN_SWITCHING); +	else +		SET_FLAG(iifp->flags, BGP_INTERFACE_MPLS_L3VPN_SWITCHING); +	/* trigger a nht update on eBGP sessions */ +	if (if_is_operative(ifp)) +		bgp_nht_ifp_up(ifp); + +	return CMD_SUCCESS; +} +  DEFPY (bgp_inq_limit,         bgp_inq_limit_cmd,         "bgp input-queue-limit (1-4294967295)$limit", @@ -19078,6 +19430,8 @@ static void bgp_vty_if_init(void)  	/* "mpls bgp forwarding" commands. */  	install_element(INTERFACE_NODE, &mpls_bgp_forwarding_cmd); +	install_element(INTERFACE_NODE, +			&mpls_bgp_l3vpn_multi_domain_switching_cmd);  }  void bgp_vty_init(void) @@ -19102,6 +19456,7 @@ void bgp_vty_init(void)  	install_node(&bgp_flowspecv4_node);  	install_node(&bgp_flowspecv6_node);  	install_node(&bgp_srv6_node); +	install_node(&bgp_ls_node);  	/* Install default VTY commands to new nodes.  */  	install_default(BGP_NODE); @@ -19118,6 +19473,7 @@ void bgp_vty_init(void)  	install_default(BGP_EVPN_NODE);  	install_default(BGP_EVPN_VNI_NODE);  	install_default(BGP_SRV6_NODE); +	install_default(BGP_LS_NODE);  	/* "global bgp inq-limit command */  	install_element(CONFIG_NODE, &bgp_inq_limit_cmd); @@ -19249,6 +19605,13 @@ void bgp_vty_init(void)  	install_element(BGP_IPV6L_NODE, &bgp_maxpaths_ibgp_cluster_cmd);  	install_element(BGP_IPV6L_NODE, &no_bgp_maxpaths_ibgp_cmd); +	install_element(BGP_LS_NODE, &bgp_maxpaths_cmd); +	install_element(BGP_LS_NODE, &no_bgp_maxpaths_cmd); +	install_element(BGP_LS_NODE, &bgp_maxpaths_ibgp_cmd); +	install_element(BGP_LS_NODE, &no_bgp_maxpaths_ibgp_cmd); +	install_element(BGP_LS_NODE, &bgp_maxpaths_ibgp_cluster_cmd); + +  	/* "timers bgp" commands. */  	install_element(BGP_NODE, &bgp_timers_cmd);  	install_element(BGP_NODE, &no_bgp_timers_cmd); @@ -19400,6 +19763,9 @@ void bgp_vty_init(void)  	install_element(BGP_NODE, &bgp_default_show_nexthop_hostname_cmd);  	install_element(BGP_NODE, &no_bgp_default_show_nexthop_hostname_cmd); +	/* bgp default software-version-capability */ +	install_element(BGP_NODE, &bgp_default_software_version_capability_cmd); +  	/* "bgp default subgroup-pkt-queue-max" commands. */  	install_element(BGP_NODE, &bgp_default_subgroup_pkt_queue_max_cmd);  	install_element(BGP_NODE, &no_bgp_default_subgroup_pkt_queue_max_cmd); @@ -19468,6 +19834,7 @@ void bgp_vty_init(void)  	install_element(BGP_FLOWSPECV4_NODE, &neighbor_activate_cmd);  	install_element(BGP_FLOWSPECV6_NODE, &neighbor_activate_cmd);  	install_element(BGP_EVPN_NODE, &neighbor_activate_cmd); +	install_element(BGP_LS_NODE, &neighbor_activate_cmd);  	/* "no neighbor activate" commands. */  	install_element(BGP_NODE, &no_neighbor_activate_hidden_cmd); @@ -19482,6 +19849,7 @@ void bgp_vty_init(void)  	install_element(BGP_FLOWSPECV4_NODE, &no_neighbor_activate_cmd);  	install_element(BGP_FLOWSPECV6_NODE, &no_neighbor_activate_cmd);  	install_element(BGP_EVPN_NODE, &no_neighbor_activate_cmd); +	install_element(BGP_LS_NODE, &no_neighbor_activate_cmd);  	/* "neighbor peer-group" set commands. */  	install_element(BGP_NODE, &neighbor_set_peer_group_cmd); @@ -19496,6 +19864,8 @@ void bgp_vty_init(void)  			&neighbor_set_peer_group_hidden_cmd);  	install_element(BGP_FLOWSPECV6_NODE,  			&neighbor_set_peer_group_hidden_cmd); +	install_element(BGP_LS_NODE, &neighbor_set_peer_group_hidden_cmd); +  	/* "no neighbor peer-group unset" commands. */  	install_element(BGP_NODE, &no_neighbor_set_peer_group_cmd); @@ -19510,6 +19880,7 @@ void bgp_vty_init(void)  			&no_neighbor_set_peer_group_hidden_cmd);  	install_element(BGP_FLOWSPECV6_NODE,  			&no_neighbor_set_peer_group_hidden_cmd); +	install_element(BGP_LS_NODE, &no_neighbor_set_peer_group_hidden_cmd);  	/* "neighbor softreconfiguration inbound" commands.*/  	install_element(BGP_NODE, &neighbor_soft_reconfiguration_hidden_cmd); @@ -19540,6 +19911,8 @@ void bgp_vty_init(void)  			&no_neighbor_soft_reconfiguration_cmd);  	install_element(BGP_EVPN_NODE, &neighbor_soft_reconfiguration_cmd);  	install_element(BGP_EVPN_NODE, &no_neighbor_soft_reconfiguration_cmd); +	install_element(BGP_LS_NODE, &neighbor_soft_reconfiguration_cmd); +	install_element(BGP_LS_NODE, &no_neighbor_soft_reconfiguration_cmd);  	/* "neighbor attribute-unchanged" commands.  */  	install_element(BGP_NODE, &neighbor_attr_unchanged_hidden_cmd); @@ -19560,9 +19933,10 @@ void bgp_vty_init(void)  	install_element(BGP_VPNV4_NODE, &no_neighbor_attr_unchanged_cmd);  	install_element(BGP_VPNV6_NODE, &neighbor_attr_unchanged_cmd);  	install_element(BGP_VPNV6_NODE, &no_neighbor_attr_unchanged_cmd); -  	install_element(BGP_EVPN_NODE, &neighbor_attr_unchanged_cmd);  	install_element(BGP_EVPN_NODE, &no_neighbor_attr_unchanged_cmd); +	install_element(BGP_LS_NODE, &neighbor_attr_unchanged_cmd); +	install_element(BGP_LS_NODE, &no_neighbor_attr_unchanged_cmd);  	install_element(BGP_FLOWSPECV4_NODE, &neighbor_attr_unchanged_cmd);  	install_element(BGP_FLOWSPECV4_NODE, &no_neighbor_attr_unchanged_cmd); @@ -19595,6 +19969,8 @@ void bgp_vty_init(void)  	install_element(BGP_VPNV6_NODE, &no_neighbor_nexthop_self_cmd);  	install_element(BGP_EVPN_NODE, &neighbor_nexthop_self_cmd);  	install_element(BGP_EVPN_NODE, &no_neighbor_nexthop_self_cmd); +	install_element(BGP_LS_NODE, &neighbor_nexthop_self_cmd); +	install_element(BGP_LS_NODE, &no_neighbor_nexthop_self_cmd);  	/* "neighbor next-hop-self force" commands. */  	install_element(BGP_NODE, &neighbor_nexthop_self_force_hidden_cmd); @@ -19643,6 +20019,8 @@ void bgp_vty_init(void)  			&no_neighbor_nexthop_self_all_hidden_cmd);  	install_element(BGP_EVPN_NODE, &neighbor_nexthop_self_force_cmd);  	install_element(BGP_EVPN_NODE, &no_neighbor_nexthop_self_force_cmd); +	install_element(BGP_LS_NODE, &neighbor_nexthop_self_force_cmd); +	install_element(BGP_LS_NODE, &no_neighbor_nexthop_self_force_cmd);  	/* "neighbor as-override" commands. */  	install_element(BGP_NODE, &neighbor_as_override_hidden_cmd); @@ -19775,6 +20153,18 @@ void bgp_vty_init(void)  			&neighbor_remove_private_as_all_replace_as_cmd);  	install_element(BGP_VPNV6_NODE,  			&no_neighbor_remove_private_as_all_replace_as_cmd); +	install_element(BGP_LS_NODE, &neighbor_remove_private_as_cmd); +	install_element(BGP_LS_NODE, &no_neighbor_remove_private_as_cmd); +	install_element(BGP_LS_NODE, &neighbor_remove_private_as_all_cmd); +	install_element(BGP_LS_NODE, &no_neighbor_remove_private_as_all_cmd); +	install_element(BGP_LS_NODE, +			&neighbor_remove_private_as_replace_as_cmd); +	install_element(BGP_LS_NODE, +			&no_neighbor_remove_private_as_replace_as_cmd); +	install_element(BGP_LS_NODE, +			&neighbor_remove_private_as_all_replace_as_cmd); +	install_element(BGP_LS_NODE, +			&no_neighbor_remove_private_as_all_replace_as_cmd);  	/* "neighbor send-community" commands.*/  	install_element(BGP_NODE, &neighbor_send_community_hidden_cmd); @@ -19813,6 +20203,10 @@ void bgp_vty_init(void)  	install_element(BGP_VPNV6_NODE, &neighbor_send_community_type_cmd);  	install_element(BGP_VPNV6_NODE, &no_neighbor_send_community_cmd);  	install_element(BGP_VPNV6_NODE, &no_neighbor_send_community_type_cmd); +	install_element(BGP_LS_NODE, &neighbor_send_community_cmd); +	install_element(BGP_LS_NODE, &neighbor_send_community_type_cmd); +	install_element(BGP_LS_NODE, &no_neighbor_send_community_cmd); +	install_element(BGP_LS_NODE, &no_neighbor_send_community_type_cmd);  	/* "neighbor route-reflector" commands.*/  	install_element(BGP_NODE, &neighbor_route_reflector_client_hidden_cmd); @@ -19850,6 +20244,8 @@ void bgp_vty_init(void)  			&no_neighbor_route_reflector_client_cmd);  	install_element(BGP_EVPN_NODE, &neighbor_route_reflector_client_cmd);  	install_element(BGP_EVPN_NODE, &no_neighbor_route_reflector_client_cmd); +	install_element(BGP_LS_NODE, &neighbor_route_reflector_client_cmd); +	install_element(BGP_LS_NODE, &no_neighbor_route_reflector_client_cmd);  	/* "neighbor route-server" commands.*/  	install_element(BGP_NODE, &neighbor_route_server_client_hidden_cmd); @@ -19878,6 +20274,8 @@ void bgp_vty_init(void)  	install_element(BGP_FLOWSPECV6_NODE, &neighbor_route_server_client_cmd);  	install_element(BGP_FLOWSPECV6_NODE,  			&no_neighbor_route_server_client_cmd); +	install_element(BGP_LS_NODE, &neighbor_route_server_client_cmd); +	install_element(BGP_LS_NODE, &no_neighbor_route_server_client_cmd);  	/* "neighbor disable-addpath-rx" commands. */  	install_element(BGP_IPV4_NODE, &neighbor_disable_addpath_rx_cmd); @@ -19917,6 +20315,40 @@ void bgp_vty_init(void)  	install_element(BGP_VPNV6_NODE, &neighbor_addpath_tx_all_paths_cmd);  	install_element(BGP_VPNV6_NODE, &no_neighbor_addpath_tx_all_paths_cmd); +	/* "neighbor addpath-tx-best-selected" commands.*/ +	install_element(BGP_IPV4_NODE, +			&neighbor_addpath_tx_best_selected_paths_cmd); +	install_element(BGP_IPV4_NODE, +			&no_neighbor_addpath_tx_best_selected_paths_cmd); +	install_element(BGP_IPV4M_NODE, +			&neighbor_addpath_tx_best_selected_paths_cmd); +	install_element(BGP_IPV4M_NODE, +			&no_neighbor_addpath_tx_best_selected_paths_cmd); +	install_element(BGP_IPV4L_NODE, +			&neighbor_addpath_tx_best_selected_paths_cmd); +	install_element(BGP_IPV4L_NODE, +			&no_neighbor_addpath_tx_best_selected_paths_cmd); +	install_element(BGP_IPV6_NODE, +			&neighbor_addpath_tx_best_selected_paths_cmd); +	install_element(BGP_IPV6_NODE, +			&no_neighbor_addpath_tx_best_selected_paths_cmd); +	install_element(BGP_IPV6M_NODE, +			&neighbor_addpath_tx_best_selected_paths_cmd); +	install_element(BGP_IPV6M_NODE, +			&no_neighbor_addpath_tx_best_selected_paths_cmd); +	install_element(BGP_IPV6L_NODE, +			&neighbor_addpath_tx_best_selected_paths_cmd); +	install_element(BGP_IPV6L_NODE, +			&no_neighbor_addpath_tx_best_selected_paths_cmd); +	install_element(BGP_VPNV4_NODE, +			&neighbor_addpath_tx_best_selected_paths_cmd); +	install_element(BGP_VPNV4_NODE, +			&no_neighbor_addpath_tx_best_selected_paths_cmd); +	install_element(BGP_VPNV6_NODE, +			&neighbor_addpath_tx_best_selected_paths_cmd); +	install_element(BGP_VPNV6_NODE, +			&no_neighbor_addpath_tx_best_selected_paths_cmd); +  	/* "neighbor addpath-tx-bestpath-per-AS" commands.*/  	install_element(BGP_NODE,  			&neighbor_addpath_tx_bestpath_per_as_hidden_cmd); @@ -20005,6 +20437,8 @@ void bgp_vty_init(void)  	install_element(BGP_IPV6M_NODE, &no_neighbor_capability_orf_prefix_cmd);  	install_element(BGP_IPV6L_NODE, &neighbor_capability_orf_prefix_cmd);  	install_element(BGP_IPV6L_NODE, &no_neighbor_capability_orf_prefix_cmd); +	install_element(BGP_LS_NODE, &neighbor_capability_orf_prefix_cmd); +	install_element(BGP_LS_NODE, &no_neighbor_capability_orf_prefix_cmd);  	/* "neighbor capability dynamic" commands.*/  	install_element(BGP_NODE, &neighbor_capability_dynamic_cmd); @@ -20141,6 +20575,8 @@ void bgp_vty_init(void)  	install_element(BGP_VPNV4_NODE, &no_neighbor_distribute_list_cmd);  	install_element(BGP_VPNV6_NODE, &neighbor_distribute_list_cmd);  	install_element(BGP_VPNV6_NODE, &no_neighbor_distribute_list_cmd); +	install_element(BGP_LS_NODE, &neighbor_distribute_list_cmd); +	install_element(BGP_LS_NODE, &no_neighbor_distribute_list_cmd);  	/* "neighbor prefix-list" commands. */  	install_element(BGP_NODE, &neighbor_prefix_list_hidden_cmd); @@ -20165,6 +20601,7 @@ void bgp_vty_init(void)  	install_element(BGP_FLOWSPECV4_NODE, &no_neighbor_prefix_list_cmd);  	install_element(BGP_FLOWSPECV6_NODE, &neighbor_prefix_list_cmd);  	install_element(BGP_FLOWSPECV6_NODE, &no_neighbor_prefix_list_cmd); +	install_element(BGP_LS_NODE, &neighbor_prefix_list_cmd);  	/* "neighbor filter-list" commands. */  	install_element(BGP_NODE, &neighbor_filter_list_hidden_cmd); @@ -20189,6 +20626,8 @@ void bgp_vty_init(void)  	install_element(BGP_FLOWSPECV4_NODE, &no_neighbor_filter_list_cmd);  	install_element(BGP_FLOWSPECV6_NODE, &neighbor_filter_list_cmd);  	install_element(BGP_FLOWSPECV6_NODE, &no_neighbor_filter_list_cmd); +	install_element(BGP_LS_NODE, &neighbor_filter_list_cmd); +	install_element(BGP_LS_NODE, &no_neighbor_filter_list_cmd);  	/* "neighbor route-map" commands. */  	install_element(BGP_NODE, &neighbor_route_map_hidden_cmd); @@ -20215,6 +20654,7 @@ void bgp_vty_init(void)  	install_element(BGP_FLOWSPECV6_NODE, &no_neighbor_route_map_cmd);  	install_element(BGP_EVPN_NODE, &neighbor_route_map_cmd);  	install_element(BGP_EVPN_NODE, &no_neighbor_route_map_cmd); +	install_element(BGP_LS_NODE, &neighbor_route_map_cmd);  	/* "neighbor unsuppress-map" commands. */  	install_element(BGP_NODE, &neighbor_unsuppress_map_hidden_cmd); @@ -20235,6 +20675,8 @@ void bgp_vty_init(void)  	install_element(BGP_VPNV4_NODE, &no_neighbor_unsuppress_map_cmd);  	install_element(BGP_VPNV6_NODE, &neighbor_unsuppress_map_cmd);  	install_element(BGP_VPNV6_NODE, &no_neighbor_unsuppress_map_cmd); +	install_element(BGP_LS_NODE, &neighbor_unsuppress_map_cmd); +	install_element(BGP_LS_NODE, &no_neighbor_unsuppress_map_cmd);  	/* "neighbor advertise-map" commands. */  	install_element(BGP_NODE, &bgp_condadv_period_cmd); @@ -20248,6 +20690,9 @@ void bgp_vty_init(void)  	install_element(BGP_VPNV4_NODE, &neighbor_advertise_map_cmd);  	install_element(BGP_VPNV6_NODE, &neighbor_advertise_map_cmd); +	/* bgp default-originate timer */ +	install_element(BGP_NODE, &bgp_def_originate_eval_cmd); +  	/* neighbor maximum-prefix-out commands. */  	install_element(BGP_NODE, &neighbor_maximum_prefix_out_cmd);  	install_element(BGP_NODE, &no_neighbor_maximum_prefix_out_cmd); @@ -20351,6 +20796,15 @@ void bgp_vty_init(void)  	install_element(BGP_VPNV6_NODE,  			&neighbor_maximum_prefix_threshold_restart_cmd);  	install_element(BGP_VPNV6_NODE, &no_neighbor_maximum_prefix_cmd); +	install_element(BGP_LS_NODE, &neighbor_maximum_prefix_cmd); +	install_element(BGP_LS_NODE, &neighbor_maximum_prefix_threshold_cmd); +	install_element(BGP_LS_NODE, &neighbor_maximum_prefix_warning_cmd); +	install_element(BGP_LS_NODE, +			&neighbor_maximum_prefix_threshold_warning_cmd); +	install_element(BGP_LS_NODE, &neighbor_maximum_prefix_restart_cmd); +	install_element(BGP_LS_NODE, +			&neighbor_maximum_prefix_threshold_restart_cmd); +	install_element(BGP_LS_NODE, &no_neighbor_maximum_prefix_cmd);  	/* "neighbor allowas-in" */  	install_element(BGP_NODE, &neighbor_allowas_in_hidden_cmd); @@ -20373,6 +20827,8 @@ void bgp_vty_init(void)  	install_element(BGP_VPNV6_NODE, &no_neighbor_allowas_in_cmd);  	install_element(BGP_EVPN_NODE, &neighbor_allowas_in_cmd);  	install_element(BGP_EVPN_NODE, &no_neighbor_allowas_in_cmd); +	install_element(BGP_LS_NODE, &neighbor_allowas_in_cmd); +	install_element(BGP_LS_NODE, &no_neighbor_allowas_in_cmd);  	/* neighbor accept-own */  	install_element(BGP_VPNV4_NODE, &neighbor_accept_own_cmd); @@ -20408,6 +20864,8 @@ void bgp_vty_init(void)  	install_element(BGP_NODE, &address_family_evpn_cmd); +	install_element(BGP_NODE, &address_family_linkstate_cmd); +  	/* "exit-address-family" command. */  	install_element(BGP_IPV4_NODE, &exit_address_family_cmd);  	install_element(BGP_IPV4M_NODE, &exit_address_family_cmd); @@ -20420,6 +20878,7 @@ void bgp_vty_init(void)  	install_element(BGP_FLOWSPECV4_NODE, &exit_address_family_cmd);  	install_element(BGP_FLOWSPECV6_NODE, &exit_address_family_cmd);  	install_element(BGP_EVPN_NODE, &exit_address_family_cmd); +	install_element(BGP_LS_NODE, &exit_address_family_cmd);  	/* BGP retain all route-target */  	install_element(BGP_VPNV4_NODE, &bgp_retain_route_target_cmd); @@ -20663,6 +21122,7 @@ DEFUN (community_list_standard,  	argv_find(argv, argc, "AA:NN", &idx);  	char *str = argv_concat(argv, argc, idx); +	assert(str);  	int ret = community_list_set(bgp_clist, cl_name_or_number, str, seq,  				     direct, style); @@ -20775,6 +21235,7 @@ DEFUN (community_list_expanded_all,  	argv_find(argv, argc, "AA:NN", &idx);  	char *str = argv_concat(argv, argc, idx); +	assert(str);  	int ret = community_list_set(bgp_clist, cl_name_or_number, str, seq,  				     direct, style); @@ -20859,16 +21320,13 @@ 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, false); -		else if (entry->style == LARGE_COMMUNITY_LIST_STANDARD) -			str = lcommunity_str(entry->u.lcom, false, false); -		else -			str = entry->config; -	} +	if (entry->style == COMMUNITY_LIST_STANDARD) +		str = community_str(entry->u.com, false, false); +	else if (entry->style == LARGE_COMMUNITY_LIST_STANDARD) +		str = lcommunity_str(entry->u.lcom, false, false); +	else +		str = entry->config; +  	return str;  } @@ -20891,13 +21349,8 @@ static void community_list_show(struct vty *vty, struct community_list *list)  						: "expanded",  					list->name);  		} -		if (entry->any) -			vty_out(vty, "    %s\n", -				community_direct_str(entry->direct)); -		else -			vty_out(vty, "    %s %s\n", -				community_direct_str(entry->direct), -				community_list_config_str(entry)); +		vty_out(vty, "    %s %s\n", community_direct_str(entry->direct), +			community_list_config_str(entry));  	}  } @@ -21256,13 +21709,8 @@ static void lcommunity_list_show(struct vty *vty, struct community_list *list)  						: "expanded",  					list->name);  		} -		if (entry->any) -			vty_out(vty, "    %s\n", -				community_direct_str(entry->direct)); -		else -			vty_out(vty, "    %s %s\n", -				community_direct_str(entry->direct), -				community_list_config_str(entry)); +		vty_out(vty, "    %s %s\n", community_direct_str(entry->direct), +			community_list_config_str(entry));  	}  } @@ -21558,13 +22006,8 @@ static void extcommunity_list_show(struct vty *vty, struct community_list *list)  						: "expanded",  					list->name);  		} -		if (entry->any) -			vty_out(vty, "    %s\n", -				community_direct_str(entry->direct)); -		else -			vty_out(vty, "    %s %s\n", -				community_direct_str(entry->direct), -				community_list_config_str(entry)); +		vty_out(vty, "    %s %s\n", community_direct_str(entry->direct), +			community_list_config_str(entry));  	}  }  | 
