Repository navigation
Conversation
|
Other open pull requests touch the same code. Merging one will break the other, or both implement the same thing. If this one builds on them, list them in Depends on.
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.
|
|
Windows run of this head (
AI-assisted: yes (Claude Code). |
rooklz
left a comment
There was a problem hiding this comment.
Approving. I checked this head (9cf7eb8c98) host-side on macOS arm64. Nothing here is a console measurement.
Merge / conventions
git merge-treeontomainbb04a4f1ea: clean.git diff --check: clean.tools/check_conventions.py --base upstream/main: all checks passed.- Merge order with #11272 (Queuse, same file): stacking this PR on #11272 gives one textual conflict, the
*optlen < sizeof(int)guard insceNetGetsockopt. #11272 adds an empty line after it, and this PR addsNET_SO_DONTROUTEto it. Whichever lands second needs a one-line rebase. There is no semantic overlap.
Reference behaviour
- FreeBSD 11.4
sys/kern/uipc_socket.clistsSO_DONTROUTEwith theso_optionsflag cases insosetopt(L2556) andsogetopt(L2797), and reads backso->so_options & sopt->sopt_name(L2808). So the bit-valued readback (0x10/0) and the truncated copy-out match the existing REUSEADDR/BROADCAST path. libkernel'sSocketOptions.cppalready mapsGuestDontRoute = 0x10to hostSO_DONTROUTE, solibSceNetnow agrees with it.
Host primitive (macOS 15, arm64): I ran set/get of SO_DONTROUTE for AF_INET/AF_INET6 × STREAM/DGRAM with settings {1,-1,0,4,0}. All 20 setsockopt calls returned 0, and getsockopt returned 0x10 for non-zero settings and 0 for zero. With the flag set, a UDP sendto to an off-link address (8.8.8.8) fails with ENETUNREACH (51). A send to 127.0.0.1 succeeds. This matches FreeBSD 11.4 udp_output (SO_DONTROUTE → IP_ROUTETOIF, L1422) and ip_output's IP_ROUTETOIF branch returning ENETUNREACH when no interface is on-link.
Mutation harness. I copied the changed set and get branches verbatim into a standalone file. They run against real sockets, and the PR's test loop is reproduced for options 4/16/32. Head: GREEN at -O2, and GREEN under ASan+UBSan.
| mutant | result |
|---|---|
drop NET_SO_DONTROUTE from the setsockopt option list |
RED |
setsockopt map 0x10 → falls through to SO_RCVBUF |
RED |
drop NET_SO_DONTROUTE from the short-optlen exemption |
RED |
drop case NET_SO_DONTROUTE: in getsockopt |
RED |
getsockopt map 0x10 → SO_BROADCAST |
RED |
The test covers every changed line.
Optional, non-blocking: the debt line could say what the flag does on each host. Microsoft's SOL_SOCKET options table says Winsock "silently ignore[s] this option and always consult[s] the routing table". So on Windows the flag only round-trips through get and set. On POSIX hosts, an off-link send fails with ENETUNREACH, as on FreeBSD. That gap is worth one sentence in docs/dev/debt/libSceNet.md. JJenkx's Windows run shows the readback round-trips there.
AI-assisted: yes
9cf7eb8 to
9172f99
Compare
What
Support
NET_SO_DONTROUTE(0x10) insceNetSetsockoptandsceNetGetsockopt(libSceNet).FreeBSD 11.4 defines
SO_DONTROUTE = 0x10, which bypasses normal routing tables and sends packets directly to the network interface. Kernel sockets already mapGuestDontRoutetoSO_DONTROUTEincore/libs/prx/libkernel/Socket/src/SocketOptions.cpp:123, butlibSceNetpreviously lackedNET_SO_DONTROUTE = 0x10and rejected bothsceNetSetsockoptandsceNetGetsockoptwithNET_EOPNOTSUPP.This change:
NET_SO_DONTROUTE = 0x10incore/libs/prx/libSceNet/Export.cpp.NET_SO_DONTROUTEtosceNetSetsockoptmapping toSOL_SOCKET/SO_DONTROUTE.NET_SO_DONTROUTEtosceNetGetsockoptreadback, returning0x10when enabled and0when disabled, matching FreeBSD 11.4sogetoptflag bit behavior.GuestNetBooleanReadback.cppto verify setsockopt and getsockopt for option16(NET_SO_DONTROUTE) across stream/dgram and IPv4/IPv6 sockets with variable buffer lengths and truncated readback.docs/dev/debt/libSceNet.mdto reflectSO_DONTROUTEin the boolean readback entry.Tested
16tocore/libs/tests/GuestNetBooleanReadback.cpp.ctest -R guest_net_boolean_readbackand all 12guest_nettest suites in/tmp/anyps5_build: 100% passed (0 failures).python3 tools/check_conventions.py: 0 errors.Checklist
python3 tools/check_conventions.py