Skip to content

Net: connect to a zero address disconnects a datagram socket instead of being refused (fixes #891) - #1071

Closed
acleofe wants to merge 1 commit into
Marvisak:mainfrom
acleofe:fix/net-connect-zero-address
Closed

acleofe wants to merge 1 commit into
Marvisak:mainfrom
acleofe:fix/net-connect-zero-address

Conversation

@acleofe

@acleofe acleofe commented Nov 24, 2026

Copy link
Copy Markdown

What

connect and WSAConnect pass an address that reaches no one to the host: an IPv4/IPv6 address of zeros, or a sockaddr of no family (AF_UNSPEC). Every other address is vetted as before, so only loopback connects.

Why

Winsock documents that connecting a datagram socket to an address of zeros dissolves its association with its peer. The offline policy refused that address as off the machine (WSAENETUNREACH), so a connected UDP socket stayed connected. An address of zeros never leaves the machine (a stream socket cannot connect to it on Windows), so passing it on does not weaken the policy.

Test

  • a_zero_address_disconnects_a_datagram_socket: a UDP socket connected to a loopback peer is disconnected (getpeername gives WSAENOTCONN) by connect with 0.0.0.0:0 and with a zeroed AF_UNSPEC sockaddr, and by WSAConnect; an off-machine address is still refused with WSAENETUNREACH. Before this change the first zero-address connect returned SOCKET_ERROR.
  • cargo clippy --workspace --all-targets [--all-features] --locked -- -D warnings and cargo test --workspace --locked pass.

🤖 Generated with Claude Code

…of being refused (fixes #891)

Winsock disconnects a datagram socket connected to an address of zeros.
The offline policy refused that address as off the machine; it reaches
no one, so it now goes to the host.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
JMAN730 pushed a commit to JMAN730/project-flamingo that referenced this pull request Nov 24, 2026
@ThomasHFWright

Copy link
Copy Markdown

Independent Linux/Wine validation of d9741ec66ce5efd505aef2d51e75f53561af64b2, base ffe310e: the new regression fails under Wine 11.22, at net.rs:939 (assert!(!connected(u))). The zero-address connect returns success, but getpeername still succeeds.

I compared direct ws2_32 calls with VIctory's wrappers in a separate diagnostic checkout. With a fresh IPv4 UDP socket connected to a loopback peer for every case, raw connect, wrapped connect, raw WSAConnect, and wrapped WSAConnect all give the same results:

Disconnect argument Connect result getpeername afterward One-byte send afterward
IPv4 0.0.0.0:0 0 0, peer 0.0.0.0:0 1 byte accepted
Zeroed AF_UNSPEC sockaddr 0 -1, WSAENOTCONN (10057) -1, WSAENOTCONN (10057)

The wrapper still rejects the off-machine test address with WSAENETUNREACH in every diagnostic case. All calls ran inside a network namespace with loopback only.

This isolates the discrepancy to the host Winsock behavior on this Wine setup, rather than the new forwarding branch. Microsoft's connect documentation specifies that the zero-address datagram operation disconnects and subsequent send returns WSAENOTCONN. The working AF_UNSPEC path is useful evidence for a Wine compatibility follow-up; I have not changed production code or checked IPv6 here.

Full workspace unit/integration suite on the unmodified PR, all features, all 14 generated Windows MSVC test executables: 341 passed, 6 failed, 6 ignored. Matched baseline: 341 passed, 5 failed, 6 ignored. The extra failure is the new disconnect test. The other five remain the empty pipeline library (#347), missing Wine Winsock export (#217), checksum-rejection expectation, nested Cargo fixture build, and Windows xtask attempting to launch host Git. Native xtask separately passes all 4 tests; asset policy passes. Both Windows-target workspace Clippy configurations (all targets, with and without all features, -D warnings) pass.

Environment: Rust 1.98.1, Wine 11.22, RTX 5090 / NVIDIA 620.73.04, vkd3d-proton 30b0eb9bc12dc9f; native d3dcompiler_47 for GPU fixtures, same runtime DLLs as baseline. Offline and offscreen. No game data, gameplay, native Windows/WARP, or Wine doctests. Aggregate counts include existing tests that return early without optional console compilers/DXIL validator. AI-assisted testing with Codex.

@acleofe acleofe closed this by deleting the head repository Nov 24, 2026
@Zipettte

Copy link
Copy Markdown

Tested on AMD Radeon RX 7700 XT (RDNA3, gfx1101), driver 32.0.32029.2010, Windows 11, Rust 1.98.1 MSVC at d9741ec: cargo test -p victory-hle passes, 96 passed / 0 failed. Workspace baseline on main (ffe310e) is green on the same machine (342 passed).

Tested with AI assistance (Claude).

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants