net: map SO_REUSEADDR and SO_REUSEPORT on Linux and macOS hosts #1275

Open
github-bot wants to merge 2 commits from github-bot/gh-1275 into main AGit
Owner

@⁠popcoder565 on GitHub · 2026-10-09 03:39 UTC · original
popcoder565:fix/net-posix-socket-options → main · +18 −0 · 2 files · 2 commits · open

Guest socket-level options without a translation reach Winsock unchanged, but on other hosts they fail with ENOPROTOOPT, and Linux numbers these two options differently from the guest anyway. Four games in the logs attached to reports set SO_REUSEADDR: Sackboy (#62), Anno 1800 (#203), The Persistence (#385) and Superliminal (#665), whose FMOD live-update listener sets it each time it recreates its socket. On Linux and macOS each of those calls fails.

Translate both options to the host constants. The new check sets and reads back SO_REUSEADDR on every host.

**@⁠popcoder565** on GitHub · 2026-10-09 03:39 UTC · [original](https://github.com/KytyPS5/KytyPS5/pull/1275) `popcoder565:fix/net-posix-socket-options` → `main` · +18 −0 · 2 files · 2 commits · open Guest socket-level options without a translation reach Winsock unchanged, but on other hosts they fail with ENOPROTOOPT, and Linux numbers these two options differently from the guest anyway. Four games in the logs attached to reports set SO_REUSEADDR: Sackboy (#62), Anno 1800 (#203), The Persistence (#385) and Superliminal (#665), whose FMOD live-update listener sets it each time it recreates its socket. On Linux and macOS each of those calls fails. Translate both options to the host constants. The new check sets and reads back SO_REUSEADDR on every host.
Guest socket-level options without a translation reach Winsock
unchanged, but on other hosts they fail with ENOPROTOOPT, and Linux
numbers these two options differently from the guest anyway. Four games
in the logs attached to reports set SO_REUSEADDR: Sackboy (#62),
Anno 1800 (#203), The Persistence (#385) and Superliminal (#665), whose
FMOD live-update listener sets it each time it recreates its socket.
On Linux and macOS each of those calls fails.

Translate both options to the host constants. The new check sets and
reads back SO_REUSEADDR on every host.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
The new mapping also translates the guest's SO_REUSEPORT (0x200), but only
SO_REUSEADDR was checked. Set and read it back on non-Windows hosts, where
the mapping applies.

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

@⁠coderabbitai[bot] on GitHub · 2026-10-09 03:43 UTC · original · edited 2026-10-09 03:56 UTC

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: c6f6e39a-3ea1-41ee-a473-16f9a3754fa8
📥 Commits

Reviewing files that changed from the base of the PR and between 7e7fb8bc67 and 172b659b06.

📒 Files selected for processing (1)
  • tests/KernelFileSystemTests.cpp

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


📝 Walkthrough

Walkthrough

ConvertSocketOptionName maps guest SO_REUSEADDR and SO_REUSEPORT options on non-Windows platforms. On Windows, these options use the existing fallback behavior. CheckSocketWakeup now checks that enabled SO_REUSEADDR and, on non-Windows platforms, SO_REUSEPORT read back as nonzero.

Suggested reviewers: nmzik

Priority: ➖ Normal

Change: Bug fix

Merge Risk: ⚪ Minimal · up to 172b6

The socket-option mappings and round-trip checks align on the inspected paths. No actionable merge risk remains; the change appears ready subject to normal checks.

🚥 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 and concisely describes the main change: mapping SO_REUSEADDR and SO_REUSEPORT for Linux and macOS hosts.
Description check Passed The description directly explains the socket-option translation problem, affected hosts, reported impact, and test coverage.
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-09 03:43 UTC · [original](https://github.com/KytyPS5/KytyPS5/pull/1275#issuecomment-6073820598) · edited 2026-10-09 03:56 UTC <!-- 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/1275?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**: `c6f6e39a-3ea1-41ee-a473-16f9a3754fa8` </details> <details> <summary>📥 Commits</summary> Reviewing files that changed from the base of the PR and between 7e7fb8bc6753b02f61d686915573fda9660f9293 and 172b659b06acfc79c80a38ca5392ddb46e94d1a9. </details> <details> <summary>📒 Files selected for processing (1)</summary> * `tests/KernelFileSystemTests.cpp` </details> **Included review availability:** This review used your included allowance. Your plan provides up to 8 included reviews per hour; 3 remain after this review. </details> --- <!-- recent_review_end --> <!-- walkthrough_start --> <details> <summary>📝 Walkthrough</summary> ## Walkthrough `ConvertSocketOptionName` maps guest `SO_REUSEADDR` and `SO_REUSEPORT` options on non-Windows platforms. On Windows, these options use the existing fallback behavior. `CheckSocketWakeup` now checks that enabled `SO_REUSEADDR` and, on non-Windows platforms, `SO_REUSEPORT` read back as nonzero. **Suggested reviewers:** `nmzik` </details> <!-- walkthrough_end --> <!-- change_assessment_start --> **Priority:** ➖ Normal <!-- change_assessment_commit:"172b659b06acfc79c80a38ca5392ddb46e94d1a9" --> **Change:** Bug fix <!-- change_assessment_end --> <!-- final_review_risk_start --> **Merge Risk:** **⚪ Minimal** · up to `172b6` <!-- final_review_risk_coverage:{"sourceCommitId":"172b659b06acfc79c80a38ca5392ddb46e94d1a9","coveredCommitId":"172b659b06acfc79c80a38ca5392ddb46e94d1a9","kind":"reviewed"} --> The socket-option mappings and round-trip checks align on the inspected paths. No actionable merge risk remains; the change appears ready subject to normal checks. <!-- 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](https://storage.googleapis.com/coderabbit_public_assets/pre-merge-checks-warning.svg) | 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](https://storage.googleapis.com/coderabbit_public_assets/pre-merge-checks-passed.svg) | The title clearly and concisely describes the main change: mapping SO_REUSEADDR and SO_REUSEPORT for Linux and macOS hosts. | | Description check | ![Passed](https://storage.googleapis.com/coderabbit_public_assets/pre-merge-checks-passed.svg) | The description directly explains the socket-option translation problem, affected hosts, reported impact, and test coverage. | | Linked Issues check | ![Passed](https://storage.googleapis.com/coderabbit_public_assets/pre-merge-checks-passed.svg) | Check skipped because no linked issues were found for this pull request. | | Out of Scope Changes check | ![Passed](https://storage.googleapis.com/coderabbit_public_assets/pre-merge-checks-passed.svg) | 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=1275)! 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

@⁠coderabbitai[bot] on GitHub · 2026-10-09 03:43 UTC · original · reviewed

🧹 Nitpick comments (1)
tests/KernelFileSystemTests.cpp (1)

1476-1482: 🎯 Functional Correctness | 🔵 Trivial | ⚡ Quick win

Add coverage for SO_REUSEPORT.

The test covers only guest option 0x0004 (SO_REUSEADDR). It does not exercise the distinct 0x0200 mapping, so an incorrect SO_REUSEPORT conversion could pass the Net API tests.

Suggested fix
   Check(Net::Setsockopt(writer, 0xffff, 0x0004, &enabled, sizeof(enabled)) == 0 &&
             Net::Getsockopt(writer, 0xffff, 0x0004, &reuse_address, &reuse_address_size) == 0 &&
             reuse_address != 0,
         "Net SO_REUSEADDR reaches the host socket");
+#if !defined(_WIN32)
+  int reuse_port = 0;
+  uint32_t reuse_port_size = sizeof(reuse_port);
+  Check(Net::Setsockopt(writer, 0xffff, 0x0200, &enabled, sizeof(enabled)) == 0 &&
+            Net::Getsockopt(writer, 0xffff, 0x0200, &reuse_port, &reuse_port_size) == 0 &&
+            reuse_port != 0,
+        "Net SO_REUSEPORT reaches the host socket");
+#endif

ℹ️ Review info
⚙️ Run configuration
  • Configuration used: Repository: KytyPS5/KytyPS5/.coderabbit.yaml
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: cf5c487a-3e4e-4f09-8130-dda81ccb2162
📥 Commits

Reviewing files that changed from the base of the PR and between 7b9997baea and 7e7fb8bc67.

📒 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; 6 remain after this review.

**@⁠coderabbitai[bot]** on GitHub · 2026-10-09 03:43 UTC · [original](https://github.com/KytyPS5/KytyPS5/pull/1275#pullrequestreview-5465486823) · **reviewed** <details> <summary>🧹 Nitpick comments (1)</summary><blockquote> <details> <summary>tests/KernelFileSystemTests.cpp (1)</summary><blockquote> `1476-1482`: **🎯 Functional Correctness** | **🔵 Trivial** | **⚡ Quick win** **Add coverage for `SO_REUSEPORT`.** The test covers only guest option `0x0004` (`SO_REUSEADDR`). It does not exercise the distinct `0x0200` mapping, so an incorrect `SO_REUSEPORT` conversion could pass the Net API tests. <details><summary>Suggested fix</summary> ```diff Check(Net::Setsockopt(writer, 0xffff, 0x0004, &enabled, sizeof(enabled)) == 0 && Net::Getsockopt(writer, 0xffff, 0x0004, &reuse_address, &reuse_address_size) == 0 && reuse_address != 0, "Net SO_REUSEADDR reaches the host socket"); +#if !defined(_WIN32) + int reuse_port = 0; + uint32_t reuse_port_size = sizeof(reuse_port); + Check(Net::Setsockopt(writer, 0xffff, 0x0200, &enabled, sizeof(enabled)) == 0 && + Net::Getsockopt(writer, 0xffff, 0x0200, &reuse_port, &reuse_port_size) == 0 && + reuse_port != 0, + "Net SO_REUSEPORT reaches the host socket"); +#endif ``` </details> <!-- cr-comment:v1:4f98730b5135a22fef78e970 --> </blockquote></details> </blockquote></details> --- <details> <summary>ℹ️ Review info</summary> <details> <summary>⚙️ Run configuration</summary> - **Configuration used**: Repository: KytyPS5/KytyPS5/.coderabbit.yaml - **Review profile**: CHILL - **Plan**: Advanced - **Run ID**: `cf5c487a-3e4e-4f09-8130-dda81ccb2162` </details> <details> <summary>📥 Commits</summary> Reviewing files that changed from the base of the PR and between 7b9997baea0d385e9e8fc2bd3abeb02110bc4148 and 7e7fb8bc6753b02f61d686915573fda9660f9293. </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; 6 remain after this review. </details> <!-- This is an auto-generated comment by CodeRabbit for review status --> <!-- coderabbit-review-publication v1 publication=2807f6dc-c59f-49b4-a964-98959d15e655 attempt=b4a37620-788a-4cd2-b580-3573a84aab25 batch=1/1 -->
This pull request has changes conflicting with the target branch.
  • src/libs/network.cpp
View command line instructions

Manual merge helper

Use this merge commit message when completing the merge manually.

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin '+refs/pull/1275/head:github-bot/gh-1275'
git switch 'github-bot/gh-1275'

Merge

Merge the changes and update on Forgejo.
git switch 'main'
git merge --no-ff 'github-bot/gh-1275'
git switch 'github-bot/gh-1275'
git rebase 'main'
git switch 'main'
git merge --ff-only 'github-bot/gh-1275'
git switch 'github-bot/gh-1275'
git rebase 'main'
git switch 'main'
git merge --no-ff 'github-bot/gh-1275'
git switch 'main'
git merge --squash 'github-bot/gh-1275'
git switch 'main'
git merge --ff-only 'github-bot/gh-1275'
git switch 'main'
git merge 'github-bot/gh-1275'
git push origin 'main'
This discussion has been locked. Commenting is limited to contributors.
No description provided.