Evgeny
b1353df5f6
etcpmon: widen debug level labels by 30% and shift radio buttons right
2026-06-02 22:16:37 +03:00
Evgeny
1d859b3fbb
etcpmon: fix autoradio button groups and add missing ETCPROUTE category
2026-06-02 22:13:18 +03:00
Evgeny
58bc8e9df0
fix: move debug logs before async operations (queue_put, timer_set, resume) for meaningful log ordering
2026-06-02 21:53:51 +03:00
Evgeny
52a4f853a6
1
2026-06-02 21:19:07 +03:00
Evgeny
4b792de7b8
1
2026-06-02 21:05:06 +03:00
Evgeny
a95de99151
etcpmon: Debug Levels block moved to right column, global radio labels removed, columns narrowed
2026-06-02 19:24:49 +03:00
Evgeny
64e6d1df40
proxy: rename + simplify + backpressure
...
- tcp_proxy/remote_proxy → tcp_proxy_client/tcp_proxy_server
- Все proxy файлы перенесены в src/proxy/
- Конфиг: [tcp_proxy]→[tcp_proxy_client], [remote_proxy]→[tcp_proxy_server]
- Убран subcmd CONNECTED (0x02) — клиент шлёт DATA сразу после CONNECT
- Backpressure: etcp_router_waiter_register/cancel через ll_queue threshold waiter
- Клиент: recv_cb send fail → tx_buf+waiter, не tcp_recved() (окно lwIP=0)
- Сервер: read_cb send fail → pause_buf+waiter, пауза read_id
- CLOSE/ERROR отправляется только после drain всех очередей
- Fail: conn не найден/closed → send ERROR вместо CLOSE/silent drop
- PROTOCOL.md: полная архитектура с диаграммами состояний и потоков
2026-06-02 18:02:37 +03:00
Evgeny
f6e67b149d
remote_proxy: гарантированная доставка CLOSE/ERROR обратно (exit→client) через retry-таймер
...
- remote_proxy_conn: close_pending, close_timer, close_backoff
- rp_send_close/rp_send_error: при сбое etcp_route_send → close_pending=1 + таймер с backoff
- rp_close_retry_cb: повторная отправка CLOSE/ERROR с экспоненциальным backoff (50→5000 tb)
- rp_conn_free: очистка close_timer
2026-06-01 23:31:39 +03:00
Evgeny
a640cebce9
tcp_proxy: гарантированная доставка CLOSE/ERROR через retry при сбое маршрута
...
- proxy_conn.close_pending: флаг недоставленного CLOSE/ERROR
- send_close/send_error: при возврате -1 выставляют close_pending=1
- proxy_poll_cb: периодический retry close_pending → CLOSE дойдёт при восстановлении ETCP
- proxy_recv_cb: проверка !close_pending перед повторной отправкой close
2026-06-01 23:26:15 +03:00
Evgeny
94286de4ed
tcp_proxy: не слать данные в lwip после закрытия TUN-стороны (tun_closed)
...
- handle_data: добавить pc->tun_closed в проверку сброса данных от exit
- proxy_feed_from_transport: не писать в PCB после tun_closed
- предотвращает ERR_RST (-14) при записи в TIME_WAIT PCB
2026-06-01 22:59:20 +03:00
Evgeny
246cdc05dc
etcpmon: исправить синтаксис — orphaned код перенесён внутрь функции etcpmon_client_add_to_history
2026-06-01 20:31:52 +03:00
Evgeny
71b5173123
etcp: адаптивный keepalive — отдельная команда ETCP_KEEPALIVE с period_ms
...
- ETCP_KEEPALIVE=0x08, формат: [0x08][period_lo][period_hi]
- link->ka_period_ms: 200ms при трафике, ×1.05+1 в idle, потолок 10s
- keepalive_timeout = peer_period * KA_TIMEOUT_MULT(10)
- приём KA обновляет keepalive_timeout адаптивно (2000ms→100000ms)
- флаг recv_keepalive по-прежнему в flag_up для быстрого сигнала
2026-06-01 20:15:06 +03:00
Evgeny
665f9b43d0
etcp: link_status = remote_keepalive && recv_keepalive (вместо только remote)
...
- link_status теперь требует двусторонней слышимости: remote && local
- recv_keepalive восстанавливается ДО вычисления link_status (избегает заклинивания)
- loadbalancer_link_ready по переходу 0→1 с проверкой was_up
2026-06-01 19:43:39 +03:00
Evgeny
d480dca13f
bbr: исправить бесконечную рекурсию в bbr_now — bbr_now(bbr) → get_time_tb()
2026-06-01 18:28:02 +03:00
Evgeny
dc1680159d
bbr: исправить отображение сырых BW-значений (bw_latest/bw_lo/bw_hi) с /125 на /2097
...
BW_RAW_TO_KBPS = bw_raw * 8000 / BW_UNIT = bw_raw / 2097.152
pacing_rate / 125 остаётся без изменений (уже в bytes/sec после bbr_rate_bytes_per_sec)
2026-06-01 18:13:07 +03:00
Evgeny
201df616f4
bbr: исправить передачу потерь в BBR + пол для cwnd на уровне BBR_CWND_MIN_TARGET*mss
...
- etcp.c: rs->lost из link->bbr_loss_since_ack (был хардкод 0), вызов bbr_note_loss при ретрансмите
- etcp_connections.h: поле bbr_loss_since_ack для per-link учёта потерь в байтах
- etcp_bbr.c: везде где BBR_CWND_MIN_TARGET — умножить на mss (юнит-мизматч пакеты/байты)
- bbr_quantization_budget, bbr_set_cwnd, bbr_bound_cwnd_for_inflight_model, bbr_probe_rtt_cwnd
- bbr_init_lower_bounds: инициализация inflight_hi из cwnd (был ~0U навсегда)
- control_server.c + etcpmon: экспорт BBR-метрик (bw_hi/lo, inflight_hi/lo, режим, потери)
- tests/bbr_integration: интеграционный тест BBR (15с, 50ms/5%loss/1Mbit) с таблицей метрик
- устранён death spiral BBR при высоких потерях: cwnd теперь не падает ниже 4*mss
2026-06-01 17:50:16 +03:00
Evgeny
e709a115ba
congestion: заменить AIMD на BBR v3 (per-link), добавить юнит-тесты BBR
...
- Новые файлы: src/etcp_bbr.h/c — полный порт BBR v3 из BBR/bbr_v3.c (референс сохранён)
- struct ETCP_LINK: удалены AIMD-поля (rtt_history, rtt_swm, stat_win, stats_timer, inflight_phase...), добавлены bbr*, delivered_bytes, bbr_pacing_rate
- struct INFLIGHT_PACKET: +3 поля для rate_sample (delivered_at_send, inflight_at_send, is_app_limited)
- etcp_ack_recv: вызов bbr_main() с rate_sample, обновление inflight_lim_bytes и pacing
- etcp_request_pkt: заполнение BBR rate_sample полей при отправке
- Шейпер: bandwidth обновляется из bbr_pacing_rate
- Конфиг: inflight_min/max заменены на bbr_max_cwnd
- Дамп: BBR поля (mode, cycle, pacing, min_rtt_us, bw_hi/lo, inflight_hi/lo)
- Time injection: bbr->now_tb для детерминированных тестов
- tests/test_etcp_bbr.c: 8 юнит-тестов (init, startup, full_bw/drain, loss, cwnd cap, loss cut, fast_path, probe_rtt)
- Отключены test_etcp_congestion и test_etcp_reinit_inflight (старый congestion control)
- 40/40 тестов пройдено
2026-06-01 12:58:31 +03:00
Evgeny
23819f0c9f
test_etcp_router_unit: fix FAIL macro — bare return in non-void function
2026-06-01 10:39:33 +03:00
Evgeny
256409eaea
debug: выделить link keepalive в отдельную категорию KEEPALIVE (21), добавить DEBUG_DEBUG при приёме keepalive-пакета
2026-06-01 10:03:14 +03:00
Evgeny
a75c4e68a4
router close_all_for_node: integrate with BGP remove_conn, fail fast on no route, stop PAUSE cycle
...
- route_bgp_remove_conn: call etcp_router_conn_close_all_for_node() when node loses all paths
- etcp_route_send: check BGP route before creating conn (return -1 early, no conn leak)
- remote_proxy: check rp_send_msg return value, close conn on error to break PAUSE↔FLUSH cycle
2026-06-01 01:44:29 +03:00
Evgeny
14c7f1bbed
etcp_router: CLOSE/RST signaling flags in seq, close notification to services
...
- ROUTER_SEQ_CLOSE_FLAG (0x80000000): normal conn close
- ROUTER_SEQ_RST_FLAG (0x40000000): conn not found
- router_send_to(): SVC_ROUTE with flags, no conn needed
- router_send_close_to_service(): notify local service [svc_id],len=1
- router_close_and_notify(): CLOSE to remote + close to local + cleanup
- etcp_router_conn_close(): sends CLOSE to remote before cleanup
- etcp_router_conn_close_all_for_node(): close all conns for dead peer
- recv_cb: flags checked only when pl_len==0 (avoid seq collision)
- etcp_router_destroy: close notification to each service
2026-06-01 01:12:52 +03:00
Evgeny
4ed4f53604
etcp_router: remove legacy, auto-conn for all services, send_q inflight control, remove tcp_proxy internal seq
...
- All SVC_ROUTE traffic now auto-creates ETCP_ROUTER_CONN, no legacy path
- etcp_route_send: auto-conn + seq + inflight check → send_q if full
- Inflight control via send_q: queue instead of drop, drain on ACK, retry timer 50ms
- router_send_one(): unified SVC_ROUTE wrapper with seq assignment
- router_deliver/try_assembly: pass real ETCP_CONN* to handlers (NAT needs it)
- tcp_proxy: remove internal 16-bit seq (send_seq/recv_last_seq/recv_init), shrink HDR 8→6
- remote_proxy: same seq removal, HDR/constants adjusted
- conn init/close/destroy: manage send_q, send_resume_timer lifecycle
- test_etcp_router_unit: −legacy, +send_q inflight test (18 tests)
2026-05-31 22:55:23 +03:00
Evgeny
89531a7831
etcp_router: simplified TCP — reorder recv_q, dedup, ACK timers, inflight control, per-(remote,svc) conn state
...
- New SVC_ROUTE_HDR (packed struct, 22 bytes): cmd+dst+src+seq+svc_id
- ETCP_ROUTER_CONN: state per (remote_node_id, svc_id), hash-indexed in router_conns
- Reorder via recv_q (hash by seq), dedup with 32-bit circular compare
- Periodic ACK (100ms), idle ACK (500ms), inflight limit via tx_seq - rx_acked
- Legacy mode: no conn → direct delivery without reorder
- etcp_router_conn_get/send/close API for seq-managed connections
- Unit test test_etcp_router_unit: 18 tests, 3ms, no ETCP/sockets/BGP
2026-05-31 21:59:46 +03:00
Evgeny
a02a00612a
add non-blocking send with EAGAIN+retry timer, normalizer flow control on recv, remove client-side send_buf buffering
2026-05-31 18:09:50 +03:00
Evgeny
383d1133dc
add traffic debug: PROXY RECV/SEND/FEED for full DATA path tracing on client
2026-05-31 17:21:47 +03:00
Evgeny
4523df583b
fix: stop forwarding after CLOSE, send CLOSE for non-existent conn in proxy data handlers
2026-05-31 16:54:36 +03:00
Evgeny
0709331c64
перевод комментариев tcp/udp/icmp proxy на русский
2026-05-31 16:32:10 +03:00
Evgeny
8d6502965a
tun: socket pair in test_mode, remove ip_fd_mode from tcp_proxy, fix test_remote_proxy stream_id size
2026-05-31 15:58:30 +03:00
Evgeny
7f3bcd39ad
ag
2026-05-31 13:44:55 +03:00
Evgeny
c6cfe4f745
refactor tcp_proxy: remove local socket mode, simplify architecture
...
- remove sock_transport, transport abstraction, active connections API
- simplify proxy_conn to 13 fields (was 15), remove tcp_proxy_mapping linked list
- new protocol: stream_id 4B, seq 2B cyclic, HDR_SIZE 8B
- add ERROR subcmd for immediate abort, CLOSE for graceful half-close
- proper half-close: shutdown SHUT_WR, keep reading, no timer
- exhaustive DEBUG_ERROR/WARN on all error/unusual branches
- config parser: report unknown options with filename:line and valid keys
2026-05-31 13:35:26 +03:00
Evgeny
616be0f15a
add backpressure support: uip_retry_timer, feed drain at closing_tun/sent, send buffering with retry
...
- proxy_uip_retry_cb: retry send from uip_to_transport every 5ms
- proxy_recv_cb: buffer to uip_to_transport when send fails, set retry timer
- proxy_feed: drain transport_to_uip when closing_tun || closing_sent (prevents RST)
- proxy_recv_cb(p==NULL): only tcp_recved + closing_tun, no drain
- proxy_poll_cb/tcp_proxy_destroy: cancel retry timer on cleanup
- uip_retry_timer field in proxy_conn
2026-05-31 03:31:03 +03:00
Evgeny
fca2ef1960
add DEBUG_ERROR in all silent proxy error paths: NULL checks, alloc fails, transport send fail, data drop
2026-05-31 01:58:44 +03:00
Evgeny
2aac55ca2c
add SOCK:EVENT unified diagnostics on exit: NEW/CONN/SEND/RECV/CLOSE/TIMER with fd, stream, total count
2026-05-31 01:31:59 +03:00
Evgeny
d042a6dd6a
drain transport_to_uip at FIN to prevent data delivery after close (eliminates RST storm)
2026-05-31 01:05:12 +03:00
Evgeny
4d8ff45586
fix tun_platform_write return value on FreeBSD: subtract 4-byte AF_INET header from writev result
2026-05-31 00:53:19 +03:00
Evgeny
a13d1e58d4
add TUN write hex dump diagnostic (ip_total, ver_ihl, proto, first 32 bytes hex) in traffic category
2026-05-31 00:44:17 +03:00
Evgeny
1529a6c2b9
add TUN write diagnostic: log tun_platform_write errors
2026-05-31 00:31:47 +03:00
Evgeny
21db2d6281
remove feed block after CLOSE: feed must remain active for streaming and half_close after FIN
2026-05-31 00:14:42 +03:00
Evgeny
c429a57db8
final RST fix: tcp_recved before closing_tun, feed stop after CLOSE, free unsent before tcp_close, proxy_try_close helper
...
- proxy_recv_cb(p==NULL): tcp_recved(pcb,gap) before closing_tun
- proxy_feed_from_transport: stop when closing_sent
- proxy_poll_cb cleanup: free unsent before tcp_close
- proxy_try_close helper: shared between poll_cb (500ms) and recv_cb
- pending_out check: don't close if data still queued for exit
- Configs: traffic=info, tun=info for diagnostics
2026-05-31 00:02:01 +03:00
Evgeny
69ae381f14
fix RST storm: stop proxy_feed after CLOSE sent + free unsent before tcp_close
2026-05-30 23:38:42 +03:00
Evgeny
a25d4dc9c8
fix RST on FIN: tcp_recved in proxy_recv_cb BEFORE closing_tun, guard proxy_err_cb with !closing_sent
2026-05-30 23:24:37 +03:00
Evgeny
75892d6f04
fix RST storm: tcp_recved before tcp_close in proxy_poll_cb cleanup
2026-05-30 23:06:28 +03:00
Evgeny
757514d95a
add lwIP state diagnostics: tcp_alloc cwnd/sndbuf, proxy_poll_cb cwnd/unsent/unacked, active_pcbs counter
2026-05-30 22:40:31 +03:00
Evgeny
b48fe18c2a
fix tcp_proxy connection lifecycle: closing_sent, destroy transport, shutdown+timer on exit
...
- Add closing_sent flag to proxy_conn (CLOSE sent to exit, no need to wait for reply)
- proxy_poll_cb: send CLOSE when done || sndbuf==0; cleanup when tun && (rem||sent)
- Destroy transport in proxy_poll_cb cleanup (fix 56-byte leak)
- remote_proxy_handle_close: shutdown(SHUT_WR) + 2s timer instead of immediate rp_conn_free
- Remove SHUTDOWN subcommand entirely (not needed with new lifecycle)
2026-05-30 22:03:37 +03:00
Evgeny
b7a5a6dade
fix half_close: send CLOSE from proxy_poll_cb when no pending data, shutdown not close on exit
2026-05-30 20:52:25 +03:00
Evgeny
39b222939e
fix tcp_proxy deadlock: send CLOSE on TUN FIN + full proxy diagnostics
...
- proxy_recv_cb(p=NULL): now calls transport->close() to signal exit side
- Add PROXY FIN/CLOSE/CONNECTED/DATA/FEED/TCP_IN/TCP_OUT logs
- Add RP RECV/SEND/CLOSE logs on exit side
- Fix queue_dgram_free/queue_entry_free ordering (UAF) in all proxy files
- Change TRAFFIC logs from ERROR to INFO level
- Add 2 extra 1MB tests in run_test.sh to verify no post-stress stall
- stress_client.py: add --verbose per-thread timing (connect/send/recv ms)
- mem.c: zero freed memory for early UAF detection
2026-05-30 20:42:44 +03:00
Evgeny
de6276fed4
clear freed memory in u_free_impl to catch UAF earlier
2026-05-30 20:03:33 +03:00
Evgeny
0dbebc0ddb
fix use-after-free in queue_entry_free/dgram_free ordering + add tcp_proxy stress test + proxy diagnostics logging
...
- Fix queue_entry_free before queue_dgram_free in all proxy files (UAF bug causing segfault)
- Add PROXY/RP prefixed diagnostic logs for transparent proxy flow tracking
- Add tcp_proxy integration test: real utun instances, ETCP, remote_proxy, DNAT routing
- 7 test scenarios: basic_1mb, concurrent_5, concurrent_20, half_close, idle, conn_refused, stress (10 threads x 20 iterations)
- stress_client.py with --verbose per-thread phase timing (connect/send/recv)
2026-05-30 20:01:05 +03:00
Evgeny
5a0f35953e
set FreeBSD TUN remote address to 192.0.2.1 instead of same as local
2026-05-30 13:13:08 +03:00
Evgeny
4511ece7e6
disable BACKTRACE_ENABLED to fix lld linker error with backtrace symbols
2026-05-30 02:17:46 +03:00