Net: forward zero-address datagram disconnects #2064
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/2066"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Imported from Marvisak/VIctory. Originally posted by fuzeofficlal on 2026-11-25T04:20:15Z.
Fixes #891.
Summary
sockaddrforms (all-zeroAF_UNSPEC,0.0.0.0:0, and[::]:0) pastreachableinnet::connectandnet::WSAConnect(crates/victory-hle/src/modules/net.rs), forwarding the caller's(name, len)buffer unchanged to the host'sws2_32.dll.SOCK_DGRAM) sockets disconnect cleanly without leaving the machine, while stream (SOCK_STREAM) sockets receive the native Winsock error (WSAEADDRNOTAVAILfor0.0.0.0:0,WSAEAFNOSUPPORTfor all-zeroAF_UNSPEC), and non-zero ports (0.0.0.0:80) or external peers remain blocked withWSAENETUNREACH.Verification
modules::net::tests::zero_address_accepts_only_disconnect_formsmodules::net::tests::zero_address_disconnects_datagram_sockets_while_blocking_external_peers(covers UDP disconnect viaconnect/WSAConnect, TCPSOCK_STREAMWSAEADDRNOTAVAIL/WSAEAFNOSUPPORT, and blocked external/non-zero-port peers)cargo test -p victory-hle --locked,cargo clippy -p victory-hle --tests --locked -- -D warnings, andcargo xtask policy: passed.Imported from Marvisak/VIctory. Originally posted by catminou4 on 2026-11-25T04:26:28Z.
Review: COMMENTED
Static review only: victory-hle is Windows-only — nothing compiles or runs on macOS; source review of the diff.
Zero-address datagram disconnects forwarded — net-stack edge case; good defensive forwarding.
Imported from Marvisak/VIctory. Originally posted by jeremygold02 on 2026-11-25T04:26:09Z.
Triage verdict — Keep the disconnect fix, account for the Wine result (
a6d773e)Evidence
WSAENOTCONN, so the earlier platform difference remains relevant. Prior Wine comparisonChecks and limits
Next step
This verification was AI-assisted.
Imported from Marvisak/VIctory. Originally posted by fuzeofficlal on 2026-11-25T05:00:22Z.
Updated in
379e1baa— thanks @jeremygold02 for pointing back to the Wine 11.22 comparison in #1071 (@ThomasHFWright).On Wine,
ws2_32!connectdisassociates a datagram socket whensa_family == AF_UNSPEC(all-zerosockaddr), whereas forwardingAF_INET0.0.0.0:0verbatim leaves the peer associated on Linux/Wine (sendsucceeds instead of returningWSAENOTCONN).connectandWSAConnectnow canonicalize any acceptedzero_address(AF_UNSPEC,0.0.0.0:0, or[::]:0) to anAF_UNSPECall-zerosockaddrof the caller's length before calling hostws2_32.dll, giving consistent disassociation andWSAENOTCONNbehavior on both native Windows and Wine.Imported from Marvisak/VIctory. Originally posted by Marvisak on 2026-11-25T10:24:24Z.
Automated triage for the maintainers.
Needs work. This needs the maintainer's decision, because it still adds a path past
reachableincrates/victory-hle/src/modules/net.rs(connect,WSAConnect). The code itself now looks right to me.On your reply: confirmed in
1f723fb. TheAF_UNSPECrewrite is gone, soconnectandWSAConnectpass the caller's own(name, len)to the host whenzero_addressholds. That covers both earlier points: a stream socket now gets the host's own error, andWSAConnectbehaves however the host behaves for0.0.0.0:0. The newSOCK_STREAMassertions (WSAEADDRNOTAVAILfor0.0.0.0:0,WSAEAFNOSUPPORTfor all-zeroAF_UNSPEC) and the checks that0.0.0.0:80and off-machine peers still getWSAENETUNREACHtest the right things.zero_addressonly accepts a zero port and a zero address (plus zero flowinfo and scope for IPv6), so nothing it lets through can reach another machine.The remaining question is policy: whether the maintainer accepts a second exception beside the loopback rule in the
netmodule. CI: passing.Generated by Claude Code
Imported from Marvisak/VIctory. Originally posted by fuzeofficlal on 2026-11-25T10:50:46Z.
Updated in
1f723fb0per triage feedback:AF_UNSPECsockaddrrewrite soconnectandWSAConnectforward the caller's(name, len)unchanged to host Winsock whenzero_address(name, len)holds.zero_address_disconnects_datagram_sockets_while_blocking_external_peerswith aSOCK_STREAMTCP socket check verifyingconnectandWSAConnectwith0.0.0.0:0fail withWSAEADDRNOTAVAIL(10049) (and all-zeroAF_UNSPECfails withWSAEAFNOSUPPORT), while UDP datagram sockets disconnect cleanly and0.0.0.0:80/ external addresses stay blocked.Imported from Marvisak/VIctory. Originally posted by cloph-dsp on 2026-11-27T03:32:03Z.
Independent CPU-only verification on Windows (Rust 1.100.0/MSVC, worktree-local
CARGO_TARGET_DIR,CARGO_BUILD_JOBS=2, no game data).1f723fb, merge base940d32f.cargo test --locked -p victory-hle --lib -- modules::net::tests::zero_address_accepts_only_disconnect_forms --exact --test-threads=1 --quiet->test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured; 144 filtered out.git diff --check 940d32f HEAD-> exit 0.940d32f(git grep -c ... crates/victory-hle/src/modules/net.rs-> exit 1).Note: only the named synthetic test was replayed; the full crate suite was not run, and Windows socket behaviour beyond the synthetic forms was not exercised. GPU/driver: N/A (CPU-only HLE test). AI-assisted (Hy4 flash). No game data, assets, extracted shaders or DRM involved.
View command line instructions
Checkout
From your project repository, check out a new branch and test the changes.Merge
Merge the changes and update on Forgejo.Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.