]> git.puffer.fish Git - matthieu/frr.git/commitdiff
zebra: fix sid allocation should be different with 2 isis instances
authorPhilippe Guibert <philippe.guibert@6wind.com>
Tue, 11 Jun 2024 16:14:58 +0000 (18:14 +0200)
committerCarmine Scarpitta <cscarpit@cisco.com>
Thu, 13 Jun 2024 12:54:17 +0000 (14:54 +0200)
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: b771bf8ce687 ("zebra: Add functions to alloc/release SRv6 SIDs")
Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
zebra/zebra_srv6.c

index 4273e52a01725ed34aba89d10a75f431f710922f..a6db66bbccea55afb5b496629d6ad90195d57ecb 100644 (file)
@@ -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",