fix(libSceNet): follow FreeBSD inet text rules for IPv6 #9494

Merged
EagleBearerYS merged 6 commits from upstream-pr/9494 into main 2026-10-25 17:23:22 +00:00
EagleBearerYS commented 2026-10-21 23:21:47 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by EagleBearerYS on 2026-10-21T23:21:47Z.


Opened again from #4886: title-less conformance fixes of this kind are merged now, for example #7365 and #8411.

What

On Windows, sceNetInetPton and sceNetInetNtop (libSceNet/Export.cpp) convert IPv6 text with Winsock's InetPtonA and InetNtopA, whose text rules differ from FreeBSD 11.4's. This is the libSceNet half of #3126: #3530 fixed the same difference in libkernel's inet_pton and inet_ntop.

With Winsock, which main's functions return as is, and with glibc, whose rules match FreeBSD's:

Call Windows on main Linux, and FreeBSD
sceNetInetNtop of ::ffff:0.0.0.1 ::ffff:0:1 ::ffff:0.0.0.1
sceNetInetNtop of ::ffff:0:102:304 ::ffff:0:1.2.3.4 ::ffff:0:102:304
sceNetInetNtop of fe80::5efe:102:304 fe80::5efe:1.2.3.4 fe80::5efe:102:304
sceNetInetPton of ::01.2.3.4 1 0
sceNetInetPton of ::1.2.3.04 1 0
sceNetInetPton of ::ffff:01.2.3.4 1 0

FreeBSD:

Both functions now convert IPv6 text with libkernel's __inet_pton_nid_postfix and __inet_ntop_nid_postfix, on every host. IPv4 text keeps the host conversion: #7921 and #8056 gave sceNetInetPton IPv4 rules measured on a PS4 since #4886 was opened, so this PR no longer touches IPv4. libSceNet's own handling around the conversion stays as main has it:

  • null pointers give EINVAL, and another family gives EAFNOSUPPORT;
  • a failed conversion leaves the destination unchanged;
  • sceNetInetNtop still converts into its own buffer and copies the text, so a short buffer still gives ENOSPC (28) through sceNetErrnoLoc.

Linux already follows these rules through glibc, so nothing changes there. No title is claimed. The new debt entry says that the IPv6 rules are libkernel's and unverified on a console, as libkernel's own entry does.

Overlap: #9231 (Gonic0) adds a macOS check of an IPv4 address's leading zeros in sceNetInetPton, before the host conversion this PR leaves IPv4 to. The two merge without a conflict in either order, and Gonic0 agreed that neither waits for the other (comment). #9506 (Noxy-HNR) changes the DNS functions in the same Export.cpp and other lines of libSceNet's debt file; it merges cleanly with this PR, and no order is needed.

Tested

On GitHub's runners from my fork, merged with main at a6dcea9279 (run):

  • guest_sce_net checks three more round trips with CheckAddressText: ::ffff:0.0.0.1, ::ffff:0:102:304 and fe80::5efe:102:304. Each goes from text to an address and back, with ENOSPC for every buffer shorter than the text.
  • New CheckRejectedAddressText checks that sceNetInetPton returns 0 and leaves the destination untouched for ::01.2.3.4 and ::ffff:01.2.3.4.
  • Windows: with main's Export.cpp guest_sce_net fails. With the change it passes 10 runs in a row, with main's IPv4 whitespace and sceNetInetPtonEx checks.
  • Linux: guest_sce_net passes with main's code, because glibc already follows these rules, and 10 runs in a row with the change.
  • On both, every test registered under core/libs/prx/libc and core/libs/prx/libkernel passes: 115 and 197 on Linux, 142 and 207 on Windows.
  • After the merge with main at 4a17c71757 (094e920c5d, no conflicts, the PR's own diff unchanged; run): guest_sce_net fails on Windows with main's Export.cpp and passes 10 runs in a row with the change; on Linux it passes both ways. The libc and libkernel suites pass on both (116 and 197 on Linux, 143 and 207 on Windows).
  • tools/check_conventions.py --base origin/main passes.
  • Not tested: macOS, a console, any title.
  • fca8266468, a merge of main db6af9e0fd (run). main now has #10275 (orezraey's sceNetInetPton, measured on a PS5: a null dst for IPv6 returns NET_EINVAL, IPv4 text ends at the first whitespace, and the dotted IPv4 part of IPv6 text is checked the same way). The merge keeps that function as main has it and sends only its IPv6 conversion through libkernel's inet_pton, as this PR does; the IPv4 conversion and the dotted-part check stay on the host. The debt file keeps main's measured entry and this PR's IPv6 entry, which now says the FreeBSD forms are unverified on a console beyond those PS5 measurements. guest_sce_net passes 10 runs in a row on both runners, 1 of 1 each, none skipped. The libc suite passes on both; in the Windows libkernel suite guest_raise_in_system_call timed out, a known intermittent timeout on GitHub's Windows runner. The suites run with APS5_SKIP_TIMING_TESTS=1, which relaxes precise_wait's median bounds on GitHub's hosted runners.
  • fc881b9259, a merge of main e05ba6feeb (run). main's #10706 removes the local declarations at the top of libSceNet's Export.cpp, where this PR had added __inet_pton and __inet_ntop. libkernel's Api.hpp, which Export.cpp includes, now declares both, so the merge takes main's side there. The guest_sce_net and public_headers tests pass 10 runs in a row. Linux: 2 run, 2 pass, 0 skip, 0 fail. Windows: 2 run, 2 pass, 0 skip, 0 fail. The before arm fails guest_sce_net on Windows. Suites: libc and libkernel pass on Linux (144 and 207) and on Windows (171 and 223). The suites ran with APS5_SKIP_TIMING_TESTS=1, which relaxes precise_wait's median bounds on GitHub's hosted runners.

Checklist

  • Based on current main; no other open PR implements the same functions
  • One topic per PR; follow-ups go in a new PR
  • No comments in code except technical debt
  • Unimplemented paths throw (NotImplemented_nid_no_patch); silent stubs are listed under Silent stubs in their library's technical debt file
  • No notes, investigation .md files or images added to the repository (attach them to this PR)
  • New third-party code is a submodule built from source
  • Generic behaviour, not specific to one title
  • Depends on: none (no order with #9231, agreed in its thread, or with #9506)
  • Fixes: none
  • Unblocks: none
  • GPUs tested: n/a
  • AI-assisted: yes
<!-- greyfinch-sync:boykopovar/AnyPS5:issue:4959681618 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/9494). Originally posted by [EagleBearerYS](https://github.com/EagleBearerYS) on 2026-10-21T23:21:47Z. --- Opened again from #4886: title-less conformance fixes of this kind are merged now, for example #7365 and #8411. ### What On Windows, `sceNetInetPton` and `sceNetInetNtop` (`libSceNet/Export.cpp`) convert IPv6 text with Winsock's `InetPtonA` and `InetNtopA`, whose text rules differ from FreeBSD 11.4's. This is the libSceNet half of #3126: #3530 fixed the same difference in libkernel's `inet_pton` and `inet_ntop`. With Winsock, which `main`'s functions return as is, and with glibc, whose rules match FreeBSD's: | Call | Windows on `main` | Linux, and FreeBSD | |---|---|---| | `sceNetInetNtop` of `::ffff:0.0.0.1` | `::ffff:0:1` | `::ffff:0.0.0.1` | | `sceNetInetNtop` of `::ffff:0:102:304` | `::ffff:0:1.2.3.4` | `::ffff:0:102:304` | | `sceNetInetNtop` of `fe80::5efe:102:304` | `fe80::5efe:1.2.3.4` | `fe80::5efe:102:304` | | `sceNetInetPton` of `::01.2.3.4` | 1 | 0 | | `sceNetInetPton` of `::1.2.3.04` | 1 | 0 | | `sceNetInetPton` of `::ffff:01.2.3.4` | 1 | 0 | FreeBSD: - prints a dotted tail only for `::a.b.c.d` and `::ffff:a.b.c.d` ([`inet_ntop.c` L167-L170](https://github.com/freebsd/freebsd-src/blob/d106002967eff712894ab8b5337bbbff106ce5e0/lib/libc/inet/inet_ntop.c#L167-L170)); - parses a dotted tail with `inet_pton4` ([`inet_pton.c` L181-L182](https://github.com/freebsd/freebsd-src/blob/d106002967eff712894ab8b5337bbbff106ce5e0/lib/libc/inet/inet_pton.c#L181-L182)), which rejects a leading zero ([L94-L95](https://github.com/freebsd/freebsd-src/blob/d106002967eff712894ab8b5337bbbff106ce5e0/lib/libc/inet/inet_pton.c#L94-L95)). Both functions now convert IPv6 text with libkernel's `__inet_pton_nid_postfix` and `__inet_ntop_nid_postfix`, on every host. IPv4 text keeps the host conversion: #7921 and #8056 gave `sceNetInetPton` IPv4 rules measured on a PS4 since #4886 was opened, so this PR no longer touches IPv4. libSceNet's own handling around the conversion stays as `main` has it: - null pointers give `EINVAL`, and another family gives `EAFNOSUPPORT`; - a failed conversion leaves the destination unchanged; - `sceNetInetNtop` still converts into its own buffer and copies the text, so a short buffer still gives `ENOSPC` (28) through `sceNetErrnoLoc`. Linux already follows these rules through glibc, so nothing changes there. No title is claimed. The new debt entry says that the IPv6 rules are libkernel's and unverified on a console, as libkernel's own entry does. **Overlap:** #9231 (Gonic0) adds a macOS check of an IPv4 address's leading zeros in `sceNetInetPton`, before the host conversion this PR leaves IPv4 to. The two merge without a conflict in either order, and Gonic0 agreed that neither waits for the other ([comment](https://github.com/boykopovar/AnyPS5/pull/9231#issuecomment-6332879742)). #9506 (Noxy-HNR) changes the DNS functions in the same `Export.cpp` and other lines of libSceNet's debt file; it merges cleanly with this PR, and no order is needed. ### Tested On GitHub's runners from my fork, merged with `main` at a6dcea9279 ([run](https://github.com/EagleBearerYS/AnyPS5/actions/runs/39689363783)): - `guest_sce_net` checks three more round trips with `CheckAddressText`: `::ffff:0.0.0.1`, `::ffff:0:102:304` and `fe80::5efe:102:304`. Each goes from text to an address and back, with `ENOSPC` for every buffer shorter than the text. - New `CheckRejectedAddressText` checks that `sceNetInetPton` returns 0 and leaves the destination untouched for `::01.2.3.4` and `::ffff:01.2.3.4`. - Windows: with `main`'s `Export.cpp` `guest_sce_net` fails. With the change it passes 10 runs in a row, with `main`'s IPv4 whitespace and `sceNetInetPtonEx` checks. - Linux: `guest_sce_net` passes with `main`'s code, because glibc already follows these rules, and 10 runs in a row with the change. - On both, every test registered under `core/libs/prx/libc` and `core/libs/prx/libkernel` passes: 115 and 197 on Linux, 142 and 207 on Windows. - **After the merge with `main` at 4a17c71757** (094e920c5d, no conflicts, the PR's own diff unchanged; [run](https://github.com/EagleBearerYS/AnyPS5/actions/runs/39728903444)): `guest_sce_net` fails on Windows with `main`'s `Export.cpp` and passes 10 runs in a row with the change; on Linux it passes both ways. The libc and libkernel suites pass on both (116 and 197 on Linux, 143 and 207 on Windows). - `tools/check_conventions.py --base origin/main` passes. - Not tested: macOS, a console, any title. - **fca8266468, a merge of `main` db6af9e0fd** ([run](https://github.com/EagleBearerYS/AnyPS5/actions/runs/40053500269)). `main` now has #10275 (orezraey's `sceNetInetPton`, measured on a PS5: a null `dst` for IPv6 returns `NET_EINVAL`, IPv4 text ends at the first whitespace, and the dotted IPv4 part of IPv6 text is checked the same way). The merge keeps that function as `main` has it and sends only its IPv6 conversion through libkernel's `inet_pton`, as this PR does; the IPv4 conversion and the dotted-part check stay on the host. The debt file keeps `main`'s measured entry and this PR's IPv6 entry, which now says the FreeBSD forms are unverified on a console beyond those PS5 measurements. `guest_sce_net` passes 10 runs in a row on both runners, 1 of 1 each, none skipped. The libc suite passes on both; in the Windows libkernel suite `guest_raise_in_system_call` timed out, a known intermittent timeout on GitHub's Windows runner. The suites run with `APS5_SKIP_TIMING_TESTS=1`, which relaxes `precise_wait`'s median bounds on GitHub's hosted runners. - **fc881b9259, a merge of `main` e05ba6feeb** ([run](https://github.com/EagleBearerYS/AnyPS5/actions/runs/40200858122)). `main`'s #10706 removes the local declarations at the top of libSceNet's `Export.cpp`, where this PR had added `__inet_pton` and `__inet_ntop`. libkernel's `Api.hpp`, which `Export.cpp` includes, now declares both, so the merge takes `main`'s side there. The `guest_sce_net` and `public_headers` tests pass 10 runs in a row. Linux: 2 run, 2 pass, 0 skip, 0 fail. Windows: 2 run, 2 pass, 0 skip, 0 fail. The before arm fails `guest_sce_net` on Windows. Suites: libc and libkernel pass on Linux (144 and 207) and on Windows (171 and 223). The suites ran with `APS5_SKIP_TIMING_TESTS=1`, which relaxes `precise_wait`'s median bounds on GitHub's hosted runners. ### Checklist <!-- Rules behind each item: https://github.com/boykopovar/AnyPS5/blob/main/CONTRIBUTING.md --> - [x] Based on current `main`; no other open PR implements the same functions - [x] One topic per PR; follow-ups go in a new PR - [x] No comments in code except [technical debt](https://github.com/boykopovar/AnyPS5/blob/main/docs/dev/CONVENTIONS.md) - [x] Unimplemented paths throw (`NotImplemented_nid_no_patch`); silent stubs are listed under Silent stubs in their library's [technical debt](https://github.com/boykopovar/AnyPS5/tree/main/docs/dev/debt) file - [x] No notes, investigation `.md` files or images added to the repository (attach them to this PR) - [x] New third-party code is a submodule built from source - [x] Generic behaviour, not specific to one title - [x] Depends on: none (no order with #9231, agreed in its thread, or with #9506) - [x] Fixes: none - [x] Unblocks: none - [x] GPUs tested: n/a - [x] AI-assisted: yes
MarcZX10 commented 2026-10-21 23:27:16 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-21T23:27:16Z.

Review: APPROVED


Reviewed the IPv6 conversion routing and regression coverage. The change delegates only IPv6 text conversion to libkernel’s FreeBSD-compatible helpers, leaves IPv4 conversion untouched, and retains libSceNet’s surrounding error and destination-buffer behavior. The tests cover mapped and embedded IPv4 forms, rejection of dotted octets with leading zeroes, and destination preservation. The reported Linux and Windows guest suites pass; conventions, intake, eligibility, labels and report checks pass, while hosted product builds are skipped.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5607466302 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/9494#pullrequestreview-5607466302). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-10-21T23:27:16Z. **Review:** APPROVED --- Reviewed the IPv6 conversion routing and regression coverage. The change delegates only IPv6 text conversion to libkernel’s FreeBSD-compatible helpers, leaves IPv4 conversion untouched, and retains libSceNet’s surrounding error and destination-buffer behavior. The tests cover mapped and embedded IPv4 forms, rejection of dotted octets with leading zeroes, and destination preservation. The reported Linux and Windows guest suites pass; conventions, intake, eligibility, labels and report checks pass, while hosted product builds are skipped.
MarcZX10 commented 2026-10-22 02:11:19 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-22T02:11:19Z.

Review: APPROVED


Re-reviewed the current head and manually checked the shared-file warnings. The open PRs listed there change adjacent socket functions, other exports, or unrelated test cases; none overlaps the IPv6 text-conversion implementation or its assertions. The conversion change remains limited to IPv6 and uses libkernel's FreeBSD-compatible helpers; IPv4 host conversion and libSceNet's error handling remain intact. The reported Windows and Linux guest suites cover the changed behavior. Hosted policy checks pass; product and relinker jobs are skipped. No local tests were run.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5608482351 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/9494#pullrequestreview-5608482351). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-10-22T02:11:19Z. **Review:** APPROVED --- Re-reviewed the current head and manually checked the shared-file warnings. The open PRs listed there change adjacent socket functions, other exports, or unrelated test cases; none overlaps the IPv6 text-conversion implementation or its assertions. The conversion change remains limited to IPv6 and uses libkernel's FreeBSD-compatible helpers; IPv4 host conversion and libSceNet's error handling remain intact. The reported Windows and Linux guest suites cover the changed behavior. Hosted policy checks pass; product and relinker jobs are skipped. No local tests were run.
MarcZX10 commented 2026-10-22 04:26:51 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-22T04:26:51Z.

Review: DISMISSED


The IPv6 conversion change remains narrowly scoped and the reported tests cover the changed Windows behavior, invalid dotted-tail leading zeroes and output preservation; IPv4 conversion and the surrounding error contract stay intact. I manually checked the uncomparable export warnings at a high level, but the live overlap table now includes #9506 touching Export.cpp and the same debt file. Its DNS implementation and this PR’s IPv6 conversion are distinct behavior, but the shared export/debt hunks need a current combined-base check and both registrations/entries must survive. The PR is based on a6dcea9279 while current upstream main is ab347d144d. Please rebase, coordinate/record any needed merge order with #9506, and rerun the focused guest_sce_net test and conventions/overlap checks on current main. Hosted product jobs are skipped; I did not run local tests.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5609257951 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/9494#pullrequestreview-5609257951). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-10-22T04:26:51Z. **Review:** DISMISSED --- The IPv6 conversion change remains narrowly scoped and the reported tests cover the changed Windows behavior, invalid dotted-tail leading zeroes and output preservation; IPv4 conversion and the surrounding error contract stay intact. I manually checked the uncomparable export warnings at a high level, but the live overlap table now includes #9506 touching `Export.cpp` and the same debt file. Its DNS implementation and this PR’s IPv6 conversion are distinct behavior, but the shared export/debt hunks need a current combined-base check and both registrations/entries must survive. The PR is based on a6dcea9279 while current upstream main is ab347d144d88fae054d9770cf0db8d3565735c02. Please rebase, coordinate/record any needed merge order with #9506, and rerun the focused `guest_sce_net` test and conventions/overlap checks on current main. Hosted product jobs are skipped; I did not run local tests.
EagleBearerYS commented 2026-10-22 06:00:48 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by EagleBearerYS on 2026-10-22T06:00:48Z.


Thanks, @MarcZX10. The branch now has main at 4a17c71757 merged in (094e920c5d), with the PR's own diff unchanged. On GitHub's runners (run) guest_sce_net passes 10 runs in a row on both and fails on Windows with main's code; the libc and libkernel suites pass on both, and conventions pass. Tested now says so. #9506 merges cleanly with this PR: its DNS changes and debt lines don't meet this PR's, so no order is needed, and Overlap and Depends on now say so.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6333920928 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/9494#issuecomment-6333920928). Originally posted by [EagleBearerYS](https://github.com/EagleBearerYS) on 2026-10-22T06:00:48Z. --- Thanks, @MarcZX10. The branch now has `main` at 4a17c71757 merged in (094e920c5d), with the PR's own diff unchanged. On GitHub's runners ([run](https://github.com/EagleBearerYS/AnyPS5/actions/runs/39728903444)) `guest_sce_net` passes 10 runs in a row on both and fails on Windows with `main`'s code; the libc and libkernel suites pass on both, and conventions pass. Tested now says so. #9506 merges cleanly with this PR: its DNS changes and debt lines don't meet this PR's, so no order is needed, and Overlap and Depends on now say so.
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
boykopovar/AnyPS5!9494
No description provided.