mirror of
https://git.proxmox.com/git/mirror_frr
synced 2025-08-17 18:27:41 +00:00
bgpd: allocate SID according to Function length
Allocate SID according to Function length to eliminate old SID allocation limits (255). Signed-off-by: Ryoga Saito <ryoga.saito@linecorp.com>
This commit is contained in:
parent
df237bd4f0
commit
c4ab9fd927
@ -527,34 +527,57 @@ static uint32_t alloc_new_sid(struct bgp *bgp, uint32_t index,
|
|||||||
struct in6_addr *sid_locator,
|
struct in6_addr *sid_locator,
|
||||||
struct in6_addr *sid)
|
struct in6_addr *sid)
|
||||||
{
|
{
|
||||||
|
int debug = BGP_DEBUG(vpn, VPN_LEAK_LABEL);
|
||||||
struct listnode *node;
|
struct listnode *node;
|
||||||
struct srv6_locator_chunk *chunk;
|
struct srv6_locator_chunk *chunk;
|
||||||
bool alloced = false;
|
bool alloced = false;
|
||||||
int label = 0;
|
int label = 0;
|
||||||
uint8_t offset = 0;
|
uint8_t offset = 0;
|
||||||
uint8_t len = 0;
|
uint8_t func_len = 0, shift_len = 0;
|
||||||
|
uint32_t index_max = 0;
|
||||||
|
|
||||||
if (!bgp || !sid_locator || !sid)
|
if (!bgp || !sid_locator || !sid)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
for (ALL_LIST_ELEMENTS_RO(bgp->srv6_locator_chunks, node, chunk)) {
|
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_locator = chunk->prefix.prefix;
|
*sid_locator = chunk->prefix.prefix;
|
||||||
*sid = chunk->prefix.prefix;
|
*sid = chunk->prefix.prefix;
|
||||||
offset = chunk->block_bits_length + chunk->node_bits_length;
|
offset = chunk->block_bits_length + chunk->node_bits_length;
|
||||||
len = chunk->function_bits_length ?: 16;
|
func_len = chunk->function_bits_length;
|
||||||
|
shift_len = BGP_PREFIX_SID_SRV6_MAX_FUNCTION_LENGTH - func_len;
|
||||||
|
|
||||||
if (index != 0) {
|
if (index != 0) {
|
||||||
label = index << 12;
|
label = index << shift_len;
|
||||||
transpose_sid(sid, label, offset, len);
|
transpose_sid(sid, label, offset, func_len);
|
||||||
if (sid_exist(bgp, sid))
|
if (sid_exist(bgp, sid))
|
||||||
return false;
|
return false;
|
||||||
alloced = true;
|
alloced = true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (size_t i = 1; i < 255; i++) {
|
for (uint32_t i = 1; i < index_max; i++) {
|
||||||
label = i << 12;
|
label = i << shift_len;
|
||||||
transpose_sid(sid, label, offset, len);
|
transpose_sid(sid, label, offset, func_len);
|
||||||
if (sid_exist(bgp, sid))
|
if (sid_exist(bgp, sid))
|
||||||
continue;
|
continue;
|
||||||
alloced = true;
|
alloced = true;
|
||||||
|
@ -41,6 +41,8 @@
|
|||||||
#define V4_HEADER_OVERLAY \
|
#define V4_HEADER_OVERLAY \
|
||||||
" Network Next Hop EthTag Overlay Index RouterMac\n"
|
" Network Next Hop EthTag Overlay Index RouterMac\n"
|
||||||
|
|
||||||
|
#define BGP_PREFIX_SID_SRV6_MAX_FUNCTION_LENGTH 20
|
||||||
|
|
||||||
extern void bgp_mplsvpn_init(void);
|
extern void bgp_mplsvpn_init(void);
|
||||||
extern int bgp_nlri_parse_vpn(struct peer *, struct attr *, struct bgp_nlri *);
|
extern int bgp_nlri_parse_vpn(struct peer *, struct attr *, struct bgp_nlri *);
|
||||||
extern uint32_t decode_label(mpls_label_t *);
|
extern uint32_t decode_label(mpls_label_t *);
|
||||||
|
Loading…
Reference in New Issue
Block a user