Test cancellation of NAT rounds when a third participant is revoked

This commit is contained in:
evgeny committed 2026-11-03 20:48:56 +01:00
1 parent 1ebfad32f5
commit 455d9971ba
2 files changed
+18 -2

No files matched your search

+2 -2
View File
@@ -682,11 +682,11 @@ fail:
static void topo_group_destroy(struct TOPO_GROUP* group) {
if (!group) return;
group->stopping = 1;
/* Отменить и локальные ожидания без router-сессии до освобождения ресурсов группы. */
topo_group_revalidate_members(group);
multicast_close_group(group->instance, group->group_id);
nat_detection_cancel_group(group->instance->nat_det, group->group_id);
stream_cancel_group(group->instance, group->group_id);
/* Отменить и локальные ожидания без router-сессии до освобождения ресурсов группы. */
topo_group_revalidate_members(group);
DEBUG_INFO(DEBUG_CATEGORY_SYS, "[GRP_DESTROY] 0 enter grp=%p id=0x%016llx rec_list=%p connect=%p",
group, (unsigned long long)group->group_id, group->recovery, group->connect);
+16
View File
@@ -316,6 +316,22 @@ static void test_all_groups_tcp(void) {
do { uasync_poll(fixture.ua, 10); assert(!nat_detection_get_status(owner->nat_det, socket, &status)); }
while (get_time_tb() < end && (status.round == old_round || !status.phase));
assert(status.phase && status.group_id == 42);
char sql[160]; snprintf(sql, sizeof(sql), "UPDATE peers_42 SET admitted=0 WHERE node_id=%lld", (long long)helper->node_id);
assert(sqlite3_exec(owner->topo_sqlite_db, sql, NULL, NULL, NULL) == SQLITE_OK);
topo_group_revalidate_members(groups[0]);
assert(!nat_detection_get_status(owner->nat_det, socket, &status) && !status.phase && !status.cycling &&
status.reason == NAT_REASON_CANCELLED);
assert(socket->address_profile.mapping == ADDRESS_MAP_UNCHANGED && socket->address_profile.inbound == ADDRESS_IN_OPEN);
assert(ab->links_up && topo_group_peer_ready(topo_groups_find(owner->topo_groups, TOPO_GROUP_UTUN), observer->node_id));
DEBUG_INFO(DEBUG_CATEGORY_NAT, "PASS NAT revoked third participant cancels owner round; profile and shared UTUN remain");
snprintf(sql, sizeof(sql), "UPDATE peers_42 SET admitted=1 WHERE node_id=%lld", (long long)helper->node_id);
assert(sqlite3_exec(owner->topo_sqlite_db, sql, NULL, NULL, NULL) == SQLITE_OK);
old_round = status.round;
assert(!nat_detection_request_check_socket(owner->nat_det, socket, observer->node_id));
end = get_time_tb() + 30000;
do { uasync_poll(fixture.ua, 10); assert(!nat_detection_get_status(owner->nat_det, socket, &status)); }
while (get_time_tb() < end && (status.round == old_round || !status.phase));
assert(status.phase && status.group_id == 42);
topo_groups_remove_group(owner->topo_groups, 42);
assert(!nat_detection_get_status(owner->nat_det, socket, &status) && !status.phase && !status.group_id);
assert(socket->address_profile.mapping == ADDRESS_MAP_UNCHANGED && socket->address_profile.inbound == ADDRESS_IN_OPEN);