fix(libSceNet): return EOPNOTSUPP when connecting a listening socket #7490

Merged
Lindamea1 merged 1 commit from upstream-pr/7490 into main 2026-11-11 21:26:44 +00:00
Lindamea1 commented 2026-10-18 09:21:36 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by Lindamea1 on 2026-10-18T09:21:36Z.


What

sceNetConnect on a listening stream socket handed the call to the host. On Linux it failed with 0x80410138 (EISCONN); on Windows, Winsock documents WSAEINVAL for it, which maps to 0x80410116 (EINVAL). With an address of the other family it failed with 0x8041012f (EAFNOSUPPORT) before reaching the host.

FreeBSD 11.4 refuses any connect on a listening socket first. sys_connect copies the address in and calls kern_connectat, which calls soconnect; soconnectat returns EOPNOTSUPP when SO_ACCEPTCONN is set, before the protocol's pru_connect looks at the address family. libkernel connect does the same since #6950.

sceNetConnect now returns 0x8041012d (EOPNOTSUPP, errno 45) for a socket that sceNetListen has put into the listening state, once the address is converted and before the family check, as #6950 does for connect. Null and short addresses keep their address errors. The listener keeps accepting afterwards. I don't know of a title that hits this.

Tested

Gentoo Linux, kernel 7.2.8, GCC 16.2.1, glibc 2.43, Release, BUILD_TESTING=ON, on main cb1d6e5bd.

  • guest_sce_net with the new lines: sceNetConnect on the listener, to its own address and to a 28-byte AF_INET6 address, returns 0x8041012d with sceNetErrnoLoc() 45, and the client connect and sceNetAccept that follow still succeed. With only Export.cpp reverted to main the test aborts; a probe against that build prints 0x80410138 (errno 56) and 0x8041012f (errno 47) for the two calls.
  • Full ctest -j6 --timeout 300: 1435 tests, 0 failed, 13 skipped (12 VideoOut tests and agc_driver_stencil_ref_export, which skip on main on this machine too).
  • Windows: Export.cpp and GuestSceNet.cpp compile with x86_64-w64-mingw32-g++ 16.2 (-fsyntax-only -Wall -Wextra). This is a syntax check, not a Windows build or run.
  • tools/check_conventions.py passes against main. tools/pr_overlap.py --branch reports no overlapping lines; it lists #5836, #6447, #7201 and #7332 (Export.cpp) and #5836, #6044 and #6138 (GuestSceNet.cpp) under shared files not compared, since they conflict with main. None of their diffs changes sceNetConnect.

Not run on Windows, macOS or a console.

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
  • Fixes: none
  • Unblocks: none
  • GPUs tested: n/a
  • AI-assisted: yes

🤖 Generated with Claude Code

<!-- greyfinch-sync:boykopovar/AnyPS5:issue:4907915801 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/7490). Originally posted by [Lindamea1](https://github.com/Lindamea1) on 2026-10-18T09:21:36Z. --- ### What `sceNetConnect` on a listening stream socket handed the call to the host. On Linux it failed with `0x80410138` (`EISCONN`); on Windows, Winsock documents `WSAEINVAL` for it, which maps to `0x80410116` (`EINVAL`). With an address of the other family it failed with `0x8041012f` (`EAFNOSUPPORT`) before reaching the host. FreeBSD 11.4 refuses any connect on a listening socket first. [`sys_connect`](https://github.com/freebsd/freebsd-src/blob/releng/11.4/sys/kern/uipc_syscalls.c#L537-L555) copies the address in and calls `kern_connectat`, which [calls `soconnect`](https://github.com/freebsd/freebsd-src/blob/releng/11.4/sys/kern/uipc_syscalls.c#L585-L588); [`soconnectat`](https://github.com/freebsd/freebsd-src/blob/releng/11.4/sys/kern/uipc_socket.c#L988-L994) returns `EOPNOTSUPP` when `SO_ACCEPTCONN` is set, before the protocol's `pru_connect` looks at the address family. libkernel `connect` does the same since #6950. `sceNetConnect` now returns `0x8041012d` (`EOPNOTSUPP`, errno 45) for a socket that `sceNetListen` has put into the listening state, once the address is converted and before the family check, as #6950 does for `connect`. Null and short addresses keep their address errors. The listener keeps accepting afterwards. I don't know of a title that hits this. ### Tested <!-- OS, title or homebrew, what was checked. "Not tested" is a valid answer. A performance change: the summary lines of main and of this PR from the same machine and scene, with the traces attached, captured as the Performance report issue form describes. --> Gentoo Linux, kernel 7.2.8, GCC 16.2.1, glibc 2.43, Release, `BUILD_TESTING=ON`, on `main` cb1d6e5bd. - `guest_sce_net` with the new lines: `sceNetConnect` on the listener, to its own address and to a 28-byte `AF_INET6` address, returns `0x8041012d` with `sceNetErrnoLoc()` 45, and the client connect and `sceNetAccept` that follow still succeed. With only `Export.cpp` reverted to `main` the test aborts; a probe against that build prints `0x80410138` (errno 56) and `0x8041012f` (errno 47) for the two calls. - Full `ctest -j6 --timeout 300`: 1435 tests, 0 failed, 13 skipped (12 VideoOut tests and `agc_driver_stencil_ref_export`, which skip on `main` on this machine too). - Windows: `Export.cpp` and `GuestSceNet.cpp` compile with `x86_64-w64-mingw32-g++` 16.2 (`-fsyntax-only -Wall -Wextra`). This is a syntax check, not a Windows build or run. - `tools/check_conventions.py` passes against `main`. `tools/pr_overlap.py --branch` reports no overlapping lines; it lists #5836, #6447, #7201 and #7332 (`Export.cpp`) and #5836, #6044 and #6138 (`GuestSceNet.cpp`) under shared files not compared, since they conflict with `main`. None of their diffs changes `sceNetConnect`. Not run on Windows, macOS or a console. ### 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 - [x] Fixes: none - [x] Unblocks: none - [x] GPUs tested: n/a - [x] AI-assisted: yes 🤖 Generated with [Claude Code](https://claude.com/claude-code)
wachi35676 commented 2026-10-18 12:20:09 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by wachi35676 on 2026-10-18T12:20:09Z.


Windows run, since this was only syntax-checked there: Windows 11 (MinGW GCC 15.2), with this PR merged onto main 9f25d0bf5.

  • guest_sce_net with the two new sceNetConnect checks passes, and the listener still accepts afterwards.
  • With only GuestSceNet.cpp from this PR, the test aborts on main on Windows, as on Ubuntu 24.04 (GCC 13.3).
  • The socket/sce_net set passes (Windows 38/38, Linux 26/26).

This matches soconnectat (uipc_socket.c:993-994).

AI-assisted: yes (Claude Code); results above were run on this machine.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6249840112 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/7490#issuecomment-6249840112). Originally posted by [wachi35676](https://github.com/wachi35676) on 2026-10-18T12:20:09Z. --- Windows run, since this was only syntax-checked there: Windows 11 (MinGW GCC 15.2), with this PR merged onto `main` `9f25d0bf5`. - `guest_sce_net` with the two new `sceNetConnect` checks passes, and the listener still accepts afterwards. - With only `GuestSceNet.cpp` from this PR, the test aborts on `main` on Windows, as on Ubuntu 24.04 (GCC 13.3). - The socket/sce_net set passes (Windows 38/38, Linux 26/26). This matches `soconnectat` ([uipc_socket.c:993-994](https://github.com/freebsd/freebsd-src/blob/release/11.4.0/sys/kern/uipc_socket.c#L993-L994)). AI-assisted: yes (Claude Code); results above were run on this machine.
ycarogabriel-lgtm commented 2026-10-19 00:13:30 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by ycarogabriel-lgtm on 2026-10-19T00:13:30Z.


Ran this on macOS, since it was not run there: Apple M1, macOS 26.6.2 (25G83), x86-64 build under Rosetta 2, AppleClang 21. Merged into the macOS host branch of #7332 (57bccfbfc, main at d71853cf2) together with #7121, #7475, #7490, #7507 and #7612; Release build.

  • guest_sce_net passes, including the new EOPNOTSUPP check for connecting a listening socket.
  • The suite without the GPU tests passes, apart from a guest_kqueue case from #7121 that is unrelated to this change.

AI-assisted: yes (Claude Code). I ran the build and tests on my machine.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6256922268 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/7490#issuecomment-6256922268). Originally posted by [ycarogabriel-lgtm](https://github.com/ycarogabriel-lgtm) on 2026-10-19T00:13:30Z. --- Ran this on macOS, since it was not run there: Apple M1, macOS 26.6.2 (25G83), x86-64 build under Rosetta 2, AppleClang 21. Merged into the macOS host branch of #7332 (`57bccfbfc`, `main` at `d71853cf2`) together with #7121, #7475, #7490, #7507 and #7612; `Release` build. - `guest_sce_net` passes, including the new `EOPNOTSUPP` check for connecting a listening socket. - The suite without the GPU tests passes, apart from a `guest_kqueue` case from #7121 that is unrelated to this change. AI-assisted: yes (Claude Code). I ran the build and tests on my machine.
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!7490
No description provided.