Skip to content

Commit

Permalink
zebra: fix sid allocation should be different with 2 isis instances
Browse files Browse the repository at this point in the history
With 2 ISIS SRv6 instances, the second ISIS instance always gets
the same End SID as the first one.

> router isis 1
> segment-routing srv6
> locator loc1
> exit
> exit
> router isis 2
> segment-routing srv6
> locator loc2
> end
> segment-routing
> srv6
> locators
> locator loc1
> prefix 2001::1/64
> exit
> locator loc2
> prefix 3001::1/64
>

output:
> 2024/06/11 17:30:15 ISIS: [N6PCR-FQ5ZA] SRv6 locator (locator loc1, prefix 2001::1/64) set for IS-IS area 1
> 2024/06/11 17:30:15 ISIS: [V4RBG-TYW5S] Requesting SRv6 SIDs for IS-IS area 1
> 2024/06/11 17:30:15 ISIS: [ZRHYM-6RMYK] isis_zebra_srv6_sid_notify: received SRv6 SID notify: ctx End USP sid_value 2001::1 sid_func 0 note ZAPI_SRV6_SID_ALLOCATED
> [..]
> 2024/06/11 17:36:49 ISIS: [N6PCR-FQ5ZA] SRv6 locator (locator loc2, prefix 3001::1/64) set for IS-IS area 2
> 2024/06/11 17:36:49 ISIS: [V4RBG-TYW5S] Requesting SRv6 SIDs for IS-IS area 2
> 2024/06/11 17:36:49 ISIS: [ZRHYM-6RMYK] isis_zebra_srv6_sid_notify: received SRv6 SID notify: ctx End USP sid_value 2001::1 sid_func 0 note ZAPI_SRV6_SID_ALLOCATED

Actually, at the second request, ZEBRA always gives an existing dynamic
SID of the first available locator, because the locator name is never
checked.

> 2024/06/11 17:36:49 ZEBRA: [XMBTQ-GE6EY] get_srv6_sid: received SRv6 SID alloc request: SID ctx End USP ((null)), mode=dynamic
> 2024/06/11 17:36:49 ZEBRA: [R61Q3-QWR23] get_srv6_sid_dynamic: returning existing SID End USP 2001::1
> 2024/06/11 17:36:49 ZEBRA: [J1GMY-B6CAK] srv6_manager_get_sid_internal: got existing SRv6 SID for ctx End USP: sid_value=2001::1 (func=0) (proto=9, instance=0, sessionId=0), notify client

Fix this by checking the locator of the existing SID.

Fixes: b771bf8 ("zebra: Add functions to alloc/release SRv6 SIDs")

Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
  • Loading branch information
pguibert6WIND authored and cscarpitta committed Jun 13, 2024
1 parent 35a87b6 commit 209223d
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions zebra/zebra_srv6.c
Original file line number Diff line number Diff line change
Expand Up @@ -1645,6 +1645,12 @@ static int get_srv6_sid_dynamic(struct zebra_srv6_sid **sid,
* SID instead of allocating a new one.
*/
for (ALL_LIST_ELEMENTS_RO(srv6->sids, node, s)) {
if (locator && s->sid && s->sid->locator) {
if (strncmp(s->sid->locator->name, locator->name,
SRV6_LOCNAME_SIZE)) {
continue;
}
}
if (memcmp(&s->ctx, ctx, sizeof(struct srv6_sid_ctx)) == 0) {
if (IS_ZEBRA_DEBUG_PACKET)
zlog_debug("%s: returning existing SID %s %pI6",
Expand Down

0 comments on commit 209223d

Please sign in to comment.