From 6f502243db0ea55a08a7e6c04046c8e22c1aff55 Mon Sep 17 00:00:00 2001 From: evgeny Date: Thu, 30 Jul 2026 09:17:28 +0300 Subject: [PATCH] fix: etcp_conn_reset resume output_queue+ack_q+normalizer; collision client-timer cancel; ETCP full state dump to debug log on sync TIMEOUT --- src/chat/db_sync.c | 19 +- src/transport_layer/etcp.c | 6 + src/transport_layer/etcp_connections.c | 1 + src/transport_layer/etcp_dump.c | 295 +++++++++++-------------- src/transport_layer/etcp_dump.h | 4 +- 5 files changed, 151 insertions(+), 174 deletions(-) diff --git a/src/chat/db_sync.c b/src/chat/db_sync.c index 11d37024..70e5e662 100644 --- a/src/chat/db_sync.c +++ b/src/chat/db_sync.c @@ -6,6 +6,7 @@ #include "../utun_instance.h" #include "../routing_layer/topo_group.h" #include "../routing_layer/topo_node_sqlite.h" +#include "../transport_layer/etcp_dump.h" #include "../transport_layer/secure_channel.h" #include "../../lib/debug_config.h" #include "../../lib/mem.h" @@ -541,12 +542,16 @@ static int db_sync_send_hash(struct DB_SYNC* db, uint64_t node_id, uint64_t hash struct ETCP_CONN* conn = instance_find_conn(db->inst, node_id); if (!conn || !conn->links_up) { - DEBUG_WARN(DEBUG_CATEGORY_DB_SYNC, "sync: send DROP — no direct conn to %04llX (hash=%016llx, type=%02x)", - (unsigned long long)(node_id >> 16), hash, plen > 0 ? payload[0] : 0); + DEBUG_WARN(DEBUG_CATEGORY_DB_SYNC, "sync: send DROP — no direct conn to %04llX (hash=%016llx, type=%02x, conn=%p lu=%d)", + (unsigned long long)(node_id >> 16), hash, plen > 0 ? payload[0] : 0, + (void*)conn, conn ? conn->links_up : -1); queue_entry_free(entry); return -1; } - return etcp_send(conn, entry); + int ret = etcp_send(conn, entry); + DEBUG_INFO(DEBUG_CATEGORY_DB_SYNC, "sync: send OK → etcp_send ret=%d conn=%s l_up=%d init=%d q=%p", + ret, conn->log_name, conn->links_up, conn->initialized, (void*)conn->send_input_q); + return ret; } static int db_sync_send(struct DB_SYNC_INSTANCE* si, uint64_t dst_node_id, const uint8_t* payload, size_t len) @@ -653,7 +658,10 @@ static void db_handle_init_sync(struct DB_SYNC_INSTANCE* si, uint64_t src, const scnt++; } resp[sp] = (uint8_t)scnt; - db_sync_send(si, src, resp, off); + int sret = db_sync_send(si, src, resp, off); + DEBUG_INFO(DEBUG_CATEGORY_DB_SYNC, "sync [%s:%04llX] → INIT_RESP: sent %u bytes to peer=%016llx ret=%d flow=%u,%u", + SI_SHRT(si), (unsigned long long)(src >> 16), off, (unsigned long long)src, sret, + resp[0], resp[1]); } static void db_handle_init_resp(struct DB_SYNC_INSTANCE* si, uint64_t src, const uint8_t* p, size_t len) @@ -1517,6 +1525,9 @@ static void db_sync_peer_check_cb(void* arg) SI_SHRT(si), (unsigned long long)(p->node_id >> 16), (unsigned long long)((now - p->sync_start_tb) / 10), p->synced_pos); p->sync_state = 0; + static int dump_ctr = 0; + if (dump_ctr++ == 0 || (dump_ctr % 10) == 0) + etcp_dump_all(db->inst); } } } diff --git a/src/transport_layer/etcp.c b/src/transport_layer/etcp.c index 8754a155..e14621c8 100644 --- a/src/transport_layer/etcp.c +++ b/src/transport_layer/etcp.c @@ -481,6 +481,12 @@ void etcp_conn_reset(struct ETCP_CONN* etcp) { queue_resume_callback(etcp->input_queue); queue_resume_callback(etcp->input_send_q); queue_resume_callback(etcp->input_wait_ack); + queue_resume_callback(etcp->output_queue); + queue_resume_callback(etcp->ack_q); + if (etcp->normalizer && etcp->normalizer->input) { + clear_queue(etcp->normalizer->input); + queue_resume_callback(etcp->normalizer->input); + } // В etcp_conn_reset(), после очистки очередей добавьте: struct ETCP_LINK* l = etcp->links; diff --git a/src/transport_layer/etcp_connections.c b/src/transport_layer/etcp_connections.c index b6feca47..1c7705fd 100644 --- a/src/transport_layer/etcp_connections.c +++ b/src/transport_layer/etcp_connections.c @@ -1905,6 +1905,7 @@ void etcp_connections_read_callback_socket(socket_t sock, void* arg) { DEBUG_INFO(DEBUG_CATEGORY_CONNECTION, "[%s] COLLISION: peer smaller, yielding master, processing as slave", conn->log_name); yielding = 1; + if (ml->init_timer) { uasync_cancel_timeout(conn->instance->ua, ml->init_timer); ml->init_timer = NULL; } } /* Sync session_id; reset only if new session (not when yielding to master) */ diff --git a/src/transport_layer/etcp_dump.c b/src/transport_layer/etcp_dump.c index 411722f2..a64e50ec 100644 --- a/src/transport_layer/etcp_dump.c +++ b/src/transport_layer/etcp_dump.c @@ -1,36 +1,34 @@ #include "etcp_dump.h" #include "etcp.h" +#include "etcp_connections.h" #include "pkt_normalizer.h" -#include "../lib/ll_queue.h" -#include "../lib/memory_pool.h" -#include "../lib/socket_compat.h" +#include "../../lib/ll_queue.h" +#include "../../lib/memory_pool.h" +#include "../../lib/socket_compat.h" +#include "../../lib/debug_config.h" #include #include -#define DUMP_FP stdout - -#define DUMP_LINE(fmt, ...) do { \ - fprintf(DUMP_FP, " " fmt "\n", ##__VA_ARGS__); \ -} while(0) - -#define DUMP_HDR(fmt, ...) do { \ - fprintf(DUMP_FP, fmt "\n", ##__VA_ARGS__); \ -} while(0) +#define DLOG(fmt, ...) DEBUG_INFO(DEBUG_CATEGORY_DEBUG, " " fmt, ##__VA_ARGS__) +#define DHDR(fmt, ...) DEBUG_INFO(DEBUG_CATEGORY_DEBUG, fmt, ##__VA_ARGS__) static void dump_queue(const char* name, struct ll_queue* q) { - if (!q) { DUMP_LINE("%-14s NULL", name); return; } - DUMP_LINE("%-14s %d pkts / %zu bytes", name, queue_entry_count(q), queue_total_bytes(q)); + if (!q) { DLOG("%-14s NULL", name); return; } + int suspended = 0; +#ifdef __cplusplus + suspended = q->callback_suspended ? 1 : 0; +#else + suspended = q->callback_suspended ? 1 : 0; +#endif + DLOG("%-14s %d pkts / %zu bytes suspended=%d", name, + queue_entry_count(q), queue_total_bytes(q), suspended); } static void dump_pool(const char* name, struct memory_pool* pool) { if (!pool) return; size_t allocs, reuse; memory_pool_get_stats(pool, &allocs, &reuse); - DUMP_LINE(" %-12s alloc=%zu reuse=%zu", name, allocs, reuse); -} - -static void dump_link_timer(const char* name, void* timer) { - DUMP_LINE(" %-14s %s", name, timer ? "ACTIVE" : "free"); + DLOG(" %-12s alloc=%zu reuse=%zu", name, allocs, reuse); } static const char* ip_to_str_buf(uint32_t ip, char* buf, size_t sz) { @@ -47,81 +45,70 @@ static const char* sockaddr_to_str(const struct sockaddr_storage* addr, char* bu return buf; } +static const char* link_state_str(int s) { + switch (s) { case 0: return "IDLE"; case 1: return "INIT"; case 2: return "RECONNECT"; case 3: return "CONNECTED"; default: return "?"; } +} + void etcp_dump_conn_state(struct ETCP_CONN* conn) { - if (!conn) { DUMP_HDR("etcp_dump_conn_state: NULL conn"); return; } + if (!conn) { DHDR("=== ETCP DUMP: NULL conn ==="); return; } char addr_buf[32], nat_buf[32]; - DUMP_HDR("=== ETCP CONN STATE [%s] ===", conn->log_name); - - /* --- GENERAL --- */ - DUMP_LINE("GENERAL: %s peer=0x%llx initialized=%d links_up=%d tx_state=%d session=0x%08x mtu=%d routing_ex=%d", - conn->name ? conn->name : "", - (unsigned long long)conn->peer_node_id, conn->initialized, conn->links_up, - conn->tx_state, conn->session_id, conn->mtu, conn->routing_exchange_active); + DHDR("=== ETCP CONN [%s] ===", conn->log_name); - /* --- IDS --- */ - DUMP_LINE("IDS: next_tx=%u last_rx=%u last_del=%u rx_ack_till=%u", - conn->next_tx_id, conn->last_rx_id, conn->last_delivered_id, conn->rx_ack_till); + DLOG("GENERAL: peer=0x%016llx state=%d init=%d l_up=%d tx=%d sess=0x%08x mtu=%d rout_ex=%d", + (unsigned long long)conn->peer_node_id, conn->state, conn->initialized, conn->links_up, + conn->tx_state, conn->session_id, conn->mtu, conn->routing_exchange_active); - /* --- RTT --- */ - DUMP_LINE("RTT: last=%u avg10=%u jitter=%u", - conn->rtt_last, conn->rtt_avg_10, conn->jitter); + DLOG("IDS: next_tx=%u last_rx=%u last_del=%u rx_ack_till=%u got_init=%d reset_done=%d", + conn->next_tx_id, conn->last_rx_id, conn->last_delivered_id, conn->rx_ack_till, + conn->got_initial_pkt, conn->reset_done); - /* --- STATS --- */ - DUMP_LINE("STATS: bytes_sent=%u retrans=%u reinit=%u reset=%u ack_pkts=%u", - conn->bytes_sent_total, conn->retransmissions_count, - conn->reinit_count, conn->reset_count, conn->ack_packets_count); + DLOG("RTT: last=%u avg10=%u jitter=%u", + conn->rtt_last, conn->rtt_avg_10, conn->jitter); - /* --- INFLIGHT --- */ - DUMP_LINE("INFLIGHT: unacked=%u optimal=%u", - conn->unacked_bytes, conn->optimal_inflight); + DLOG("STATS: bytes_sent=%u retrans=%u reinit=%u reset=%u acks=%u dup_rx=%u dup_tx=%u", + conn->bytes_sent_total, conn->retransmissions_count, + conn->reinit_count, conn->reset_count, conn->ack_packets_count, + conn->rx_dup_count, conn->tx_dup_count); - /* --- ACK DEBUG --- */ - DUMP_LINE("ACK_DEBUG: hit_inf=%u hit_sndq=%u miss=%u link_wait=%u rx_dup=%u tx_dup=%u", - conn->cnt_ack_hit_inf, conn->cnt_ack_hit_sndq, conn->cnt_ack_miss, - conn->cnt_link_wait, conn->rx_dup_count, conn->tx_dup_count); + DLOG("INFLIGHT: unacked=%u optimal=%u max=%u", + conn->unacked_bytes, conn->optimal_inflight, conn->max_inflight); - /* --- DEBUG[8] --- */ - DUMP_LINE("DEBUG: [0]=%u [1]=%u [2]=%u [3]=%u [4]=%u [5]=%u [6]=%u [7]=%u", - conn->debug[0], conn->debug[1], conn->debug[2], conn->debug[3], - conn->debug[4], conn->debug[5], conn->debug[6], conn->debug[7]); + DLOG("ACK: hit_inf=%u hit_sndq=%u miss=%u link_wait=%u", + conn->cnt_ack_hit_inf, conn->cnt_ack_hit_sndq, conn->cnt_ack_miss, conn->cnt_link_wait); - /* --- TIMERS --- */ - DUMP_LINE("TIMERS: retrans=%s ack_resp=%s", - conn->retrans_timer ? "ACTIVE" : "free", - conn->ack_resp_timer ? "ACTIVE" : "free"); + DLOG("TIMERS: retrans=%s ack_resp=%s", + conn->retrans_timer ? "ACTIVE" : "free", conn->ack_resp_timer ? "ACTIVE" : "free"); - /* --- QUEUES --- */ - DUMP_HDR(" --- QUEUES ---"); + DHDR(" --- QUEUES ---"); dump_queue("input", conn->input_queue); + dump_queue("send_input_q", conn->send_input_q); dump_queue("input_send_q", conn->input_send_q); dump_queue("input_wait_ack", conn->input_wait_ack); dump_queue("ack_q", conn->ack_q); dump_queue("recv_q", conn->recv_q); dump_queue("output", conn->output_queue); + if (conn->transit_queues) + DLOG("%-14s %d entries", "transit", queue_entry_count(conn->transit_queues)); - /* --- NORMALIZER --- */ if (conn->normalizer) { struct PKTNORM* pn = (struct PKTNORM*)conn->normalizer; - DUMP_HDR(" --- NORMALIZER ---"); - DUMP_LINE("frag=%u data_ptr=%u/%u flush=%s pending=%s recvpart=%s", - pn->frag_size, pn->data_ptr, pn->data_size, - pn->flush_timer ? "ACTIVE" : "free", - pn->pending ? "ACTIVE" : "free", - pn->recvpart ? "ACTIVE" : "free"); + DHDR(" --- NORMALIZER ---"); + DLOG("frag=%u data_ptr=%u/%u flush=%s recvpart=%s", + pn->frag_size, pn->data_ptr, pn->data_size, + pn->flush_timer ? "ACTIVE" : "free", pn->recvpart ? "ACTIVE" : "free"); dump_queue("pn-input", pn->input); dump_queue("pn-output", pn->output); - DUMP_LINE("alloc_err=%u logic_err=%u in=%llu/%llu out=%llu/%llu", - pn->alloc_errors, pn->logic_errors, - (unsigned long long)pn->in_total_pkts, (unsigned long long)pn->in_total_bytes, - (unsigned long long)pn->out_total_pkts, (unsigned long long)pn->out_total_bytes); + DLOG("err: alloc=%u logic=%u in=%llu/%llu out=%llu/%llu", + pn->alloc_errors, pn->logic_errors, + (unsigned long long)pn->in_total_pkts, (unsigned long long)pn->in_total_bytes, + (unsigned long long)pn->out_total_pkts, (unsigned long long)pn->out_total_bytes); } else { - DUMP_HDR(" --- NORMALIZER --- NULL"); + DHDR(" --- NORMALIZER --- NULL"); } - /* --- POOLS --- */ - DUMP_HDR(" --- POOLS ---"); + DHDR(" --- POOLS ---"); dump_pool("inflight", conn->inflight_pool); dump_pool("io", conn->io_pool); if (conn->instance) { @@ -130,120 +117,92 @@ void etcp_dump_conn_state(struct ETCP_CONN* conn) { dump_pool("pkt", conn->instance->pkt_pool); } - /* --- LINKS --- */ int link_idx = 0; struct ETCP_LINK* link = conn->links; while (link) { - DUMP_HDR(" --- LINK %d ---", link_idx); - + DHDR(" --- LINK %d ---", link_idx); sockaddr_to_str(&link->remote_addr, addr_buf, sizeof(addr_buf)); - - /* basic link state */ - DUMP_LINE("BASIC: id=%d/%d is_server=%d link_state=%d link_status=%d initialized=%d mtu=%d", - link->local_link_id, link->remote_link_id, link->is_server, - link->link_state, link->link_status, link->initialized, link->mtu); - DUMP_LINE("ADDR: remote=%s remote_sock=%d remote_type=%d remote_only_local=%d", - addr_buf, link->remote_socket_id, link->remote_type, link->remote_only_local); - - /* keepalive */ - DUMP_LINE("KA: recv=%d remote=%d sent=%u recv=%u interval=%u timeout=%u", - link->recv_keepalive, link->remote_keepalive, - link->keepalive_sent_count, link->keepalive_recv_count, - link->keepalive_interval, link->keepalive_timeout); - - /* timers */ - DUMP_LINE("TIMERS: init=%s(%u/%u) ka=%s shaper=%s burst=%s keepalive=%s", - link->init_timer ? "ACTIVE" : "free", - link->init_timeout, link->init_retry_count, - link->keepalive_timer ? "ACTIVE" : "free", - link->shaper_timer ? "ACTIVE" : "free", - link->burst_resp_timer ? "ACTIVE" : "free", - link->keepalive_sent_count > 0 ? "has_sent" : "idle"); - - /* inflight (BBR) */ - DUMP_LINE("BBR: bytes=%u pkts=%u lim=%u mode=%d cycle=%d pacing=%u", - link->inflight_bytes, link->inflight_packets, link->inflight_lim_bytes, - link->bbr ? link->bbr->mode : -1, - link->bbr ? link->bbr->cycle_idx : -1, - link->bbr_pacing_rate); - - /* rtt (BBR) */ - DUMP_LINE("RTT: last=%u jitter=%u min_rtt_us=%u bw_lo=%u bw_hi=%u inflight_lo=%u inflight_hi=%u", - link->rtt_last, link->jitter, - link->bbr ? link->bbr->min_rtt_us : 0, - link->bbr ? link->bbr->bw_lo : 0, - link->bbr ? (link->bbr->bw_hi[0] > link->bbr->bw_hi[1] ? link->bbr->bw_hi[0] : link->bbr->bw_hi[1]) : 0, - link->bbr ? link->bbr->inflight_lo : 0, - link->bbr ? link->bbr->inflight_hi : 0); - - /* tt/rt/bandwidth */ - DUMP_LINE("TT/RT: tt=%u rt=%u recv_dt_tx=%u recv_dt_rx=%u bw=%u", - link->tt_last, link->rt_last, - link->recv_dt_avg_tx, link->recv_dt_avg_rx, - link->bandwidth); - - /* errors */ - DUMP_LINE("MTU: %u local=%u remote=%u", link->mtu, link->mtu_local, link->mtu_remote); - DUMP_LINE("ERRORS: enc=%zu dec=%zu snd=%zu rcv=%zu total_enc=%zu total_dec=%zu retrans=%u", - link->encrypt_errors, link->decrypt_errors, - link->send_errors, link->recv_errors, - link->total_encrypted, link->total_decrypted, - link->total_retransmissions); - - /* nat */ - ip_to_str_buf(link->nat_ip, nat_buf, sizeof(nat_buf)); - DUMP_LINE("NAT: ip=%s:%u chg=%u hits=%u check=%d type=%d", - nat_buf, link->nat_port, - link->nat_changes_count, link->nat_hits_count, - link->nat_check_status, link->nat_type); - - /* last recv */ - DUMP_LINE("LAST_RECV: time=%llu ts=%u updated=%d", - (unsigned long long)link->last_recv_local_time, - link->last_recv_timestamp, link->last_recv_updated); - - /* handshake */ - DUMP_LINE("HANDSHAKE: min=%u max=%u", link->handshake_minsize, link->handshake_maxsize); - - /* burst */ - DUMP_LINE("BURST: active=%d id=%u seq=%u/%u last_tb=%llu resp=%s", - link->burst_active, link->burst_id, - link->burst_seq, link->burst_count, - (unsigned long long)link->burst_last_time_tb, - link->burst_resp_timer ? "ACTIVE" : "free"); - - /* shaper */ - DUMP_LINE("SHAPER: load_tb=%llu sub=%llu state=%d", - (unsigned long long)link->shaper_load_time_tb, - (unsigned long long)link->shaper_sub_nanotime, - link->shaper_state); - + DLOG("STATE: id=%d/%d sv=%d st=%d(%s) status=%d init=%d mtu=%d/%d", + link->local_link_id, link->remote_link_id, link->is_server, + link->link_state, link_state_str(link->link_state), + link->link_status, link->initialized, link->mtu, link->mtu_local); + DLOG("ADDR: remote=%s sock=%d type=%d only_local=%d mtu_remote=%d", + addr_buf, link->remote_socket_id, link->remote_type, link->remote_only_local, link->mtu_remote); + DLOG("TIMERS: init=%s(to=%u/retry=%u) keepalive=%s ka_timer=%s shaper=%s burst=%s", + link->init_timer ? "ACTIVE" : "free", link->init_timeout, link->init_retry_count, + link->keepalive_sent_count > 0 ? "ACTIVE" : "idle", + link->keepalive_timer ? "ACTIVE" : "free", + link->shaper_timer ? "ACTIVE" : "free", + link->burst_resp_timer ? "ACTIVE" : "free"); + DLOG("KA: recv=%d remote=%d sent=%u recv=%u ival=%u to=%u", + link->recv_keepalive, link->remote_keepalive, + link->keepalive_sent_count, link->keepalive_recv_count, + link->keepalive_interval, link->keepalive_timeout); + DLOG("INFLIGHT: bytes=%u pkts=%u lim=%u pacing=%u", + link->inflight_bytes, link->inflight_packets, + link->inflight_lim_bytes, link->bbr_pacing_rate); + DLOG("RTT: last=%u jitter=%u min_rtt_us=%u", + link->rtt_last, link->jitter, + link->bbr ? link->bbr->min_rtt_us : 0); + DLOG("TT/RT: tt=%u rt=%u dt_tx=%u dt_rx=%u bw=%u", + link->tt_last, link->rt_last, + link->recv_dt_avg_tx, link->recv_dt_avg_rx, link->bandwidth); + DLOG("ERRORS: enc=%zu dec=%zu snd=%zu rcv=%zu total_enc=%zu total_dec=%zu retrans=%u", + link->encrypt_errors, link->decrypt_errors, + link->send_errors, link->recv_errors, + link->total_encrypted, link->total_decrypted, link->total_retransmissions); + DLOG("NAT: type=%d chk=%d chg=%u hits=%u", + link->nat_type, link->nat_check_status, + link->nat_changes_count, link->nat_hits_count); + DLOG("LAST_RECV: tb=%llu ts=%u", + (unsigned long long)link->last_recv_local_time, link->last_recv_timestamp); + DLOG("BURST: active=%d id=%u seq=%u/%u", + link->burst_active, link->burst_id, link->burst_seq, link->burst_count); link = link->next; link_idx++; } - if (link_idx == 0) DUMP_HDR(" --- NO LINKS ---"); + if (link_idx == 0) DHDR(" --- NO LINKS ---"); - DUMP_HDR("=== END [%s] ===", conn->log_name); + DHDR("=== END [%s] ===", conn->log_name); } void etcp_dump_all_conns(struct UTUN_INSTANCE* instance) { - if (!instance) { - DUMP_HDR("etcp_dump_all_conns: NULL instance"); - return; - } - DUMP_HDR("=== DUMP ALL CONNS for instance node=0x%llx ===", - (unsigned long long)instance->node_id); - struct ll_entry* entry = instance->connections->head; + if (!instance) { DHDR("=== ETCP DUMP: NULL instance ==="); return; } + DHDR("=== ETCP DUMP ALL CONNS node=0x%016llx ===", (unsigned long long)instance->node_id); + struct ll_entry* entry = instance->connections ? instance->connections->head : NULL; int idx = 0; while (entry) { struct conn_queue_entry* ce = (struct conn_queue_entry*)entry->data; - if (ce && ce->conn) { - DUMP_HDR("--- CONN %d ---", idx); - etcp_dump_conn_state(ce->conn); - idx++; - } + if (ce && ce->conn) { etcp_dump_conn_state(ce->conn); idx++; } entry = entry->next; } - if (idx == 0) DUMP_HDR("--- NO CONNECTIONS ---"); - DUMP_HDR("=== END DUMP ALL ==="); + if (idx == 0) DHDR("--- NO CONNECTIONS ---"); + DHDR("=== END DUMP ALL CONNS ==="); +} + +void etcp_dump_sockets(struct UTUN_INSTANCE* instance) { + if (!instance) { DHDR("=== ETCP DUMP: NULL instance ==="); return; } + DHDR("=== ETCP DUMP SOCKETS node=0x%016llx ===", (unsigned long long)instance->node_id); + struct ETCP_SOCKET* s = instance->etcp_sockets; + int idx = 0; + while (s) { + char abuf[32]; sockaddr_to_str(&s->local_addr, abuf, sizeof(abuf)); + DLOG("SOCK %d: '%s' fd=%d addr=%s type=%d nat=%d mtu=%d links=%d", + idx, s->name, (int)s->fd, abuf, s->type, s->nat_type, + s->mtu, s->links_queue ? queue_entry_count(s->links_queue) : 0); + s = s->next; idx++; + } + if (idx == 0) DHDR("--- NO SOCKETS ---"); + if (instance->stcp_server) DLOG("TCP: stcp_server ACTIVE"); + if (instance->tcp_connections) + DLOG("TCP: tcp_connections queue %d entries", queue_entry_count(instance->tcp_connections)); + DHDR("=== END DUMP SOCKETS ==="); +} + +void etcp_dump_all(struct UTUN_INSTANCE* instance) { + if (!instance) { DHDR("=== ETCP DUMP: NULL instance ==="); return; } + DHDR("=== ETCP FULL DUMP node=0x%016llx ===", (unsigned long long)instance->node_id); + etcp_dump_sockets(instance); + etcp_dump_all_conns(instance); + DHDR("=== END FULL DUMP ==="); } diff --git a/src/transport_layer/etcp_dump.h b/src/transport_layer/etcp_dump.h index 17562f22..b0c775fb 100644 --- a/src/transport_layer/etcp_dump.h +++ b/src/transport_layer/etcp_dump.h @@ -5,13 +5,13 @@ extern "C" { #endif - #include "etcp.h" #include "utun_instance.h" void etcp_dump_conn_state(struct ETCP_CONN* conn); void etcp_dump_all_conns(struct UTUN_INSTANCE* instance); - +void etcp_dump_sockets(struct UTUN_INSTANCE* instance); +void etcp_dump_all(struct UTUN_INSTANCE* instance); #ifdef __cplusplus }