Skip to content

XCL_NETWORK=0: IPv4-mapped loopback (::ffff:127.x.x.x) goes through - #619

Open
Kalmarv wants to merge 1 commit into
xcl-dev:mainfrom
Kalmarv:fix/netoff-mapped-loopback
Open

Kalmarv wants to merge 1 commit into
xcl-dev:mainfrom
Kalmarv:fix/netoff-mapped-loopback

Conversation

@Kalmarv

@Kalmarv Kalmarv commented Nov 24, 2026 •

Copy link
Copy Markdown
Contributor

With XCL_NETWORK=0 loopback is let through, because titles make socket pairs. loopback knew 127.0.0.0/8 and ::1, but not the IPv4-mapped form: a socket for both IPv6 and IPv4 (IPV6_V6ONLY off) names 127.0.0.1 as ::ffff:127.0.0.1. On main 508a0c7 the hooked connect and sendto refuse that address with WSAENETUNREACH, although its listener is on this machine. The mapped form of 127.0.0.0/8 now counts as loopback.

Follow-up to #305 (closed).

What is in it

  • crates/xcl/src/hle/netoff.rs, loopback: a sockaddr_in6 whose address is ::ffff:127.x.x.x is loopback.
  • hle::netoff::tests::only_loopback_goes_through: the mapped form of 127.0.0.1 is loopback, that of 8.8.8.8 is not.

Tested

  • RTX 5070 Ti, NVIDIA 610.74, Ryzen 9 9950X, Windows 11 Pro 26200; Rust 1.99.0, MSVC stable, debug.
  • cargo test --workspace -- --test-threads=4 on 2970626 (this PR, on main 508a0c7): 680 passed, 0 failed, 41 ignored (the xcl library: 640 passed, 21 ignored). SKIPPED GPU tests: 2, both no wave64 (gpu_geometry_wave32_prefix_count_over_a_mask, gpu_wave32_program_in_wave64_hardware).
  • The changed test:
    • main 508a0c7 with only the two new asserts: fails at the first (the mapped 127.0.0.1);
    • this change: passes.
  • A scratch test, not in the PR, loopback only: a TCP listener and a UDP socket on 127.0.0.1, reached from a socket for both IPv6 and IPv4 as ::ffff:127.0.0.1.
    • main 508a0c7 with the hooks: connect and sendto are refused (10051);
    • this change with the hooks: the connection and the datagram arrive.
  • @MesshM's run on AMD (comment): Radeon RX 9060 XT 16 GB, driver 32.0.32029.2010, Ryzen 7 5700X, Windows 11 Pro 26200, Rust 1.100.0, debug. 2970626 merged onto main dd2ae9a: 690 passed, 0 failed, 41 ignored (the xcl library: 650 passed, 21 ignored), no SKIPPED tests.

Regression run

Our own runs, one after the other on the machine under Tested (RTX 5070 Ti), release builds, no uncommitted changes.

main:

xcl-smoke v1
commit: 508a0c74d7c0625d6d2de8d24494e69dc2e1926f
gpu: NVIDIA GeForce RTX 5070 Ti
title: ea3b5e4d
seconds: 60
exit: 0x0
frames shown: 1513 (PresentX 1513)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 14266 MB

PR:

xcl-smoke v1
commit: 29706267219676b8beab0d05dc8cab5364789014
gpu: NVIDIA GeForce RTX 5070 Ti
title: ea3b5e4d
seconds: 60
exit: 0x0
frames shown: 1510 (PresentX 1510)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 14269 MB

Not tested

  • Whether any title makes its socket pairs this way.
  • The address as a name: getaddrinfo("::ffff:127.0.0.1") is still refused (local_name is unchanged).
  • WSASendTo, which refuses every destination, loopback too, before and after this change.
  • Intel GPUs. Wine.
  • macOS / Linux: not built.
  • It merges without conflicts with Netoff: block ConnectEx when network is disabled #462 (17172b5), whose ConnectEx detour uses the same loopback.

AI use

  • Claude Code, Claude Fable 5.2: wrote the change, the test and this description; the runs above are its own.

🤖 Generated with Claude Code

A socket for both IPv6 and IPv4 names an IPv4 host by its mapped address,
so a connection to 127.0.0.1 from one arrives at the hooks as
::ffff:127.0.0.1. Only ::1 counted as IPv6 loopback, and connect and
sendto refused it (WSAENETUNREACH) although nothing leaves the machine.
Titles make socket pairs on loopback, which is why loopback is let
through at all.

Test: only_loopback_goes_through takes the mapped form of 127.0.0.1 as
loopback and that of 8.8.8.8 as not; the first fails on main.

Co-Authored-By: Claude <noreply@anthropic.com>
@MesshM

MesshM commented Nov 24, 2026

Copy link
Copy Markdown

Test run of 29706267219676b8beab0d05dc8cab5364789014 on AMD RDNA4. I merged it onto current main dd2ae9a 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: 690 passed, 0 failed, 41 ignored, exit code 0; xcl lib tests 650 passed, 0 failed, 21 ignored
  • 0 SKIPPED; only_loopback_goes_through (with the new mapped cases) passes.

Review: The mapped form is checked on the right bytes of sin6_addr (ten zero bytes, ff ff, then 127), and the test builds an AF_INET6 sockaddr with the address at offset 8, so it exercises the same layout the hook reads. A mapped non-loopback address (8.8.8.8) is still refused. 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.

@tiagonleal

tiagonleal commented Nov 24, 2026 •

Copy link
Copy Markdown
Contributor

Windows / NVIDIA test of #612 (bbf3174694) and #619 (2970626721) merged together onto main 47efa2e (both clean), with #570 rebased on top.

Tested

Not tested: a retail run of this combined tree; AMD / Intel.

Run and written with Claude Code (Claude Opus 5.5).

@JJAutoCompare

Copy link
Copy Markdown

Empirical test report (2970626)

Hardware / environment

  • PR XCL_NETWORK=0: IPv4-mapped loopback (::ffff:127.x.x.x) goes through #619 tested at detached commit 29706267219676b8beab0d05dc8cab5364789014 on Windows x64, OS build 10.0.26200.9974.
  • CPU identifier reported by Windows was AMD64 Family 23 Model 113 Stepping 0, AuthenticAMD.
  • Rust 1.100.0 (0ef1bc386, x86_64-pc-windows-msvc), Cargo 1.100.0, and DXC 1.9.2609.5 (01b62ad47). The test profile was unoptimized, with debug info and incremental compilation disabled.
  • The focused run used XCL_ADAPTER=NONE_CPU_ONLY and RUST_TEST_NOCAPTURE=1. Both commands ran directly, outside Invoke-ArcTest.ps1, with no Arc GPU mutex hold.

Commands and results

  • cargo test --workspace --no-run — exit 0. Cargo built the workspace test executables. This step compiled only.
  • cargo test -p xcl --lib hle::netoff::tests:: -- --test-threads=1 — exit 0. 2 passed / 0 failed / 0 ignored / 0 skipped. Libtest filtered out 659 tests. The skipped count is the number of case-sensitive ^SKIPPED lines in the combined output.
  • Both commands emitted a deprecation warning for AtomicU32::fetch_update in XGameRuntime. The PR extends one unit test and changes no integration tests.

Observed behavior

  • only_loopback_goes_through accepted ::ffff:127.0.0.1 and rejected ::ffff:8.8.8.8 as socket address inputs. Its existing IPv4 and IPv6 loopback checks also passed.
  • the_systems_own_network_functions_refuse confirmed that the system hooks reject the WinHTTP and WinINet calls and the external name lookup in the test. The localhost lookup reached Winsock.

Not tested

  • Full GPU workspace suite, game smoke runs, and live traffic over a dual-stack socket.

AI use

Verified with T3 Code / Codex (gpt-6.2-sol, reasoningEffort: high). Coordinator #2 (T3 Code / Antigravity, gemini-4-neon) verified counts against pr619-focused.log and published.

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.

4 participants