From cdcc32cf845d945f05d3cb8e07ef2c3b8203d5db Mon Sep 17 00:00:00 2001 From: Evgeny Date: Thu, 16 Jul 2026 22:03:33 +0300 Subject: [PATCH] fix: move DECRYPT FAIL/collision/reinit logs from DEBUG_CATEGORY_DEBUG to proper categories MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - DECRYPT FAIL (1554): DEBUG_DEBUG → ETCP (main failure signal) - not an init packet (1623): DEBUG_DEBUG → CONNECTION (was invisible ERROR) - pkt_pool exhaust (1537): add ERROR log (was silent) - REINIT/collision events (1473,1751-1838): DEBUG_DEBUG → CONNECTION --- src/etcp_connections.c | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/src/etcp_connections.c b/src/etcp_connections.c index e581373c..9316aa00 100644 --- a/src/etcp_connections.c +++ b/src/etcp_connections.c @@ -1470,7 +1470,7 @@ static int handle_init_response_client(struct ETCP_SOCKET* e_sock, struct ETCP_D } if (pkt_code == ETCP_INIT_RESPONSE && !link->etcp->reset_done) { - DEBUG_INFO(DEBUG_CATEGORY_DEBUG, "[%s] REINIT from client: INIT_RESPONSE(0x03) received, reinit conn=%p", + DEBUG_INFO(DEBUG_CATEGORY_CONNECTION, "[%s] REINIT from client: INIT_RESPONSE(0x03) received, reinit conn=%p", link->etcp->log_name, link->etcp); etcp_conn_reinit(link->etcp); } @@ -1534,7 +1534,7 @@ void etcp_connections_read_callback_socket(socket_t sock, void* arg) { if (debug_should_output(DEBUG_LEVEL_DEBUG, DEBUG_CATEGORY_CRYPTO)) log_dump(DEBUG_LEVEL_DEBUG, DEBUG_CATEGORY_CRYPTO, "RECV in:", data, recv_len); struct ETCP_DGRAM* pkt = memory_pool_alloc(e_sock->instance->pkt_pool); - if (!pkt) return; + if (!pkt) { DEBUG_ERROR(DEBUG_CATEGORY_ETCP, "pkt_pool exhausted, dropping packet from %s", sockaddr_storage_to_str(&addr).str); return; } size_t pkt_len=0; int errorcode=0; @@ -1551,7 +1551,7 @@ void etcp_connections_read_callback_socket(socket_t sock, void* arg) { if (!dec_rc) { goto process_decrypted; } - DEBUG_INFO(DEBUG_CATEGORY_DEBUG, "etcp: DECRYPT FAIL rc=%d link=%p log=%s sess=%d link_state=%d keepalive=%d enc_errs=%zu my_pub=%016llx peer_pub=%016llx", + DEBUG_INFO(DEBUG_CATEGORY_ETCP, "etcp: DECRYPT FAIL rc=%d link=%p log=%s sess=%d link_state=%d keepalive=%d enc_errs=%zu my_pub=%016llx peer_pub=%016llx", dec_rc, link, link->etcp->log_name, link->etcp->crypto_ctx.session_ready, link->link_state, link->recv_keepalive, link->encrypt_errors, *(uint64_t*)link->etcp->crypto_ctx.pk->public_key, *(uint64_t*)link->etcp->crypto_ctx.peer_public_key); @@ -1620,7 +1620,7 @@ void etcp_connections_read_callback_socket(socket_t sock, void* arg) { return; } if (code!=ETCP_INIT_REQUEST && code!=ETCP_INIT_REQUEST_NOINIT) { - DEBUG_ERROR(DEBUG_CATEGORY_DEBUG, "not an init packet: code=0x%02x (expected 0x02/0x04) from %s — packet dropped", + DEBUG_ERROR(DEBUG_CATEGORY_CONNECTION, "not an init packet: code=0x%02x (expected 0x02/0x04) from %s — packet dropped", code, sockaddr_storage_to_str(&addr).str); errorcode=4; goto ec_fr; @@ -1748,7 +1748,7 @@ void etcp_connections_read_callback_socket(socket_t sock, void* arg) { // ── Collision handling ── if (req->collision) { - DEBUG_INFO(DEBUG_CATEGORY_DEBUG, "[%s] INIT collision=1 from peer=%016llx — remote is master, becoming slave", + DEBUG_INFO(DEBUG_CATEGORY_CONNECTION, "[%s] INIT collision=1 from peer=%016llx — remote is master, becoming slave", conn->log_name, (unsigned long long)peer_id); conn->session_id = session_id; etcp_conn_reinit(conn); @@ -1759,13 +1759,13 @@ void etcp_connections_read_callback_socket(socket_t sock, void* arg) { while (ml) { if (ml->is_server == 0) break; ml = ml->next; } if (ml) { if (conn->instance->node_id < peer_id) { - DEBUG_INFO(DEBUG_CATEGORY_DEBUG, "[%s] COLLISION: we=master node_id=%016llx < peer=%016llx — sending collision INIT", + DEBUG_INFO(DEBUG_CATEGORY_CONNECTION, "[%s] COLLISION: we=master node_id=%016llx < peer=%016llx — sending collision INIT", conn->log_name, (unsigned long long)conn->instance->node_id, (unsigned long long)peer_id); memory_pool_free(e_sock->instance->pkt_pool, pkt); etcp_link_send_init(ml, 0, 1); return; } - DEBUG_INFO(DEBUG_CATEGORY_DEBUG, "[%s] COLLISION: peer smaller, yielding master, processing as slave", + DEBUG_INFO(DEBUG_CATEGORY_CONNECTION, "[%s] COLLISION: peer smaller, yielding master, processing as slave", conn->log_name); } @@ -1773,14 +1773,14 @@ void etcp_connections_read_callback_socket(socket_t sock, void* arg) { if (!conn->reset_done) { if (code == ETCP_INIT_REQUEST || conn->session_id != session_id || !conn->got_initial_pkt) { send_reset = 1; - DEBUG_INFO(DEBUG_CATEGORY_DEBUG, "[%s] REINIT existing link: code=0x%02x sess=%08x→%08x got_init=%d initialized=%d links_up=%d", + DEBUG_INFO(DEBUG_CATEGORY_CONNECTION, "[%s] REINIT existing link: code=0x%02x sess=%08x→%08x got_init=%d initialized=%d links_up=%d", conn->log_name, code, conn->session_id, session_id, conn->got_initial_pkt, conn->initialized, conn->links_up); conn->session_id = session_id; etcp_conn_reinit(conn); } } else if (conn->session_id != session_id) { send_reset = 1; - DEBUG_INFO(DEBUG_CATEGORY_DEBUG, "[%s] REINIT existing link (session changed): sess=%08x→%08x", + DEBUG_INFO(DEBUG_CATEGORY_CONNECTION, "[%s] REINIT existing link (session changed): sess=%08x→%08x", conn->log_name, conn->session_id, session_id); conn->session_id = session_id; etcp_conn_reinit(conn); @@ -1807,7 +1807,7 @@ void etcp_connections_read_callback_socket(socket_t sock, void* arg) { // ── Collision handling ── if (req->collision) { - DEBUG_INFO(DEBUG_CATEGORY_DEBUG, "[%s] INIT collision=1 from peer=%016llx — remote is master, becoming slave", + DEBUG_INFO(DEBUG_CATEGORY_CONNECTION, "[%s] INIT collision=1 from peer=%016llx — remote is master, becoming slave", conn->log_name, (unsigned long long)peer_id); conn->session_id = session_id; etcp_conn_reinit(conn); @@ -1817,7 +1817,7 @@ void etcp_connections_read_callback_socket(socket_t sock, void* arg) { struct ETCP_LINK* ml = conn->links; while (ml) { if (ml->is_server == 0) break; ml = ml->next; } if (ml && conn->instance->node_id < peer_id) { - DEBUG_INFO(DEBUG_CATEGORY_DEBUG, "[%s] COLLISION: we=master node_id=%016llx < peer=%016llx — sending collision INIT", + DEBUG_INFO(DEBUG_CATEGORY_CONNECTION, "[%s] COLLISION: we=master node_id=%016llx < peer=%016llx — sending collision INIT", conn->log_name, (unsigned long long)conn->instance->node_id, (unsigned long long)peer_id); memory_pool_free(e_sock->instance->pkt_pool, pkt); etcp_link_send_init(ml, 0, 1); @@ -1828,14 +1828,14 @@ void etcp_connections_read_callback_socket(socket_t sock, void* arg) { if (!conn->reset_done) { if (code == ETCP_INIT_REQUEST || conn->session_id != session_id || !conn->got_initial_pkt) { send_reset = 1; - DEBUG_INFO(DEBUG_CATEGORY_DEBUG, "[%s] REINIT new link: code=0x%02x sess=%08x→%08x got_init=%d initialized=%d links_up=%d", + DEBUG_INFO(DEBUG_CATEGORY_CONNECTION, "[%s] REINIT new link: code=0x%02x sess=%08x→%08x got_init=%d initialized=%d links_up=%d", conn->log_name, code, conn->session_id, session_id, conn->got_initial_pkt, conn->initialized, conn->links_up); conn->session_id = session_id; etcp_conn_reinit(conn); } } else if (conn->session_id != session_id) { send_reset = 1; - DEBUG_INFO(DEBUG_CATEGORY_DEBUG, "[%s] REINIT new link (session changed): sess=%08x→%08x", + DEBUG_INFO(DEBUG_CATEGORY_CONNECTION, "[%s] REINIT new link (session changed): sess=%08x→%08x", conn->log_name, conn->session_id, session_id); conn->session_id = session_id; etcp_conn_reinit(conn);