fix(libkernel): return EPROTOTYPE for a socket type inet does not have #7151

Merged
Bonjourcestmatt merged 2 commits from upstream-pr/7151 into main 2026-10-17 20:51:51 +00:00
Bonjourcestmatt commented 2026-10-17 14:02:52 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by Bonjourcestmatt on 2026-10-17T14:02:52Z.


What

socket() returned EPROTONOSUPPORT for every type it does not create. FreeBSD 11.4's socreate returns EPROTOTYPE when no protocol is found, the protocol is 0 and the type is not 0, and EPROTONOSUPPORT when a protocol was given.

The inet domain (in_proto.c) has SOCK_RAW entries in every kernel and a SOCK_SEQPACKET entry only with SCTP, and nothing else. So only a type it never has (for example SOCK_RDM or 99) with protocol 0 now returns EPROTOTYPE. SOCK_RAW and SOCK_SEQPACKET keep EPROTONOSUPPORT, because whether the console creates them is not known; this, IPPROTO_UDPLITE and AF_UNIX are listed in docs/dev/debt/libkernel.md.

Not measured on a console.

Tested

  • Windows 11, MinGW-w64 GCC 15.2.0 UCRT, full configure with submodules: the 22 guest_socket* tests pass, including the new SocketTypeErrors (unknown types and mismatched protocols for AF_INET and AF_INET6). The checked paths return before any host socket call.
  • python3 tools/check_conventions.py --base origin/main: passed.
  • Not run on Linux or macOS.

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
  • Unblocks: none
  • GPUs tested: n/a
  • AI-assisted: yes, written with Claude (Anthropic); I am responsible for every line.

🤖 Generated with Claude Code

<!-- greyfinch-sync:boykopovar/AnyPS5:issue:4900693092 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/7151). Originally posted by [Bonjourcestmatt](https://github.com/Bonjourcestmatt) on 2026-10-17T14:02:52Z. --- ### What `socket()` returned `EPROTONOSUPPORT` for every type it does not create. FreeBSD 11.4's [`socreate`](https://github.com/freebsd/freebsd-src/blob/release/11.4.0/sys/kern/uipc_socket.c) returns `EPROTOTYPE` when no protocol is found, the protocol is 0 and the type is not 0, and `EPROTONOSUPPORT` when a protocol was given. The inet domain ([`in_proto.c`](https://github.com/freebsd/freebsd-src/blob/release/11.4.0/sys/netinet/in_proto.c)) has `SOCK_RAW` entries in every kernel and a `SOCK_SEQPACKET` entry only with `SCTP`, and nothing else. So only a type it never has (for example `SOCK_RDM` or 99) with protocol 0 now returns `EPROTOTYPE`. `SOCK_RAW` and `SOCK_SEQPACKET` keep `EPROTONOSUPPORT`, because whether the console creates them is not known; this, `IPPROTO_UDPLITE` and `AF_UNIX` are listed in `docs/dev/debt/libkernel.md`. Not measured on a console. ### Tested - Windows 11, MinGW-w64 GCC 15.2.0 UCRT, full configure with submodules: the 22 `guest_socket*` tests pass, including the new `SocketTypeErrors` (unknown types and mismatched protocols for `AF_INET` and `AF_INET6`). The checked paths return before any host socket call. - `python3 tools/check_conventions.py --base origin/main`: passed. - Not run on Linux or macOS. ### Checklist - [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] Unblocks: none - [x] GPUs tested: n/a - [x] AI-assisted: yes, written with Claude (Anthropic); I am responsible for every line. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
github-actions[bot] commented 2026-10-17 14:35:04 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by github-actions[bot] on 2026-10-17T14:35:04Z.


Some comparisons could not be completed because a pull request conflicts with the base branch. Review these shared files manually before concluding that there is no overlap.

Pull request Shared files not compared
PR 5021 core/libs/prx/libkernel/Socket/src/Udp.cpp
docs/dev/debt/libkernel.md
PR 6044 core/libs/tests/GuestSocketDescriptors.cpp
PR 6222 core/libs/prx/libkernel/Socket/src/Udp.cpp
docs/dev/debt/libkernel.md
PR 6228 docs/dev/debt/libkernel.md
PR 6343 docs/dev/debt/libkernel.md
PR 6510 docs/dev/debt/libkernel.md
PR 6542 docs/dev/debt/libkernel.md
PR 6710 docs/dev/debt/libkernel.md
PR 6908 docs/dev/debt/libkernel.md
PR 6962 core/libs/prx/libkernel/Socket/src/Udp.cpp
docs/dev/debt/libkernel.md
PR 7049 docs/dev/debt/libkernel.md
PR 7075 core/libs/prx/libkernel/Socket/src/Udp.cpp
docs/dev/debt/libkernel.md
PR 7088 core/libs/prx/libkernel/Socket/src/Udp.cpp
docs/dev/debt/libkernel.md
PR 7121 docs/dev/debt/libkernel.md
PR 7129 core/libs/prx/libkernel/Socket/src/Udp.cpp
docs/dev/debt/libkernel.md
PR 7135 docs/dev/debt/libkernel.md
PR 7139 core/libs/prx/libkernel/Socket/src/Udp.cpp
core/libs/tests/GuestSocketDescriptors.cpp
docs/dev/debt/libkernel.md
PR 7201 core/libs/prx/libkernel/Socket/src/Udp.cpp
PR 7248 core/libs/prx/libkernel/Socket/src/Udp.cpp
core/libs/tests/GuestSocketDescriptors.cpp
docs/dev/debt/libkernel.md
<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6235151348 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/7151#issuecomment-6235151348). Originally posted by [github-actions[bot]](https://github.com/apps/github-actions) on 2026-10-17T14:35:04Z. --- <!-- pr-overlap --> Some comparisons could not be completed because a pull request conflicts with the base branch. Review these shared files manually before concluding that there is no overlap. | Pull request | Shared files not compared | |---|---| | [PR 5021](https://www.github.com/boykopovar/AnyPS5/pull/5021) | `core/libs/prx/libkernel/Socket/src/Udp.cpp`<br>`docs/dev/debt/libkernel.md` | | [PR 6044](https://www.github.com/boykopovar/AnyPS5/pull/6044) | `core/libs/tests/GuestSocketDescriptors.cpp` | | [PR 6222](https://www.github.com/boykopovar/AnyPS5/pull/6222) | `core/libs/prx/libkernel/Socket/src/Udp.cpp`<br>`docs/dev/debt/libkernel.md` | | [PR 6228](https://www.github.com/boykopovar/AnyPS5/pull/6228) | `docs/dev/debt/libkernel.md` | | [PR 6343](https://www.github.com/boykopovar/AnyPS5/pull/6343) | `docs/dev/debt/libkernel.md` | | [PR 6510](https://www.github.com/boykopovar/AnyPS5/pull/6510) | `docs/dev/debt/libkernel.md` | | [PR 6542](https://www.github.com/boykopovar/AnyPS5/pull/6542) | `docs/dev/debt/libkernel.md` | | [PR 6710](https://www.github.com/boykopovar/AnyPS5/pull/6710) | `docs/dev/debt/libkernel.md` | | [PR 6908](https://www.github.com/boykopovar/AnyPS5/pull/6908) | `docs/dev/debt/libkernel.md` | | [PR 6962](https://www.github.com/boykopovar/AnyPS5/pull/6962) | `core/libs/prx/libkernel/Socket/src/Udp.cpp`<br>`docs/dev/debt/libkernel.md` | | [PR 7049](https://www.github.com/boykopovar/AnyPS5/pull/7049) | `docs/dev/debt/libkernel.md` | | [PR 7075](https://www.github.com/boykopovar/AnyPS5/pull/7075) | `core/libs/prx/libkernel/Socket/src/Udp.cpp`<br>`docs/dev/debt/libkernel.md` | | [PR 7088](https://www.github.com/boykopovar/AnyPS5/pull/7088) | `core/libs/prx/libkernel/Socket/src/Udp.cpp`<br>`docs/dev/debt/libkernel.md` | | [PR 7121](https://www.github.com/boykopovar/AnyPS5/pull/7121) | `docs/dev/debt/libkernel.md` | | [PR 7129](https://www.github.com/boykopovar/AnyPS5/pull/7129) | `core/libs/prx/libkernel/Socket/src/Udp.cpp`<br>`docs/dev/debt/libkernel.md` | | [PR 7135](https://www.github.com/boykopovar/AnyPS5/pull/7135) | `docs/dev/debt/libkernel.md` | | [PR 7139](https://www.github.com/boykopovar/AnyPS5/pull/7139) | `core/libs/prx/libkernel/Socket/src/Udp.cpp`<br>`core/libs/tests/GuestSocketDescriptors.cpp`<br>`docs/dev/debt/libkernel.md` | | [PR 7201](https://www.github.com/boykopovar/AnyPS5/pull/7201) | `core/libs/prx/libkernel/Socket/src/Udp.cpp` | | [PR 7248](https://www.github.com/boykopovar/AnyPS5/pull/7248) | `core/libs/prx/libkernel/Socket/src/Udp.cpp`<br>`core/libs/tests/GuestSocketDescriptors.cpp`<br>`docs/dev/debt/libkernel.md` |
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!7151
No description provided.