summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLouis Scalbert <louis.scalbert@6wind.com>2023-02-09 14:11:49 +0100
committerLouis Scalbert <louis.scalbert@6wind.com>2023-09-18 14:39:56 +0200
commitae2f3bb5b4eed01df1f7a69c7710c9be519390f6 (patch)
tree44c3209af699d535cc8f79f16a2b66cc417bc7eb
parent3cf5ff27155138ad7b7bafd2e815ca1bba5744ea (diff)
bgpd: add bgp link-state address-family configuration context
Add the bgp link-state configuration context cli: > router bgp 65001 > address-family link-state link-state > neighbor 192.0.2.2 activate > exit-address-family Signed-off-by: Louis Scalbert <louis.scalbert@6wind.com>
-rw-r--r--bgpd/bgp_vty.c152
-rw-r--r--bgpd/bgpd.c12
-rw-r--r--bgpd/bgpd.h28
-rw-r--r--lib/command.h1
-rw-r--r--vtysh/vtysh.c25
5 files changed, 208 insertions, 10 deletions
diff --git a/bgpd/bgp_vty.c b/bgpd/bgp_vty.c
index 67e2b467e8..bedfffe342 100644
--- a/bgpd/bgp_vty.c
+++ b/bgpd/bgp_vty.c
@@ -203,7 +203,22 @@ static enum node_type bgp_node_type(afi_t afi, safi_t safi)
case AFI_L2VPN:
return BGP_EVPN_NODE;
case AFI_LINKSTATE:
- /* TODO */
+ 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..
@@ -245,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";
@@ -287,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";
@@ -377,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;
@@ -409,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;
@@ -473,6 +504,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;
}
@@ -587,7 +622,24 @@ static const char *get_bgp_default_af_flag(afi_t afi, safi_t safi)
}
break;
case AFI_LINKSTATE:
- /* TODO */
+ 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;
case AFI_UNSPEC:
case AFI_MAX:
return "unknown-afi/safi";
@@ -10279,6 +10331,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",
@@ -10419,7 +10480,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;
}
@@ -18362,6 +18424,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");
@@ -18905,6 +18972,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
@@ -19029,6 +19101,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)
@@ -19343,6 +19422,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);
@@ -19359,6 +19439,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);
@@ -19490,6 +19571,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);
@@ -19712,6 +19800,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);
@@ -19726,6 +19815,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);
@@ -19740,6 +19830,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);
@@ -19754,6 +19846,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);
@@ -19784,6 +19877,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);
@@ -19804,9 +19899,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);
@@ -19839,6 +19935,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);
@@ -19887,6 +19985,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);
@@ -20019,6 +20119,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);
@@ -20057,6 +20169,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);
@@ -20094,6 +20210,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);
@@ -20122,6 +20240,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);
@@ -20283,6 +20403,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);
@@ -20419,6 +20541,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);
@@ -20443,6 +20567,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);
@@ -20467,6 +20592,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);
@@ -20493,6 +20620,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);
@@ -20513,6 +20641,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);
@@ -20632,6 +20762,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);
@@ -20654,6 +20793,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);
@@ -20689,6 +20830,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);
@@ -20701,6 +20844,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);
diff --git a/bgpd/bgpd.c b/bgpd/bgpd.c
index 895f36f992..802f91e22a 100644
--- a/bgpd/bgpd.c
+++ b/bgpd/bgpd.c
@@ -2040,6 +2040,10 @@ void peer_as_change(struct peer *peer, as_t as, int as_specified,
PEER_FLAG_REFLECTOR_CLIENT);
UNSET_FLAG(peer->af_flags[AFI_L2VPN][SAFI_EVPN],
PEER_FLAG_REFLECTOR_CLIENT);
+ UNSET_FLAG(peer->af_flags[AFI_LINKSTATE][SAFI_LINKSTATE],
+ PEER_FLAG_REFLECTOR_CLIENT);
+ UNSET_FLAG(peer->af_flags[AFI_LINKSTATE][SAFI_LINKSTATE_VPN],
+ PEER_FLAG_REFLECTOR_CLIENT);
}
}
@@ -4384,7 +4388,9 @@ bool peer_active(struct peer *peer)
|| peer->afc[AFI_IP6][SAFI_MPLS_VPN]
|| peer->afc[AFI_IP6][SAFI_ENCAP]
|| peer->afc[AFI_IP6][SAFI_FLOWSPEC]
- || peer->afc[AFI_L2VPN][SAFI_EVPN])
+ || peer->afc[AFI_L2VPN][SAFI_EVPN]
+ || peer->afc[AFI_LINKSTATE][SAFI_LINKSTATE]
+ || peer->afc[AFI_LINKSTATE][SAFI_LINKSTATE_VPN])
return true;
return false;
}
@@ -4404,7 +4410,9 @@ bool peer_active_nego(struct peer *peer)
|| peer->afc_nego[AFI_IP6][SAFI_MPLS_VPN]
|| peer->afc_nego[AFI_IP6][SAFI_ENCAP]
|| peer->afc_nego[AFI_IP6][SAFI_FLOWSPEC]
- || peer->afc_nego[AFI_L2VPN][SAFI_EVPN])
+ || peer->afc_nego[AFI_L2VPN][SAFI_EVPN]
+ || peer->afc_nego[AFI_LINKSTATE][SAFI_LINKSTATE]
+ || peer->afc_nego[AFI_LINKSTATE][SAFI_LINKSTATE_VPN])
return true;
return false;
}
diff --git a/bgpd/bgpd.h b/bgpd/bgpd.h
index 1319607a3f..92f27c0120 100644
--- a/bgpd/bgpd.h
+++ b/bgpd/bgpd.h
@@ -81,6 +81,8 @@ enum bgp_af_index {
BGP_AF_IPV6_LBL_UNICAST,
BGP_AF_IPV4_FLOWSPEC,
BGP_AF_IPV6_FLOWSPEC,
+ BGP_AF_LINKSTATE,
+ BGP_AF_LINKSTATE_VPN,
BGP_AF_MAX
};
@@ -2552,7 +2554,23 @@ static inline int afindex(afi_t afi, safi_t safi)
}
break;
case AFI_LINKSTATE:
- /* TODO */
+ switch (safi) {
+ case SAFI_LINKSTATE:
+ return BGP_AF_LINKSTATE;
+ case SAFI_LINKSTATE_VPN:
+ return BGP_AF_LINKSTATE_VPN;
+ case SAFI_EVPN:
+ case SAFI_UNICAST:
+ case SAFI_MULTICAST:
+ case SAFI_LABELED_UNICAST:
+ case SAFI_MPLS_VPN:
+ case SAFI_ENCAP:
+ case SAFI_FLOWSPEC:
+ case SAFI_UNSPEC:
+ case SAFI_MAX:
+ return BGP_AF_MAX;
+ }
+ break;
case AFI_UNSPEC:
case AFI_MAX:
return BGP_AF_MAX;
@@ -2578,7 +2596,9 @@ static inline int peer_afi_active_nego(const struct peer *peer, afi_t afi)
|| peer->afc_nego[afi][SAFI_MPLS_VPN]
|| peer->afc_nego[afi][SAFI_ENCAP]
|| peer->afc_nego[afi][SAFI_FLOWSPEC]
- || peer->afc_nego[afi][SAFI_EVPN])
+ || peer->afc_nego[afi][SAFI_EVPN]
+ || peer->afc_nego[afi][SAFI_LINKSTATE]
+ || peer->afc_nego[afi][SAFI_LINKSTATE_VPN])
return 1;
return 0;
}
@@ -2598,7 +2618,9 @@ static inline int peer_group_af_configured(struct peer_group *group)
|| peer->afc[AFI_IP6][SAFI_MPLS_VPN]
|| peer->afc[AFI_IP6][SAFI_ENCAP]
|| peer->afc[AFI_IP6][SAFI_FLOWSPEC]
- || peer->afc[AFI_L2VPN][SAFI_EVPN])
+ || peer->afc[AFI_L2VPN][SAFI_EVPN]
+ || peer->afc[AFI_LINKSTATE][SAFI_LINKSTATE]
+ || peer->afc[AFI_LINKSTATE][SAFI_LINKSTATE_VPN])
return 1;
return 0;
}
diff --git a/lib/command.h b/lib/command.h
index 718d34b007..36640c493f 100644
--- a/lib/command.h
+++ b/lib/command.h
@@ -174,6 +174,7 @@ enum node_type {
BMP_NODE, /* BMP config under router bgp */
ISIS_SRV6_NODE, /* ISIS SRv6 node */
ISIS_SRV6_NODE_MSD_NODE, /* ISIS SRv6 Node MSDs node */
+ BGP_LS_NODE, /* BGP-LS configuration node */
NODE_TYPE_MAX, /* maximum */
};
/* clang-format on */
diff --git a/vtysh/vtysh.c b/vtysh/vtysh.c
index 113a15c172..050807ccd8 100644
--- a/vtysh/vtysh.c
+++ b/vtysh/vtysh.c
@@ -1447,6 +1447,13 @@ static struct cmd_node bgp_ipv6l_node = {
.no_xpath = true,
};
+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)# ",
+};
+
#ifdef ENABLE_BGP_VNC
static struct cmd_node bgp_vnc_defaults_node = {
.name = "bgp vnc defaults",
@@ -1758,6 +1765,14 @@ DEFUNSH(VTYSH_BGPD, address_family_flowspecv6, address_family_flowspecv6_cmd,
return CMD_SUCCESS;
}
+DEFUNSH(VTYSH_BGPD, 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->node = BGP_LS_NODE;
+ return CMD_SUCCESS;
+}
+
DEFUNSH(VTYSH_BGPD, address_family_ipv4_multicast,
address_family_ipv4_multicast_cmd, "address-family ipv4 multicast",
"Enter Address Family command mode\n"
@@ -2420,7 +2435,8 @@ DEFUNSH(VTYSH_BGPD, exit_address_family, exit_address_family_cmd,
|| vty->node == BGP_IPV6L_NODE || vty->node == BGP_IPV6M_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;
}
@@ -4671,6 +4687,13 @@ void vtysh_init_vty(void)
install_element(BGP_EVPN_VNI_NODE, &vtysh_end_all_cmd);
install_element(BGP_EVPN_VNI_NODE, &exit_vni_cmd);
+ install_node(&bgp_ls_node);
+ install_element(BGP_NODE, &address_family_linkstate_cmd);
+ install_element(BGP_LS_NODE, &vtysh_exit_bgpd_cmd);
+ install_element(BGP_LS_NODE, &vtysh_quit_bgpd_cmd);
+ install_element(BGP_LS_NODE, &vtysh_end_all_cmd);
+ install_element(BGP_LS_NODE, &exit_address_family_cmd);
+
install_node(&rpki_node);
install_element(CONFIG_NODE, &rpki_cmd);
install_element(RPKI_NODE, &rpki_exit_cmd);