Commit Graph
30 Commits
Author SHA1 Message Date
jeka 65b6b6c150 fix ack timestamp 2026-03-13 22:35:26 +03:00
jeka 60d97a90b1 1 2026-03-08 17:35:00 +03:00
jeka 2beb945bb0 1 2026-03-08 17:31:56 +03:00
jeka 8880db0ca2 1 2026-03-08 16:52:24 +03:00
jeka 5d4cef0c3e race condition fix (win tun) 2026-03-07 12:21:01 +03:00
jeka 066a9aa89e +memory check module
fix double free @routing
2026-03-06 15:55:16 +03:00
jeka 15c7968c8c mem 2026-03-06 01:36:57 +03:00
jeka de053a00c0 cleanup tests (winsock) 2026-03-04 17:27:33 +03:00
jeka c271084d35 tun/win шлёт в routing. 2026-03-02 20:22:34 +03:00
jeka 9d0223d3fa refactor 2026-02-28 15:15:34 +03:00
Evgeny 8502451ec7 compile fixes 2026-02-21 21:30:39 +03:00
jeka d10bddd1f7 Build: incremental build support, Windows uasync fixes, TUN cross-platform refactoring
- build.sh: added --full flag for full rebuild (autoreconf + configure + make)
- build_direct.sh: incremental compilation (skips unchanged files)
- build_full.bat: new Windows batch for full rebuild
- configure.ac: fixed Windows detection using AC_COMPILE_IFELSE
- lib/u_async.c/h: Windows wakeup socket support, uasync_post for thread-safe callbacks
- src/tun_if.c/h: cross-platform TUN refactoring, Windows read thread support
- src/tun_windows.c: Windows TUN implementation improvements
- src/control_server.c: removed premature return statement
- src/routing.c: include ordering fix
- src/utun.c: windows compat includes
- Deleted obsolete net_emulator/Makefile and tinycrypt/Makefile
2026-02-20 21:20:50 +03:00
jeka 734851329f Control: Add monitoring server with ETCP protocol support
- Implement control_server.c/h for monitoring and management
- Add Windows-compatible uasync_poll using select() instead of WSAPoll
- Fix Wintun adapter creation to open existing adapters first
- Add debug category for control server operations
- Update build files to include control server in compilation
- Add test_control_server to test suite
2026-02-19 01:24:42 +03:00
jeka 78dfdde400 Fix Windows test failures: proper WSAPoll error handling and FD_SETSIZE check 2026-02-16 10:33:43 +03:00
jeka 6dfeac03a8 1 2026-02-16 08:44:05 +03:00
jeka c8af35c4b9 Fix u_async: Windows socket registration, timers, and poll issues
- Remove FD_SETSIZE check for Windows sockets (can have any value)
- Fix process_timeouts to handle all expired timers (continue instead of break)
- Handle case when no sockets to poll (sleep instead of calling poll)
- Disable wakeup pipe on Windows (incompatible with WSAPoll)
- Add gettimeofday and ssize_t implementations for Windows
2026-02-15 17:38:45 +03:00
Evgeny 0c43a633b9 Add platform_compat.h for Windows POSIX compatibility
- Add platform_compat.h with Windows implementations of:
  * gettimeofday() using GetSystemTimeAsFileTime
  * poll() using select()
  * pipe() using _pipe()
  * fcntl() using ioctlsocket for O_NONBLOCK
  * pollfd structure and POLL* constants
  * strcasecmp/strncasecmp macros

- Update debug_config.c and u_async.c/h to use platform_compat.h
- Remove POSIX-specific headers (arpa/inet.h, sys/time.h, etc.)
- All 22 tests pass on Linux
- Fixes build errors on Windows MSYS2
2026-02-15 02:46:41 +03:00
Evgeny 3f1d4077e9 Add cross-platform socket compatibility layer for Windows support
- Add socket_compat.h/c with platform abstraction for POSIX/Windows
- socket_t typedef: int on POSIX, SOCKET on Windows
- Add socket_platform_init/cleanup for WSAStartup on Windows
- Add socket operations: create_udp, sendto, recvfrom, set_nonblocking
- Add socket options: set_buffers, set_reuseaddr, set_mark (Linux), bind_to_device (Linux)
- Update u_async: add socket_t support with uasync_add_socket_t/remove_socket_t
- Update ETCP: use socket_t and socket_compat functions
- Add DEBUG_CATEGORY_SOCKET for socket debugging
- All 22 tests pass on Linux
- MSYS2 UCRT64 compatible
2026-02-15 01:01:35 +03:00
Evgeny 994a4bf779 Fix ETCP timestamp overflow bug and enable epoll for Linux 2026-02-05 03:47:34 +03:00
Evgeny acd48f99d1 Add epoll support for Linux with poll() fallback for other systems 2026-02-05 03:24:28 +03:00
Evgeny 4f287c711f Optimize uasync_poll: cache pollfd array, add active_indices for O(1) socket traversal 2026-02-05 03:13:23 +03:00
Evgeny 5840e77e1e Fix test_pkt_normalizer_etcp: fixed packet normalizer and test verification logic
- Fixed pkt_normalizer.c to send packets immediately instead of buffering
- Added queue_resume_callback() call in etcp.c after adding to output_queue
- Updated test to use simple checksum verification instead of pattern-based
- Added strict sequence order checking in test
- Reduced MAX_TEST_PACKET_SIZE to 1400 to fit in normalizer fragment
- Reduced TOTAL_PACKETS to 10 and TEST_TIMEOUT_MS to 5s for faster testing
2026-02-03 23:54:15 +03:00
Evgeny 41626a02c3 Fix ll_queue callback signature and add debug utilities
Changes:
- ll_queue callback now receives only queue pointer and arg (no data)
- Added log_dump and addr_to_string utility functions
- Removed temporary backup files
- Updated AGENTS.md with additional guidelines
- Fixed compiler warnings in etcp.c and pkt_normalizer.c
2026-01-27 22:43:18 +03:00
Evgeny edba76c4ed ll_queue: fix pointer arithmetic (xxx=0), callback now receives struct ll_entry*
- Change xxx from 1 to 0, fixing pointer arithmetic in queue_resume_timeout_cb
- Update comments: callback receives struct ll_entry* not user data
- Rename payload field to data in struct ll_entry
- etcp: fix INFLIGHT_PACKET to ACK_PACKET type in etcp_conn_input
- debug: remove excessive DEBUG_ERROR/DEBUG_DEBUG messages
- tests: rewrite test_ll_queue.c for new architecture
2026-01-27 13:39:42 +03:00
Evgeny 1bafe6a681 Backup before fixing etcp_connections list addition 2026-01-26 17:40:51 +03:00
Evgeny 69ed944ce4 Fix uasync socket counting bug and add lookup function
Complete fix for use-after-free bug in uasync tests:

Library Changes:
- Added uasync_lookup_socket() function for safe socket lookup by FD
- Function returns current pointer even after memory reallocation
- Maintains full backward compatibility with existing API

Test Changes:
- Modified test to store file descriptors instead of raw pointers
- Uses lookup function to get current pointers during removal
- Eliminates stale pointer issues after socket array growth

Results:
- test_u_async_performance: 25/25 sockets successfully removed (was failing)
- test_u_async_comprehensive: PASS
- No memory leaks - clean 25/25 socket statistics
- All uasync tests now pass without corruption

Technical Details:
- Root cause: realloc() moved memory, making stored pointers invalid
- Solution: Store FDs, lookup current pointers when needed
- Minimal changes: only added necessary lookup function
- Backward compatible: existing code continues to work
2026-01-25 14:43:58 +03:00
Evgeny d74f76a5a0 Fix: Resolved double free in timeout_heap_pop() and test_etcp_simple_traffic bind conflict
- Fixed incorrect init_connections() call in test_etcp_simple_traffic.c (was calling server_instance instead of client_instance)
- Fixed double free in timeout_heap_pop() when handling deleted elements
- Enhanced NULL pointer safety in uasync_print_resources() by removing complex heap manipulation
- Added debug logging to timeout_heap_pop() for better error tracking

Test results: test_etcp_simple_traffic now passes without double free errors
2026-01-25 10:47:02 +03:00
Evgeny f1a76c9d30 Fix memory leaks and crashes in ETCP tests
✅ Fixed critical segmentation fault (SIGABRT) in test_etcp_two_instances
✅ Added comprehensive timer debug logging with DEBUG_CATEGORY_TIMERS
✅ Created uasync_print_resources() function for resource diagnostics
✅ Created utun_instance_diagnose_leaks() function for leak analysis
✅ Fixed cleanup order - cancel timers before destroying uasync instances
✅ Fixed timer cancellation to properly update counters
✅ Fixed socket cleanup to unregister from uasync before destruction
✅ Added detailed diagnostic output for memory leak tracking
✅ All tests now pass without crashes

Key fixes:
- Fixed use-after-free in test cleanup sequence
- Added proper timer leak detection and cleanup
- Enhanced debug capabilities for future debugging
- Fixed ETCP socket cleanup to prevent resource leaks

The test_etcp_two_instances now runs successfully without segmentation faults.
2026-01-22 00:57:45 +03:00
Evgeny 3f7fd9f8ad Сохранить текущее состояние перед исправлением компиляционных ошибок 2026-01-19 23:10:44 +03:00
Evgeny 3f0a23aa93 Fix build: rename u_async to lib, add missing constants, out-of-tree build support 2026-01-18 16:18:28 +03:00