xcl run: rewrite non-loopback bind to loopback under XCL_NETWORK=0 #1532

Closed
github-bot wants to merge 1 commit from gh-pr/1532/head into gh-pr/1532/base
Owner

@⁠OtavioTadeu on GitHub · 2026-11-24 17:18 UTC · original
OtavioTadeu:fix/netoff-bind-loopback-568 → main · +124 −1 · 1 files · 1 commits · closed without merging

Hooks ws2_32!bind (ordinal 2) in netoff under XCL_NETWORK=0 so non-loopback IPv4/IPv6 binds (such as 0.0.0.0:3074 or [::]) are rewritten to 127.0.0.1 / ::1 preserving the requested port, preventing LAN exposure and Windows Firewall prompts. Fixes #568.

What is in it

  • crates/xcl/src/hle/netoff.rs: add bind to import table (ordinal 2) and install_system_hooks, add rewrite_bind_to_loopback, and add unit + real Winsock IPv4/IPv6 bind + getsockname tests

Tested

  • NVIDIA GeForce GTX 1660 SUPER (driver 32.0.16.1088), AMD Ryzen 5 5600G, Windows 11 build 26200, DXC 1.9.2602.17 (Windows SDK 10.0.26100.0), rustc 1.100.0 (stable-x86_64-pc-windows-msvc), debug build
  • cargo test --workspace -- --test-threads=4: 777 passed, 0 failed, 41 ignored (SKIPPED GPU tests: gpu::recomp::tests::gpu_geometry_wave32_prefix_count_over_a_mask [no wave64], gpu::recomp::tests::gpu_wave32_program_in_wave64_hardware [no wave64], heap_window_out_of_memory_falls_back_to_the_switch_form [no heap windows])
  • cargo test -p xcl --lib netoff: 3 passed, 0 failed

Regression run

  • scripts/smoke.ps1 -Game retail_title -Seconds 60 (main baseline vs PR head on NVIDIA GeForce GTX 1660 SUPER):

xcl-smoke v1

commit: 9e3831e1f570d3646e53ab753b19ec07eb8f1485

gpu: NVIDIA GeForce GTX 1660 SUPER

title: retail_title

seconds: 60

exit: 0x0

frames shown: 631 (PresentX 631)

presents per 2 s (last 3): 47 47 49

device removals: 0

crashes: 0

peak commit: 15199 MB


xcl-smoke v1

commit: a12bbdd597e81495ce05bcdf336b53e5b15544c4

gpu: NVIDIA GeForce GTX 1660 SUPER

title: retail_title

seconds: 60

exit: 0x0

frames shown: 636 (PresentX 636)

presents per 2 s (last 3): 60 60 53

device removals: 0

crashes: 0

peak commit: 15200 MB

Not tested

  • AMD / native wave64 GPUs, Linux/Wine, and extended gameplay past the 60 s smoke window

AI use

  • Antigravity with Gemini 4 Neon: analyzed the issue, wrote the fix, tests, and PR description; reviewed by author.
**@⁠OtavioTadeu** on GitHub · 2026-11-24 17:18 UTC · [original](https://github.com/xcl-dev/xcl/pull/1532) `OtavioTadeu:fix/netoff-bind-loopback-568` → `main` · +124 −1 · 1 files · 1 commits · closed without merging Hooks `ws2_32!bind` (ordinal 2) in `netoff` under `XCL_NETWORK=0` so non-loopback IPv4/IPv6 binds (such as `0.0.0.0:3074` or `[::]`) are rewritten to `127.0.0.1` / `::1` preserving the requested port, preventing LAN exposure and Windows Firewall prompts. Fixes #568. **What is in it** - `crates/xcl/src/hle/netoff.rs`: add `bind` to import table (ordinal 2) and `install_system_hooks`, add `rewrite_bind_to_loopback`, and add unit + real Winsock IPv4/IPv6 `bind` + `getsockname` tests **Tested** - NVIDIA GeForce GTX 1660 SUPER (driver 32.0.16.1088), AMD Ryzen 5 5600G, Windows 11 build 26200, DXC 1.9.2602.17 (Windows SDK 10.0.26100.0), rustc 1.100.0 (`stable-x86_64-pc-windows-msvc`), debug build - `cargo test --workspace -- --test-threads=4`: 777 passed, 0 failed, 41 ignored (SKIPPED GPU tests: `gpu::recomp::tests::gpu_geometry_wave32_prefix_count_over_a_mask` [no wave64], `gpu::recomp::tests::gpu_wave32_program_in_wave64_hardware` [no wave64], `heap_window_out_of_memory_falls_back_to_the_switch_form` [no heap windows]) - `cargo test -p xcl --lib netoff`: 3 passed, 0 failed **Regression run** - `scripts/smoke.ps1 -Game retail_title -Seconds 60` (`main` baseline vs PR head on NVIDIA GeForce GTX 1660 SUPER): ``` xcl-smoke v1 commit: 9e3831e1f570d3646e53ab753b19ec07eb8f1485 gpu: NVIDIA GeForce GTX 1660 SUPER title: retail_title seconds: 60 exit: 0x0 frames shown: 631 (PresentX 631) presents per 2 s (last 3): 47 47 49 device removals: 0 crashes: 0 peak commit: 15199 MB ``` ``` xcl-smoke v1 commit: a12bbdd597e81495ce05bcdf336b53e5b15544c4 gpu: NVIDIA GeForce GTX 1660 SUPER title: retail_title seconds: 60 exit: 0x0 frames shown: 636 (PresentX 636) presents per 2 s (last 3): 60 60 53 device removals: 0 crashes: 0 peak commit: 15200 MB ``` **Not tested** - AMD / native wave64 GPUs, Linux/Wine, and extended gameplay past the 60 s smoke window **AI use** - Antigravity with Gemini 4 Neon: analyzed the issue, wrote the fix, tests, and PR description; reviewed by author.
Adds ws2_32!bind to netoff's import table and system hooks so non-loopback IPv4/IPv6 binds (such as 0.0.0.0:3074 or [::]) are rewritten to 127.0.0.1 / ::1 with the requested port instead of exposing a LAN socket or triggering Windows Firewall.

Fixes #568.
Verified with cargo test -p xcl --lib netoff (3 passed, including real Winsock IPv4/IPv6 bind + getsockname checks).

Assisted-by: Antigravity (Gemini 4 Neon)
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 04:56:42 +00:00
github-bot closed this pull request 2026-11-26 04:56:42 +00:00
Author
Owner

@⁠dcastell1 on GitHub · 2026-11-24 17:34 UTC · original

Verified on Windows 11 10.0.26300, NVIDIA GeForce RTX 5090 (driver 621.24), Rust 1.100.0 MSVC 14.44.35207, debug build, on main@9e3831e (baseline 776 passed, 0 failed, 41 ignored on this box):

patch -p1 < this PR            # clean, no fuzz
cargo test --workspace -- --test-threads=4
777 passed; 0 failed; 41 ignored   (exit 0)

One more passing test than the baseline; rewriting a non-loopback bind to loopback is exercised and green.

Tree restored afterwards (full diff against a clean checkout), hardware adapter, no Wine, no game data. AI-assisted (opencode): applied the patch to a built tree, ran the suite, reverted it. (The PR is a draft; this is the suite as it stands.)

**@⁠dcastell1** on GitHub · 2026-11-24 17:34 UTC · [original](https://github.com/xcl-dev/xcl/pull/1532#issuecomment-7139390652) Verified on Windows 11 10.0.26300, NVIDIA GeForce RTX 5090 (driver 621.24), Rust 1.100.0 MSVC 14.44.35207, debug build, on `main@9e3831e` (baseline **776 passed, 0 failed, 41 ignored** on this box): ``` patch -p1 < this PR # clean, no fuzz cargo test --workspace -- --test-threads=4 777 passed; 0 failed; 41 ignored (exit 0) ``` One more passing test than the baseline; rewriting a non-loopback bind to loopback is exercised and green. Tree restored afterwards (full diff against a clean checkout), hardware adapter, no Wine, no game data. AI-assisted (opencode): applied the patch to a built tree, ran the suite, reverted it. (The PR is a draft; this is the suite as it stands.)
Author
Owner

@⁠DavidM1911 on GitHub · 2026-11-24 19:05 UTC · original

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

  • cargo test -p xcl --lib: all passed, 0 failed, ~21 ignored.

Thanks!

**@⁠DavidM1911** on GitHub · 2026-11-24 19:05 UTC · [original](https://github.com/xcl-dev/xcl/pull/1532#issuecomment-7141592983) Verification on RTX 3060 Ti (Windows 11), branch merged with current `main`: - `cargo test -p xcl --lib`: all passed, 0 failed, ~21 ignored. Thanks!
Author
Owner

@⁠throny on GitHub · 2026-11-24 19:38 UTC · original

Two contributors checked independently and found that this PR makes the same change as #570 (for #568): #1607, group D14. They suggest keeping #570. If you agree, closing this PR or joining the other one would save the maintainers a review. If the two differ in a way the checks missed, a note in #1607 helps.

This is a hint, not a request from the maintainers; nobody from the project has adopted #1607 so far.

AI use: Claude Code (Claude Opus 5.5), posted by a script from the #1607 table.

**@⁠throny** on GitHub · 2026-11-24 19:38 UTC · [original](https://github.com/xcl-dev/xcl/pull/1532#issuecomment-7142378684) <!-- xcl-1607-hint:D14 --> Two contributors checked independently and found that this PR makes the same change as #570 (for #568): #1607, group D14. They suggest keeping #570. If you agree, closing this PR or joining the other one would save the maintainers a review. If the two differ in a way the checks missed, a note in #1607 helps. This is a hint, not a request from the maintainers; nobody from the project has adopted #1607 so far. AI use: Claude Code (Claude Opus 5.5), posted by a script from the #1607 table.
Author
Owner

@⁠ivall on GitHub · 2026-11-24 20:42 UTC · original

Closing this as a duplicate: #570 makes the same change and was opened first (under XCL_NETWORK=0 a non-loopback bind is made on loopback). It stays open and is the one that will be reviewed and merged.

This says nothing about the quality of the code here. I compared the two diffs; the pair was also found by independent checks in #1607. If this PR covers a case #570 does not, or #570 is closed without being merged, say so and I'll reopen it. A test that is only here is welcome on #570.

Thank you for the work.

AI use: Claude Code (Claude Opus 5.5) compared the diffs and wrote this comment; the decision is the maintainer's.

**@⁠ivall** on GitHub · 2026-11-24 20:42 UTC · [original](https://github.com/xcl-dev/xcl/pull/1532#issuecomment-7143952404) Closing this as a duplicate: #570 makes the same change and was opened first (under XCL_NETWORK=0 a non-loopback bind is made on loopback). It stays open and is the one that will be reviewed and merged. This says nothing about the quality of the code here. I compared the two diffs; the pair was also found by independent checks in #1607. If this PR covers a case #570 does not, or #570 is closed without being merged, say so and I'll reopen it. A test that is only here is welcome on #570. Thank you for the work. AI use: Claude Code (Claude Opus 5.5) compared the diffs and wrote this comment; the decision is the maintainer's.

Pull request closed

This discussion has been locked. Commenting is limited to contributors.
No description provided.