Commit 32ff3a8f4e for frr
commit 32ff3a8f4e0b2bf727e53df650b667f84bc5623e
Author: Andreas Karis <ak.karis@gmail.com>
Date: Wed Sep 16 23:58:39 2026 +0200
zebra: fix SRv6 locator memory leak due to deferred list insertion
A newly allocated SRv6 locator is not added to srv6->locators until
its prefix is configured. Any code path that enters the locator
context without setting a prefix (and then re-enters it) will
allocate a second locator, orphaning the first. Even a manual vtysh
session will trigger the leak:
locator MAIN
exit
locator MAIN
prefix fd00:0:33::/48 block-len 32 node-len 16
exit
The first entry allocates a locator that is never added to the list.
The second entry cannot find it via zebra_srv6_locator_lookup(), so
it allocates again. This also occurs during frr-reload, which enters
the context several times: once for each nested level, each as an
independent enter/exit block.
Lines To Add
============
segment-routing
exit
segment-routing
srv6
exit
exit
segment-routing
srv6
locators
exit
exit
exit
segment-routing
srv6
locators
locator MAIN
exit
exit
exit
exit
segment-routing
srv6
locators
locator MAIN
prefix fd00:0:33::/48 block-len 32 node-len 16
exit
exit
exit
exit
Fix by adding the locator to srv6->locators immediately on
allocation, so zebra_srv6_locator_lookup() finds it on subsequent
entries. Zclient notification is still deferred until the prefix is
configured.
Reported-at: https://github.com/FRRouting/frr/issues/23388
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Signed-off-by: Andreas Karis <ak.karis@gmail.com>
diff --git a/zebra/zebra_srv6_vty.c b/zebra/zebra_srv6_vty.c
index 2c9d1d5aa8..da2af776f3 100644
--- a/zebra/zebra_srv6_vty.c
+++ b/zebra/zebra_srv6_vty.c
@@ -812,6 +812,8 @@ DEFUN_NOSH (srv6_locator,
locator = srv6_locator_alloc(argv[1]->arg);
locator->status_up = true;
+ listnode_add(zebra_srv6_get_default()->locators, locator);
+
VTY_PUSH_CONTEXT(SRV6_LOC_NODE, locator);
return CMD_SUCCESS;
}