cleanup BGP/connection logging
- Consolidate on_up/on_down to single INFO line with peer_id - Remove DEBUG_CATEGORY_DEBUG duplications from route_bgp.c - NODEINFO: inline lightweight dump (no malloc), verbose log -> DEBUG - NAT_INFO: remove hex dump duplications, single clean INFO line - Send NODEINFO per-recipient: INFO->DEBUG_DEBUG - Per-ping callbacks: INFO->DEBUG_TRACE - Per-packet traffic direction: INFO->DEBUG_TRACE - route_insert/delete: use node_id instead of pointer - Add cancel_all log, add_to_senders conn name - send_full_table: ERROR->WARN for consistency checks - is_local_subnet: DEBUG->TRACE - Fix etcp_send_ping BGP category
This commit is contained in:
1 parent
227a1aafad
commit
a356eedc0d
6 files changed
+71
-71
No files matched your search
@@ -1143,7 +1143,7 @@ int etcp_send_ping(struct UTUN_INSTANCE* instance, const uint8_t* peer_pubkey_bi
|
||||
DEBUG_ERROR(DEBUG_CATEGORY_BGP, "no socket");
|
||||
return -2;
|
||||
}
|
||||
DEBUG_ERROR(DEBUG_CATEGORY_CONNECTION, "ping N1 [%s]", sockaddr_storage_to_str(addr).str);
|
||||
DEBUG_ERROR(DEBUG_CATEGORY_BGP, "ping N1 [%s]", sockaddr_storage_to_str(addr).str);
|
||||
return etcp_send_ping_to_socket(instance, e_sock, peer_pubkey_bin, addr, timeout_ms,
|
||||
cb, user_arg, user_data, user_data_len);
|
||||
}
|
||||
|
||||
+46
-38
@@ -47,6 +47,15 @@ static bool route_bgp_should_send_to(const struct NODEINFO_Q* nq, uint64_t targe
|
||||
static void route_bgp_send_full_table(struct ROUTE_BGP* bgp, struct ETCP_CONN* conn);
|
||||
static void route_bgp_handle_request_table(struct ROUTE_BGP* bgp, struct ETCP_CONN* conn);
|
||||
|
||||
static void nodeinfo_dump_log(const uint8_t* data, size_t len) {
|
||||
if (!data || len < sizeof(struct BGP_NODEINFO_PACKET)) return;
|
||||
struct BGP_NODEINFO_PACKET* pkt = (struct BGP_NODEINFO_PACKET*)data;
|
||||
struct NODEINFO* ni = &pkt->node;
|
||||
DEBUG_DEBUG(DEBUG_CATEGORY_BGP, "NODEINFO nid=%016llx ver=%u v4s=%u v4a=%u hops=%u",
|
||||
(unsigned long long)ni->node_id, ni->ver,
|
||||
ni->local_v4_sockets, ni->local_v4_addrs, ni->hop_count);
|
||||
}
|
||||
|
||||
static char* nodeinfo_format(const uint8_t* data, size_t len) {
|
||||
if (!data || len < sizeof(struct BGP_NODEINFO_PACKET)) return NULL;
|
||||
struct BGP_NODEINFO_PACKET* pkt = (struct BGP_NODEINFO_PACKET*)data;
|
||||
@@ -80,7 +89,18 @@ static char* nodeinfo_format(const uint8_t* data, size_t len) {
|
||||
return buf;
|
||||
}
|
||||
|
||||
/* Old full table sending removed - now using NODEINFO broadcast now */
|
||||
static const char* bgp_subcmd_name(uint8_t subcmd) {
|
||||
switch (subcmd) {
|
||||
case ROUTE_SUBCMD_NODEINFO: return "NODEINFO";
|
||||
case ROUTE_SUBCMD_REQUEST_TABLE: return "REQ_TABLE";
|
||||
case ROUTE_SUBCMD_WITHDRAW: return "WITHDRAW";
|
||||
case ROUTE_SUBCMD_PING_REQ: return "PING_REQ";
|
||||
case ROUTE_SUBCMD_PING_RESP: return "PING_RESP";
|
||||
case ROUTE_SUBCMD_NAT_INFO: return "NAT_INFO";
|
||||
case ROUTE_SUBCMD_NAT_CHECK_REQ: return "NAT_CHECK_REQ";
|
||||
default: return "?";
|
||||
}
|
||||
}
|
||||
|
||||
// ============================================================================
|
||||
// Broadcast / Withdraw: node_id - удаляемый узел, wd_source - от кого получена команда удалить
|
||||
@@ -147,11 +167,11 @@ static void route_bgp_receive_cbk(struct ETCP_CONN* from_conn, struct ll_entry*
|
||||
return;
|
||||
}
|
||||
|
||||
DEBUG_INFO(DEBUG_CATEGORY_BGP, "Received BGP packet from %s, subcmd=%d, len=%zu",
|
||||
from_conn->log_name, subcmd, entry->len);
|
||||
DEBUG_INFO(DEBUG_CATEGORY_BGP, "BGP recv %s from %s len=%zu",
|
||||
bgp_subcmd_name(subcmd), from_conn->log_name, entry->len);
|
||||
|
||||
if (subcmd == ROUTE_SUBCMD_NODEINFO) {
|
||||
char* s = nodeinfo_format(data, entry->len); if (s) { DEBUG_INFO(DEBUG_CATEGORY_BGP, "%s from %s", s, from_conn->log_name); u_free(s); }
|
||||
nodeinfo_dump_log(data, entry->len);
|
||||
route_bgp_process_nodeinfo(bgp, from_conn, data, entry->len);
|
||||
} else if (subcmd == ROUTE_SUBCMD_WITHDRAW) {
|
||||
route_bgp_process_withdraw(bgp, from_conn, data, entry->len);
|
||||
@@ -180,8 +200,7 @@ static void route_bgp_receive_cbk(struct ETCP_CONN* from_conn, struct ll_entry*
|
||||
static void route_bgp_on_conn_up(struct ETCP_CONN* conn, void* arg) {
|
||||
(void)arg;
|
||||
if (conn && conn->instance && conn->instance->bgp) {
|
||||
DEBUG_INFO(DEBUG_CATEGORY_DEBUG, "BGP ON UP %s", conn->log_name);
|
||||
DEBUG_TRACE(DEBUG_CATEGORY_BGP, "Connection %s on up ", conn->log_name);
|
||||
DEBUG_INFO(DEBUG_CATEGORY_BGP, "BGP peer UP: %s peer=%016llx", conn->log_name, (unsigned long long)conn->peer_node_id);
|
||||
route_bgp_new_conn(conn);
|
||||
}
|
||||
}
|
||||
@@ -189,8 +208,7 @@ static void route_bgp_on_conn_up(struct ETCP_CONN* conn, void* arg) {
|
||||
static void route_bgp_on_conn_down(struct ETCP_CONN* conn, void* arg) {
|
||||
(void)arg;
|
||||
if (conn && conn->instance && conn->instance->bgp) {
|
||||
DEBUG_INFO(DEBUG_CATEGORY_DEBUG, "BGP ON DOWN %s", conn->log_name);
|
||||
DEBUG_TRACE(DEBUG_CATEGORY_BGP, "Connection %s on down ", conn->log_name);
|
||||
DEBUG_INFO(DEBUG_CATEGORY_BGP, "BGP peer DOWN: %s peer=%016llx", conn->log_name, (unsigned long long)conn->peer_node_id);
|
||||
route_bgp_remove_conn(conn);
|
||||
}
|
||||
}
|
||||
@@ -199,8 +217,7 @@ static void route_bgp_on_conn_down(struct ETCP_CONN* conn, void* arg) {
|
||||
static void route_bgp_etcp_conn_cbk(struct ETCP_CONN* conn, void* arg) {
|
||||
(void)arg;
|
||||
if (conn && conn->instance && conn->instance->bgp) {
|
||||
DEBUG_INFO(DEBUG_CATEGORY_DEBUG, "BGP SET CBKS %s", conn->log_name);
|
||||
DEBUG_TRACE(DEBUG_CATEGORY_BGP, "Set ETCP ready callback for connection %s", conn->log_name);
|
||||
DEBUG_INFO(DEBUG_CATEGORY_BGP, "BGP set callbacks: %s", conn->log_name);
|
||||
etcp_conn_set_up_cbk(conn, route_bgp_on_conn_up, conn->instance->bgp);
|
||||
etcp_conn_set_down_cbk(conn, route_bgp_on_conn_down, conn->instance->bgp);
|
||||
}
|
||||
@@ -401,6 +418,7 @@ void route_bgp_remove_conn(struct ETCP_CONN* conn) {
|
||||
|
||||
// Remove this connection from all nodes' path lists
|
||||
bool need_withdraw = false;
|
||||
int nodes_removed = 0;
|
||||
struct ll_entry* node_entry = bgp->nodes ? bgp->nodes->head : NULL;
|
||||
while (node_entry) {
|
||||
struct ll_entry* next = node_entry->next;
|
||||
@@ -414,7 +432,8 @@ void route_bgp_remove_conn(struct ETCP_CONN* conn) {
|
||||
uint64_t key = nq->node.node_id;
|
||||
struct ll_entry* entry = node_entry;
|
||||
if (entry) { queue_remove_data(bgp->nodes, entry); queue_entry_free(entry); }
|
||||
DEBUG_INFO(DEBUG_CATEGORY_BGP, "Removed node %016llx after link down", (unsigned long long)key);
|
||||
nodes_removed++;
|
||||
DEBUG_DEBUG(DEBUG_CATEGORY_BGP, "Removed node %016llx after link down", (unsigned long long)key);
|
||||
}
|
||||
node_entry = next;
|
||||
}
|
||||
@@ -435,7 +454,8 @@ void route_bgp_remove_conn(struct ETCP_CONN* conn) {
|
||||
route_bgp_broadcast_withdraw(bgp, conn->peer_node_id, conn->instance->node_id, NULL);
|
||||
}
|
||||
|
||||
DEBUG_INFO(DEBUG_CATEGORY_BGP, "Connection removed, paths updated");
|
||||
DEBUG_INFO(DEBUG_CATEGORY_BGP, "BGP peer removed: %s nodes=%d withdraw=%d",
|
||||
conn->log_name, nodes_removed, need_withdraw);
|
||||
}
|
||||
|
||||
|
||||
@@ -590,7 +610,9 @@ static void nat_link_check_cb(int success, uint16_t avg_rtt, uint8_t count_sent,
|
||||
uint8_t socket_id = link->remote_socket_id;
|
||||
route_bgp_send_nat_info(link->etcp, socket_id, na->nat_ip, na->nat_port, nat_type);
|
||||
}
|
||||
DEBUG_INFO(DEBUG_CATEGORY_BGP, "nat check result: type=%s for node %s", success ? "OPEN" : "RESTRICTED", link->etcp->log_name);
|
||||
DEBUG_INFO(DEBUG_CATEGORY_BGP, "NAT check result: type=%s for conn=%s nat=%s:%u",
|
||||
success ? "EIM" : "STRICT", link->etcp->log_name,
|
||||
ip_to_str(&na->nat_ip, AF_INET).str, na->nat_port);
|
||||
u_free(na);
|
||||
}
|
||||
|
||||
@@ -705,17 +727,15 @@ int route_bgp_process_nodeinfo(struct ROUTE_BGP* bgp, struct ETCP_CONN* from, co
|
||||
struct NODEINFO_Q* nodeinfo1 = route_bgp_get_node(bgp, node_id);
|
||||
uint8_t new_ver = ni->ver;
|
||||
|
||||
DEBUG_INFO(DEBUG_CATEGORY_BGP, "NODEINFO from %s node=%016llx new_ver=%d local_ver=%d local_node=%p nodeinfo1=%p",
|
||||
from->log_name, (unsigned long long)node_id, new_ver,
|
||||
nodeinfo1 ? nodeinfo1->last_ver : 0,
|
||||
(void*)bgp->local_node, (void*)nodeinfo1);
|
||||
|
||||
if (nodeinfo1 && (int8_t)(nodeinfo1->last_ver-new_ver)>=0) {
|
||||
DEBUG_TRACE(DEBUG_CATEGORY_BGP, "NODEINFO from %s ignored (old ver %d <= %d)",
|
||||
from->log_name, new_ver, nodeinfo1->last_ver);
|
||||
DEBUG_TRACE(DEBUG_CATEGORY_BGP, "NODEINFO ignored old ver: node=%016llx ver=%d<=%d from=%s",
|
||||
(unsigned long long)node_id, new_ver, nodeinfo1->last_ver, from->log_name);
|
||||
return 0;
|
||||
}
|
||||
|
||||
DEBUG_INFO(DEBUG_CATEGORY_BGP, "NODEINFO: node=%016llx ver=%d v4s=%d v4a=%d hops=%d from=%s",
|
||||
(unsigned long long)node_id, new_ver, ni->local_v4_sockets, ni->local_v4_addrs, ni->hop_count, from->log_name);
|
||||
|
||||
int new_data_size=sizeof(struct NODEINFO_Q) - sizeof(struct ll_entry) + dyn_size + 8;
|
||||
struct ll_queue* paths=NULL;
|
||||
int need_alloc=0;
|
||||
@@ -751,8 +771,6 @@ int route_bgp_process_nodeinfo(struct ROUTE_BGP* bgp, struct ETCP_CONN* from, co
|
||||
}
|
||||
|
||||
/* Если это наш local_node (по node_id), обновляем его данные */
|
||||
DEBUG_INFO(DEBUG_CATEGORY_BGP, "Checking local_node update: node_id=%016llx my_id=%016llx local_node=%p",
|
||||
(unsigned long long)node_id, (unsigned long long)bgp->instance->node_id, (void*)bgp->local_node);
|
||||
if (node_id == bgp->instance->node_id && bgp->local_node) {
|
||||
uint8_t* dyn_src = (uint8_t*)&nodeinfo1->node + sizeof(struct NODEINFO);
|
||||
uint8_t* dyn_dst = (uint8_t*)&bgp->local_node->node + sizeof(struct NODEINFO);
|
||||
@@ -766,7 +784,7 @@ int route_bgp_process_nodeinfo(struct ROUTE_BGP* bgp, struct ETCP_CONN* from, co
|
||||
memcpy(dyn_dst, dyn_src, dyn_sz);
|
||||
bgp->local_node->node.ver = nodeinfo1->node.ver;
|
||||
bgp->local_node->last_ver = new_ver;
|
||||
DEBUG_INFO(DEBUG_CATEGORY_BGP, "Updated local_node from NODEINFO for node %016llx", (unsigned long long)node_id);
|
||||
DEBUG_INFO(DEBUG_CATEGORY_BGP, "Updated local_node from remote NODEINFO: node=%016llx", (unsigned long long)node_id);
|
||||
}
|
||||
nodeinfo1->paths = paths;
|
||||
nodeinfo1->last_ver = new_ver;
|
||||
@@ -796,7 +814,7 @@ int route_bgp_process_nodeinfo(struct ROUTE_BGP* bgp, struct ETCP_CONN* from, co
|
||||
int found=0;
|
||||
for (int i=0; i<hop_count; i++) if (hop_list[i]==id) found=1;
|
||||
if (found==0) route_bgp_send_nodeinfo(nodeinfo1, item->conn);
|
||||
else DEBUG_INFO(DEBUG_CATEGORY_BGP, "Skip send NODEINFO to node %016llx",id);
|
||||
else DEBUG_DEBUG(DEBUG_CATEGORY_BGP, "Skip send NODEINFO to node %016llx (loop prevention)",id);
|
||||
}
|
||||
e = e->next;
|
||||
}
|
||||
@@ -847,7 +865,7 @@ void route_bgp_send_nodeinfo(struct NODEINFO_Q* node, struct ETCP_CONN* conn) {
|
||||
return;
|
||||
}
|
||||
|
||||
DEBUG_INFO(DEBUG_CATEGORY_BGP, "Sending NODEINFO to %s", conn->log_name);
|
||||
DEBUG_DEBUG(DEBUG_CATEGORY_BGP, "Sending NODEINFO to %s", conn->log_name);
|
||||
|
||||
int dyn = nodeinfo_dyn_size(&node->node);
|
||||
|
||||
@@ -893,7 +911,7 @@ static void route_bgp_add_to_senders(struct ROUTE_BGP* bgp, struct ETCP_CONN* co
|
||||
if (item_entry) {
|
||||
((struct ROUTE_BGP_CONN_ITEM*)item_entry->data)->conn = conn;
|
||||
queue_data_put(bgp->senders_list, item_entry);
|
||||
DEBUG_INFO(DEBUG_CATEGORY_BGP, "Added to senders_list");
|
||||
DEBUG_INFO(DEBUG_CATEGORY_BGP, "Added to senders_list: %s", conn->log_name);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -921,11 +939,11 @@ static void route_bgp_send_full_table(struct ROUTE_BGP* bgp, struct ETCP_CONN* c
|
||||
while (e) {
|
||||
struct NODEINFO_Q* nq = (struct NODEINFO_Q*)e;
|
||||
if (nq->node.hop_count == 0) {
|
||||
DEBUG_ERROR(DEBUG_CATEGORY_BGP, "local node in learned list");
|
||||
DEBUG_WARN(DEBUG_CATEGORY_BGP, "local node in learned list");
|
||||
e = e->next; continue;
|
||||
}
|
||||
if (!nq->paths) {
|
||||
DEBUG_ERROR(DEBUG_CATEGORY_BGP, "node has no paths");
|
||||
DEBUG_WARN(DEBUG_CATEGORY_BGP, "node has no paths");
|
||||
e = e->next; continue;
|
||||
}
|
||||
if (route_bgp_should_send_to(nq, target)) {
|
||||
@@ -951,9 +969,6 @@ static void route_bgp_handle_nat_info(struct ROUTE_BGP* bgp, struct ETCP_CONN* f
|
||||
(info->nat_ip[2] << 8) | info->nat_ip[3];
|
||||
uint16_t nat_port = ntohs(info->nat_port);
|
||||
uint8_t socket_id = info->socket_id;
|
||||
DEBUG_INFO(DEBUG_CATEGORY_BGP, "NAT_INFO recv: ip_bytes=0x%02x%02x%02x%02x ip_host=0x%08x port_net=%u port_host=%u socket_id=%u type=%d",
|
||||
info->nat_ip[0], info->nat_ip[1], info->nat_ip[2], info->nat_ip[3],
|
||||
nat_ip, info->nat_port, nat_port, socket_id, info->nat_type);
|
||||
|
||||
// Обновить тип в socket meta
|
||||
uint8_t* dynamic = (uint8_t*)&bgp->local_node->node + sizeof(struct NODEINFO);
|
||||
@@ -980,14 +995,11 @@ static void route_bgp_handle_nat_info(struct ROUTE_BGP* bgp, struct ETCP_CONN* f
|
||||
while (es) {
|
||||
if (es->sock_id == socket_id) {
|
||||
if (verified_type == NAT_VERIFIED_STRICT) {
|
||||
// STRICT: не добавляем NAT адрес в список (бесполезен для probing)
|
||||
// но обновляем nat_addr в сокете для информации
|
||||
struct sockaddr_in* nat_sin = (struct sockaddr_in*)&es->nat_addr;
|
||||
nat_sin->sin_family = AF_INET;
|
||||
nat_sin->sin_addr.s_addr = nat_ip;
|
||||
nat_sin->sin_port = htons(nat_port);
|
||||
es->nat_type = verified_type;
|
||||
DEBUG_INFO(DEBUG_CATEGORY_BGP, "NAT_INFO: socket %d is STRICT, not adding to addr list", socket_id);
|
||||
} else {
|
||||
struct sockaddr_in* nat_sin = (struct sockaddr_in*)&es->nat_addr;
|
||||
uint32_t old_nat_ip = nat_sin->sin_addr.s_addr;
|
||||
@@ -997,7 +1009,6 @@ static void route_bgp_handle_nat_info(struct ROUTE_BGP* bgp, struct ETCP_CONN* f
|
||||
nat_sin->sin_port = htons(nat_port);
|
||||
if (old_nat_ip != nat_ip || old_nat_port != nat_port) data_changed = 1;
|
||||
es->nat_type = verified_type;
|
||||
DEBUG_INFO(DEBUG_CATEGORY_BGP, "NAT_INFO: socket %d type=%d ip=%08x port=%u", socket_id, verified_type, nat_ip, nat_port);
|
||||
}
|
||||
break;
|
||||
}
|
||||
@@ -1087,9 +1098,6 @@ void route_bgp_send_nat_info(struct ETCP_CONN* conn, uint8_t socket_id, uint32_t
|
||||
pkt->nat_ip[3] = nat_ip & 0xFF;
|
||||
pkt->nat_port = htons(nat_port);
|
||||
pkt->nat_type = nat_type;
|
||||
DEBUG_INFO(DEBUG_CATEGORY_BGP, "NAT_INFO send: ip_host=0x%08x ip_bytes=0x%02x%02x%02x%02x port_host=%u port_net=%u",
|
||||
nat_ip, pkt->nat_ip[0], pkt->nat_ip[1], pkt->nat_ip[2], pkt->nat_ip[3],
|
||||
nat_port, pkt->nat_port);
|
||||
|
||||
struct ll_entry* e = queue_entry_new(0);
|
||||
if (!e) {
|
||||
|
||||
@@ -148,10 +148,12 @@ static void conn_probe_start_series(struct conn_probe_ctx* ctx) {
|
||||
ctx->count_ok = 0;
|
||||
ctx->min_rtt = 65535;
|
||||
|
||||
DEBUG_INFO(DEBUG_CATEGORY_BGP, "probe series start: socket=%s (idx=%d/%d) addr_type=%d target=%s:%u",
|
||||
sock->name, ctx->candidate_index, ctx->candidate_count, ctx->addr_type,
|
||||
static const char* atype_names[] = {"INTERFACE", "NAT", "REAL"};
|
||||
DEBUG_DEBUG(DEBUG_CATEGORY_BGP, "probe series start: socket=%s target=%s:%u type=%s",
|
||||
sock->name,
|
||||
ip_to_str(&((struct sockaddr_in*)&ctx->target_addr)->sin_addr, AF_INET).str,
|
||||
(unsigned)ntohs(((struct sockaddr_in*)&ctx->target_addr)->sin_port));
|
||||
(unsigned)ntohs(((struct sockaddr_in*)&ctx->target_addr)->sin_port),
|
||||
atype_names[ctx->addr_type]);
|
||||
|
||||
int ret = etcp_send_ping_to_socket(ctx->instance, sock, ctx->peer_pubkey,
|
||||
&ctx->target_addr, ctx->timeout_ms,
|
||||
@@ -176,8 +178,9 @@ static void conn_probe_single_cb(int success, uint16_t rtt, void* arg,
|
||||
if (rtt < ctx->min_rtt) ctx->min_rtt = rtt;
|
||||
}
|
||||
|
||||
DEBUG_INFO(DEBUG_CATEGORY_BGP, "probe cb: success=%d rtt=%u sent=%d ok=%d min_rtt=%u",
|
||||
success, rtt, ctx->count_sent, ctx->count_ok, ctx->min_rtt);
|
||||
DEBUG_TRACE(DEBUG_CATEGORY_BGP, "probe ping: ok=%d rtt=%u sent=%d/%d socket=%s",
|
||||
success, rtt, ctx->count_sent, ctx->count_total,
|
||||
ctx->candidate_sockets[ctx->candidate_index]->name);
|
||||
|
||||
if (ctx->count_sent < ctx->count_total) {
|
||||
// продолжаем с тем же сокетом
|
||||
@@ -338,11 +341,14 @@ void route_connectivity_cancel_node(struct UTUN_INSTANCE* instance, struct NODEI
|
||||
|
||||
void route_connectivity_cancel_all(struct UTUN_INSTANCE* instance) {
|
||||
if (!instance || !instance->bgp || !instance->bgp->nodes) return;
|
||||
int count = 0;
|
||||
struct ll_entry* e = instance->bgp->nodes->head;
|
||||
while (e) {
|
||||
struct NODEINFO_Q* nq = (struct NODEINFO_Q*)e;
|
||||
nq->connectivity.probe_status = PROBE_STATUS_NONE;
|
||||
nq->connectivity.pending_count = 0;
|
||||
e = e->next;
|
||||
count++;
|
||||
}
|
||||
DEBUG_INFO(DEBUG_CATEGORY_BGP, "probe cancel ALL: %d nodes", count);
|
||||
}
|
||||
+6
-5
@@ -216,15 +216,16 @@ bool route_insert(struct ROUTE_TABLE *table, struct NODEINFO_Q *node) {
|
||||
if (node && node->node.hop_count == 0) table->stats.local_routes++; else table->stats.learned_routes++;
|
||||
}
|
||||
|
||||
DEBUG_INFO(DEBUG_CATEGORY_ROUTING, "route_insert: added %zu route(s) for node_info=%p",
|
||||
count, (void*)node);
|
||||
DEBUG_INFO(DEBUG_CATEGORY_ROUTING, "route_insert: added %zu route(s) for node=%016llx",
|
||||
count, node ? (unsigned long long)node->node.node_id : 0ULL);
|
||||
return true;
|
||||
}
|
||||
|
||||
void route_delete(struct ROUTE_TABLE *table, struct NODEINFO_Q *node) {
|
||||
if (!table || !node) return;
|
||||
|
||||
DEBUG_INFO(DEBUG_CATEGORY_ROUTING, "route_delete: removing all routes for node_info=%p", (void*)node);
|
||||
DEBUG_INFO(DEBUG_CATEGORY_ROUTING, "route_delete: removing all routes for node=%016llx",
|
||||
(unsigned long long)node->node.node_id);
|
||||
|
||||
size_t i = 0;
|
||||
size_t removed = 0;
|
||||
@@ -313,7 +314,7 @@ int is_local_subnet(uint32_t ip) {
|
||||
uint8_t first_octet = bip[0];
|
||||
uint8_t second_octet = bip[1];
|
||||
|
||||
DEBUG_DEBUG(DEBUG_CATEGORY_BGP, "check ip %d.%d : ", first_octet, second_octet);
|
||||
DEBUG_TRACE(DEBUG_CATEGORY_BGP, "check ip %d.%d : ", first_octet, second_octet);
|
||||
|
||||
if (first_octet == 0) return 1;
|
||||
if (first_octet == 10) return 1;
|
||||
@@ -323,7 +324,7 @@ int is_local_subnet(uint32_t ip) {
|
||||
if (first_octet == 172 && second_octet >= 16 && second_octet <= 31) return 1;
|
||||
if (first_octet == 192 && second_octet == 168) return 1;
|
||||
if (ip==0xffffffff) return 1;
|
||||
DEBUG_DEBUG(DEBUG_CATEGORY_BGP, "result: global ip %d.%d : ", first_octet, second_octet);
|
||||
DEBUG_TRACE(DEBUG_CATEGORY_BGP, "result: global ip %d.%d : ", first_octet, second_octet);
|
||||
|
||||
return 0;
|
||||
}
|
||||
+5
-21
@@ -275,9 +275,8 @@ static void route_ping_single_cb(int success,
|
||||
ctx->sum_rtt += rtt;
|
||||
}
|
||||
|
||||
DEBUG_INFO(DEBUG_CATEGORY_BGP, "ping callback nonce=%016llx success=%d rtt=%u sent=%u ok=%u",
|
||||
(unsigned long long)nonce, success, (unsigned)rtt,
|
||||
(unsigned)ctx->count_sent, (unsigned)ctx->count_ok);
|
||||
DEBUG_TRACE(DEBUG_CATEGORY_BGP, "ping cb: ok=%d rtt=%u sent=%d/%d nonce=%016llx",
|
||||
success, rtt, ctx->count_sent, ctx->count_total, (unsigned long long)nonce);
|
||||
|
||||
/* Если ещё не все пакеты отправлены — сразу шлём следующий */
|
||||
if (ctx->count_sent < ctx->count_total) {
|
||||
@@ -366,24 +365,9 @@ void route_ping_handle_req(struct ROUTE_BGP* bgp,
|
||||
return;
|
||||
}
|
||||
|
||||
DEBUG_INFO(DEBUG_CATEGORY_BGP,
|
||||
"PING series start request_id=%08x target=%s:%u count=%u timeout=%u",
|
||||
(unsigned)ctx->request_id,
|
||||
ip_to_str(&sin->sin_addr, AF_INET).str,
|
||||
ntohs(sin->sin_port),
|
||||
(unsigned)ctx->count_total,
|
||||
(unsigned)ctx->timeout_ms);
|
||||
|
||||
/* Отладка: показываем что передаем в etcp_send_ping_to_socket */
|
||||
{
|
||||
struct sockaddr_in* dbg_sin = (struct sockaddr_in*)&ctx->target_addr;
|
||||
uint8_t* k = ctx->pubkey;
|
||||
DEBUG_INFO(DEBUG_CATEGORY_BGP, "SEND_PING: family=%u addr=0x%08x port=%u pubkey=%02x%02x%02x%02x...%02x%02x",
|
||||
(unsigned)dbg_sin->sin_family,
|
||||
(unsigned)dbg_sin->sin_addr.s_addr,
|
||||
(unsigned)ntohs(dbg_sin->sin_port),
|
||||
k[0], k[1], k[2], k[3], k[60], k[61]);
|
||||
}
|
||||
DEBUG_INFO(DEBUG_CATEGORY_BGP, "PING series start request_id=%08x target=%s:%u count=%u timeout=%u",
|
||||
(unsigned)ctx->request_id, ip_to_str(&sin->sin_addr, AF_INET).str,
|
||||
ntohs(sin->sin_port), (unsigned)ctx->count_total, (unsigned)ctx->timeout_ms);
|
||||
|
||||
/* Запускаем первый пинг (дальше цепочка через callback) */
|
||||
int ret = etcp_send_ping_to_socket(
|
||||
|
||||
+2
-1
@@ -171,8 +171,9 @@ void route_pkt(struct UTUN_INSTANCE* instance, struct ll_entry* entry, uint64_t
|
||||
if (debug_should_output(DEBUG_LEVEL_DEBUG, DEBUG_CATEGORY_TRAFFIC)) {
|
||||
char* packet_str = dump_ip_packet_to_buffer(ip_data, ip_len);
|
||||
DEBUG_DEBUG(DEBUG_CATEGORY_TRAFFIC, "DUMP: %s", packet_str);
|
||||
} else {
|
||||
DEBUG_TRACE(DEBUG_CATEGORY_TRAFFIC, "NODE %016llx -> NODE %016llx", (unsigned long long)src_node_id, (unsigned long long)dst_node_id);
|
||||
}
|
||||
else DEBUG_INFO(DEBUG_CATEGORY_TRAFFIC, "NODE %016llx -> NODE %016llx", (unsigned long long)src_node_id, (unsigned long long)dst_node_id);
|
||||
|
||||
if (!nq || nq->node.hop_count == 0) {
|
||||
int put_err = queue_data_put(instance->tun->input_queue, entry);
|
||||
|
||||
Reference in new issue
Block a user