HLE net: classify bracketed IPv6 literals as IP literals in reachable_name #3068

Open
Dukestar69 wants to merge 2 commits from upstream-pr/3070 into main
Dukestar69 commented 2026-11-26 06:17:48 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by Dukestar69 on 2026-11-26T06:17:48Z.


Summary

Classifies bracketed IPv6 literals (such as [2001:db8::1]) consistently as IP literals in reachable_name so blocked non-loopback bracketed IPv6 connects report WSAENETUNREACH instead of WSAHOST_NOT_FOUND, and tightens bracket stripping in loopback_name to match only a single surrounding [...] pair.

Why

loopback_name in crates/victory-hle/src/modules/net.rs already strips brackets around IPv6 literals ([::1]), but reachable_name immediately below called name.parse::<IpAddr>() on the unstripped string. As a result, a blocked connect to [2001:db8::1] set WSAHOST_NOT_FOUND (11001) instead of WSAENETUNREACH (10051). Using a shared bare_host helper (strip_prefix('[').and_then(|s| s.strip_suffix(']')).unwrap_or(name)) fixes reachable_name and also avoids accepting malformed/unmatched brackets like [::1 or [[::1]] in loopback_name.

Verification

  • Added unit test modules::net::tests::bracketed_ipv6_literal_fails_with_netunreach_not_host_not_found:
    • Failed on 63bcca4 (left: 11001, right: 10051).
    • Passes with fix.
  • cargo test -p victory-hle net::tests: 3 passed, 0 failed.
  • cargo clippy -p victory-hle --all-targets -- -D warnings: clean.
  • cargo xtask policy: 191 files ok.

Synthetic tests only (no game files used). AI-assisted (Gemini 4 Neon).

<!-- greyfinch-sync:Marvisak/VIctory:issue:5505064737 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/3070). Originally posted by [Dukestar69](https://github.com/Dukestar69) on 2026-11-26T06:17:48Z. --- ## Summary Classifies bracketed IPv6 literals (such as `[2001:db8::1]`) consistently as IP literals in `reachable_name` so blocked non-loopback bracketed IPv6 connects report `WSAENETUNREACH` instead of `WSAHOST_NOT_FOUND`, and tightens bracket stripping in `loopback_name` to match only a single surrounding `[...]` pair. ### Why `loopback_name` in `crates/victory-hle/src/modules/net.rs` already strips brackets around IPv6 literals (`[::1]`), but `reachable_name` immediately below called `name.parse::<IpAddr>()` on the unstripped string. As a result, a blocked connect to `[2001:db8::1]` set `WSAHOST_NOT_FOUND` (11001) instead of `WSAENETUNREACH` (10051). Using a shared `bare_host` helper (`strip_prefix('[').and_then(|s| s.strip_suffix(']')).unwrap_or(name)`) fixes `reachable_name` and also avoids accepting malformed/unmatched brackets like `[::1` or `[[::1]]` in `loopback_name`. ### Verification - Added unit test `modules::net::tests::bracketed_ipv6_literal_fails_with_netunreach_not_host_not_found`: - Failed on `63bcca4` (`left: 11001, right: 10051`). - Passes with fix. - `cargo test -p victory-hle net::tests`: 3 passed, 0 failed. - `cargo clippy -p victory-hle --all-targets -- -D warnings`: clean. - `cargo xtask policy`: 191 files ok. Synthetic tests only (no game files used). AI-assisted (Gemini 4 Neon).
kotekompotek commented 2026-11-26 06:31:55 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by kotekompotek on 2026-11-26T06:31:55Z.

Review: APPROVED


Verified: bare_host strips exactly one matched bracket pair, so [::1 and ::1 no longer collapse to parseable literals; reachable_name now classifies bracketed literals as IP literals -> WSAENETUNREACH instead of HOST_NOT_FOUND. Test covers all four bracket shapes.

<!-- greyfinch-sync:Marvisak/VIctory:review:6069530310 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/3070#pullrequestreview-6069530310). Originally posted by [kotekompotek](https://github.com/kotekompotek) on 2026-11-26T06:31:55Z. **Review:** APPROVED --- Verified: bare_host strips exactly one matched bracket pair, so [::1 and [[::1]] no longer collapse to parseable literals; reachable_name now classifies bracketed literals as IP literals -> WSAENETUNREACH instead of HOST_NOT_FOUND. Test covers all four bracket shapes.
fuzeofficlal commented 2026-11-26 08:42:01 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by fuzeofficlal on 2026-11-26T08:42:01Z.

Review: CHANGES_REQUESTED


Verified 64588459 locally on Windows 11 x64:

  • cargo clippy --all-targets --locked -- -D warnings: clean (1.58s).
  • cargo test -p xtask --locked policy::tests::repository_passes_policy: 1 passed, 0 failed (0.34s).
  • cargo test -p victory-hle --locked: 155 passed, 0 failed (153 lib + 1 fidelityfx + 1 no_dll_planting, 5.17s).
  • rustfmt --edition 2024 --check crates/victory-hle/src/modules/net.rs: clean.

bare_host (crates/victory-hle/src/modules/net.rs:135-145, 167-176) fixes the error code for [2001:db8::1] and rejects malformed inputs like [::1 and [[::1]], but because it strips any [...] pair before calling parse::<IpAddr>() and comparing "localhost", it also reclassifies bracketed IPv4 [1.2.3.4] from WSAHOST_NOT_FOUND (on main) to WSAENETUNREACH, and still lets [127.0.0.1] and [localhost] pass loopback_name.

Per RFC 3986 section 3.2.2, only IPv6 literals belong inside [...]. Please restrict bracketed stripping to inputs whose inner slice parses as std::net::Ipv6Addr, and add test cases for [1.2.3.4], [127.0.0.1], and [localhost] (plus ::1], [::1%1], and [2001:db8::1]:443).

<!-- greyfinch-sync:Marvisak/VIctory:review:6070869982 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/3070#pullrequestreview-6070869982). Originally posted by [fuzeofficlal](https://github.com/fuzeofficlal) on 2026-11-26T08:42:01Z. **Review:** CHANGES_REQUESTED --- Verified `64588459` locally on Windows 11 x64: - `cargo clippy --all-targets --locked -- -D warnings`: clean (`1.58s`). - `cargo test -p xtask --locked policy::tests::repository_passes_policy`: 1 passed, 0 failed (`0.34s`). - `cargo test -p victory-hle --locked`: 155 passed, 0 failed (`153` lib + `1` fidelityfx + `1` no_dll_planting, `5.17s`). - `rustfmt --edition 2024 --check crates/victory-hle/src/modules/net.rs`: clean. `bare_host` (`crates/victory-hle/src/modules/net.rs:135-145, 167-176`) fixes the error code for `[2001:db8::1]` and rejects malformed inputs like `[::1` and `[[::1]]`, but because it strips any `[...]` pair before calling `parse::<IpAddr>()` and comparing `"localhost"`, it also reclassifies bracketed IPv4 `[1.2.3.4]` from `WSAHOST_NOT_FOUND` (on `main`) to `WSAENETUNREACH`, and still lets `[127.0.0.1]` and `[localhost]` pass `loopback_name`. Per RFC 3986 section 3.2.2, only IPv6 literals belong inside `[...]`. Please restrict bracketed stripping to inputs whose inner slice parses as `std::net::Ipv6Addr`, and add test cases for `[1.2.3.4]`, `[127.0.0.1]`, and `[localhost]` (plus `::1]`, `[::1%1]`, and `[2001:db8::1]:443`).
Marvisak commented 2026-11-26 09:06:07 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by Marvisak on 2026-11-26T08:23:22Z.


Automated triage for the maintainers.

Verdict: merge candidate. In modules/net.rs, bare_host strips exactly one surrounding [...] pair. loopback_name no longer takes [::1 or [[::1]] for loopback, which only tightens the offline guard: such names were passed to the host before. reachable_name now classes a bracketed literal as an IP literal (WSAENETUNREACH), as the module doc and loopback_name already treat it.

The new test covers both. CI: not run on this head yet (the workflow needs a maintainer's approval for this contributor), so this verdict depends on it passing.


Generated by Claude Code

<!-- greyfinch-sync:Marvisak/VIctory:comment:7186534518 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/3070#issuecomment-7186534518). Originally posted by [Marvisak](https://github.com/Marvisak) on 2026-11-26T08:23:22Z. --- <!-- victory-triage v1 head=64588459a0bb1e9a51fa48db72919ed2645aeb32 verdict=merge-candidate at=2026-11-26T08:18:50Z --> Automated triage for the maintainers. **Verdict: merge candidate.** In `modules/net.rs`, `bare_host` strips exactly one surrounding `[...]` pair. `loopback_name` no longer takes `[::1` or `[[::1]]` for loopback, which only tightens the offline guard: such names were passed to the host before. `reachable_name` now classes a bracketed literal as an IP literal (`WSAENETUNREACH`), as the module doc and `loopback_name` already treat it. The new test covers both. CI: not run on this head yet (the workflow needs a maintainer's approval for this contributor), so this verdict depends on it passing. --- _Generated by [Claude Code](https://claude.ai/code)_
fuzeofficlal commented 2026-11-26 10:03:14 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by fuzeofficlal on 2026-11-26T10:03:14Z.

Review: APPROVED


parse_ip_literal cleanly resolves the bracket-stripping regression from 64588459. Bracketed IPv4 inputs ([1.2.3.4], [127.0.0.1]), [localhost], [::1%1], [2001:db8::1]:443, and unmatched/nested brackets now fall through to WSAHOST_NOT_FOUND, while valid [2001:db8::1] returns WSAENETUNREACH and [::1] / [::ffff:127.0.0.1] still pass loopback canonicalization.

Verified locally on Windows 11 x64 (09257ae1):

  • rustfmt --edition 2024 --check crates/victory-hle/src/modules/net.rs: clean
  • cargo run --locked -p xtask -- policy: passed (191 files ok)
  • cargo clippy -p victory-hle --all-targets --locked -- -D warnings (default and --all-features): clean
  • cargo test -p victory-hle --lib --locked modules::net::: 3 passed, 0 failed
  • cargo test -p victory-hle --locked: 153 lib + 2 integration tests passed, 0 failed

Optional: adding [::ffff:127.0.0.1] and [] to the test table would round out the boundary matrix.

<!-- greyfinch-sync:Marvisak/VIctory:review:6072052306 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/3070#pullrequestreview-6072052306). Originally posted by [fuzeofficlal](https://github.com/fuzeofficlal) on 2026-11-26T10:03:14Z. **Review:** APPROVED --- `parse_ip_literal` cleanly resolves the bracket-stripping regression from `64588459`. Bracketed IPv4 inputs (`[1.2.3.4]`, `[127.0.0.1]`), `[localhost]`, `[::1%1]`, `[2001:db8::1]:443`, and unmatched/nested brackets now fall through to `WSAHOST_NOT_FOUND`, while valid `[2001:db8::1]` returns `WSAENETUNREACH` and `[::1]` / `[::ffff:127.0.0.1]` still pass loopback canonicalization. Verified locally on Windows 11 x64 (`09257ae1`): - `rustfmt --edition 2024 --check crates/victory-hle/src/modules/net.rs`: clean - `cargo run --locked -p xtask -- policy`: passed (`191 files ok`) - `cargo clippy -p victory-hle --all-targets --locked -- -D warnings` (default and `--all-features`): clean - `cargo test -p victory-hle --lib --locked modules::net::`: 3 passed, 0 failed - `cargo test -p victory-hle --locked`: 153 lib + 2 integration tests passed, 0 failed Optional: adding `[::ffff:127.0.0.1]` and `[]` to the test table would round out the boundary matrix.
Dukestar69 commented 2026-11-26 10:05:06 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by Dukestar69 on 2026-11-26T09:31:13Z.


Good catch @fuzeofficlal, thanks! Fixed in 09257ae:

  • Replaced bare_host with parse_ip_literal so [...] stripping only accepts inner slices that parse as std::net::Ipv6Addr (per RFC 3986 section 3.2.2).
  • [1.2.3.4], [127.0.0.1], [localhost], ::1], [::1%1], and [2001:db8::1]:443 are no longer treated as loopback or IP literals and return WSAHOST_NOT_FOUND; all added to bracketed_ipv6_literal_fails_with_netunreach_not_host_not_found.
  • Re-verified rustfmt --edition 2024 --check, cargo test -p victory-hle --locked --lib modules::net:: (3/3 passed), cargo clippy -p victory-hle --all-targets --locked -- -D warnings (clean), and cargo xtask policy (191 files ok).

Synthetic tests only (no game files used). AI-assisted (Gemini 4 Neon).

<!-- greyfinch-sync:Marvisak/VIctory:comment:7188099800 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/3070#issuecomment-7188099800). Originally posted by [Dukestar69](https://github.com/Dukestar69) on 2026-11-26T09:31:13Z. --- Good catch @fuzeofficlal, thanks! Fixed in `09257ae`: - Replaced `bare_host` with `parse_ip_literal` so `[...]` stripping only accepts inner slices that parse as `std::net::Ipv6Addr` (per RFC 3986 section 3.2.2). - `[1.2.3.4]`, `[127.0.0.1]`, `[localhost]`, `::1]`, `[::1%1]`, and `[2001:db8::1]:443` are no longer treated as loopback or IP literals and return `WSAHOST_NOT_FOUND`; all added to `bracketed_ipv6_literal_fails_with_netunreach_not_host_not_found`. - Re-verified `rustfmt --edition 2024 --check`, `cargo test -p victory-hle --locked --lib modules::net::` (3/3 passed), `cargo clippy -p victory-hle --all-targets --locked -- -D warnings` (clean), and `cargo xtask policy` (191 files ok). Synthetic tests only (no game files used). AI-assisted (Gemini 4 Neon).
futurepro62 commented 2026-11-27 10:45:23 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by futurepro62 on 2026-11-27T10:45:23Z.


NVIDIA full-suite run, to go with the reports above by fuzeofficlal, since none of them names a GPU run. Tested exact head 09257ae (on its base 63bcca4).

Tested

  • NVIDIA GeForce RTX 5070 Ti 16 GB (Blackwell, 32-lane waves only, mesh shaders), driver 621.40, Ryzen 7 9800X3D, Windows 11 Home 26300, Rust 1.98.1 MSVC (pinned), dxil.dll from Windows SDK 10.0.26100 (the loader's default), debug.
  • cargo build --workspace --locked, then cargo test --workspace --locked --no-fail-fast -- --test-threads=4 --skip emit::memory_tests::heap_direct_texture_reads_mark_their_heap_index --skip descriptor::host::tests::dynamic_slots_are_held_until_released --skip memory::tests::lists_share_a_table_and_copies_keep_their_views --skip emit::stride_tests::a_heap_buffer_read_by_element_takes_the_views_stride --skip emit::stride_tests::a_heap_buffer_read_where_no_buffer_view_is_reads_zeros --skip emit::synthetic_tests::gathers_at_a_level_match_the_hardware: 867 passed, 0 failed, 10 ignored.
  • The new tests ran and passed: bracketed_ipv6_literal_fails_with_netunreach_not_host_not_found.
  • --skip leaves out tests that fail on main 63bcca4 on this card too, not because of this PR: heap_direct_texture_reads_mark_their_heap_index ends the victory-shader test process with 0xc0000005 (#2571), so without the skip the rest of that crate never reports; dynamic_slots_are_held_until_released, lists_share_a_table_and_copies_keep_their_views and the two stride_tests hit the 1,000,000-view heap cap of NVIDIA drivers (#1835, #2317); gathers_at_a_level_match_the_hardware fails on lane 0 (#1744).

Not tested

  • AMD (the tests take the default adapter), a release build, the title (test run only).

AI use

  • Claude Code (Claude Opus 5.5) ran the tests and wrote this report. I checked it before posting.
<!-- greyfinch-sync:Marvisak/VIctory:comment:7216266898 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/3070#issuecomment-7216266898). Originally posted by [futurepro62](https://github.com/futurepro62) on 2026-11-27T10:45:23Z. --- NVIDIA full-suite run, to go with the reports above by fuzeofficlal, since none of them names a GPU run. Tested exact head `09257ae` (on its base `63bcca4`). **Tested** - NVIDIA GeForce RTX 5070 Ti 16 GB (Blackwell, 32-lane waves only, mesh shaders), driver 621.40, Ryzen 7 9800X3D, Windows 11 Home 26300, Rust 1.98.1 MSVC (pinned), `dxil.dll` from Windows SDK 10.0.26100 (the loader's default), debug. - `cargo build --workspace --locked`, then `cargo test --workspace --locked --no-fail-fast -- --test-threads=4 --skip emit::memory_tests::heap_direct_texture_reads_mark_their_heap_index --skip descriptor::host::tests::dynamic_slots_are_held_until_released --skip memory::tests::lists_share_a_table_and_copies_keep_their_views --skip emit::stride_tests::a_heap_buffer_read_by_element_takes_the_views_stride --skip emit::stride_tests::a_heap_buffer_read_where_no_buffer_view_is_reads_zeros --skip emit::synthetic_tests::gathers_at_a_level_match_the_hardware`: **867 passed, 0 failed, 10 ignored**. - The new tests ran and passed: `bracketed_ipv6_literal_fails_with_netunreach_not_host_not_found`. - `--skip` leaves out tests that fail on main `63bcca4` on this card too, not because of this PR: `heap_direct_texture_reads_mark_their_heap_index` ends the `victory-shader` test process with `0xc0000005` (#2571), so without the skip the rest of that crate never reports; `dynamic_slots_are_held_until_released`, `lists_share_a_table_and_copies_keep_their_views` and the two `stride_tests` hit the 1,000,000-view heap cap of NVIDIA drivers (#1835, #2317); `gathers_at_a_level_match_the_hardware` fails on lane 0 (#1744). **Not tested** - AMD (the tests take the default adapter), a release build, the title (test run only). **AI use** - Claude Code (Claude Opus 5.5) ran the tests and wrote this report. I checked it before posting.
This pull request cannot be merged automatically due to conflicts.
Merge manually to resolve the conflicts.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin 'upstream-pr/3070:upstream-pr/3070'
git switch 'upstream-pr/3070'

Merge

Merge the changes and update on Forgejo.

Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.

git switch 'main'
git merge --no-ff 'upstream-pr/3070'
git switch 'upstream-pr/3070'
git rebase 'main'
git switch 'main'
git merge --ff-only 'upstream-pr/3070'
git switch 'upstream-pr/3070'
git rebase 'main'
git switch 'main'
git merge --no-ff 'upstream-pr/3070'
git switch 'main'
git merge --squash 'upstream-pr/3070'
git switch 'main'
git merge --ff-only 'upstream-pr/3070'
git switch 'main'
git merge 'upstream-pr/3070'
git push origin 'main'
Sign in to join this conversation.
No reviewers
No labels
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.

Reference
Marvisak/VIctory!3068
No description provided.