From 46f5ff7ecada647414e76024f3da49c5975a9c8a Mon Sep 17 00:00:00 2001 From: Evgeny Date: Mon, 6 Jul 2026 12:28:54 +0300 Subject: [PATCH] test_etcp_router: fix flaky keepalive timeout under dummynet congestion MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Root cause: 80kbps congestion causes 9+ second backpressure during push phase. No packets reach server → keepalive timeout (2s default) fires → ETCP link down → BGP cleanup → etcp_router_conn_restart() - frees send_q (up to 64 = ROUTER_MAX_SEND_Q_PACKETS lost) - sends 9-byte restart notification to service handler (conn=NULL) - resets seq to 0 Fixes: 1. Set keepalive_timeout=60000, keepalive_adaptive=0 in test configs to prevent spurious timeouts during intentional congestion testing 2. Handle 9-byte restart notification in srv_handler: when conn==NULL && len==9 → reset g_expected_seq=0 gracefully --- tests/test_etcp_router.c | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/tests/test_etcp_router.c b/tests/test_etcp_router.c index 902976dc..217e9159 100644 --- a/tests/test_etcp_router.c +++ b/tests/test_etcp_router.c @@ -169,6 +169,8 @@ static void write_configs(void) { "my_public_key=%s\n" "tun_ip=10.99.0.1/24\n" "tun_ifname=tun99\n" + "keepalive_timeout=60000\n" + "keepalive_adaptive=0\n" "[server: s1]\n" "addr=127.0.0.1:%d\n" "type=public\n" @@ -188,6 +190,8 @@ static void write_configs(void) { "my_public_key=%s\n" "tun_ip=10.99.0.2/24\n" "tun_ifname=tun98\n" + "keepalive_timeout=60000\n" + "keepalive_adaptive=0\n" "[server: s1]\n" "addr=127.0.0.1:%d\n" "type=public\n" @@ -242,9 +246,15 @@ static int send_one_pkt(uint32_t seq, int data_len) { // ======================== Server handler ======================== static void srv_handler(struct ETCP_CONN* conn, struct ll_entry* entry) { - (void)conn; + // Restart notification: conn=NULL, len=9, format [svc_id:1][node_id:8] + if (!conn && entry && entry->dgram && entry->len == 9) { + DEBUG_DEBUG(DEBUG_CATEGORY_DEBUG, "srv_handler: restart notification, resetting expected_seq from %u to 0", g_expected_seq); + g_expected_seq = 0; + queue_dgram_free(entry); queue_entry_free(entry); + return; + } if (!entry || !entry->dgram || entry->len < 10) { - printf("[FAIL] srv_handler: bad entry len=%zu\n", entry ? entry->len : 0); + printf("[FAIL] srv_handler: bad entry len=%zu conn=%p\n", entry ? entry->len : 0, (void*)conn); if (entry) { queue_dgram_free(entry); queue_entry_free(entry); } g_fail = 4; g_done = -1; return;