Net: forward zero-address datagram disconnects #2066

Open
github-bot wants to merge 1 commit from github-bot/gh-2066 into main AGit
Owner

@⁠fuzeofficlal on GitHub · 2026-11-25 04:20 UTC · original
fuzeofficlal:fix/hle-net-zero-address-disconnect-891 → main · +156 −2 · 1 files · 1 commits · open

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.
**@⁠fuzeofficlal** on GitHub · 2026-11-25 04:20 UTC · [original](https://github.com/Marvisak/VIctory/pull/2066) `fuzeofficlal:fix/hle-net-zero-address-disconnect-891` → `main` · +156 −2 · 1 files · 1 commits · open 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.
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.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 04:53:44 +00:00
Author
Owner

@⁠jeremygold02 on GitHub · 2026-11-25 04:26 UTC · original

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

Evidence

  • @⁠fuzeofficlal’s patch revisits #891 after @⁠acleofe’s #1071 closed without merging. Both let the host handle the datagram disconnect. This version adds explicit zero-address classification controls and checks both entry points. Forwarding and tests
  • The earlier independent Wine run found that the native host call and wrapper agreed: the zeroed address-family case disconnected, while the IPv4 zero-address case returned success without disassociating the datagram socket. The new integration test still requires that second case to produce WSAENOTCONN, so the earlier platform difference remains relevant. Prior Wine comparison

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

  • Preserve the native Windows contract check and run the loopback-only fixture on Wine separately. If Wine still differs, document which behavior the project intends to provide before treating both environments as covered. Keep credit for #1071’s implementation and test evidence.

This verification was AI-assisted.

**@⁠jeremygold02** on GitHub · 2026-11-25 04:26 UTC · [original](https://github.com/Marvisak/VIctory/pull/2066#issuecomment-7152840058) **Triage verdict — Keep the disconnect fix, account for the Wine result** (`a6d773e`) **Evidence** - @⁠fuzeofficlal’s patch revisits #891 after @⁠acleofe’s #1071 closed without merging. Both let the host handle the datagram disconnect. This version adds explicit zero-address classification controls and checks both entry points. [Forwarding and tests](https://github.com/Marvisak/VIctory/blob/a6d773e2c33a2c9b1296f00528e78df44a699a35/crates/victory-hle/src/modules/net.rs#L221-L269) - The earlier independent Wine run found that the native host call and wrapper agreed: the zeroed address-family case disconnected, while the IPv4 zero-address case returned success without disassociating the datagram socket. The new integration test still requires that second case to produce `WSAENOTCONN`, so the earlier platform difference remains relevant. [Prior Wine comparison](https://git.gtahub.st/github/Marvisak--VIctory/pulls/1071) **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** - Preserve the native Windows contract check and run the loopback-only fixture on Wine separately. If Wine still differs, document which behavior the project intends to provide before treating both environments as covered. Keep credit for #1071’s implementation and test evidence. This verification was AI-assisted.
Author
Owner

@⁠fuzeofficlal on GitHub · 2026-11-25 05:00 UTC · original

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.

**@⁠fuzeofficlal** on GitHub · 2026-11-25 05:00 UTC · [original](https://github.com/Marvisak/VIctory/pull/2066#issuecomment-7153360796) 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.
Author
Owner

@⁠Marvisak on GitHub · 2026-11-25 10:24 UTC · original · edited 2026-11-25 11:23 UTC

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

**@⁠Marvisak** on GitHub · 2026-11-25 10:24 UTC · [original](https://github.com/Marvisak/VIctory/pull/2066#issuecomment-7159649754) · edited 2026-11-25 11:23 UTC <!-- victory-triage v1 head=1f723fb0b4ede757e49cbb26d564203232ba1855 verdict=needs-work at=2026-11-25T11:23:22Z --> 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](https://claude.ai/code)_
Author
Owner

@⁠fuzeofficlal on GitHub · 2026-11-25 10:50 UTC · original

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.
**@⁠fuzeofficlal** on GitHub · 2026-11-25 10:50 UTC · [original](https://github.com/Marvisak/VIctory/pull/2066#issuecomment-7160249832) 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.
This pull request can be merged automatically.
This branch is out-of-date with the base branch
You are not authorized to merge this pull request.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin '+refs/pull/2066/head:github-bot/gh-2066'
git switch 'github-bot/gh-2066'

Merge

Merge the changes and update on Forgejo.
git switch 'main'
git merge --no-ff 'github-bot/gh-2066'
git switch 'github-bot/gh-2066'
git rebase 'main'
git switch 'main'
git merge --ff-only 'github-bot/gh-2066'
git switch 'github-bot/gh-2066'
git rebase 'main'
git switch 'main'
git merge --no-ff 'github-bot/gh-2066'
git switch 'main'
git merge --squash 'github-bot/gh-2066'
git switch 'main'
git merge --ff-only 'github-bot/gh-2066'
git switch 'main'
git merge 'github-bot/gh-2066'
git push origin 'main'
This discussion has been locked. Commenting is limited to contributors.
No reviewers
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
github/Marvisak--VIctory!2066
No description provided.