Keep connection construction independent from link admission policy

This commit is contained in:
evgeny committed 2026-10-30 22:50:10 +01:00
1 parent a5299749fb
commit 2c1ba2b1c0
3 files changed
+6 -6

No files matched your search

+3 -3
View File
@@ -98,7 +98,7 @@ static struct UTUN_INSTANCE* make_instance(struct UASYNC* ua, const char* privat
}
static struct ETCP_CONN* make_connection(struct UTUN_INSTANCE* inst, const struct SC_MYKEYS* peer) {
struct ETCP_CONN* conn = etcp_connection_create(inst, "padding-test", 0); CHECK(conn);
struct ETCP_CONN* conn = etcp_connection_create(inst, "padding-test"); CHECK(conn);
conn->peer_node_id = sc_derive_node_id_from_pubkey(peer->public_key);
etcp_conn_queue_set_ready(conn);
CHECK(sc_init_ctx(&conn->crypto_ctx, &inst->my_keys) == SC_OK);
@@ -222,7 +222,7 @@ int main(void) {
CHECK(link.keepalive_recv_count == received && !link.ka_peer_sleeping);
puts("PASS keepalive: encrypted padding boundaries and receive parsing");
struct ETCP_CONN* sibling = etcp_connection_create(sender, "padding-sibling", 0); CHECK(sibling);
struct ETCP_CONN* sibling = etcp_connection_create(sender, "padding-sibling"); CHECK(sibling);
struct ETCP_PADDING saved = sender->padding, saved_peer = peer_conn->padding, saved_sibling = sibling->padding;
force_refresh(&conn->padding);
CHECK(memcmp(&saved, &sender->padding, sizeof(saved)) == 0);
@@ -247,7 +247,7 @@ int main(void) {
CHECK(etcp_padding_for_peer(sender, receiver->my_keys.public_key) == &sender->padding);
etcp_conn_ref_free(conn); etcp_connection_close(peer_conn); etcp_connection_close(sibling); uasync_poll(ua, 0);
fail_timer = 1;
CHECK(etcp_connection_create(sender, "padding-allocation-failure", 0) == NULL);
CHECK(etcp_connection_create(sender, "padding-allocation-failure") == NULL);
uasync_drain_immediate(ua); // завершить deferred free до снимка числа живых блоков
size_t allocations = u_get_allocated_count();
CHECK(utun_instance_create_from_config(ua, sender->config) == NULL);
+2 -2
View File
@@ -184,7 +184,7 @@ static void setup(int multi) {
ep[i].inst.pkt_pool=memory_pool_init(sizeof(struct ETCP_DGRAM)+PACKET_DATA_SIZE,"session_packets");
ep[i].inst.ack_pool=memory_pool_init(sizeof(struct ACK_PACKET),"session_acks"); CHECK(ep[i].inst.ack_pool);
CHECK(sc_generate_keypair(&ep[i].inst.my_keys) == SC_OK);
ep[i].c=etcp_connection_create(&ep[i].inst,"session_test", 0); CHECK(ep[i].c);
ep[i].c=etcp_connection_create(&ep[i].inst,"session_test"); CHECK(ep[i].c);
ep[i].c->peer_node_id=2-i; ep[i].c->links_up=1;
etcp_conn_ready(ep[i].c);
etcp_conn_add_cbk(ep[i].c,event,(void*)(intptr_t)i,ETCP_CBK_EVENT_REINIT|ETCP_CBK_EVENT_DOWN);
@@ -235,7 +235,7 @@ static void fresh_endpoint(int i) {
}
ep[i].c->links = NULL;
etcp_connection_close(ep[i].c); uasync_poll(ua, 0);
ep[i].c = etcp_connection_create(&ep[i].inst, "fresh_session", 0); CHECK(ep[i].c);
ep[i].c = etcp_connection_create(&ep[i].inst, "fresh_session"); CHECK(ep[i].c);
ep[i].c->peer_node_id = 2 - i;
CHECK(sc_init_ctx(&ep[i].c->crypto_ctx, &ep[i].inst.my_keys) == SC_OK);
CHECK(sc_set_peer_public_key(&ep[i].c->crypto_ctx, ep[1-i].inst.my_keys.public_key, SC_PEER_PUBKEY_BIN) == SC_OK);
+1 -1
View File
@@ -183,7 +183,7 @@ static void setup(void) {
inst.data_pool = memory_pool_init(PACKET_DATA_SIZE, "window_data");
inst.ack_pool = memory_pool_init(sizeof(struct ACK_PACKET), "window_acks");
CHECK(inst.connections && inst.pkt_pool && inst.data_pool && inst.ack_pool);
conn = etcp_connection_create(&inst, "windows", 0); CHECK(conn);
conn = etcp_connection_create(&inst, "windows"); CHECK(conn);
conn->peer_node_id = 2; conn->links_up = 1;
etcp_conn_ready(conn);
a = u_calloc(1, sizeof(*a)); b = u_calloc(1, sizeof(*b)); CHECK(a && b);