Browse Source

Log cold candidate eligibility and reservation changes

master
evgeny 7 days ago
parent
commit
3294f67dbf
  1. 6
      src/routing_layer/nat_detection.c
  2. 1
      tests/test_nat_detection.c

6
src/routing_layer/nat_detection.c

@ -1204,6 +1204,9 @@ static uint64_t candidate_fingerprint(struct nat_socket *state, int ready) {
group_total += hash; group_total += hash;
} }
if (ready || (candidates >= 2 && observers)) total += group_total; if (ready || (candidates >= 2 && observers)) total += group_total;
if (!ready) DEBUG_DEBUG(DEBUG_CATEGORY_NAT, "NAT cold group candidates node=%016llx socket=%s group=%016llx candidates=%u observers=%u",
(unsigned long long)detector->instance->node_id, state->socket->name,
(unsigned long long)group->group_id, candidates, observers);
} }
return total; return total;
} }
@ -1221,6 +1224,9 @@ uint64_t nat_detection_probe_delay(struct NAT_DETECTION *detector) {
if (!state) continue; if (!state) continue;
uint64_t fingerprint = candidate_fingerprint(state, 0); uint64_t fingerprint = candidate_fingerprint(state, 0);
if (fingerprint != state->reservation_fingerprint) { if (fingerprint != state->reservation_fingerprint) {
DEBUG_DEBUG(DEBUG_CATEGORY_NAT, "NAT cold reservation node=%016llx socket=%s previous=%016llx current=%016llx",
(unsigned long long)detector->instance->node_id, socket->name,
(unsigned long long)state->reservation_fingerprint, (unsigned long long)fingerprint);
state->reservation_fingerprint = fingerprint; state->reservation_fingerprint = fingerprint;
if (fingerprint) state->cold_until = now + NAT_ROUND_TB + 2500; if (fingerprint) state->cold_until = now + NAT_ROUND_TB + 2500;
} }

1
tests/test_nat_detection.c

@ -111,6 +111,7 @@ static void test_all_groups_tcp(void) {
int main(void) { int main(void) {
debug_config_init(); debug_set_level(DEBUG_LEVEL_WARN); debug_set_category_level(DEBUG_CATEGORY_NAT, DEBUG_LEVEL_DEBUG); debug_config_init(); debug_set_level(DEBUG_LEVEL_WARN); debug_set_category_level(DEBUG_CATEGORY_NAT, DEBUG_LEVEL_DEBUG);
if (getenv("UTUN_TEST_DEBUG")) debug_set_category_level(DEBUG_CATEGORY_BGP, DEBUG_LEVEL_DEBUG);
struct nat_fixture fixture; nat_fixture_init(&fixture); struct nat_fixture fixture; nat_fixture_init(&fixture);
struct SC_MYKEYS first, second; struct SC_MYKEYS first, second;
assert(sc_generate_keypair(&first) == SC_OK && sc_generate_keypair(&second) == SC_OK); assert(sc_generate_keypair(&first) == SC_OK && sc_generate_keypair(&second) == SC_OK);

Loading…
Cancel
Save