feat(libkernel): support SO_LINGER and IPV6_V6ONLY in setsockopt #1090

Closed
kjhq wants to merge 1 commit from upstream-pr/1090 into main
kjhq commented 2026-10-07 10:35:56 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by kjhq on 2026-10-07T10:35:56Z.


What

setsockopt accepted only the SOL_SOCKET options in the existing table and returned ENOPROTOOPT for everything else. This adds two options:

  • SO_LINGER (SOL_SOCKET, 0x80): the guest's {int l_onoff; int l_linger;} (8 bytes) is converted to the host linger struct, whose fields are u_short on Windows. Another length or a linger time outside 0..65535 is EINVAL.
  • IPV6_V6ONLY (IPPROTO_IPV6 41, option 27): passed to the host on IPv6 sockets; on an IPv4 socket or with a length other than sizeof(int) it is EINVAL.

Other levels and options still return ENOPROTOOPT.

guest_udp covers both options, their invalid lengths and families, and an unknown option at IPPROTO_IP.

Tested

Debian 13 (WSL2), GCC 14.2.0, Release: guest_udp and guest_tcp pass.

The same change was part of a local build used to run PPSA17221 (Minecraft) on Windows 11, where it compiled with WinLibs GCC; it was not tested on its own there. Not tested with Windows ctest.

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 in TechnicalDebt
  • 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
  • AI-assisted: yes

🤖 Generated with Claude Code

<!-- greyfinch-sync:boykopovar/AnyPS5:issue:4771393090 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/1090). Originally posted by [kjhq](https://github.com/kjhq) on 2026-10-07T10:35:56Z. --- ### What `setsockopt` accepted only the `SOL_SOCKET` options in the existing table and returned `ENOPROTOOPT` for everything else. This adds two options: - `SO_LINGER` (`SOL_SOCKET`, 0x80): the guest's `{int l_onoff; int l_linger;}` (8 bytes) is converted to the host `linger` struct, whose fields are `u_short` on Windows. Another length or a linger time outside 0..65535 is `EINVAL`. - `IPV6_V6ONLY` (`IPPROTO_IPV6` 41, option 27): passed to the host on IPv6 sockets; on an IPv4 socket or with a length other than `sizeof(int)` it is `EINVAL`. Other levels and options still return `ENOPROTOOPT`. `guest_udp` covers both options, their invalid lengths and families, and an unknown option at `IPPROTO_IP`. ### Tested Debian 13 (WSL2), GCC 14.2.0, Release: `guest_udp` and `guest_tcp` pass. The same change was part of a local build used to run PPSA17221 (Minecraft) on Windows 11, where it compiled with WinLibs GCC; it was not tested on its own there. Not tested with Windows `ctest`. ### 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 - [x] Unimplemented paths throw (`NotImplemented_nid_no_patch`); silent stubs are listed in TechnicalDebt - [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] AI-assisted: yes 🤖 Generated with [Claude Code](https://claude.com/claude-code)
kjhq commented 2026-10-07 11:30:47 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by kjhq on 2026-10-07T11:30:47Z.


Closing: a leave-one-out run shows PPSA17221 (Minecraft) reaches a loaded world without this change, so no title is known to need it yet. I'll reopen with the title ID and log line if one does.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6036993254 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/1090#issuecomment-6036993254). Originally posted by [kjhq](https://github.com/kjhq) on 2026-10-07T11:30:47Z. --- Closing: a leave-one-out run shows PPSA17221 (Minecraft) reaches a loaded world without this change, so no title is known to need it yet. I'll reopen with the title ID and log line if one does.

Pull request closed

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!1090
No description provided.