|
|
|
|
@ -379,6 +379,14 @@ bool route_insert(struct ROUTE_TABLE *table,
|
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
uint64_t peer_node_id=0; |
|
|
|
|
if (conn) { |
|
|
|
|
peer_node_id=conn->peer_node_id; |
|
|
|
|
DEBUG_INFO(DEBUG_CATEGORY_ROUTING, "peer: %s %016llx", conn->log_name, (unsigned long long)peer_node_id); |
|
|
|
|
} |
|
|
|
|
else DEBUG_INFO(DEBUG_CATEGORY_ROUTING, "no peer"); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// === 1. Точный матч префикса ===
|
|
|
|
|
struct ROUTE_ENTRY *existing = find_exact(table, entry->network, entry->prefix_length); |
|
|
|
|
|
|
|
|
|
@ -397,7 +405,7 @@ bool route_insert(struct ROUTE_TABLE *table,
|
|
|
|
|
if (new_local) { |
|
|
|
|
existing->last_update = get_time_tb(); |
|
|
|
|
if (table->change_callback) |
|
|
|
|
table->change_callback(table, existing, 1, table->change_callback_arg); |
|
|
|
|
table->change_callback(table, existing, 1, peer_node_id, table->change_callback_arg); |
|
|
|
|
DEBUG_TRACE(DEBUG_CATEGORY_ROUTING, "route_insert: UPDATED local route %s/%d", ip_to_string(entry->network).a, entry->prefix_length); |
|
|
|
|
return true; |
|
|
|
|
} |
|
|
|
|
@ -415,7 +423,7 @@ bool route_insert(struct ROUTE_TABLE *table,
|
|
|
|
|
existing->last_update = get_time_tb(); |
|
|
|
|
|
|
|
|
|
if (table->change_callback) |
|
|
|
|
table->change_callback(table, existing, 1, table->change_callback_arg); |
|
|
|
|
table->change_callback(table, existing, 1, peer_node_id, table->change_callback_arg); |
|
|
|
|
|
|
|
|
|
DEBUG_INFO(DEBUG_CATEGORY_ROUTING, "route_insert: UPDATED learned route %s/%d node_id=%016llx", |
|
|
|
|
ip_to_string(entry->network).a, entry->prefix_length, (unsigned long long)node_id); |
|
|
|
|
@ -486,7 +494,7 @@ bool route_insert(struct ROUTE_TABLE *table,
|
|
|
|
|
|
|
|
|
|
// === 7. Callback ===
|
|
|
|
|
if (table->change_callback) { |
|
|
|
|
table->change_callback(table, &table->entries[pos], 0, table->change_callback_arg); |
|
|
|
|
table->change_callback(table, &table->entries[pos], 0, peer_node_id, table->change_callback_arg); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// === 8. Отладочное сообщение ===
|
|
|
|
|
@ -545,7 +553,7 @@ void route_remove_conn(struct ROUTE_TABLE *table, struct ETCP_CONN *conn) {
|
|
|
|
|
struct ROUTE_ENTRY *e = &table->entries[i]; |
|
|
|
|
if (e->conn_list && e->conn_list->conninfo_count == 0) { |
|
|
|
|
if (table->change_callback) |
|
|
|
|
table->change_callback(table, e, 2, table->change_callback_arg); |
|
|
|
|
table->change_callback(table, e, 2, 0, table->change_callback_arg); |
|
|
|
|
|
|
|
|
|
struct NODE_CONNS_INFO *info = e->conn_list; |
|
|
|
|
e->conn_list = NULL; |
|
|
|
|
@ -566,7 +574,7 @@ void route_remove_conn(struct ROUTE_TABLE *table, struct ETCP_CONN *conn) {
|
|
|
|
|
if (affected[k] == e->conn_list && needs_reroute[k]) { |
|
|
|
|
e->last_update = get_time_tb(); |
|
|
|
|
if (table->change_callback) |
|
|
|
|
table->change_callback(table, e, 1, table->change_callback_arg); |
|
|
|
|
table->change_callback(table, e, 1, 0, table->change_callback_arg); |
|
|
|
|
break; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
@ -613,7 +621,7 @@ bool route_remove_path(struct ROUTE_TABLE *table,
|
|
|
|
|
if (e->conn_list == info) { |
|
|
|
|
e->last_update = get_time_tb(); |
|
|
|
|
if (table->change_callback) |
|
|
|
|
table->change_callback(table, e, 1, table->change_callback_arg); |
|
|
|
|
table->change_callback(table, e, 1, 0, table->change_callback_arg); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
DEBUG_INFO(DEBUG_CATEGORY_ROUTING, "route_remove_path: REROUTE node_id=%016llx", (unsigned long long)node_id); |
|
|
|
|
@ -648,7 +656,7 @@ void route_delete(struct ROUTE_TABLE *table, uint64_t node_id) {
|
|
|
|
|
entry->conn_list = NULL; |
|
|
|
|
|
|
|
|
|
if (table->change_callback) { |
|
|
|
|
table->change_callback(table, entry, 2, table->change_callback_arg); |
|
|
|
|
table->change_callback(table, entry, 2, 0, table->change_callback_arg); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if (i < table->count - 1) { |
|
|
|
|
|