Browse Source

Expose pending NAT candidate cycles in local diagnostic status

master
evgeny 6 days ago
parent
commit
2354e94347
  1. 2
      src/routing_layer/nat_detection.c
  2. 2
      src/routing_layer/nat_detection.h
  3. 3
      tests/test_nat_detection.c

2
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;
}

2
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;
};

3
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);

Loading…
Cancel
Save