Commit Graph
818 Commits
Author SHA1 Message Date
Evgeny 075d97a459 fix .gitignore: stop ignoring test_*.c source files; add missing test_ipv6_sockets, test_tcp_proxy, test_radix, test_route6_lib sources 2026-05-10 00:34:28 +03:00
Evgeny c24a6367cc add IPv6 default route interface auto-detection for permanent/temporary IPv6 without netif
- get_default_route_netif_index(): UDP connect trick + getifaddrs to find default route iface
- etcp_socket_add(): auto-detect netif_index when not specified in config
- queue_new() API: explicit index_offset/index_size params instead of implicit from hash_size
- radix: cleanup types (uint8_t*), replace bzero/bcmp with memset/memcmp, remove kernel ifdefs
- route6_lib: new IPv6 routing library + get_node_v6_routes()
2026-05-10 00:05:23 +03:00
Evgeny 9869cf66f1 add etcp_router service routing layer + remote TCP proxy (uip+socket via router)
etcp_router: routable service packets with dst/src node_id
- etcp_router_bind/unbind: per-instance service handler registry
- etcp_route_send: send to node by id via BGP routing
- multi-hop forwarding through intermediate nodes
- loopback optimization (dst==self dispatches directly)

remote_proxy: exit node creating OS sockets on demand
- handles CONNECT/DATA/CLOSE via etcp_router
- non-blocking socket connect with uasync callbacks
- echo back response data to requesting node

tcp_proxy: etcp_transport for remote proxy
- via_node_id in mapping selects between sock/etcp transport
- unified handler for both tcp_proxy and remote_proxy roles
- config: forward = port -> ip:port via NODE_HEX [remote_proxy] section

tests: test_etcp_router (20 pkts bidirectional), test_remote_proxy (echo)
2026-04-28 20:01:12 +03:00
Evgeny 171e70a810 add inflight data return to normalizer on reinit + configurable inflight min/max limits + test 2026-04-27 23:50:52 +03:00
Evgeny dea3a39598 fix: reconnect test — cancel timers in conn_reset, add init_timer cancel on link_state=3, add reinit resilience to test
- etcp_conn_reset: cancel retrans_timer/ack_resp_timer via uasync_cancel_timeout
  before nulling (was leaking timer handles, confirmed by 'Timer leak: diff')
- etcp_connections: cancel link->init_timer explicitly when link_state becomes 3
  on both client and server INIT_RESPONSE paths (prevents spurious INIT after
  connection is established that could trigger cascading reinits)
- etcp_connections: remove duplicate conn->session_id assignment in new conn path
  (session_id is set later via conn_reinit flow)
- pkt_normalizer: resume output queue callback after pn_reset
- Add test_etcp_reconnect with reinit detection — monitors conn->reinit_count
  and restarts data transfer if reinit occurs during active phase
- Add etcp_dump.c/h — ETCP connection state dump utility for debugging
2026-04-27 19:46:45 +03:00
Evgeny 0f8df44b2b build: out-of-tree VPATH build, tests run once with colored timing
- Root Makefile: hand-written bootstrap delegating to build/
- Makefile.am: simplified to SUBDIRS + clean-local
- build.sh: delegates to make, autoreconf only
- tests: removed duplicate TESTS run, added colored [PASS]/[FAIL]/[SKIP] with timing
- .gitignore: added /build/ for out-of-tree artifacts

Result: 0 .o files in source dirs, 29/29 tests pass
2026-04-27 13:48:22 +03:00
Evgeny d0d4199273 etcp: unified send hook via etcp_udp_send, remove loss_rate, add dummynet_filter inline mode, rewrite BGP test
- Add etcp_udp_send_fn_t hook typedef, send_hook/send_hook_ctx fields to ETCP_LINK
- Implement etcp_udp_send() wrapper — all UDP sends go through one point
- Remove loss_rate from ETCP_SOCKET, CFG_SERVER, config parser, send path
- Add dummynet_filter: inline send-hook with loss/delay, no proxy socket needed
- Rewrite test_bgp_route_exchange: 3-node chain A(2 links)↔B↔C, 7 phases
  with dummynet_filter-based link failure/recovery simulation
- Clean up tests: remove skeleton test_routing_mesh, 6 debug/stale test files
- Refactor test_etcp_simple_traffic and test_pkt_normalizer_etcp (remove debug spam)
- Fix test_etcp_two_instances: remove private field access, fix false PASS on timeout
2026-04-27 12:43:52 +03:00
Evgeny 61fee27478 congestion: burst-based BW measurement + adaptive inflight (slow start/cong avoidance/loss response)
New features:
- get_time_us() in lib/u_async.c/h for µs-precision timing
- Burst measurement (ETCP_SECTION_MEAS_TS 0x07, MEAS_RESP 0x08, FILLER 0x09)
  - 12 MTU packets sent at line rate, receiver measures inter-packet gaps
  - Burst triggered when link saturated + min 500ms interval
  - Result: measured BW -> bandwidth for shaper, burst_target_bdp for window cap
- 3-phase adaptive inflight in link_stats_timer_cb:
  - Slow start: windows doubles each RTT, exits on loss/RTT spike/threshold
  - Congestion avoidance: additive increase, proportional RTT shrink, multiplicative loss shrink
  - Burst target cap: inflight_lim <= burst_target_bdp * 1.1
- Dynamic optimal_inflight = sum(link->inflight_lim_bytes), recalculated on change
- Adaptive win_timebase = rtt/2 (was hardcoded 10ms)

Fixes:
- dummynet.c: shaper formula fixed (80000 -> 80)
- dummynet.c: queue_data_put call fixed (3 args -> 2)
- etcp.c: SIZE ERROR format string (missing log_name argument)
- etcp_request_pkt: FILLER leaves room for PAYLOAD overhead

Tests:
- test_etcp_congestion.c: single-threaded, 5-phase BW/delay/loss test
  - sender + receiver + dummynet in one uasync
  - CSV metrics output every 100ms
- All 29 existing tests pass
2026-04-26 00:17:32 +03:00
Evgeny 9c509d4c86 add connectivity probing + NAT type rename OPEN->EIM, RESTRICTED->STRICT
- Rename NAT types: OPEN->EIM, RESTRICTED->STRICT across all code
- Add flat addr list {type,ip,port,socket_id} to NODEINFO (NODEINFO_IPV4_ADDR)
- Add NODEINFO_IPV4_SOCKET_META for per-socket metadata
- Add NODE_CONNECTIVITY with per-type probe status and min_rtt
- New module: route_connectivity.c/h (probing engine with socket fallback)
- STRICT verified addresses excluded from NODEINFO broadcast
- Trigger probing on new/updated BGP node, cancel on remove/withdraw
- Update NAT type names in etcpmon GUI
2026-04-25 18:41:45 +03:00
Evgeny 2fadec947b Fix: Split multi-var init and rename s_net/d_net to src_net/dst_net to avoid MSYS2 S_un macro conflict 2026-04-25 01:21:38 +03:00
Evgeny 595d2b177b Refactor: Replace custom tc_hton*/tc_ntoh* with standard htobe16/be16toh/htobe32/be32toh, move htobe16/be16toh to platform_compat.h 2026-04-25 01:16:09 +03:00
Evgeny aafa0cfcab Fix: Add portable tc_htonl/tc_htons/tc_ntohl/tc_ntohs macros, replace winsock2-incompatible hton*/nto* in NAT test files 2026-04-25 00:52:33 +03:00
Evgeny 3dd8fa4085 Fix: Remove arpa/inet.h from test_nat_stress.c and test_nat_transport.c, use platform_compat.h for byte-order funcs 2026-04-25 00:50:46 +03:00
Evgeny ba30f2adc6 Fix: Remove arpa/inet.h from test_nat_engine.c, use platform_compat.h for byte-order funcs 2026-04-25 00:48:40 +03:00
Evgeny 907ef244c6 NAT: Full Cone (EIM) NAT with ETCP_ID_NAT protocol, per-node routing, and comprehensive test suite
- New ETCP protocol ETCP_ID_NAT (0x02) for NAT traffic between nodes
- eim_nat.c/h: Pure NAT engine (table, port allocation, checksum updates, egress/ingress)
- nat_transport.c/h: Transport layer (NAT TUN, ETCP binding, client/provider roles)
- route_bgp_find_conn_for_node(): shared utility for optimal connection lookup
- tun_init_nat(): dedicated TUN creation for NAT
- Config: [nat] section with tun_ip, port_start/end, nat_via, forward rules
- Fix: csum_update_ip/transport use htonl() halves (correct on LE systems)
- Fix: IP_FRAG_MF_MASK changed to 0x2000 (after ntohs, MF is bit 13)
- Tests: 26 engine unit + 4 transport integration + 7 stress (29 total)
2026-04-25 00:43:25 +03:00
Evgeny 11d511797a Fix compiler warnings: remove incorrect address-of operator and add getpid for Windows
- etcp_connections.c:1142: remove & before addr in sockaddr_storage_to_str call
- test_etcp_simple_traffic.c: add #include <process.h> and #define getpid _getpid for Windows
2026-04-24 14:48:29 +03:00
Evgeny e39979bfac Config: Added [allowed_keys] section for client public key authorization on server
- Added CFG_ALLOWED_KEY struct with binary key storage (64 bytes) for fast memcmp comparison
- Implemented parsing of [allowed_keys] section with allow_all flag and per-key entries
- Added key validation in etcp_connections.c server handler (errorcode=8 for rejected keys)
- Default behavior: deny all if [allowed_keys] section is missing or allow_all=0 with no keys
- Added proper memory cleanup and debug logging for allowed_keys configuration
- Updated all test configs to include [allowed_keys] allow_all=1 for backward compatibility
2026-04-24 00:16:30 +03:00
Evgeny a3063ea47a NODEINFO: Add nat_addr/nat_port fields, use interface_addr for addr/port 2026-04-23 23:21:12 +03:00
Evgeny 57dba26e7c GUI: поле действия и кнопка Send для отправки команд в utun
- Добавлен ETCPMON_CMD_ACTION в протокол (32 байта текст)
- В GUI добавлено поле ввода и кнопка Send правее блока Sockets
- Добавлен etcpmon_client_send_action для отправки команд
- Обработка action 'nat' в control_server: запускает NAT check для всех линков
- Сделана route_bgp_start_link_nat_check не-static
- Добавлена route_bgp_request_nat_check_all
- Исправлен баг route_ping.c (request_id -> nonce)
- Исправлена линковка tests/Makefile.am
2026-04-22 20:52:30 +03:00
Evgeny 0984ea749a Исправлен byte order для IP адресов в NAT detection flow
- etcp_connections.c: парсинг NAT IP через memcpy (сохраняет NBO)
- route_bgp.c: убраны ntohl() для IP в NAT detection и route_bgp_send_nat_info
- route_ping.c: убран htonl() для IP в ping request
- тесты: обновлены ожидания NBO для nat_ip
2026-04-22 18:23:32 +03:00
Evgeny cbde38d52a Remove accidentally committed binaries and temp files 2026-04-22 11:45:54 +03:00
Evgeny c136db5666 Fix: round-robin link selection + byte order fixes + local_node update 2026-04-22 11:39:50 +03:00
Evgeny 77fd7c19de WIP: debug byte order diagnostics 2026-04-22 02:14:47 +03:00
Evgeny d74ab1c1c6 Add name parameter to uasync_set_timeout for timer identification in dumps 2026-04-21 19:06:45 +03:00
Evgeny 54982f2dfb ping 2026-04-14 19:19:41 +03:00
Evgeny 7cdb84c7a2 Add NAT detection with burst ping, test timing, fix port conflicts
- route_ping.c: burst mode - send next ping immediately on response
- route_ping.h: add target_ipv4/target_port/pubkey to BGP_PING_REQUEST
- test_nat_detection.c: add test for ping without embedded pubkey
- test_etcp_simple_traffic.c: use dynamic ports + fix timebase units
- Makefile.am: show test execution time in ms
2026-04-14 14:25:36 +03:00
Evgeny 31eb4a5d26 Add NAT detection with STUN-like ping and integration test 2026-04-14 12:02:43 +03:00
Evgeny b613e3a8e0 serializer 2026-04-14 02:03:59 +03:00
Evgeny 5dc8ad6784 1 2026-04-13 23:56:19 +03:00
Evgeny 2903b82941 Add test_serialize to Makefile and include serialize in libuasync.a
- tests/Makefile.am: add test_serialize to check_PROGRAMS
- lib/Makefile.am: add serialize.c/h to libuasync_a_SOURCES
2026-04-13 23:50:32 +03:00
Evgeny dba092d88b Add serialize library for binary serialization with dynamic allocation
- serialize.h/c: universal binary serialization for structures with
  variable-length fields (ASCIIZ, ARRAY) using pointers
- Auto allocation via u_malloc during deserialization
- Support for header (arbitrary bytes at buffer start)
- serialize_encode(): serialize structure to buffer
- serialize_decode(): deserialize from buffer (without header)
- serialize_free(): free structure and all its pointers
- tests/test_serialize.c: unit tests
2026-04-13 23:08:54 +03:00
Evgeny 3b31821316 Add test_route_ping.c test file 2026-04-13 20:42:47 +03:00
Evgeny ffbc0da86f add ping 2026-04-13 20:12:13 +03:00
Evgeny 389124d327 Fix test_bgp_route_exchange: correct IP byte order constants and platform_compat.h endian include 2026-04-13 14:05:32 +03:00
Evgeny 05323ded60 WIP: backup before debugging test_bgp_route_exchange 2026-04-13 13:55:21 +03:00
Evgeny 07306e378b backup: state before full initialization for ping test with real links 2026-04-13 02:09:53 +03:00
Evgeny feb8024506 1 2026-03-31 13:37:49 +03:00
Evgeny 9f13cf5459 route redesign + tests 2026-03-30 18:26:56 +03:00
Evgeny be6058c642 backup: before plan 1 fix for route_lib test (non-overlapping subnets) 2026-03-30 18:25:47 +03:00
Evgeny 27618217cc fix: update tests for new NODEINFO routing API
- Added route_node.o to test linking
- Simplified test_route_lib to avoid old API calls
- Minor fixes to build system

Branch: feature/nodeinfo-routing
2026-03-29 20:55:40 +03:00
Evgeny 097e1acc6d queue: add variable size hash
bgp: add to headers new node info
2026-03-28 21:52:46 +03:00
Evgeny 9517454ee6 firewall + random init pkt size 2026-03-26 22:42:22 +03:00
Evgeny 46b62e2e77 1 2026-03-25 23:33:11 +03:00
Evgeny 98f886b8a8 test fix, log update 2026-03-25 22:49:57 +03:00
Evgeny 12ba3b9719 backup: before adding inflight bytes limit to loadbalancer 2026-03-23 14:28:32 +03:00
Evgeny 7261e596eb fix: improve test_routing_mesh and fix duplicate init_connections in test_etcp_two_instances
- Refactored test_routing_mesh to use proper ETCP + normalizer flow
- Removed duplicate init_connections() calls that caused 'Address already in use'
- Improved error reporting in etcp_link_new()
- Test now respects single mainloop architecture
2026-03-23 01:56:17 +03:00
Evgeny 0d9c18c653 conn fix 2026-03-13 11:28:24 +03:00
Evgeny ef75d20d0f 1 2026-03-13 00:19:43 +03:00
jeka e8b6153297 bugfix 2026-03-12 04:36:45 +03:00
jeka aa5171bcd1 route improvements 2026-03-12 02:57:38 +03:00