fix(nat): retain cold ingress reservation after partial measurements
This commit is contained in:
1 parent
7bf877b7d6
commit
37e092672a
2 files changed
+8
-4
No files matched your search
@@ -1427,7 +1427,6 @@ uint64_t nat_detection_probe_delay(struct NAT_DETECTION *detector) {
|
||||
for (struct nat_socket *state = detector->sockets; state; state = state->next) {
|
||||
if (state->socket->is_tcp || !state->reservation_fingerprint || state->cold_until <= now ||
|
||||
(!detector->automatic && !state->phase && !state->forced) ||
|
||||
(state->completed_tb && !state->phase && !state->cycling && !state->forced && state->due > now + 2500) ||
|
||||
(!state->phase && !state->cycling && !state->forced && state->measured_profile.source == ADDRESS_SOURCE_ETCP &&
|
||||
state->measured_profile.mapping && state->measured_profile.inbound))
|
||||
continue;
|
||||
@@ -1444,7 +1443,6 @@ int nat_detection_ping_allowed(struct NAT_DETECTION *detector, struct ETCP_SOCKE
|
||||
struct nat_socket *state = socket_state(detector, socket, 0);
|
||||
if (!state || (!state->reservation_fingerprint && !state->available_fingerprint) || state->cold_until <= get_time_tb() ||
|
||||
(!detector->automatic && !state->phase && !state->forced) ||
|
||||
(state->completed_tb && !state->phase && !state->cycling && !state->forced && state->due > get_time_tb() + 2500) ||
|
||||
(!state->phase && !state->cycling && !state->forced && state->measured_profile.source == ADDRESS_SOURCE_ETCP &&
|
||||
state->measured_profile.mapping && state->measured_profile.inbound)) return 1;
|
||||
uint64_t peer = sc_derive_node_id_from_pubkey(peer_key);
|
||||
|
||||
@@ -197,7 +197,7 @@ static void run_case(enum fault_mode mode, uint8_t mapping, uint8_t inbound) {
|
||||
nat_detection_set_automatic(observer->nat_det, 0); nat_detection_set_automatic(helper->nat_det, 0);
|
||||
nat_fixture_connect(&fixture, observer, "udp", helper);
|
||||
nat_fixture_connect(&fixture, owner, "udp", observer);
|
||||
nat_detection_set_automatic(owner->nat_det, 0);
|
||||
if (mode != FAULT_CONTACT) nat_detection_set_automatic(owner->nat_det, 0);
|
||||
memset(&fault, 0, sizeof(fault)); fault.fixture = &fixture; fault.owner = owner;
|
||||
fault.observer = observer; fault.helper = helper; fault.socket = test_etcp_bound_socket(owner, "udp"); fault.mode = mode;
|
||||
if (mode == FAULT_EIM_UNVERIFIED)
|
||||
@@ -216,7 +216,13 @@ static void run_case(enum fault_mode mode, uint8_t mapping, uint8_t inbound) {
|
||||
assert(fault.socket->address_profile.mapping == mapping && fault.socket->address_profile.inbound == inbound);
|
||||
if (mode == FAULT_NO_PONG || mode == FAULT_FILTERED || mode == FAULT_LATE_PRE || mode == FAULT_NO_REPORT) assert(fault.dropped);
|
||||
if (mode == FAULT_LATE_PRE || mode == FAULT_CONTACT) assert(fault.injected);
|
||||
if (mode == FAULT_CONTACT) assert(status.rounds == rounds + 1 && status.helper_reselections == 1);
|
||||
if (mode == FAULT_CONTACT) {
|
||||
assert(status.rounds == rounds + 1 && status.helper_reselections == 1);
|
||||
struct sockaddr_storage fresh = test_etcp_bound_socket(helper, "udp")->local_addr;
|
||||
assert(inet_pton(AF_INET, "127.0.0.9", &((struct sockaddr_in *)&fresh)->sin_addr) == 1);
|
||||
assert(nat_detection_probe_delay(owner->nat_det) > 0);
|
||||
assert(!nat_detection_ping_allowed(owner->nat_det, fault.socket, helper->my_keys.public_key, &fresh, 0, NULL, 0));
|
||||
}
|
||||
if (mode == FAULT_DEPENDENT || mode == FAULT_UNSTABLE) assert(fault.altered);
|
||||
if (mode == FAULT_LOCAL_OBSERVER) assert(fault.injected && status.helper_reselections && !fault.observations);
|
||||
if (mode == FAULT_CONTROL_STALL) assert(fault.dropped && fault.observations >= 2 && status.rounds == rounds + 1);
|
||||
|
||||
Reference in new issue
Block a user