Evgeny 4 days ago
parent
commit
9628686d63
  1. 2
      src/route_bgp.c
  2. 7
      src/route_lib.c

2
src/route_bgp.c

@ -551,7 +551,7 @@ int route_bgp_process_nodeinfo(struct ROUTE_BGP* bgp, struct ETCP_CONN* from,
memcpy(hop_dest, &sender, 8);
existing->node.hop_count = ni->hop_count + 1;
if (ni->hop_count > 0) {
if (ni->hop_count >= 0) {
route_bgp_add_path(existing, from, (uint64_t*)hop_dest, existing->node.hop_count);
}

7
src/route_lib.c

@ -207,10 +207,10 @@ bool route_insert(struct ROUTE_TABLE *table, struct NODEINFO_Q *node) {
struct ROUTE_ENTRY *e = &table->entries[pos];
e->network = network;
e->prefix_length = prefix_length;
e->v_node_info = node; // все префиксы узла ссылаются на один объект
e->v_node_info = node;
table->count++;
table->stats.learned_routes++;
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",
@ -227,13 +227,12 @@ void route_delete(struct ROUTE_TABLE *table, struct NODEINFO_Q *node) {
size_t removed = 0;
while (i < table->count) {
if (table->entries[i].v_node_info == node) {
// v_node_info — внешний, не освобождаем
if (i < table->count - 1) {
memmove(&table->entries[i], &table->entries[i + 1],
(table->count - i - 1) * sizeof(struct ROUTE_ENTRY));
}
table->count--;
table->stats.learned_routes--;
if (node && node->node.hop_count == 0) table->stats.local_routes--; else table->stats.learned_routes--;
removed++;
continue;
}

Loading…
Cancel
Save