From 4f038ecad87777bc1d74f8f93f267da8cd396446 Mon Sep 17 00:00:00 2001 From: user Date: Fri, 17 Jul 2026 19:45:13 +0200 Subject: net: unbreak ping against hosts that intermittently drop ICMP Pinging sl0p.foo through gbhub looked hung: DNS resolved, then nothing. Packet-tracing showed the echo request leaving the hub's TUN and eth0 correctly NATed every time - but 80.78.19.56 blackholes ICMP for all ids in windows of tens of seconds (provider rate limiting). One lost reply wedged ping for minutes because net_recv's pump-counted timeout is effectively unbounded at native emulation speed. Two fixes: - NET_RECVNB (op 8): non-blocking recv - one RX pump, $FE if nothing buffered, same delivery/EOF semantics as NET_RECV otherwise. ping now waits <=~2s per seq (net_recv_nb + msleep loop), prints 'seq=N timeout' and moves on, like real ping. - ICMP echo id was hardcoded $1234 for every GB, every boot, so all sessions produced byte-identical flows - hostile to NAT conntrack (keyed on icmp id). wNetEchoId is now our host octet + rDIV timing noise sampled at DHCP lease, distinct per GB and per boot. Verified: 8 back-to-back native-speed gbhub runs, zero hangs; a run that hit a blackhole window printed seq=1 timeout then recovered to 3/4 received. GB<->GB ping and DNS/DHCP unaffected. --- include/gbos.inc | 3 +++ 1 file changed, 3 insertions(+) (limited to 'include') diff --git a/include/gbos.inc b/include/gbos.inc index 937d083..e9f8d7d 100644 --- a/include/gbos.inc +++ b/include/gbos.inc @@ -153,6 +153,9 @@ DEF NET_CLOSE EQU 4 ; NR_SOCK DEF NET_BIND EQU 5 ; NR_SOCK, NR_PORT -> bind local port (UDP) DEF NET_POLL EQU 6 ; pump RX once (answer pings) -> A=0 DEF NET_SETIP EQU 7 ; set our IPv4 address from NR_IP (DHCP) +DEF NET_RECVNB EQU 8 ; like NET_RECV but never blocks: pump once, then + ; A=len if a datagram was buffered, $FE if none yet, + ; 0 on TCP EOF. Lets programs own their timeouts (ping). ; socket types DEF SOCK_ICMP EQU 1 DEF SOCK_UDP EQU 2 -- cgit v1.3.1-sl0p