From 1aface994f8a89b257455d6228efa5bb52484e55 Mon Sep 17 00:00:00 2001 From: evgeny Date: Tue, 27 Oct 2026 07:41:04 +0100 Subject: [PATCH] fix(routing): report nodeinfo subscription allocation failure --- src/routing_layer/topo_group.c | 7 ++++--- src/routing_layer/topo_group.h | 3 ++- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/src/routing_layer/topo_group.c b/src/routing_layer/topo_group.c index f628eae2..0526ba39 100644 --- a/src/routing_layer/topo_group.c +++ b/src/routing_layer/topo_group.c @@ -1961,13 +1961,14 @@ void topo_group_remove_node_cbk(struct TOPO_GROUP* group, topo_node_event_fn fn, /* ── Global nodeinfo callbacks (instance-level, any node change) ── */ /* Регистрирует глобальный колбэк изменения nodeinfo (уровень инстанса). */ -void utun_add_nodeinfo_cbk(struct UTUN_INSTANCE* instance, nodeinfo_cbk_fn fn, void* arg) { - if (!instance || !fn) { DEBUG_ERROR(DEBUG_CATEGORY_BGP, "nodeinfo subscription: invalid arguments"); return; } +int utun_add_nodeinfo_cbk(struct UTUN_INSTANCE* instance, nodeinfo_cbk_fn fn, void* arg) { + if (!instance || !fn) { DEBUG_ERROR(DEBUG_CATEGORY_BGP, "nodeinfo subscription: invalid arguments"); return -1; } struct nodeinfo_cbk_entry* e = u_malloc(sizeof(*e)); - if (!e) { DEBUG_ERROR(DEBUG_CATEGORY_BGP, "nodeinfo subscription allocation failed"); return; } + if (!e) { DEBUG_ERROR(DEBUG_CATEGORY_BGP, "nodeinfo subscription allocation failed"); return -1; } e->fn = fn; e->arg = arg; e->next = instance->nodeinfo_cbks; instance->nodeinfo_cbks = e; + return 0; } /* Снимает глобальный колбэк nodeinfo. */ diff --git a/src/routing_layer/topo_group.h b/src/routing_layer/topo_group.h index 8920d110..ff554c17 100644 --- a/src/routing_layer/topo_group.h +++ b/src/routing_layer/topo_group.h @@ -108,7 +108,8 @@ struct nodeinfo_cbk_entry { struct nodeinfo_cbk_entry* next; }; -void utun_add_nodeinfo_cbk(struct UTUN_INSTANCE* instance, nodeinfo_cbk_fn fn, void* arg); +/* Зарегистрировать0/-1;fn/arg принадлежат caller до remove/уничтожения instance. */ +int utun_add_nodeinfo_cbk(struct UTUN_INSTANCE* instance, nodeinfo_cbk_fn fn, void* arg); void utun_remove_nodeinfo_cbk(struct UTUN_INSTANCE* instance, nodeinfo_cbk_fn fn, void* arg); void topo_fire_nodeinfo_cbk(struct UTUN_INSTANCE* instance, struct TOPO_GROUP* group, struct TOPO_GROUP_NODE* node);