net: report unknown socket options as ENOPROTOOPT on Windows #1159

Closed
github-bot wants to merge 1 commit from gh-pr/1159/head into gh-pr/1159/base
Owner

@⁠popcoder565 on GitHub · 2026-10-07 19:52 UTC · original
popcoder565:fix/net-unknown-socket-options → main · +27 −1 · 2 files · 1 commits · closed without merging

On Windows, guest SOL_SOCKET options without an explicit translation go straight to Winsock, which numbers most BSD socket options like the guest does. Winsock reports an option number it does not know as WSAEINVAL rather than WSAENOPROTOOPT, so the guest saw EINVAL where the PS5 and the Linux path return ENOPROTOOPT, and kernel_file_system failed on Windows with "Net unknown socket options return protocol-option errors".

Pass through only the BSD socket-level options that Winsock defines and treat any other option number as unknown. Options that reached Winsock before still do, which a new Windows-only check covers.

**@⁠popcoder565** on GitHub · 2026-10-07 19:52 UTC · [original](https://github.com/KytyPS5/KytyPS5/pull/1159) `popcoder565:fix/net-unknown-socket-options` → `main` · +27 −1 · 2 files · 1 commits · closed without merging On Windows, guest SOL_SOCKET options without an explicit translation go straight to Winsock, which numbers most BSD socket options like the guest does. Winsock reports an option number it does not know as WSAEINVAL rather than WSAENOPROTOOPT, so the guest saw EINVAL where the PS5 and the Linux path return ENOPROTOOPT, and kernel_file_system failed on Windows with "Net unknown socket options return protocol-option errors". Pass through only the BSD socket-level options that Winsock defines and treat any other option number as unknown. Options that reached Winsock before still do, which a new Windows-only check covers.
On Windows, guest SOL_SOCKET options without an explicit translation
go straight to Winsock, which numbers most BSD socket options like the
guest does. Winsock reports an option number it does not know as
WSAEINVAL rather than WSAENOPROTOOPT, so the guest saw EINVAL where the
PS5 and the Linux path return ENOPROTOOPT, and kernel_file_system failed
on Windows with "Net unknown socket options return protocol-option
errors".

Pass through only the BSD socket-level options that Winsock defines and
treat any other option number as unknown. Options that reached Winsock
before still do, which a new Windows-only check covers.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 09:45:33 +00:00
github-bot closed this pull request 2026-11-26 09:45:33 +00:00
Author
Owner

@⁠coderabbitai[bot] on GitHub · 2026-10-07 20:00 UTC · original

Review in Change Stack →

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration
  • Configuration used: Repository: KytyPS5/KytyPS5/.coderabbit.yaml
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 673b684f-d4f4-4159-9c97-8a89d98d97cd
📥 Commits

Reviewing files that changed from the base of the PR and between 45b6d2c597 and f5d8d52a27.

📒 Files selected for processing (2)
  • src/libs/network.cpp
  • tests/KernelFileSystemTests.cpp

Included review availability: This review used your included allowance. Your plan provides up to 8 included reviews per hour; 7 remain after this review.


📝 Walkthrough

Walkthrough

On Windows, ConvertSocketOptionName now passes through recognized BSD socket-level options using their host values. Unrecognized options still return -1. A Windows-only test checks retrieval of SO_TYPE and setting and retrieval of SO_REUSEADDR.

Suggested reviewers: nmzik

Priority: ⬇️ Low

Change: Bug fix

Merge Risk: ⚪ Minimal · up to f5d8d

The Windows changes support the tested socket options without introducing an actionable behavior regression. No PR-introduced risk remains that should block merging.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 2 functions across 2 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly identifies the main change: Windows now reports ENOPROTOOPT for unknown socket options.
Description check ✅ Passed The description explains the Windows error-mapping issue, the pass-through behavior, and the added test. It directly matches the changeset.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
  • Autopilot · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

**@⁠coderabbitai[bot]** on GitHub · 2026-10-07 20:00 UTC · [original](https://github.com/KytyPS5/KytyPS5/pull/1159#issuecomment-6045779165) <!-- This is an auto-generated comment: summarize by coderabbit.ai --> <!-- review_stack_entry_start --> <a href="https://app.coderabbit.ai/change-stack/KytyPS5/KytyPS5/pull/1159?scope=ghh_OusAJGA4HG8ljoOV0wJvVx8NmnZIjc2DdjmxOu0xZWA&amp;cs_source=review_comment"><img src="https://storage.googleapis.com/coderabbit_public_assets/review-stack-in-coderabbit-ui-dark.svg?v=2" alt="Review in Change Stack →" width="220" height="32"></a> <!-- review_stack_entry_end --> <!-- recent_review_start --> No actionable comments were generated in the recent review. 🎉 <details> <summary>ℹ️ Recent review info</summary> <details> <summary>⚙️ Run configuration</summary> - **Configuration used**: Repository: KytyPS5/KytyPS5/.coderabbit.yaml - **Review profile**: CHILL - **Plan**: Advanced - **Run ID**: `673b684f-d4f4-4159-9c97-8a89d98d97cd` </details> <details> <summary>📥 Commits</summary> Reviewing files that changed from the base of the PR and between 45b6d2c597cbb1a738669fa87e4983f45e6697b0 and f5d8d52a27b27b519a7e62139ee07ef99abe9f61. </details> <details> <summary>📒 Files selected for processing (2)</summary> * `src/libs/network.cpp` * `tests/KernelFileSystemTests.cpp` </details> **Included review availability:** This review used your included allowance. Your plan provides up to 8 included reviews per hour; 7 remain after this review. </details> --- <!-- recent_review_end --> <!-- walkthrough_start --> <details> <summary>📝 Walkthrough</summary> ## Walkthrough On Windows, `ConvertSocketOptionName` now passes through recognized BSD socket-level options using their host values. Unrecognized options still return `-1`. A Windows-only test checks retrieval of `SO_TYPE` and setting and retrieval of `SO_REUSEADDR`. **Suggested reviewers:** `nmzik` </details> <!-- walkthrough_end --> <!-- change_assessment_start --> **Priority:** ⬇️ Low <!-- change_assessment_commit:"f5d8d52a27b27b519a7e62139ee07ef99abe9f61" --> **Change:** Bug fix <!-- change_assessment_end --> <!-- final_review_risk_start --> **Merge Risk:** _⚪ Minimal_ · up to `f5d8d` <!-- final_review_risk_coverage:{"sourceCommitId":"f5d8d52a27b27b519a7e62139ee07ef99abe9f61","coveredCommitId":"f5d8d52a27b27b519a7e62139ee07ef99abe9f61","kind":"reviewed"} --> The Windows changes support the tested socket options without introducing an actionable behavior regression. No PR-introduced risk remains that should block merging. <!-- final_review_risk_end --> <!-- pre_merge_checks_walkthrough_start --> <details> <summary>🚥 Pre-merge checks | ✅ 4 | ❌ 1</summary> ### ❌ Failed checks (1 warning) | Check name | Status | Explanation | Resolution | | :----------------: | :--------- | :---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | :--------------------------------------------------------------------------------- | | Docstring Coverage | ⚠️ Warning | Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 2 functions across 2 files. | Write docstrings for the functions missing them to satisfy the coverage threshold. | <details> <summary>✅ Passed checks (4 passed)</summary> | Check name | Status | Explanation | | :------------------------: | :------- | :------------------------------------------------------------------------------------------------------------------------------------------ | | Title check | ✅ Passed | The title clearly identifies the main change: Windows now reports ENOPROTOOPT for unknown socket options. | | Description check | ✅ Passed | The description explains the Windows error-mapping issue, the pass-through behavior, and the added test. It directly matches the changeset. | | Linked Issues check | ✅ Passed | Check skipped because no linked issues were found for this pull request. | | Out of Scope Changes check | ✅ Passed | Check skipped because no linked issues were found for this pull request. | </details> </details> <!-- pre_merge_checks_walkthrough_end --> <!-- autopilot:start --> - [ ] <!-- {"checkboxId":"2708ad07-9f24-4260-9c11-7dc76a49f2e3"} --> <strong title="Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts">Autopilot</strong> · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts <!-- autopilot:end --> <!-- tips_start --> --- Thanks for using [CodeRabbit](https://coderabbit.ai?utm_source=oss&utm_medium=github&utm_campaign=KytyPS5/KytyPS5&utm_content=1159)! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. <details> <summary>❤️ Share</summary> - [X](https://twitter.com/intent/tweet?text=I%20just%20used%20%40coderabbitai%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20the%20proprietary%20code.%20Check%20it%20out%3A&url=https%3A//coderabbit.ai) - [Mastodon](https://mastodon.social/share?text=I%20just%20used%20%40coderabbitai%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20the%20proprietary%20code.%20Check%20it%20out%3A%20https%3A%2F%2Fcoderabbit.ai) - [Reddit](https://www.reddit.com/submit?title=Great%20tool%20for%20code%20review%20-%20CodeRabbit&text=I%20just%20used%20CodeRabbit%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20proprietary%20code.%20Check%20it%20out%3A%20https%3A//coderabbit.ai) - [LinkedIn](https://www.linkedin.com/sharing/share-offsite/?url=https%3A%2F%2Fcoderabbit.ai&mini=true&title=Great%20tool%20for%20code%20review%20-%20CodeRabbit&summary=I%20just%20used%20CodeRabbit%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20proprietary%20code) </details> <sub>Comment `@coderabbitai help` to get the list of available commands.</sub> <!-- tips_end -->
Author
Owner

@⁠Nawid3333 on GitHub · 2026-10-07 20:58 UTC · original · reviewed

Tested on Windows 11 (clang-cl 19.1.5, Release): kernel_file_system_tests passes completely with this PR ("all cases passed"), including the new Windows-only check. On main it fails at "Net unknown socket options return protocol-option errors". I also confirmed the cause directly against Winsock: setsockopt/getsockopt with SOL_SOCKET and option 0x7fffffff fail with 10022 (WSAEINVAL), not 10042.

**@⁠Nawid3333** on GitHub · 2026-10-07 20:58 UTC · [original](https://github.com/KytyPS5/KytyPS5/pull/1159#pullrequestreview-5448283853) · **reviewed** Tested on Windows 11 (clang-cl 19.1.5, Release): `kernel_file_system_tests` passes completely with this PR ("all cases passed"), including the new Windows-only check. On `main` it fails at "Net unknown socket options return protocol-option errors". I also confirmed the cause directly against Winsock: `setsockopt`/`getsockopt` with `SOL_SOCKET` and option `0x7fffffff` fail with 10022 (`WSAEINVAL`), not 10042.
Author
Owner

@⁠popcoder565 on GitHub · 2026-10-07 21:10 UTC · original

Thanks for check !!

**@⁠popcoder565** on GitHub · 2026-10-07 21:10 UTC · [original](https://github.com/KytyPS5/KytyPS5/pull/1159#issuecomment-6046926076) Thanks for check !!
Author
Owner

@⁠Nawid3333 on GitHub · 2026-10-07 21:32 UTC · original

no problem

**@⁠Nawid3333** on GitHub · 2026-10-07 21:32 UTC · [original](https://github.com/KytyPS5/KytyPS5/pull/1159#issuecomment-6047262952) no problem
Author
Owner

@⁠theantipopau on GitHub · 2026-10-07 23:47 UTC · original

Reproduced and verified on our Windows fork (theantipopau/KytyPS5) against current upstream/main (420bb51d):

Without f5d8d52a — freshly built kernel_file_system_tests.exe on Windows (MSVC/clang-cl x64) fails exactly the check this PR targets:

KernelFileSystemTests: failed: Net unknown socket options return protocol-option errors

The net_setsockopt/net_getsockopt calls with guest optname 0x7fffffff come back with a Winsock error that translates to the wrong guest errno instead of ENOPROTOOPT.

With f5d8d52a cherry-picked — same fresh-binary run: KernelFileSystemTests: all cases passed, and 13/13 in our local Windows ctest sweep (CI subset + kernel_file_system).

Note for maintainers: this test isn't in the .github/workflows/build.yml ctest -R subsets on any platform, so CI can't catch the Windows regression today — worth adding kernel_file_system to the workflow alongside this fix.

**@⁠theantipopau** on GitHub · 2026-10-07 23:47 UTC · [original](https://github.com/KytyPS5/KytyPS5/pull/1159#issuecomment-6049142315) Reproduced and verified on our Windows fork (theantipopau/KytyPS5) against current upstream/main (420bb51d): **Without `f5d8d52a`** — freshly built `kernel_file_system_tests.exe` on Windows (MSVC/clang-cl x64) fails exactly the check this PR targets: ``` KernelFileSystemTests: failed: Net unknown socket options return protocol-option errors ``` The `net_setsockopt`/`net_getsockopt` calls with guest optname `0x7fffffff` come back with a Winsock error that translates to the wrong guest errno instead of `ENOPROTOOPT`. **With `f5d8d52a` cherry-picked** — same fresh-binary run: `KernelFileSystemTests: all cases passed`, and 13/13 in our local Windows ctest sweep (CI subset + `kernel_file_system`). Note for maintainers: this test isn't in the `.github/workflows/build.yml` ctest `-R` subsets on any platform, so CI can't catch the Windows regression today — worth adding `kernel_file_system` to the workflow alongside this fix.
Author
Owner

@⁠Nawid3333 on GitHub · 2026-10-08 02:40 UTC · original

I’m planning to spend some time improving the regression tests and the test suite in general. I’ll keep this in mind as part of that work and implement it when I get to this area.

**@⁠Nawid3333** on GitHub · 2026-10-08 02:40 UTC · [original](https://github.com/KytyPS5/KytyPS5/pull/1159#issuecomment-6051064744) I’m planning to spend some time improving the regression tests and the test suite in general. I’ll keep this in mind as part of that work and implement it when I get to this area.

Pull request closed

This discussion has been locked. Commenting is limited to contributors.
No description provided.