etcp_keepalive: протокол смены keepalive-режима (standby/normal) + событие active mode

- новый модуль etcp_keepalive.c/h: keepalive-пакеты, таймер, адаптивный период,
  согласование при handshake вынесены из etcp_connections.c как есть
- протокол KEEPALIVE_REQ/RESP (0x09/0x0A): мобильный узел при смене active mode
  шлёт желаемый режим; отвечающий считает max (standby при любом standby), не-мобильный
  применяет как есть; инициатор применяет согласованный режим после RESP
- режимы: NORMAL (3с, адаптивный рост), STANDBY (30с, ka_pinned=1 без роста)
- active mode как событие: utun_add/remove_activity_cbk; подписчики topo_group
  (nodeinfo) и etcp_keepalive (рассылка REQ всем линкам)
This commit is contained in:
evgeny committed 2026-08-12 20:32:57 +03:00
1 parent ad6d8fe2c6
commit f23daff0ce
13 files changed
+446 -206

No files matched your search

+21
View File
@@ -338,11 +338,31 @@ struct TOPO_GROUPS* topo_groups_init(struct UTUN_INSTANCE* instance) {
etcp_add_conn_status_cbk(instance, topo_group_conn_status, g);
etcp_add_socket_cbk(instance, topo_node_on_socket_changed, NULL,
ETCP_SOCKET_EVENT_ADDR_CHANGED | ETCP_SOCKET_EVENT_STATUS_CHANGED);
utun_add_activity_cbk(instance, topo_group_on_activity_change, NULL);
DEBUG_INFO(DEBUG_CATEGORY_BGP, "TOPO groups initialized (with default group)");
return g;
}
void topo_group_on_activity_change(struct UTUN_INSTANCE* instance, int active, void* arg) {
(void)active; (void)arg;
if (!instance || !instance->topo_groups || !instance->topo_groups->group_list) return;
struct ll_entry* ge = instance->topo_groups->group_list->head;
while (ge) {
struct TOPO_GROUP* g = (struct TOPO_GROUP*)ge;
topo_group_update_my_nodeinfo(instance, g);
if (g->senders_list) {
struct ll_entry* se = g->senders_list->head;
while (se) {
struct TOPO_GROUP_CONN_ITEM* item = (struct TOPO_GROUP_CONN_ITEM*)se->data;
if (item && item->conn) topo_group_send_nodeinfo(g, g->local_node, item->conn, 0);
se = se->next;
}
}
ge = ge->next;
}
}
void topo_groups_destroy(struct UTUN_INSTANCE* instance) {
if (!instance) { DEBUG_ERROR(DEBUG_CATEGORY_BGP, "instance is NULL"); return; }
if (!instance->topo_groups) { DEBUG_ERROR(DEBUG_CATEGORY_BGP, "topo_groups is NULL"); return; }
@@ -355,6 +375,7 @@ void topo_groups_destroy(struct UTUN_INSTANCE* instance) {
DEBUG_INFO(DEBUG_CATEGORY_SYS, "[TOPO_DESTROY] 2 conn_cbk_remove done");
etcp_remove_socket_cbk(instance, topo_node_on_socket_changed, NULL);
DEBUG_INFO(DEBUG_CATEGORY_SYS, "[TOPO_DESTROY] 3 socket_cbk_remove done");
utun_remove_activity_cbk(instance, topo_group_on_activity_change, NULL);
route_connectivity_cancel_all(instance);
DEBUG_INFO(DEBUG_CATEGORY_SYS, "[TOPO_DESTROY] 4 connectivity_cancel done");
+7
View File
@@ -197,6 +197,13 @@ struct TOPO_GROUPS {
*/
struct TOPO_GROUPS* topo_groups_init(struct UTUN_INSTANCE* instance);
/**
* @brief Обработчик события смены active mode (подписчик utun_add_activity_cbk).
*
* Обновляет свой nodeinfo и рассылает его по всем группам и активным BGP-пирам.
*/
void topo_group_on_activity_change(struct UTUN_INSTANCE* instance, int active, void* arg);
/**
* @brief Освобождает все группы и контейнер.
*