=== BGP Route Exchange Test === [03:05:50-854.046] [INFO] [8] (test_bgp_route_exchange.c:321) main() Creating server instance... [CONFIG DEBUG] Opening config file: /tmp/utun_bgp_test_BzwJMx/server.conf [CONFIG DEBUG] Successfully opened config file [CONFIG DEBUG] Checking config - priv_key='67b705a92b41bcaae105af2d6a17743faa7b26ccebba8b3b9b0af05e9cd1d5fb' (len=64), pub_key='1c55e4ccae7c4470707759086738b10681bf88b81f198cc2ab54a647d1556e17c65e6b1833e0c771e5a39382c03067c388915a4c732191bc130480f20f8e00b9' (len=128), node_id=1229782938247303441 [CONFIG DEBUG] Validation results - need_priv_key=0, need_pub_key=0, need_node_id=0 [CONFIG DEBUG] Opening config file: /tmp/utun_bgp_test_BzwJMx/server.conf [CONFIG DEBUG] Successfully opened config file [03:05:50-854.164] [INFO] [512] (routing.c:272) routing_create() Routing module initialized for instance [03:05:50-854.169] [INFO] [512] (utun_instance.c:91) utun_instance_create() Routing module created [03:05:50-854.174] [INFO] [512] (route_lib.c:379) route_table_insert() Route inserted: 0.11.168.192/24 (LOCAL) [03:05:50-854.178] [INFO] [512] (utun_instance.c:110) utun_instance_create() Added local route: 192.168.11.0/24 [03:05:50-854.181] [INFO] [512] (route_lib.c:379) route_table_insert() Route inserted: 0.10.168.192/24 (LOCAL) [03:05:50-854.185] [INFO] [512] (utun_instance.c:110) utun_instance_create() Added local route: 192.168.10.0/24 [03:05:50-854.188] [INFO] [4096] (route_bgp.c:382) route_bgp_init() Route change callback registered [03:05:50-854.192] [INFO] [4096] (route_bgp.c:385) route_bgp_init() BGP module initialized [03:05:50-854.195] [INFO] [4096] (utun_instance.c:143) utun_instance_create() BGP module initialized DEBUG: utun_instance_init() calling init_connections() for instance 0x5a72b6bb9cd0 [03:05:50-854.218] [INFO] [8] (etcp_connections.c:340) etcp_socket_add() [ETCP] Successfully bound socket to local address, family=2 [03:05:50-854.224] [INFO] [8] (etcp_connections.c:364) etcp_socket_add() [ETCP] Socket 0x5a72b6bbb530 registered and active DEBUG: init_connections() returned: 0 DEBUG: Connections initialized successfully, count=0 [03:05:50-854.230] [INFO] [8] (test_bgp_route_exchange.c:335) main() Server instance ready (node_id=1111111111111111, bgp=0x5a72b6bb9c90) [03:05:50-854.234] [INFO] [8] (test_bgp_route_exchange.c:339) main() Creating client instance... [CONFIG DEBUG] Opening config file: /tmp/utun_bgp_test_BzwJMx/client.conf [CONFIG DEBUG] Successfully opened config file [CONFIG DEBUG] Checking config - priv_key='4813d31d28b7e9829247f488c6be7672f2bdf61b2508333128e386d1759afed2' (len=64), pub_key='c594f33c91f3a2222795c2c110c527bf214ad1009197ce14556cb13df3c461b3c373bed8f205a8dd1fc0c364f90bf471d7c6f5db49564c33e4235d268569ac71' (len=128), node_id=2459565876494606882 [CONFIG DEBUG] Validation results - need_priv_key=0, need_pub_key=0, need_node_id=0 [CONFIG DEBUG] Opening config file: /tmp/utun_bgp_test_BzwJMx/client.conf [CONFIG DEBUG] Successfully opened config file [03:05:50-854.390] [INFO] [512] (routing.c:272) routing_create() Routing module initialized for instance [03:05:50-854.400] [INFO] [512] (utun_instance.c:91) utun_instance_create() Routing module created [03:05:50-854.404] [INFO] [512] (route_lib.c:379) route_table_insert() Route inserted: 0.21.168.192/24 (LOCAL) [03:05:50-854.408] [INFO] [512] (utun_instance.c:110) utun_instance_create() Added local route: 192.168.21.0/24 [03:05:50-854.411] [INFO] [512] (route_lib.c:379) route_table_insert() Route inserted: 0.20.168.192/24 (LOCAL) [03:05:50-854.415] [INFO] [512] (utun_instance.c:110) utun_instance_create() Added local route: 192.168.20.0/24 [03:05:50-854.418] [INFO] [4096] (route_bgp.c:382) route_bgp_init() Route change callback registered [03:05:50-854.421] [INFO] [4096] (route_bgp.c:385) route_bgp_init() BGP module initialized [03:05:50-854.424] [INFO] [4096] (utun_instance.c:143) utun_instance_create() BGP module initialized DEBUG: utun_instance_init() calling init_connections() for instance 0x5a72b6bbe4f0 [03:05:50-854.437] [INFO] [8] (etcp_connections.c:340) etcp_socket_add() [ETCP] Successfully bound socket to local address, family=2 [03:05:50-854.447] [INFO] [8] (etcp_connections.c:364) etcp_socket_add() [ETCP] Socket 0x5a72b6bbf8a0 registered and active [03:05:50-854.854] [INFO] [8] (etcp_connections.c:88) etcp_link_send_init() [ETCP] INIT sending to 127.0.0.1:39011, link=0x5a72b6bd78f0 [03:05:50-854.860] [INFO] [8] (etcp_connections.c:485) etcp_encrypt_send() Encrypt start [03:05:50-855.654] [INFO] [8] (etcp_connections.c:487) etcp_encrypt_send() Encrypt end DEBUG: init_connections() returned: 0 DEBUG: Connections initialized successfully, count=1 [03:05:50-855.761] [INFO] [8] (test_bgp_route_exchange.c:353) main() Client instance ready (node_id=2222222222222222, bgp=0x5a72b6bbc060) [03:05:50-855.766] [INFO] [8] (test_bgp_route_exchange.c:357) main() Waiting for server initialization... [03:05:50-855.854] [INFO] [8] (etcp_connections.c:669) etcp_connections_read_callback_socket() [ETCP DEBUG] Send INIT RESPONSE [03:05:50-855.859] [INFO] [8] (etcp_connections.c:485) etcp_encrypt_send() Encrypt start [03:05:50-855.866] [INFO] [8] (etcp_connections.c:487) etcp_encrypt_send() Encrypt end [03:05:50-855.876] [INFO] [8] (etcp_loadbalancer.c:156) loadbalancer_link_ready() loadbalancer_link_ready: link=0x5a72b6c06520 now ready, notifying ETCP_CONN [03:05:50-855.881] [INFO] [4096] (route_bgp.c:452) route_bgp_new_conn() Added connection 0x5a72b6c072a0 to senders_list [03:05:50-855.885] [INFO] [4096] (route_bgp.c:338) route_bgp_send_table_to_conn_internal() Sending full routing table (2 routes) to connection [03:05:50-855.894] [INFO] [8] (etcp_connections.c:685) etcp_connections_read_callback_socket() Decrypt start [03:05:50-855.899] [INFO] [8] (etcp_connections.c:694) etcp_connections_read_callback_socket() Decrypt end [03:05:50-855.903] [INFO] [8] (etcp_loadbalancer.c:156) loadbalancer_link_ready() loadbalancer_link_ready: link=0x5a72b6bd78f0 now ready, notifying ETCP_CONN [03:05:50-855.906] [INFO] [4096] (route_bgp.c:452) route_bgp_new_conn() Added connection 0x5a72b6bc0040 to senders_list [03:05:50-855.910] [INFO] [4096] (route_bgp.c:338) route_bgp_send_table_to_conn_internal() Sending full routing table (2 routes) to connection [03:05:50-857.281] [INFO] [8] (etcp_connections.c:485) etcp_encrypt_send() Encrypt start [03:05:50-857.329] [INFO] [8] (etcp_connections.c:487) etcp_encrypt_send() Encrypt end [03:05:50-857.354] [INFO] [8] (etcp_connections.c:685) etcp_connections_read_callback_socket() Decrypt start [03:05:50-857.361] [INFO] [8] (etcp_connections.c:694) etcp_connections_read_callback_socket() Decrypt end [03:05:50-857.373] [INFO] [4096] (route_bgp.c:67) route_bgp_receive_cbk() Received BGP packet: subcmd=1, network=000ba8c0/24, node_id=1111111111111111 [03:05:50-857.378] [INFO] [512] (route_lib.c:379) route_table_insert() Route inserted: 0.11.168.192/24 (LEARNED) [03:05:50-857.382] [INFO] [4096] (route_bgp.c:101) route_bgp_receive_cbk() Added learned route: 000ba8c0/24 via node 1111111111111111 (hops=1) [03:05:50-857.386] [INFO] [4096] (route_bgp.c:67) route_bgp_receive_cbk() Received BGP packet: subcmd=1, network=000aa8c0/24, node_id=1111111111111111 [03:05:50-857.389] [INFO] [512] (route_lib.c:379) route_table_insert() Route inserted: 0.10.168.192/24 (LEARNED) [03:05:50-857.393] [INFO] [4096] (route_bgp.c:101) route_bgp_receive_cbk() Added learned route: 000aa8c0/24 via node 1111111111111111 (hops=1) [03:05:50-857.397] [INFO] [8] (etcp_connections.c:485) etcp_encrypt_send() Encrypt start [03:05:50-857.402] [INFO] [8] (etcp_connections.c:487) etcp_encrypt_send() Encrypt end [03:05:50-857.413] [INFO] [8] (etcp_connections.c:685) etcp_connections_read_callback_socket() Decrypt start [03:05:50-857.418] [INFO] [8] (etcp_connections.c:694) etcp_connections_read_callback_socket() Decrypt end [03:05:50-857.422] [INFO] [4096] (route_bgp.c:67) route_bgp_receive_cbk() Received BGP packet: subcmd=1, network=0015a8c0/24, node_id=2222222222222222 [03:05:50-857.426] [INFO] [512] (route_lib.c:379) route_table_insert() Route inserted: 0.21.168.192/24 (LEARNED) [03:05:50-857.430] [INFO] [4096] (route_bgp.c:101) route_bgp_receive_cbk() Added learned route: 0015a8c0/24 via node 2222222222222222 (hops=1) [03:05:50-857.440] [INFO] [4096] (route_bgp.c:67) route_bgp_receive_cbk() Received BGP packet: subcmd=1, network=0014a8c0/24, node_id=2222222222222222 [03:05:50-857.444] [INFO] [512] (route_lib.c:379) route_table_insert() Route inserted: 0.20.168.192/24 (LEARNED) [03:05:50-857.447] [INFO] [4096] (route_bgp.c:101) route_bgp_receive_cbk() Added learned route: 0014a8c0/24 via node 2222222222222222 (hops=1) [03:05:50-859.571] [INFO] [8] (etcp_connections.c:485) etcp_encrypt_send() Encrypt start [03:05:50-859.588] [INFO] [8] (etcp_connections.c:487) etcp_encrypt_send() Encrypt end [03:05:50-859.603] [INFO] [8] (etcp_connections.c:685) etcp_connections_read_callback_socket() Decrypt start [03:05:50-859.609] [INFO] [8] (etcp_connections.c:694) etcp_connections_read_callback_socket() Decrypt end [03:05:50-914.496] [INFO] [8] (test_bgp_route_exchange.c:363) main() Starting connection monitoring... [03:05:50-914.578] [INFO] [8] (test_bgp_route_exchange.c:368) main() Running event loop... [03:05:50-924.649] [INFO] [8] (test_bgp_route_exchange.c:245) monitor_connections() === Connection established! Waiting for BGP exchange... === [03:05:50-944.759] [INFO] [512] (test_bgp_route_exchange.c:255) monitor_connections() === Checking BGP route exchange === [03:05:50-944.814] [INFO] [512] (test_bgp_route_exchange.c:199) verify_bgp_exchange() === Verifying BGP Route Exchange === [03:05:50-944.819] [INFO] [512] (test_bgp_route_exchange.c:150) print_routing_table() === SERVER Routing Table (4 routes) === [03:05:50-944.824] [INFO] [512] (test_bgp_route_exchange.c:167) print_routing_table() Route 1: 0.11.168.192/24 [LOCAL] node_id=0000000000000000 hops=0 [03:05:50-944.828] [INFO] [512] (test_bgp_route_exchange.c:167) print_routing_table() Route 2: 0.10.168.192/24 [LOCAL] node_id=0000000000000000 hops=0 [03:05:50-944.832] [INFO] [512] (test_bgp_route_exchange.c:167) print_routing_table() Route 3: 0.21.168.192/24 [LEARNED] node_id=2222222222222222 hops=1 [03:05:50-944.835] [INFO] [512] (test_bgp_route_exchange.c:167) print_routing_table() Route 4: 0.20.168.192/24 [LEARNED] node_id=2222222222222222 hops=1 [03:05:50-944.838] [INFO] [512] (test_bgp_route_exchange.c:172) print_routing_table() ===================================== [03:05:50-944.841] [INFO] [512] (test_bgp_route_exchange.c:150) print_routing_table() === CLIENT Routing Table (4 routes) === [03:05:50-944.845] [INFO] [512] (test_bgp_route_exchange.c:167) print_routing_table() Route 1: 0.21.168.192/24 [LOCAL] node_id=0000000000000000 hops=0 [03:05:50-944.848] [INFO] [512] (test_bgp_route_exchange.c:167) print_routing_table() Route 2: 0.20.168.192/24 [LOCAL] node_id=0000000000000000 hops=0 [03:05:50-944.851] [INFO] [512] (test_bgp_route_exchange.c:167) print_routing_table() Route 3: 0.11.168.192/24 [LEARNED] node_id=1111111111111111 hops=1 [03:05:50-944.855] [INFO] [512] (test_bgp_route_exchange.c:167) print_routing_table() Route 4: 0.10.168.192/24 [LEARNED] node_id=1111111111111111 hops=1 [03:05:50-944.858] [INFO] [512] (test_bgp_route_exchange.c:172) print_routing_table() ===================================== [03:05:50-944.861] [INFO] [512] (test_bgp_route_exchange.c:206) verify_bgp_exchange() Checking server learned client's routes... [03:05:50-944.864] [INFO] [512] (test_bgp_route_exchange.c:212) verify_bgp_exchange() PASS: Server has learned route 192.168.20.0/24 [03:05:50-944.867] [INFO] [512] (test_bgp_route_exchange.c:219) verify_bgp_exchange() PASS: Server has learned route 192.168.21.0/24 [03:05:50-944.870] [INFO] [512] (test_bgp_route_exchange.c:225) verify_bgp_exchange() Checking client learned server's routes (disabled - server->client not implemented)... [03:05:50-944.873] [INFO] [512] (test_bgp_route_exchange.c:260) monitor_connections() === BGP ROUTE EXCHANGE SUCCESS === [03:05:50-944.876] [INFO] [8] (test_bgp_route_exchange.c:375) main() Cleaning up... [03:05:50-944.880] [INFO] [512] (test_bgp_route_exchange.c:150) print_routing_table() === SERVER (final) Routing Table (4 routes) === [03:05:50-944.900] [INFO] [512] (test_bgp_route_exchange.c:167) print_routing_table() Route 1: 0.11.168.192/24 [LOCAL] node_id=0000000000000000 hops=0 [03:05:50-944.903] [INFO] [512] (test_bgp_route_exchange.c:167) print_routing_table() Route 2: 0.10.168.192/24 [LOCAL] node_id=0000000000000000 hops=0 [03:05:50-944.907] [INFO] [512] (test_bgp_route_exchange.c:167) print_routing_table() Route 3: 0.21.168.192/24 [LEARNED] node_id=2222222222222222 hops=1 [03:05:50-944.910] [INFO] [512] (test_bgp_route_exchange.c:167) print_routing_table() Route 4: 0.20.168.192/24 [LEARNED] node_id=2222222222222222 hops=1 [03:05:50-944.913] [INFO] [512] (test_bgp_route_exchange.c:172) print_routing_table() ===================================== [03:05:50-944.916] [INFO] [512] (test_bgp_route_exchange.c:150) print_routing_table() === CLIENT (final) Routing Table (4 routes) === [03:05:50-944.919] [INFO] [512] (test_bgp_route_exchange.c:167) print_routing_table() Route 1: 0.21.168.192/24 [LOCAL] node_id=0000000000000000 hops=0 [03:05:50-944.922] [INFO] [512] (test_bgp_route_exchange.c:167) print_routing_table() Route 2: 0.20.168.192/24 [LOCAL] node_id=0000000000000000 hops=0 [03:05:50-944.926] [INFO] [512] (test_bgp_route_exchange.c:167) print_routing_table() Route 3: 0.11.168.192/24 [LEARNED] node_id=1111111111111111 hops=1 [03:05:50-944.929] [INFO] [512] (test_bgp_route_exchange.c:167) print_routing_table() Route 4: 0.10.168.192/24 [LEARNED] node_id=1111111111111111 hops=1 [03:05:50-944.932] [INFO] [512] (test_bgp_route_exchange.c:172) print_routing_table() ===================================== 🔍 [UTUN_INSTANCE LEAK DIAGNOSIS] Phase: BEFORE_CLEANUP Instance: 0x5a72b6bb9cd0 Node ID: 1229782938247303441 UA instance: 0x5a72b6bb9490 Running: 0 📊 STRUCTURE COUNTS: ETCP Sockets: 1 active ETCP Connections: 1 active ETCP Links: 2 total 🔧 RESOURCE STATUS: Memory Pool: ALLOCATED TUN Interface: NULL TUN FD: -1 Connections list: 0x5a72b6c072a0 ETCP Sockets list: 0x5a72b6bbb530 ⚠️ POTENTIAL LEAKS: ❌ Memory Pool not freed ❌ 1 ETCP sockets still allocated ❌ 1 ETCP connections still allocated ❌ 2 ETCP links still allocated 📋 RECOMMENDATIONS: → Call memory_pool_destroy() before freeing instance → Iterate and call etcp_socket_remove() for each socket → Iterate and call etcp_connection_close() for each connection [03:05:50-944.940] [INFO] [8] (etcp_connections.c:373) etcp_socket_remove() [ETCP] Removing socket 0x5a72b6bbb530, socket_id=0x5a72b6bb9540 [03:05:50-944.943] [INFO] [8] (etcp_connections.c:377) etcp_socket_remove() [ETCP] Removing socket from uasync, instance=0x5a72b6bb9cd0, ua=0x5a72b6bb9490 [03:05:50-944.953] [INFO] [8] (etcp_connections.c:380) etcp_socket_remove() [ETCP] Unregistered socket from uasync [03:05:50-944.973] [INFO] [8] (etcp_connections.c:385) etcp_socket_remove() [ETCP] Closed socket [03:05:50-944.978] [INFO] [4096] (route_bgp.c:471) route_bgp_remove_conn() Removing connection 0x5a72b6c072a0 from senders_list [03:05:50-944.981] [INFO] [4096] (route_bgp.c:200) route_bgp_send_withdraw_for_conn() Sending withdraw for routes via conn 0x5a72b6c072a0 to all peers [03:05:50-944.986] [INFO] [4096] (route_bgp.c:484) route_bgp_remove_conn() Connection 0x5a72b6c072a0 removed from senders_list [03:05:50-944.989] [INFO] [512] (route_lib.c:425) route_table_delete() Removed 2 routes for connection 0x5a72b6c072a0 [03:05:50-944.996] [INFO] [512] (routing.c:281) routing_destroy() Destroying routing module [03:05:50-945.000] [INFO] [4096] (utun_instance.c:198) utun_instance_destroy() Destroying BGP module [03:05:50-945.003] [INFO] [4096] (route_bgp.c:418) route_bgp_destroy() BGP module destroyed 🔍 [UTUN_INSTANCE LEAK DIAGNOSIS] Phase: BEFORE_CLEANUP Instance: 0x5a72b6bbe4f0 Node ID: 2459565876494606882 UA instance: 0x5a72b6bb9490 Running: 0 📊 STRUCTURE COUNTS: ETCP Sockets: 1 active ETCP Connections: 1 active ETCP Links: 2 total 🔧 RESOURCE STATUS: Memory Pool: ALLOCATED TUN Interface: NULL TUN FD: -1 Connections list: 0x5a72b6bc0040 ETCP Sockets list: 0x5a72b6bbf8a0 ⚠️ POTENTIAL LEAKS: ❌ Memory Pool not freed ❌ 1 ETCP sockets still allocated ❌ 1 ETCP connections still allocated ❌ 2 ETCP links still allocated 📋 RECOMMENDATIONS: → Call memory_pool_destroy() before freeing instance → Iterate and call etcp_socket_remove() for each socket → Iterate and call etcp_connection_close() for each connection [03:05:50-945.009] [INFO] [8] (etcp_connections.c:373) etcp_socket_remove() [ETCP] Removing socket 0x5a72b6bbf8a0, socket_id=0x5a72b6bb9588 [03:05:50-945.016] [INFO] [8] (etcp_connections.c:377) etcp_socket_remove() [ETCP] Removing socket from uasync, instance=0x5a72b6bbe4f0, ua=0x5a72b6bb9490 [03:05:50-945.020] [INFO] [8] (etcp_connections.c:380) etcp_socket_remove() [ETCP] Unregistered socket from uasync [03:05:50-945.028] [INFO] [8] (etcp_connections.c:385) etcp_socket_remove() [ETCP] Closed socket [03:05:50-945.031] [INFO] [4096] (route_bgp.c:471) route_bgp_remove_conn() Removing connection 0x5a72b6bc0040 from senders_list [03:05:50-945.034] [INFO] [4096] (route_bgp.c:200) route_bgp_send_withdraw_for_conn() Sending withdraw for routes via conn 0x5a72b6bc0040 to all peers [03:05:50-945.038] [INFO] [4096] (route_bgp.c:484) route_bgp_remove_conn() Connection 0x5a72b6bc0040 removed from senders_list [03:05:50-945.041] [INFO] [512] (route_lib.c:425) route_table_delete() Removed 2 routes for connection 0x5a72b6bc0040 [03:05:50-945.047] [INFO] [512] (routing.c:281) routing_destroy() Destroying routing module [03:05:50-945.050] [INFO] [4096] (utun_instance.c:198) utun_instance_destroy() Destroying BGP module [03:05:50-945.053] [INFO] [4096] (route_bgp.c:418) route_bgp_destroy() BGP module destroyed 🔍 BEFORE_DESTROY: UASYNC Resource Report for 0x5a72b6bb9490 Timer Statistics: allocated=12, freed=9, active=3 Socket Statistics: allocated=2, freed=2, active=0 Timer: node=0x5a72b6c06040, expires=1771113950958 ms, cancelled=0 Timer: node=0x5a72b6c06100, expires=1771113950958 ms, cancelled=0 Active timers in heap: 2 Socket array capacity: 16, active: 0 Total active sockets: 0 🔚 BEFORE_DESTROY: End of resource report === TEST PASSED === BGP route exchange working (client -> server direction)