@@ -10157,31 +10157,37 @@ DEFPY (af_sid_vpn_export,
1015710157
1015810158DEFPY (bgp_sid_vpn_export,
1015910159 bgp_sid_vpn_export_cmd,
10160- "[no] sid vpn per-vrf export <(1-1048575)$sid_idx|auto$sid_auto>",
10160+ "[no] sid vpn per-vrf export <(1-1048575)$sid_idx|auto$sid_auto|explicit$sid_explicit X:X::X:X$sid_value >",
1016110161 NO_STR
1016210162 "sid value for VRF\n"
1016310163 "Between current vrf and vpn\n"
1016410164 "sid per-VRF (both IPv4 and IPv6 address families)\n"
1016510165 "For routes leaked from current vrf to vpn\n"
1016610166 "Sid allocation index\n"
10167- "Automatically assign a label\n")
10167+ "Automatically assign a label\n"
10168+ "Explicitly assign a sid value\n"
10169+ "Sid value\n")
1016810170{
1016910171 VTY_DECLVAR_CONTEXT(bgp, bgp);
1017010172 int debug;
10173+ struct in6_addr *tovpn_sid_explicit = NULL;
1017110174
1017210175 debug = (BGP_DEBUG(vpn, VPN_LEAK_TO_VRF) |
1017310176 BGP_DEBUG(vpn, VPN_LEAK_FROM_VRF));
1017410177
1017510178 if (no) {
1017610179 /* when per-VRF SID is not set, do nothing */
1017710180 if (bgp->tovpn_sid_index == 0 &&
10178- !CHECK_FLAG(bgp->vrf_flags, BGP_VRF_TOVPN_SID_AUTO))
10181+ !CHECK_FLAG(bgp->vrf_flags, BGP_VRF_TOVPN_SID_AUTO) &&
10182+ !CHECK_FLAG(bgp->vrf_flags, BGP_VRF_TOVPN_SID_EXPLICIT))
1017910183 return CMD_SUCCESS;
1018010184
1018110185 sid_idx = 0;
1018210186 sid_auto = false;
10187+ sid_explicit = false;
1018310188 bgp->tovpn_sid_index = 0;
1018410189 UNSET_FLAG(bgp->vrf_flags, BGP_VRF_TOVPN_SID_AUTO);
10190+ UNSET_FLAG(bgp->vrf_flags, BGP_VRF_TOVPN_SID_EXPLICIT);
1018510191 }
1018610192
1018710193 if (bgp->vpn_policy[AFI_IP].tovpn_sid_index != 0 ||
@@ -10198,18 +10204,28 @@ DEFPY (bgp_sid_vpn_export,
1019810204
1019910205 /* skip when it's already configured */
1020010206 if ((sid_idx != 0 && bgp->tovpn_sid_index != 0) ||
10201- (sid_auto && CHECK_FLAG(bgp->vrf_flags, BGP_VRF_TOVPN_SID_AUTO)))
10207+ (sid_auto && CHECK_FLAG(bgp->vrf_flags, BGP_VRF_TOVPN_SID_AUTO)) ||
10208+ (sid_explicit && CHECK_FLAG(bgp->vrf_flags, BGP_VRF_TOVPN_SID_EXPLICIT)))
1020210209 return CMD_SUCCESS;
1020310210
1020410211 /*
10205- * mode change between sid_idx and sid_auto isn't supported.
10212+ * mode change among sid_idx, sid_auto and sid_explicit isn't supported.
1020610213 * user must negate sid vpn export when they want to change the mode
1020710214 */
1020810215 if ((sid_auto && bgp->tovpn_sid_index != 0) ||
10209- (sid_idx != 0 &&
10210- CHECK_FLAG(bgp->vrf_flags, BGP_VRF_TOVPN_SID_AUTO))) {
10211- vty_out(vty, "it's already configured as %s.\n",
10212- sid_auto ? "auto-mode" : "idx-mode");
10216+ (sid_auto && CHECK_FLAG(bgp->vrf_flags, BGP_VRF_TOVPN_SID_EXPLICIT)) ||
10217+ (sid_idx != 0 && CHECK_FLAG(bgp->vrf_flags, BGP_VRF_TOVPN_SID_AUTO)) ||
10218+ (sid_idx != 0 && CHECK_FLAG(bgp->vrf_flags, BGP_VRF_TOVPN_SID_EXPLICIT)) ||
10219+ (sid_explicit && bgp->tovpn_sid_index != 0) ||
10220+ (sid_explicit && CHECK_FLAG(bgp->vrf_flags, BGP_VRF_TOVPN_SID_AUTO))) {
10221+ vty_out(vty, "it's already configured as ");
10222+ if (CHECK_FLAG(bgp->vrf_flags, BGP_VRF_TOVPN_SID_AUTO))
10223+ vty_out(vty, "auto-mode.\n");
10224+ else if (CHECK_FLAG(bgp->vrf_flags, BGP_VRF_TOVPN_SID_EXPLICIT))
10225+ vty_out(vty, "explicit-mode.\n");
10226+ else if (sid_idx != 0)
10227+ vty_out(vty, "idx-mode.\n");
10228+
1021310229 return CMD_WARNING_CONFIG_FAILED;
1021410230 }
1021510231
@@ -10230,6 +10246,15 @@ DEFPY (bgp_sid_vpn_export,
1023010246 zlog_debug("%s: idx %ld per-vrf sid alloc.", __func__,
1023110247 sid_idx);
1023210248 bgp->tovpn_sid_index = sid_idx;
10249+ } else if (sid_explicit) {
10250+ /* SID allocation explicit-mode */
10251+ tovpn_sid_explicit = XCALLOC(MTYPE_BGP_SRV6_SID, sizeof(struct in6_addr));
10252+ memcpy(tovpn_sid_explicit, &sid_value, sizeof(struct in6_addr));
10253+ bgp->tovpn_sid_explicit = tovpn_sid_explicit;
10254+
10255+ if (debug)
10256+ zlog_debug("%s: explicit per-vrf sid alloc.", __func__);
10257+ SET_FLAG(bgp->vrf_flags, BGP_VRF_TOVPN_SID_EXPLICIT);
1023310258 }
1023410259
1023510260 /* post-change */
@@ -20032,6 +20057,9 @@ int bgp_config_write(struct vty *vty)
2003220057 tovpn_sid_index = bgp->tovpn_sid_index;
2003320058 if (CHECK_FLAG(bgp->vrf_flags, BGP_VRF_TOVPN_SID_AUTO)) {
2003420059 vty_out(vty, " sid vpn per-vrf export auto\n");
20060+ } else if (CHECK_FLAG(bgp->vrf_flags, BGP_VRF_TOVPN_SID_EXPLICIT)) {
20061+ vty_out(vty, " sid vpn per-vrf export explicit %pI6\n",
20062+ bgp->tovpn_sid_explicit);
2003520063 } else if (tovpn_sid_index != 0) {
2003620064 vty_out(vty, " sid vpn per-vrf export %d\n",
2003720065 tovpn_sid_index);
0 commit comments