Skip to content

Commit

Permalink
bgpd: Cleanup related to SRv6
Browse files Browse the repository at this point in the history
Remove unused SRv6 code.

Signed-off-by: Carmine Scarpitta <[email protected]>
  • Loading branch information
cscarpitta committed Apr 3, 2024
1 parent c2e10c0 commit 025a328
Showing 1 changed file with 0 additions and 94 deletions.
94 changes: 0 additions & 94 deletions bgpd/bgp_mplsvpn.c
Original file line number Diff line number Diff line change
Expand Up @@ -642,100 +642,6 @@ static bool sid_exist(struct bgp *bgp, const struct in6_addr *sid)
return false;
}

/*
* This function generates a new SID based on bgp->srv6_locator_chunks and
* index. The locator and generated SID are stored in arguments sid_locator
* and sid, respectively.
*
* if index != 0: try to allocate as index-mode
* else: try to allocate as auto-mode
*/
static uint32_t alloc_new_sid(struct bgp *bgp, uint32_t index,
struct srv6_locator_chunk *sid_locator_chunk,
struct in6_addr *sid)
{
int debug = BGP_DEBUG(vpn, VPN_LEAK_LABEL);
struct listnode *node;
struct srv6_locator_chunk *chunk;
bool alloced = false;
int label = 0;
uint8_t offset = 0;
uint8_t func_len = 0, shift_len = 0;
uint32_t index_max = 0;

if (!bgp || !sid_locator_chunk || !sid)
return false;

for (ALL_LIST_ELEMENTS_RO(bgp->srv6_locator_chunks, node, chunk)) {
if (chunk->function_bits_length >
BGP_PREFIX_SID_SRV6_MAX_FUNCTION_LENGTH) {
if (debug)
zlog_debug(
"%s: invalid SRv6 Locator chunk (%pFX): Function Length must be less or equal to %d",
__func__, &chunk->prefix,
BGP_PREFIX_SID_SRV6_MAX_FUNCTION_LENGTH);
continue;
}

index_max = (1 << chunk->function_bits_length) - 1;

if (index > index_max) {
if (debug)
zlog_debug(
"%s: skipped SRv6 Locator chunk (%pFX): Function Length is too short to support specified index (%u)",
__func__, &chunk->prefix, index);
continue;
}

*sid = chunk->prefix.prefix;
*sid_locator_chunk = *chunk;
offset = chunk->block_bits_length + chunk->node_bits_length;
func_len = chunk->function_bits_length;
shift_len = BGP_PREFIX_SID_SRV6_MAX_FUNCTION_LENGTH - func_len;

if (index != 0) {
label = index << shift_len;
if (label < MPLS_LABEL_UNRESERVED_MIN) {
if (debug)
zlog_debug(
"%s: skipped to allocate SRv6 SID (%pFX): Label (%u) is too small to use",
__func__, &chunk->prefix,
label);
continue;
}

transpose_sid(sid, label, offset, func_len);
if (sid_exist(bgp, sid))
continue;
alloced = true;
break;
}

for (uint32_t i = 1; i < index_max; i++) {
label = i << shift_len;
if (label < MPLS_LABEL_UNRESERVED_MIN) {
if (debug)
zlog_debug(
"%s: skipped to allocate SRv6 SID (%pFX): Label (%u) is too small to use",
__func__, &chunk->prefix,
label);
continue;
}
transpose_sid(sid, label, offset, func_len);
if (sid_exist(bgp, sid))
continue;
alloced = true;
break;
}
}

if (!alloced)
return 0;

sid_register(bgp, sid, bgp->srv6_locator_name);
return label;
}

/**
* Return the SRv6 SID value obtained composing the LOCATOR and FUNCTION.
*
Expand Down

0 comments on commit 025a328

Please sign in to comment.