From: Philippe Guibert Date: Tue, 11 Jun 2024 16:14:58 +0000 (+0200) Subject: zebra: fix sid allocation should be different with 2 isis instances X-Git-Tag: base_10.2~338^2~1 X-Git-Url: https://git.puffer.fish/?a=commitdiff_plain;h=209223dae298ed33388563f2947923c0471b2ce7;p=mirror%2Ffrr.git zebra: fix sid allocation should be different with 2 isis instances 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 --- diff --git a/zebra/zebra_srv6.c b/zebra/zebra_srv6.c index 4273e52a01..a6db66bbcc 100644 --- a/zebra/zebra_srv6.c +++ b/zebra/zebra_srv6.c @@ -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",