]> git.puffer.fish Git - mirror/frr.git/commitdiff
zebra: ensure proper return for failure for Sid allocation 18392/head
authorRajasekar Raja <rajasekarr@nvidia.com>
Mon, 10 Mar 2025 22:26:38 +0000 (15:26 -0700)
committerMergify <37929162+mergify[bot]@users.noreply.github.com>
Fri, 14 Mar 2025 15:08:32 +0000 (15:08 +0000)
The functions alloc_srv6_sid_func_explicit/dynamic expect to return bool
but we have places where we return a -1 or NULL which the caller is
assuming as a True/Valid and ending up allocating Sid

Without Fix:
2025/03/10 21:44:04.295350 ZEBRA: [XWV20-TGK70] alloc_srv6_sid_func_explicit: trying to allocate explicit SID function 65088 from block fcbb:bbbb::/32
2025/03/10 21:44:04.295351 ZEBRA: [MM61M-TQZNP] alloc_srv6_sid_func_explicit: elib s 10000 e 20000 wlib s 1000 ewlib s 30000 e 1000 SID_FUNC 65088
2025/03/10 21:44:04.295352 ZEBRA: [QGHMB-SWNFW] alloc_srv6_sid_func_explicit: function 65088 is outside ELIB [10000/20000] and EWLIB alloc ranges [30000/1000]
2025/03/10 21:44:04.295367 ZEBRA: [H0GZA-NNSWJ] get_srv6_sid_explicit: allocated explicit SRv6 SID fcbb:bbbb:1:fe40:: for context End.X nh6 2001::2
2025/03/10 21:44:04.295368 ZEBRA: [XBBYD-T1Q7P] srv6_manager_get_sid_internal: got new SRv6 SID for ctx End.X nh6 2001::2: sid_value=fcbb:bbbb:1:fe40:: (func=65088) (proto=4, instance=0, sessionId=0), notifying all clients

With Fix:
2025/03/10 22:04:25.052235 ZEBRA: [MM61M-TQZNP] alloc_srv6_sid_func_explicit: elib s 30000 e 31000 wlib s 31000 ewlib s 30000 e 31000 SID_FUNC 65056
2025/03/10 22:04:25.052236 ZEBRA: [YHMRC-EMYNX] alloc_srv6_sid_func_explicit: function 65056 is outside ELIB [30000/31000] and EWLIB alloc ranges [30000/31000]
2025/03/10 22:04:25.052254 ZEBRA: [XSG8X-Q2XJX] get_srv6_sid_explicit: invalid SM request arguments: failed to allocate SID function 65056 from block fcbb:bbbb::/32
2025/03/10 22:04:25.052257 ZEBRA: [YC52T-427SJ] srv6_manager_get_sid_internal: not got SRv6 SID for ctx End.DT6 vrf_id 4, sid_value=fcbb:bbbb:1:fe20::, locator_name=MAIN
root@rajasekarr:/tmp/topotests/static_srv6_sids.test_static_srv6_sids/r1#

Ticket :#
Signed-off-by: Rajasekar Raja <rajasekarr@nvidia.com>
(cherry picked from commit 5a63cf4c0d1e7b84f59003877599c6575ba08a25)

zebra/zebra_srv6.c

index 082d4609aacde5ad4dcf1820f4a31e6a69322d15..85b6b42464887f1bc7ac75015eed95fd6d1a9ce8 100644 (file)
@@ -1235,7 +1235,7 @@ static bool alloc_srv6_sid_func_explicit(struct zebra_srv6_sid_block *block,
                                zlog_warn("%s: function %u is outside ELIB [%u/%u] and EWLIB alloc ranges [%u/%u]",
                                          __func__, sid_func, elib_start,
                                          elib_end, ewlib_start, ewlib_end);
-                               return -1;
+                               return false;
                        }
                } else if (format->type == SRV6_SID_FORMAT_TYPE_UNCOMPRESSED) {
                        uint32_t explicit_start =
@@ -1394,7 +1394,7 @@ static bool alloc_srv6_sid_func_dynamic(struct zebra_srv6_sid_block *block,
                            dynamic_end) {
                                zlog_warn("%s: SRv6: Warning, SRv6 SID Dynamic alloc space is depleted",
                                          __func__);
-                               return NULL;
+                               return false;
                        }
 
                        /*