Skip to content

XCL_NETWORK=0: a bind to a network address binds to loopback - #570

Open
tiagonleal wants to merge 1 commit into
xcl-dev:mainfrom
tiagonleal:netoff-bind-loopback
Open

tiagonleal wants to merge 1 commit into
xcl-dev:mainfrom
tiagonleal:netoff-bind-loopback

Conversation

@tiagonleal

@tiagonleal tiagonleal commented Nov 24, 2026 •

Copy link
Copy Markdown
Contributor

With XCL_NETWORK=0 a retail title still bound UDP 3074 on 0.0.0.0: netoff refused connect, sendto and name lookups, but not bind. Windows Firewall then asked to let the network in for xcl.exe (once per folder it runs from; "Allow" needs an administrator), and once allowed, the network reached the title's socket. Fixes #568.

A bind to a non-loopback IPv4 / IPv6 address now binds to 127.0.0.1 / ::1 on the same port. The bind succeeds as on a console without a network, the title's loopback traffic still reaches the socket, nothing from the network does, and Windows does not ask.

What is in it

  • crates/xcl/src/hle/netoff.rs: a bind hook, in the title's ws2_32 imports (table(), ordinal 2) and in the system's ws2_32!bind (install_system_hooks), next to connect's; loopback binds go through unchanged.
  • Test a_bind_to_every_interface_stays_on_loopback: UDP and TCP binds to 0.0.0.0:0 end up on 127.0.0.1, loopback traffic reaches them, [::]:0 ends up on ::1 when the machine has IPv6. It fails without the hook (the socket stays on 0.0.0.0).

Tested

  • NVIDIA GeForce RTX 5070 Ti (driver 32.0.16.1742), Ryzen 7 9800X3D, Windows 11 Pro build 26300, rustc 1.100.0 MSVC, debug for the tests, release for the runs.
  • cargo build --workspace && cargo test --workspace -- --test-threads=4: 742 passed, 0 failed, 41 ignored (rebased onto main 47efa2e). SKIPPED: gpu::recomp::tests::gpu_geometry_wave32_prefix_count_over_a_mask, gpu::recomp::tests::gpu_wave32_program_in_wave64_hardware (no wave64).
  • cargo test -p xcl --lib netoff with the system bind hook taken out: the new test fails (0.0.0.0 ≠ 127.0.0.1); with it: 3 passed.
  • Retail title (1.0.2.1), Get-NetUDPEndpoint 25 s into each smoke run below: main 0.0.0.0:3074; this PR 127.0.0.1:3074, and the log says XCL_NETWORK=0: a bind to a network address is bound to 127.0.0.1 instead (no network).

Regression run

xcl-smoke v1
commit: 9e3831e1f570d3646e53ab753b19ec07eb8f1485
gpu: NVIDIA GeForce RTX 5070 Ti
title: 9cc6a39e
seconds: 60
exit: 0x0
frames shown: 1656 (PresentX 1656)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 14426 MB
xcl-smoke v1
commit: eaf034e43c2273b2a409cb92788449991a332b4f
gpu: NVIDIA GeForce RTX 5070 Ti
title: 9cc6a39e
seconds: 60
exit: 0x0
frames shown: 1657 (PresentX 1657)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 14431 MB

Not tested

  • A title that binds a dual-stack socket on :: and expects IPv4 loopback connections to it (after this it is on ::1 only).
  • The 24-byte sockaddr_in6 form (no scope id) is rewritten too, but no test calls bind with it.
  • AMD / Intel GPUs (the change has no GPU part), Windows 10.

AI use

  • Claude Code with Claude Opus 5.5: found the socket during test runs, wrote the hook, the test and this description, and ran the tests and the smoke runs on my machine.

@FelipeCRamos

Copy link
Copy Markdown

claude code session is invalid anyway, might as well remove it ;)

@tiagonleal
tiagonleal marked this pull request as ready for review November 24, 2026 02:10
Copilot AI balanced review requested due to automatic review settings November 24, 2026 02:11

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.

@MesshM

MesshM commented Nov 24, 2026

Copy link
Copy Markdown

Test run of fc1e7a99f186a028bda6d02b1067b330f98fb4a4 on AMD RDNA4. I merged it onto current main 91f9a5e locally (clean merge) and tested that tree.

Tested

  • AMD Radeon RX 9060 XT 16 GB (RDNA4), driver 32.0.32029.2010; Ryzen 7 5700X, 64 GB RAM, Windows 11 Pro build 26200, Rust 1.100.0 stable-x86_64-pc-windows-msvc, debug
  • cargo build --workspace + cargo test --workspace -- --test-threads=4 on the merge: 693 passed, 0 failed, 41 ignored, exit code 0; xcl lib tests 653 passed, 0 failed, 21 ignored
  • 0 SKIPPED; a_bind_to_every_interface_stays_on_loopback passes.

Review: A bind to a network address (or to every interface) is moved to loopback with its port kept, so a title's sockets still bind and the firewall prompt from #568 no longer comes up; loopback binds go to the original. I found nothing to change.

Not tested: no retail title or regression run (I have no unpacked game), no XCL_SAMPLE_* tests, release build; the PR's head on its old base was not run, only its merge onto main.

Run and review by Claude Code (Claude Opus 5.5) on this machine; the review points were checked against the code.

@upipibi upipibi mentioned this pull request Nov 24, 2026
@upipibi

upipibi commented Nov 24, 2026

Copy link
Copy Markdown
Contributor

Merge-order note for the three XCL_NETWORK=0 PRs that touch crates/xcl/src/hle/netoff.rs. I merged each pair onto main f4ce27ceb6, heads #570 fc1e7a99f1, #612 bbf3174694 and #619 2970626721:

result
#619 + #612 clean in either order; the hooks array ends up […; 19] with 19 entries
#570 + #619 conflict in either order: note_bind is inserted right above the loopback doc comment that #619 rewrites
#570 + #612 conflict in either order: O_BIND next to O_WSA_SEND_MSG, and both change hooks: [...; 18] to 19
#570 alone clean

So the simplest order is #619 and #612 first, then a rebase of #570. Its hooks array then becomes 20, with both the bind and WSASendMsg entries.

I also read #619 and #612:

Read-only, not built. AI-assisted (Claude Code).

With XCL_NETWORK=0 a retail title still bound UDP 3074 on 0.0.0.0:
netoff refused connect, sendto and name lookups but not bind. Windows
Firewall then asked to let the network in for xcl.exe (once per folder
it runs from; "Allow" needs an administrator), and once allowed, the
network reached the title's socket.

A bind to a non-loopback IPv4 / IPv6 address now binds to 127.0.0.1 /
::1 on the same port, in the title's ws2_32 imports (ordinal 2) and in
the system's ws2_32!bind. The bind succeeds as on a console without a
network and loopback traffic still reaches the socket.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@tiagonleal

Copy link
Copy Markdown
Contributor Author

@FelipeCRamos dropped the session trailer; the commit is otherwise unchanged.

@upipibi thanks for checking the merge order. Rebased onto main 47efa2e (clean, same diff). If #612 and #619 go in first I'll rebase again and the hooks array becomes 20 with both the bind and WSASendMsg entries. New test counts and both smoke blocks are in the description; Get-NetUDPEndpoint 25 s in: main 0.0.0.0:3074, this PR 127.0.0.1:3074.

AI-assisted (Claude Code).

@zorde23

zorde23 commented Nov 24, 2026

Copy link
Copy Markdown

AMD RX 6750 XT data point for #570 (RDNA2, driver 32.0.21045.29003; Ryzen 7 5700X, 32 GB; Windows 11 Pro 26200; release builds)

eaf034e cherry-picks cleanly onto current main 930e8b4 (local commit 4b7356a, which is the commit in the PR smoke block below). Both builds came from fresh worktrees, so each xcl.exe was at a path Windows Firewall had never seen. Retail title of #505, XCL_NETWORK=0, 60 s smoke each, with the UDP endpoints of the xcl.exe processes polled every 2 s (Get-NetUDPEndpoint -OwningProcess):

UDP endpoint of the title's host process Windows Firewall prompt firewall rules created for that xcl.exe
main 930e8b4 0.0.0.0:3074 (first seen ~8 s into the run) yes, opened in the same second as the bind 2 (Inbound Block, TCP and UDP, Private profile; Windows added them while the prompt was unanswered)
#570 on 930e8b4 127.0.0.1:3074 for the whole run none 0

main:

xcl-smoke v1
commit: 930e8b49c1c2ec683d22c724a398b39111cd0e56
gpu: AMD Radeon RX 6750 XT
title: retail-a
seconds: 60
exit: 0x0
frames shown: 1406 (PresentX 1406)
presents per 2 s (last 3): 1 0 0
device removals: 0
crashes: 0
peak commit: 54309 MB

PR:

xcl-smoke v1
commit: 4b7356abc555b709401fb54b4eef35dae1204077
gpu: AMD Radeon RX 6750 XT
title: retail-a
seconds: 60
exit: 0x0
frames shown: 1172 (PresentX 1172)
presents per 2 s (last 3): 1 1 1
device removals: 0
crashes: 0
peak commit: 54245 MB

Written with Claude Code from runs on this machine.

@tiagonleal

Copy link
Copy Markdown
Contributor Author

@zorde23 thanks for the RDNA2 run. For your last "not tested" point: #570 merged with the other eight open netoff PRs (#462, #612, #619, #807, #808, #821, #494, #299) builds and passes the whole suite on the RTX 5070 Ti (758 passed, 0 failed, 41 ignored; 7 netoff tests); the merge order and resolutions are in my comment on #568.

AI-assisted (Claude Code).

@JJAutoCompare

Copy link
Copy Markdown

Independent Windows x64 test report on commit eaf034e43c2273b2a409cb92788449991a332b4f.

Environment

  • OS: Windows 11 Enterprise Evaluation x64 (build 26200.9974, Session 0)
  • CPU: AMD Ryzen 7 3800X
  • Toolchain: rustc 1.100.0 (0ef1bc386 2026-11-09)
  • Note: CPU-only targeted run (XCL_ADAPTER=NONE_CPU_ONLY)

Command

xcl-77aca8ccb20e299f.exe --exact --nocapture --test-threads=1 `
  hle::netoff::tests::a_bind_to_every_interface_stays_on_loopback `
  hle::netoff::tests::only_loopback_goes_through

Results

  • Passed: 2, Failed: 0, Ignored: 0, Skipped: 0 (0.02s, exit code 0)
  • hle::netoff::tests::a_bind_to_every_interface_stays_on_loopback: ok
  • hle::netoff::tests::only_loopback_goes_through: ok

Not tested

  • Full workspace suite and game smoke run.

AI use

  • Verified and published with T3 Code / Antigravity (gemini-4-neon).

@DavidM1911

Copy link
Copy Markdown
Contributor

Verification on RTX 3060 Ti (Windows 11), branch merged with current main:

Thanks!

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.

XCL_NETWORK=0: the title still binds UDP 3074 on every interface (Windows Firewall asks, the network can reach it)

8 participants