From 8dbc966132e3b3b4a081b0327510397cd7384197 Mon Sep 17 00:00:00 2001 From: Torkel Niklasson Date: Wed, 18 Mar 2026 10:43:45 +0100 Subject: [PATCH] linking-utils: raise canLinkGroupCheck recursion limit to 32 hops The canLinkGroupCheck() function had a hard-coded limit of 8 hops when traversing the link-group graph to determine whether two nodes are eligible to link. Replace the magic number with a named constant MAX_LINK_GROUP_HOPS. Also change the equality check == to a >=. Add a Log.warning() when the limit is hit. --- src/scripts/lib/linking-utils.lua | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/scripts/lib/linking-utils.lua b/src/scripts/lib/linking-utils.lua index b379a1eb..c8962c23 100644 --- a/src/scripts/lib/linking-utils.lua +++ b/src/scripts/lib/linking-utils.lua @@ -245,6 +245,9 @@ function lutils.getNodePeerId (node_id) return nil end +-- Maximum recursion depth for link-group compatibility checks. +local MAX_LINK_GROUP_HOPS = 32 + function lutils.canLink (properties, si_target) local target_props = si_target.properties @@ -272,7 +275,11 @@ function lutils.canLink (properties, si_target) local target_props = si_target.properties local target_link_group = target_props ["node.link-group"] - if hops == 8 then + if hops >= MAX_LINK_GROUP_HOPS then + Log.warning (string.format ( + "link-group hop count exceeded the %d-hop limit (at %d) while checking '%s' against target '%s'", + MAX_LINK_GROUP_HOPS, hops, tostring (link_group), + tostring (target_props ["node.name"]))) return false end