Browse Source

bgp: prevent sending NODEINFO to self + own NODEINFO early return

- route_bgp_process_nodeinfo: skip own node_id early, don't add to bgp->nodes
- broadcast loop: skip sending NODEINFO to connection where peer == node_id
- route_bgp_should_send_to: don't send node's NODEINFO to itself
- tests: lower debug level to ERROR, fix keepalive adaptive config
chatgui
Evgeny 3 months ago
parent
commit
c5123e4baf
  1. 3
      src/route_bgp.c
  2. 4
      tests/test_bgp_route_exchange.c
  3. 4
      tests/test_bgp_triangle.c

3
src/route_bgp.c

@ -843,11 +843,13 @@ int route_bgp_process_nodeinfo(struct ROUTE_BGP* bgp, struct ETCP_CONN* from, co
struct ROUTE_BGP_CONN_ITEM* item = (struct ROUTE_BGP_CONN_ITEM*)e->data;
if (item->conn) {
uint64_t id=item->conn->peer_node_id;
if (id != node_id) {
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_DEBUG(DEBUG_CATEGORY_BGP, "Skip send NODEINFO to node %016llx (loop prevention)",id);
}
}
e = e->next;
}
@ -954,6 +956,7 @@ static void route_bgp_add_to_senders(struct ROUTE_BGP* bgp, struct ETCP_CONN* co
static bool route_bgp_should_send_to(const struct NODEINFO_Q* nq, uint64_t target_id) {
if (!nq || !nq->paths) return false;
if (target_id == nq->node.node_id) return false;
struct ll_entry* e = nq->paths->head;
while (e) {
struct NODEINFO_PATH* path = (struct NODEINFO_PATH*)e;

4
tests/test_bgp_route_exchange.c

@ -291,8 +291,8 @@ static int cond_bgp_c_to_a_gone(void) {
// -------------------- Main --------------------
int main(void) {
debug_config_init();
debug_set_level(DEBUG_LEVEL_INFO);
debug_set_categories(DEBUG_CATEGORY_BGP | DEBUG_CATEGORY_ETCP | DEBUG_CATEGORY_CONNECTION);
debug_set_level(DEBUG_LEVEL_ERROR);
debug_set_categories(DEBUG_CATEGORY_BGP);
utun_instance_set_tun_init_enabled(0);
if (create_temp_configs() != 0) return 1;

4
tests/test_bgp_triangle.c

@ -254,8 +254,8 @@ static int cond_c_one_path(void) { return node_path_count(inst_a, NODE_ID_C) ==
int main(void) {
debug_config_init();
debug_set_level(DEBUG_LEVEL_INFO);
debug_set_categories(DEBUG_CATEGORY_BGP | DEBUG_CATEGORY_ETCP | DEBUG_CATEGORY_CONNECTION);
debug_set_level(DEBUG_LEVEL_ERROR);
debug_set_categories(DEBUG_CATEGORY_BGP);
utun_instance_set_tun_init_enabled(0);
/* ---------- Pre-generate 5 keypairs ---------- */

Loading…
Cancel
Save