fix(net): make new IPv6 sockets IPv6-only as FreeBSD does #4370
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/4370"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Imported from boykopovar/AnyPS5. Originally posted by milescoviello on 2026-10-12T07:54:43Z.
What
On Linux,
socket()(libkernel) andsceNetSocket()(libSceNet) createAF_INET6sockets in the host's default dual-stack mode (net.ipv6.bindv6onlyis 0), so a wildcard IPv6 bind also takes the IPv4 port. A title that keeps an IPv4 and an IPv6 socket on the same port, the usual way to serve both families, fails on main: with0.0.0.0:Pbound, binding[::]:PreturnsEADDRINUSE(48). An IPv6 socket bound to[::]also receives IPv4 traffic from v4-mapped peers, which the console never delivers to it.FreeBSD makes every new IPv6 socket IPv6-only.
sys/netinet6/in6_proto.c:sys/netinet/in_pcb.c,in_pcballoc():and
sys/netinet6/in6_pcb.c,in6_pcbbind(), only looks for an IPv4 owner of the port when that flag is clear:socket()andsceNetSocket()now setIPV6_V6ONLYon every IPv6 socket they create; a failure closes the socket and returns the error. Windows already makes IPv6 sockets IPv6-only by default. No title is claimed.Tested
Ubuntu 24.04, GCC 13.3 (CI's compiler), Release with CI's configure flags.
guest_tcp(libkernel) binds a TCP listener to0.0.0.0:0, reads its port P and binds and listens on an IPv6 TCP socket at[::]:P;guest_sce_net(libSceNet) does the same with UDP sockets. Both binds must succeed. The libkernel check is skipped when the host has no IPv6 (EAFNOSUPPORTfromsocket()orEADDRNOTAVAILfrombind()); the libSceNet one runs only when the existing IPv6 checks found a usable IPv6 loopback.guest_udp,guest_socket_pair,guest_socket_read_writeandguest_socket_events, and all 299guest_*tests pass (-E '^guest_video_out_').Checklist
main; no other open PR implements the same functionsNotImplemented_nid_no_patch); silent stubs are listed in TechnicalDebt.mdfiles or images added to the repository (attach them to this PR)🤖 Generated with Claude Code
Imported from boykopovar/AnyPS5. Originally posted by xXPBSXx on 2026-10-12T12:20:23Z.
Windows test: head
98f6639e9merged onto currentmainffa198407(clean merge, no conflicts). Windows 10, MinGW GCC (WinLibs), Ninja Release,-j4: full build 0 errors; ctest with the filterguest_sce_net|guest_tcp: guest_sce_net passed, guest_tcp passed (2 test(s), 0 failed);python tools/check_conventions.py --base upstream/mainpassed. I did not run the new tests againstmainwithout the change.AI-assisted (Claude Code).
Imported from boykopovar/AnyPS5. Originally posted by github-actions[bot] on 2026-10-12T17:49:26Z.
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.
main)core/libs/tests/GuestTcp.cppL50, L52core/libs/tests/GuestTcp.cppL3-4, L50, L52