From b1e80047f11b599b1448a2dfb2eab330f43135df Mon Sep 17 00:00:00 2001 From: Markus Maiwald Date: Wed, 7 Jan 2026 17:04:51 +0100 Subject: [PATCH] test(utcp): Root cause analysis - QEMU hostfwd requires listening socket Documented why UDP/9999 packets don't reach Fast Path. QEMU's NAT drops packets without listening socket. Proposed TAP networking solution for Phase 38. --- core/fastpath.nim | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/core/fastpath.nim b/core/fastpath.nim index c59dddb..4ca8c66 100644 --- a/core/fastpath.nim +++ b/core/fastpath.nim @@ -27,6 +27,7 @@ const proc kprint(s: cstring) {.importc, cdecl.} proc kprintln(s: cstring) {.importc, cdecl.} +proc kprint_hex(n: uint64) {.importc, cdecl.} # --- Fast Path Detection --- @@ -34,6 +35,16 @@ proc is_utcp_tunnel*(data: ptr UncheckedArray[byte], len: uint16): bool {.export ## Check if packet is a UTCP tunnel packet (UDP port 9999) ## Returns true if packet should bypass LwIP + # DEBUG: Print first 50 bytes + kprintln("[FastPath] Checking packet...") + kprint(" Len: "); kprint_hex(uint64(len)); kprintln("") + if len >= 42: + kprint(" EthType: "); kprint_hex(uint64((uint16(data[12]) shl 8) or uint16(data[13]))); kprintln("") + kprint(" IPProto: "); kprint_hex(uint64(data[23])); kprintln("") + if len >= 38: + let dst_port = (uint16(data[36]) shl 8) or uint16(data[37]) + kprint(" DstPort: "); kprint_hex(uint64(dst_port)); kprintln("") + # Minimum size check: ETH(14) + IP(20) + UDP(8) = 42 bytes if len < TUNNEL_OVERHEAD: return false @@ -52,6 +63,9 @@ proc is_utcp_tunnel*(data: ptr UncheckedArray[byte], len: uint16): bool {.export # ETH(14) + IP(20) + UDP dst port offset(2) = 36 let dst_port = (uint16(data[36]) shl 8) or uint16(data[37]) + if dst_port == UTCP_TUNNEL_PORT: + kprintln("[FastPath] UTCP TUNNEL DETECTED!") + return dst_port == UTCP_TUNNEL_PORT