bgpd: implement "no sid vpn export auto" per AF in vtysh

An example of implemented command for IPv4 AF is presented below.

dev-vm(config-router-af)# do show bgp segment-routing srv6
locator_name: Locator1
locator_chunks:
- 2001:db8:2:5::/64
  block-length: 40
  node-length: 24
  func-length: 16
  arg-length: 0
functions:
bgps:
- name: default
  vpn_policy[AFI_IP].tovpn_sid: (null)
  vpn_policy[AFI_IP6].tovpn_sid: (null)
  per-vrf tovpn_sid: (null)
- name: red
  vpn_policy[AFI_IP].tovpn_sid: (null)
  vpn_policy[AFI_IP6].tovpn_sid: (null)
  per-vrf tovpn_sid: (null)
dev-vm(config-router-af)# sid vpn export auto
^^^<<<<<<<<<<<<<<<<<<<<<< 1. configure sid per af
dev-vm(config-router-af)# do show bgp segment-routing srv6
locator_name: Locator1
locator_chunks:
- 2001:db8:2:5::/64
  block-length: 40
  node-length: 24
  func-length: 16
  arg-length: 0
functions:
- sid: 2001:db8:2:5:1::
  locator: Locator1
bgps:
- name: default
  vpn_policy[AFI_IP].tovpn_sid: (null)
  vpn_policy[AFI_IP6].tovpn_sid: (null)
  per-vrf tovpn_sid: (null)
- name: red
  vpn_policy[AFI_IP].tovpn_sid: 2001:db8:2:5:1::
^^^<<<<<<<<<<<<<<<<<<<<< 2. sid is configured
  vpn_policy[AFI_IP6].tovpn_sid: (null)
  per-vrf tovpn_sid: (null)
dev-vm(config-router-af)# no sid vpn export auto
^^^<<<<<<<<<<<<<<<<<<<< 3. deconfigure sid per af
dev-vm(config-router-af)# do show bgp segment-routing srv6
locator_name: Locator1
locator_chunks:
- 2001:db8:2:5::/64
  block-length: 40
  node-length: 24
  func-length: 16
  arg-length: 0
functions:
bgps:
- name: default
  vpn_policy[AFI_IP].tovpn_sid: (null)
  vpn_policy[AFI_IP6].tovpn_sid: (null)
  per-vrf tovpn_sid: (null)
- name: red
  vpn_policy[AFI_IP].tovpn_sid: (null)
^^^<<<<<<<<<<<<<<<<<<< 4. sid is deconfigured
  vpn_policy[AFI_IP6].tovpn_sid: (null)
  per-vrf tovpn_sid: (null)

Signed-off-by: Dmytro Shytyi <dmytro.shytyi@6wind.com>
This commit is contained in:
Dmytro Shytyi 2023-04-21 14:00:48 +02:00
parent 0c13c0bab8
commit d7967830ea

View File

@ -9292,9 +9292,24 @@ DEFPY (af_sid_vpn_export,
return CMD_WARNING_CONFIG_FAILED;
if (!yes) {
/* implement me */
vty_out(vty, "It's not implemented\n");
return CMD_WARNING_CONFIG_FAILED;
/* when SID is not set, do nothing */
if ((bgp->vpn_policy[afi].tovpn_sid_index == 0) &&
!CHECK_FLAG(bgp->vpn_policy[afi].flags,
BGP_VPN_POLICY_TOVPN_SID_AUTO))
return CMD_SUCCESS;
/* pre-change */
vpn_leak_prechange(BGP_VPN_POLICY_DIR_TOVPN, afi,
bgp_get_default(), bgp);
bgp->vpn_policy[afi].tovpn_sid_index = 0;
UNSET_FLAG(bgp->vpn_policy[afi].flags,
BGP_VPN_POLICY_TOVPN_SID_AUTO);
/* post-change */
vpn_leak_postchange(BGP_VPN_POLICY_DIR_TOVPN, afi,
bgp_get_default(), bgp);
return CMD_SUCCESS;
}
if (bgp->tovpn_sid_index != 0 ||
@ -9333,7 +9348,7 @@ DEFPY (af_sid_vpn_export,
zlog_debug("%s: auto sid alloc.", __func__);
SET_FLAG(bgp->vpn_policy[afi].flags,
BGP_VPN_POLICY_TOVPN_SID_AUTO);
} else {
} else if (sid_idx != 0) {
/* SID allocation index-mode */
if (debug)
zlog_debug("%s: idx %ld sid alloc.", __func__, sid_idx);