Skip to content

Net: forward zero-address datagram disconnects - #2066

Open
fuzeofficlal wants to merge 1 commit into
Marvisak:mainfrom
fuzeofficlal:fix/hle-net-zero-address-disconnect-891
Open

fuzeofficlal wants to merge 1 commit into
Marvisak:mainfrom
fuzeofficlal:fix/hle-net-zero-address-disconnect-891

Conversation

@fuzeofficlal

@fuzeofficlal fuzeofficlal commented Nov 25, 2026 •

Copy link
Copy Markdown
Contributor

Fixes #891.

Summary

  • Allow zero sockaddr forms (all-zero AF_UNSPEC, 0.0.0.0:0, and [::]:0) past reachable in net::connect and net::WSAConnect (crates/victory-hle/src/modules/net.rs), forwarding the caller's (name, len) buffer unchanged to the host's ws2_32.dll.
  • Datagram (SOCK_DGRAM) sockets disconnect cleanly without leaving the machine, while stream (SOCK_STREAM) sockets receive the native Winsock error (WSAEADDRNOTAVAIL for 0.0.0.0:0, WSAEAFNOSUPPORT for all-zero AF_UNSPEC), and non-zero ports (0.0.0.0:80) or external peers remain blocked with WSAENETUNREACH.

Verification

  • modules::net::tests::zero_address_accepts_only_disconnect_forms
  • modules::net::tests::zero_address_disconnects_datagram_sockets_while_blocking_external_peers (covers UDP disconnect via connect/WSAConnect, TCP SOCK_STREAM WSAEADDRNOTAVAIL/WSAEAFNOSUPPORT, and blocked external/non-zero-port peers)
  • cargo test -p victory-hle --locked, cargo clippy -p victory-hle --tests --locked -- -D warnings, and cargo xtask policy: passed.

@jeremygold02

Copy link
Copy Markdown
Contributor

Triage verdict — Keep the disconnect fix, account for the Wine result (a6d773e)

Evidence

Checks and limits

  • Compared the current test to the earlier Wine report. I did not rerun the new head on Wine, so the prior result is evidence of a compatibility case to verify.

Next step

This verification was AI-assisted.

@catminou4 catminou4 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@fuzeofficlal
fuzeofficlal force-pushed the fix/hle-net-zero-address-disconnect-891 branch from a6d773e to 379e1ba Compare November 25, 2026 05:00
@fuzeofficlal

Copy link
Copy Markdown
Contributor Author

Updated in 379e1baa — thanks @jeremygold02 for pointing back to the Wine 11.22 comparison in #1071 (@ThomasHFWright).

On Wine, ws2_32!connect disassociates a datagram socket when sa_family == AF_UNSPEC (all-zero sockaddr), whereas forwarding AF_INET 0.0.0.0:0 verbatim leaves the peer associated on Linux/Wine (send succeeds instead of returning WSAENOTCONN). connect and WSAConnect now canonicalize any accepted zero_address (AF_UNSPEC, 0.0.0.0:0, or [::]:0) to an AF_UNSPEC all-zero sockaddr of the caller's length before calling host ws2_32.dll, giving consistent disassociation and WSAENOTCONN behavior on both native Windows and Wine.

Marvisak commented Nov 25, 2026 •

Copy link
Copy Markdown
Owner

Automated triage for the maintainers.

Needs work. This needs the maintainer's decision, because it still adds a path past reachable in crates/victory-hle/src/modules/net.rs (connect, WSAConnect). The code itself now looks right to me.

On your reply: confirmed in 1f723fb. The AF_UNSPEC rewrite is gone, so connect and WSAConnect pass the caller's own (name, len) to the host when zero_address holds. That covers both earlier points: a stream socket now gets the host's own error, and WSAConnect behaves however the host behaves for 0.0.0.0:0. The new SOCK_STREAM assertions (WSAEADDRNOTAVAIL for 0.0.0.0:0, WSAEAFNOSUPPORT for all-zero AF_UNSPEC) and the checks that 0.0.0.0:80 and off-machine peers still get WSAENETUNREACH test the right things. zero_address only 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 net module. CI: passing.


Generated by Claude Code

Allow all-zero sockaddrs, AF_INET 0.0.0.0:0, and AF_INET6 [::]:0 in connect and WSAConnect to reach host Winsock unchanged so connected UDP sockets can disconnect and stream sockets receive the host's native error without weakening the loopback-only offline policy.
@fuzeofficlal
fuzeofficlal force-pushed the fix/hle-net-zero-address-disconnect-891 branch from 379e1ba to 1f723fb Compare November 25, 2026 10:50
@fuzeofficlal

Copy link
Copy Markdown
Contributor Author

Updated in 1f723fb0 per triage feedback:

  • Removed the AF_UNSPEC sockaddr rewrite so connect and WSAConnect forward the caller's (name, len) unchanged to host Winsock when zero_address(name, len) holds.
  • Extended zero_address_disconnects_datagram_sockets_while_blocking_external_peers with a SOCK_STREAM TCP socket check verifying connect and WSAConnect with 0.0.0.0:0 fail with WSAEADDRNOTAVAIL (10049) (and all-zero AF_UNSPEC fails with WSAEAFNOSUPPORT), while UDP datagram sockets disconnect cleanly and 0.0.0.0:80 / external addresses stay blocked.

@cloph-dsp

Copy link
Copy Markdown

Independent CPU-only verification on Windows (Rust 1.100.0/MSVC, worktree-local CARGO_TARGET_DIR, CARGO_BUILD_JOBS=2, no game data).

  • PR head 1f723fb, merge base 940d32f.
  • 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.
  • Negative control: the new test name is absent from 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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Net: connect/WSAConnect with a zero address are refused as off-machine instead of disconnecting a datagram socket

5 participants