Skip to content

Commit a9044d2

Browse files
committed
zebra: Fix SRv6 explicit SID allocation to use the provided locator
Currently, when staticd allocates an explicit SID using the CLI: segment-routing srv6 static-sids sid fcbb:bbbb:1:fe00::/64 locator MAIN behavior uDT46 vrf Vrf10 staticd requests the SRv6 SID Manager to allocate SID fcbb:bbbb:1:fe00:: from locator MAIN. However, the SID Manager incorrectly ignores the provided locator MAIN and instead performs a lookup to find the first locator that matches the SID prefix, then allocates the SID from that locator regardless of which locator was requested. This behavior can lead to SIDs being allocated from unintended locators when multiple locators have overlapping prefixes, violating the user's explicit locator specification. This commit fixes the issue by adding a constraint in zebra_srv6_sid_decompose() that enforces the SID Manager to allocate the SID only from the provided locator when one is specified. The fix adds an early check in the locator lookup loop to skip locators that don't match the caller-provided locator, ensuring explicit SID allocation respects the user's locator choice. Signed-off-by: Carmine Scarpitta <[email protected]>
1 parent a12bfc5 commit a9044d2

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

zebra/zebra_srv6.c

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1322,10 +1322,14 @@ static bool zebra_srv6_sid_decompose(struct in6_addr *sid_value,
13221322
tmp_prefix.prefix = *sid_value;
13231323

13241324
/*
1325-
* Lookup the parent locator of the SID and return the locator and
1326-
* the function of the SID.
1325+
* If the parent locator of the SID is provided, allocate the SID from that locator;
1326+
* otherwise lookup the parent locator. Return the locator and SID function.
13271327
*/
13281328
for (ALL_LIST_ELEMENTS_RO(srv6->locators, node, l)) {
1329+
/* Skip locators that don't match the provided locator */
1330+
if (*locator != NULL && *locator != l)
1331+
continue;
1332+
13291333
/*
13301334
* Check if the locator prefix includes the temporary prefix
13311335
* representing the SID.
@@ -1801,7 +1805,7 @@ static int get_srv6_sid_explicit(struct zebra_srv6_sid **sid, struct srv6_sid_ct
18011805
{
18021806
struct zebra_srv6_sid_ctx *zctx = NULL;
18031807
uint32_t sid_func = 0, sid_func_wide = 0;
1804-
struct srv6_locator *loc = NULL;
1808+
struct srv6_locator *loc = locator;
18051809
struct zebra_srv6_sid_block *block = NULL;
18061810
char buf[256];
18071811

0 commit comments

Comments
 (0)