From 2354e9434714a703124b2d95d09997588bb92c04 Mon Sep 17 00:00:00 2001 From: evgeny Date: Mon, 12 Oct 2026 20:17:44 +0200 Subject: [PATCH] Expose pending NAT candidate cycles in local diagnostic status --- src/routing_layer/nat_detection.c | 2 +- src/routing_layer/nat_detection.h | 2 +- tests/test_nat_detection.c | 3 +-- 3 files changed, 3 insertions(+), 4 deletions(-) diff --git a/src/routing_layer/nat_detection.c b/src/routing_layer/nat_detection.c index c49af52e..9485b9f9 100644 --- a/src/routing_layer/nat_detection.c +++ b/src/routing_layer/nat_detection.c @@ -1436,7 +1436,7 @@ int nat_detection_get_status(struct NAT_DETECTION *detector, struct ETCP_SOCKET *status = (struct nat_check_status){.generation = socket->generation, .round = state->round, .group_id = state->group_id, .observer = state->observer, .helper = state->helper, .rounds = state->rounds, .helper_reselections = state->helper_reselections, - .phase = state->phase, .reason = state->reason, .history_complete = state->history_complete, + .phase = state->phase, .reason = state->reason, .history_complete = state->history_complete, .cycling = state->cycling, .measured_profile = state->measured_profile, .effective_profile = socket->address_profile, .fallback_allowed = state->fallback_allowed}; return 0; } diff --git a/src/routing_layer/nat_detection.h b/src/routing_layer/nat_detection.h index 59733262..1a291559 100644 --- a/src/routing_layer/nat_detection.h +++ b/src/routing_layer/nat_detection.h @@ -30,7 +30,7 @@ struct nat_check_status { uint64_t generation, round; uint64_t group_id, observer, helper; uint32_t rounds, helper_reselections; - uint8_t phase, reason, history_complete; + uint8_t phase, reason, history_complete, cycling; uint8_t fallback_allowed; }; diff --git a/tests/test_nat_detection.c b/tests/test_nat_detection.c index ab99fd77..3b3bf2e9 100644 --- a/tests/test_nat_detection.c +++ b/tests/test_nat_detection.c @@ -111,7 +111,6 @@ static void test_all_groups_tcp(void) { int main(void) { debug_config_init(); debug_set_level(DEBUG_LEVEL_WARN); debug_set_category_level(DEBUG_CATEGORY_NAT, DEBUG_LEVEL_DEBUG); - debug_set_category_level(DEBUG_CATEGORY_BGP, DEBUG_LEVEL_DEBUG); struct nat_fixture fixture; nat_fixture_init(&fixture); struct SC_MYKEYS first, second; assert(sc_generate_keypair(&first) == SC_OK && sc_generate_keypair(&second) == SC_OK); @@ -167,7 +166,7 @@ int main(void) { nat_detection_request_check_all(owner->nat_det); uint64_t end = get_time_tb() + 180000; 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)); + while (get_time_tb() < end && (status.round == old_round || status.phase || status.cycling)); assert(status.round != old_round && !status.phase && status.reason == NAT_REASON_CONTACT_HISTORY); assert(socket->address_profile.mapping == ADDRESS_MAP_UNCHANGED && socket->address_profile.inbound == ADDRESS_IN_OPEN); assert(snapshot->timestamp == old_timestamp && topo_node_verify(snapshot) == 0);