feat(libkernel): follow FreeBSD for SO_ACCEPTFILTER on a listening socket #14756

Merged
kallmek3nny merged 2 commits from upstream-pr/14756 into main 2026-11-13 05:30:08 +00:00
kallmek3nny commented 2026-11-01 17:43:57 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by kallmek3nny on 2026-11-01T17:43:57Z.


What

On a listening socket, setsockopt and getsockopt of SO_ACCEPTFILTER (0x1000) threw NotImplemented_nid_no_patch. They now follow FreeBSD 11.4 (8c639945a4, the revision the libkernel debt entries already cite) in every case that does not depend on which accept filters the kernel registers:

  • setsockopt with a NULL value returns 0, as do_setopt_accept_filter does on a listener when it removes the filter. No filter can be attached here, so there is nothing to detach.
  • setsockopt with a value shorter than the 256-byte struct accept_filter_arg fails with EINVAL, as sooptcopyin does when sopt_valsize is below its minimum length.
  • getsockopt fails with EINVAL and leaves the buffer and its length unchanged, as do_getopt_accept_filter does when SO_ACCEPTFILTER is not set; a filter is never installed here.
  • A setsockopt that names a filter still throws: the filters a PS5 kernel registers are not known, so whether it attaches one or returns ENOENT is open.

The EINVAL results on a socket that is not listening are unchanged (measured on a PS5, firmware 13.60). The listener cases above are not measured on a PS5. The getsockopt, setsockopt entry in docs/dev/debt/libkernel.md is cut to what stays open. AcceptFilterFollowsFreeBsd in core/libs/tests/GuestSocketOptions.cpp checks each case above and a NULL-value set on a socket that is not listening.

Overlap: no open PR implements SO_ACCEPTFILTER. tools/pr_overlap.py lists #14183 because it rewrites the neighbouring debt entry (socket error numbers, line 281); the two changes don't depend on each other, but whichever merges second needs a rebase of that debt line. It could not compare 40 PRs that conflict with main; each of their diffs (for #5021, which is over GitHub's 300-file diff limit, its per-file patches) was searched for acceptfilter/accept_filter, and none changes it. #14212 only adds blank lines around this entry. #12688, #12700 and #12965 change SocketOptions.cpp only in one hunk of SetSocketLevelOption at line 214, away from the accept-filter branch.

Tested

Windows 11 Home 10.0.26300.9711, Git Bash, WinLibs gcc/g++, Ninja, Release. No title or homebrew; the guest socket-option tests only.

  • Full build of this worktree at e450145140, before the branch was cut: git submodule update --init --recursive --jobs 8, cmake -S . -B build -G Ninja -DCMAKE_BUILD_TYPE=Release -DCMAKE_C_COMPILER=gcc -DCMAKE_CXX_COMPILER=g++ -DCMAKE_C_COMPILER_LAUNCHER=ccache -DCMAKE_CXX_COMPILER_LAUNCHER=ccache -DBUILD_TESTING=ON -DPython3_EXECUTABLE=C:/Python314/python.exe, cmake --build build --parallel 4: exit 0.
  • On this branch (base f2d874c1fd): cmake --build build --target guest_socket_options_tests --parallel 4 rebuilt SocketOptions.cpp and GuestSocketOptions.cpp and relinked libkernel.prx and guest_socket_options_tests.exe: exit 0.
  • ctest --test-dir build -R guest_socket_options --output-on-failure: 2/2 passed (guest_socket_options, guest_socket_options_multicast). Rerun after the last amend, which only shortened the debt entry: ninja had no work to do, 2/2 passed (0.77 s and 0.08 s).
  • python tools/check_conventions.py --base origin/main: All conventions checks passed.
  • python tools/pr_overlap.py --branch feat/libkernel-accept-filter: exit 2, as it fails closed when it cannot compare every PR; the manual comparison is under What.

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

🤖 Generated with Claude Code

<!-- greyfinch-sync:boykopovar/AnyPS5:issue:5109910717 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/14756). Originally posted by [kallmek3nny](https://github.com/kallmek3nny) on 2026-11-01T17:43:57Z. --- ### What On a listening socket, `setsockopt` and `getsockopt` of `SO_ACCEPTFILTER` (0x1000) threw `NotImplemented_nid_no_patch`. They now follow FreeBSD 11.4 (`8c639945a4`, the revision the libkernel debt entries already cite) in every case that does not depend on which accept filters the kernel registers: - `setsockopt` with a NULL value returns 0, as [`do_setopt_accept_filter`](https://github.com/freebsd/freebsd-src/blob/8c639945a44588f6cfdddfb057bb5aad88735da0/sys/kern/uipc_accf.c) does on a listener when it removes the filter. No filter can be attached here, so there is nothing to detach. - `setsockopt` with a value shorter than the 256-byte [`struct accept_filter_arg`](https://github.com/freebsd/freebsd-src/blob/8c639945a44588f6cfdddfb057bb5aad88735da0/sys/sys/socket.h) fails with `EINVAL`, as [`sooptcopyin`](https://github.com/freebsd/freebsd-src/blob/8c639945a44588f6cfdddfb057bb5aad88735da0/sys/kern/uipc_socket.c) does when `sopt_valsize` is below its minimum length. - `getsockopt` fails with `EINVAL` and leaves the buffer and its length unchanged, as `do_getopt_accept_filter` does when `SO_ACCEPTFILTER` is not set; a filter is never installed here. - A `setsockopt` that names a filter still throws: the filters a PS5 kernel registers are not known, so whether it attaches one or returns `ENOENT` is open. The `EINVAL` results on a socket that is not listening are unchanged (measured on a PS5, firmware 13.60). The listener cases above are not measured on a PS5. The `getsockopt, setsockopt` entry in `docs/dev/debt/libkernel.md` is cut to what stays open. `AcceptFilterFollowsFreeBsd` in `core/libs/tests/GuestSocketOptions.cpp` checks each case above and a NULL-value set on a socket that is not listening. Overlap: no open PR implements `SO_ACCEPTFILTER`. `tools/pr_overlap.py` lists #14183 because it rewrites the neighbouring debt entry (socket error numbers, line 281); the two changes don't depend on each other, but whichever merges second needs a rebase of that debt line. It could not compare 40 PRs that conflict with `main`; each of their diffs (for #5021, which is over GitHub's 300-file diff limit, its per-file patches) was searched for `acceptfilter`/`accept_filter`, and none changes it. #14212 only adds blank lines around this entry. #12688, #12700 and #12965 change `SocketOptions.cpp` only in one hunk of `SetSocketLevelOption` at line 214, away from the accept-filter branch. ### 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. --> Windows 11 Home 10.0.26300.9711, Git Bash, WinLibs gcc/g++, Ninja, Release. No title or homebrew; the guest socket-option tests only. - Full build of this worktree at `e450145140`, before the branch was cut: `git submodule update --init --recursive --jobs 8`, `cmake -S . -B build -G Ninja -DCMAKE_BUILD_TYPE=Release -DCMAKE_C_COMPILER=gcc -DCMAKE_CXX_COMPILER=g++ -DCMAKE_C_COMPILER_LAUNCHER=ccache -DCMAKE_CXX_COMPILER_LAUNCHER=ccache -DBUILD_TESTING=ON -DPython3_EXECUTABLE=C:/Python314/python.exe`, `cmake --build build --parallel 4`: exit 0. - On this branch (base `f2d874c1fd`): `cmake --build build --target guest_socket_options_tests --parallel 4` rebuilt `SocketOptions.cpp` and `GuestSocketOptions.cpp` and relinked `libkernel.prx` and `guest_socket_options_tests.exe`: exit 0. - `ctest --test-dir build -R guest_socket_options --output-on-failure`: 2/2 passed (`guest_socket_options`, `guest_socket_options_multicast`). Rerun after the last amend, which only shortened the debt entry: ninja had no work to do, 2/2 passed (0.77 s and 0.08 s). - `python tools/check_conventions.py --base origin/main`: All conventions checks passed. - `python tools/pr_overlap.py --branch feat/libkernel-accept-filter`: exit 2, as it fails closed when it cannot compare every PR; the manual comparison is under What. ### 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: <!-- #PR, or none --> #14183 - [x] Fixes: <!-- issue it closes as Fixes #N, or none --> none - [x] Unblocks: <!-- title ID and Game bring-up discussion, e.g. PPSA01325 #3232, or none --> none - [x] GPUs tested: <!-- for AGC, shader recompiler or VideoOut changes: vendor, model, driver and OS of each GPU the GPU tests ran on; otherwise n/a --> n/a - [x] AI-assisted: <!-- yes / no --> yes 🤖 Generated with [Claude Code](https://claude.com/claude-code)
MarcZX10 commented 2026-11-01 19:49:51 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-01T19:49:51Z.

Review: COMMENTED


Reviewed — no blocking findings

SO_ACCEPTFILTER on a non-listening socket, on a listener with a NULL value, and on a short argument now return the errors the new test expects, and a failed get leaves the caller's buffer unchanged. Approval is not given because the Linux and relinker jobs were skipped by the workflow.

What I ran

  • Head 8f54a85c1cdd9810bc64d8cc765c603f97c94aa4; base f2d874c1fd (merge base is the same commit). 3 files, +25/-3: libkernel/Socket/src/SocketOptions.cpp (4/2), core/libs/tests/GuestSocketOptions.cpp (20/0), and docs/dev/debt/libkernel.md (1/1). I read the whole diff.
  • Checked the code paths: SetSocketLevelOption returns ErrorInvalid for a socket that is not listening before it looks at the value (lines 175-185); on a listener a NULL value returns 0, and a value shorter than the 256-byte accept_filter_arg returns ErrorInvalid. GetSocketLevelOption now returns ErrorInvalid on a listener before writing anything (lines 291-296), so the buffer and its length stay unchanged.
  • Checked the new test cases against those paths, including the order of the null check and the listening check on a non-listening socket.
  • The debt entry describes the same behaviour and says where it comes from (FreeBSD 11.4 do_setopt_accept_filter and do_getopt_accept_filter), and that a set naming a filter still throws.
  • Hosted: conventions (two runs), eligibility, intake, labels, library portability, report and windows passed. The PR body has the template headings.
  • Precheck report at this exact head (head and base unchanged at completion). Its ABI and test-quality rows failed because their helpers are not in the head tree; the PR changes no export.

Results

Check Result Note
Diff check passed
Conventions and PR template passed
Mergeability and dependencies passed depends on none
Accept-filter error paths passed non-listening, NULL value, short value and failed get match the test
Debt entry passed describes the new behaviour and its source
Build and runtime tests not run no build; the Windows job passed (hosted)
Negative controls not run no build
Hosted CI not run conventions, eligibility, intake, labels, library portability, report and windows passed; linux, relinker, relinker-asan, register-context and write-watch skipped
Commands and unedited precheck output

Commands:

  • Precheck: python3 tools/pr_precheck.py --repo boykopovar/AnyPS5 --pr 14756 --output-dir <scratch>/precheck/14756 (report.md in that directory).
  • Head fetched by URL (objects only): git fetch https://github.com/boykopovar/AnyPS5.git pull/14756/head.
  • Hosted checks: gh api repos/boykopovar/AnyPS5/commits/8f54a85c1cdd9810bc64d8cc765c603f97c94aa4/check-runs.

Precheck table (unedited):

Check Status Command / reason
build_and_compile not_applicable The precheck deliberately does not configure, build, or compile AnyPS5.
diff_check passed git diff --check f2d874c1fdccf781c0fa5d86619bb5dd8894b958...8f54a85c1cdd9810bc64d8cc765c603f97c94aa4
conventions_and_pr_template passed /marc/Conlyse-VIEJO/.venv/bin/python3 tools/check_conventions.py --base f2d874c1fdccf781c0fa5d86619bb5dd8894b958 --head 8f54a85c1cdd9810bc64d8cc765c603f97c94aa4 --title feat(libkernel): follow FreeBSD for SO_ACCEPTFILTER on a listening socket --body /dev/shm/reviewer-run/precheck/14756/pr-body.md
changed_export_abi_audit failed /marc/Conlyse-VIEJO/.venv/bin/python3 tools/pr_abi_audit.py --base f2d874c1fdccf781c0fa5d86619bb5dd8894b958 --head 8f54a85c1cdd9810bc64d8cc765c603f97c94aa4 --json
python_syntax not_applicable No changed Python implementation files.
related_python_unit_tests not_applicable No changed tools/ module has an existing sibling tools/tests/test_<module>.py suite.
python_test_registration not_applicable No changed test_*.py files.
live_dependency_and_mergeability_check passed /marc/Conlyse-VIEJO/.venv/bin/python3 /marc/AnyPS5/tools/pr_stack_check.py 14756 --repo boykopovar/AnyPS5 --output-dir /dev/shm/reviewer-run/precheck/14756/stack
build_dependent_cpp_tests not_applicable Not run: C++ tests need exact-head binaries, which require a build; the precheck does not build.
test_quality_heuristics failed /marc/Conlyse-VIEJO/.venv/bin/python3 /dev/shm/reviewer-run/precheck/14756/head-8f54a85c1cdd-eb14481b/tools/pr_test_quality.py --root /dev/shm/reviewer-run/precheck/14756/head-8f54a85c1cdd-eb14481b --json core/libs/prx/libkernel/Socket/src/SocketOptions.cpp core/libs/tests/GuestSocketOptions.cpp docs/dev/debt/libkernel.md
negative_controls not_applicable No changed Python test module in tools/ can be run as a no-build base-source control.

Negative control

Not run here. The socket tests need a build.

Findings

Blocking

None.

Non-blocking

  • The set path still throws for a value that names a filter on a listener. The debt entry records this, so it is a known limit rather than a defect.

Sources

Not verified

  • No build or test run here; the Windows job passed on hosted CI.
  • The FreeBSD behaviour cited by the debt entry was not re-read.
  • The skipped jobs were not run.

To get this to a good state

  • Nothing blocking. Approval waits for the skipped jobs to be run or confirmed as not required on this head.
<!-- greyfinch-sync:boykopovar/AnyPS5:review:5729923601 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/14756#pullrequestreview-5729923601). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-11-01T19:49:51Z. **Review:** COMMENTED --- # Reviewed — no blocking findings `SO_ACCEPTFILTER` on a non-listening socket, on a listener with a NULL value, and on a short argument now return the errors the new test expects, and a failed get leaves the caller's buffer unchanged. Approval is not given because the Linux and relinker jobs were skipped by the workflow. ## What I ran - Head `8f54a85c1cdd9810bc64d8cc765c603f97c94aa4`; base `f2d874c1fd` (merge base is the same commit). 3 files, +25/-3: `libkernel/Socket/src/SocketOptions.cpp` (4/2), `core/libs/tests/GuestSocketOptions.cpp` (20/0), and `docs/dev/debt/libkernel.md` (1/1). I read the whole diff. - Checked the code paths: `SetSocketLevelOption` returns `ErrorInvalid` for a socket that is not listening before it looks at the value (lines 175-185); on a listener a NULL value returns 0, and a value shorter than the 256-byte `accept_filter_arg` returns `ErrorInvalid`. `GetSocketLevelOption` now returns `ErrorInvalid` on a listener before writing anything (lines 291-296), so the buffer and its length stay unchanged. - Checked the new test cases against those paths, including the order of the null check and the listening check on a non-listening socket. - The debt entry describes the same behaviour and says where it comes from (FreeBSD 11.4 `do_setopt_accept_filter` and `do_getopt_accept_filter`), and that a set naming a filter still throws. - Hosted: conventions (two runs), eligibility, intake, labels, library portability, report and windows passed. The PR body has the template headings. - Precheck report at this exact head (head and base unchanged at completion). Its ABI and test-quality rows failed because their helpers are not in the head tree; the PR changes no export. ## Results | Check | Result | Note | | --- | --- | --- | | Diff check | passed | | | Conventions and PR template | passed | | | Mergeability and dependencies | passed | depends on none | | Accept-filter error paths | passed | non-listening, NULL value, short value and failed get match the test | | Debt entry | passed | describes the new behaviour and its source | | Build and runtime tests | not run | no build; the Windows job passed (hosted) | | Negative controls | not run | no build | | Hosted CI | not run | conventions, eligibility, intake, labels, library portability, report and windows passed; linux, relinker, relinker-asan, register-context and write-watch skipped | <details><summary>Commands and unedited precheck output</summary> Commands: - Precheck: `python3 tools/pr_precheck.py --repo boykopovar/AnyPS5 --pr 14756 --output-dir <scratch>/precheck/14756` (report.md in that directory). - Head fetched by URL (objects only): `git fetch https://github.com/boykopovar/AnyPS5.git pull/14756/head`. - Hosted checks: `gh api repos/boykopovar/AnyPS5/commits/8f54a85c1cdd9810bc64d8cc765c603f97c94aa4/check-runs`. Precheck table (unedited): | Check | Status | Command / reason | |---|---|---| | build_and_compile | not_applicable | `The precheck deliberately does not configure, build, or compile AnyPS5.` | | diff_check | passed | `git diff --check f2d874c1fdccf781c0fa5d86619bb5dd8894b958...8f54a85c1cdd9810bc64d8cc765c603f97c94aa4` | | conventions_and_pr_template | passed | `/marc/Conlyse-VIEJO/.venv/bin/python3 tools/check_conventions.py --base f2d874c1fdccf781c0fa5d86619bb5dd8894b958 --head 8f54a85c1cdd9810bc64d8cc765c603f97c94aa4 --title feat(libkernel): follow FreeBSD for SO_ACCEPTFILTER on a listening socket --body /dev/shm/reviewer-run/precheck/14756/pr-body.md` | | changed_export_abi_audit | failed | `/marc/Conlyse-VIEJO/.venv/bin/python3 tools/pr_abi_audit.py --base f2d874c1fdccf781c0fa5d86619bb5dd8894b958 --head 8f54a85c1cdd9810bc64d8cc765c603f97c94aa4 --json` | | python_syntax | not_applicable | `No changed Python implementation files.` | | related_python_unit_tests | not_applicable | `No changed tools/ module has an existing sibling tools/tests/test_<module>.py suite.` | | python_test_registration | not_applicable | `No changed test_*.py files.` | | live_dependency_and_mergeability_check | passed | `/marc/Conlyse-VIEJO/.venv/bin/python3 /marc/AnyPS5/tools/pr_stack_check.py 14756 --repo boykopovar/AnyPS5 --output-dir /dev/shm/reviewer-run/precheck/14756/stack` | | build_dependent_cpp_tests | not_applicable | `Not run: C++ tests need exact-head binaries, which require a build; the precheck does not build.` | | test_quality_heuristics | failed | `/marc/Conlyse-VIEJO/.venv/bin/python3 /dev/shm/reviewer-run/precheck/14756/head-8f54a85c1cdd-eb14481b/tools/pr_test_quality.py --root /dev/shm/reviewer-run/precheck/14756/head-8f54a85c1cdd-eb14481b --json core/libs/prx/libkernel/Socket/src/SocketOptions.cpp core/libs/tests/GuestSocketOptions.cpp docs/dev/debt/libkernel.md` | | negative_controls | not_applicable | `No changed Python test module in tools/ can be run as a no-build base-source control.` | </details> ## Negative control Not run here. The socket tests need a build. ## Findings **Blocking** None. **Non-blocking** - The set path still throws for a value that names a filter on a listener. The debt entry records this, so it is a known limit rather than a defect. ## Sources - Set and get paths: https://github.com/boykopovar/AnyPS5/blob/8f54a85c1cdd9810bc64d8cc765c603f97c94aa4/core/libs/prx/libkernel/Socket/src/SocketOptions.cpp#L175-L185 and #L291-L296 - Test: https://github.com/boykopovar/AnyPS5/blob/8f54a85c1cdd9810bc64d8cc765c603f97c94aa4/core/libs/tests/GuestSocketOptions.cpp - Debt entry: https://github.com/boykopovar/AnyPS5/blob/8f54a85c1cdd9810bc64d8cc765c603f97c94aa4/docs/dev/debt/libkernel.md ## Not verified - No build or test run here; the Windows job passed on hosted CI. - The FreeBSD behaviour cited by the debt entry was not re-read. - The skipped jobs were not run. ## To get this to a good state - Nothing blocking. Approval waits for the skipped jobs to be run or confirmed as not required on this head.
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!14756
No description provided.