Commit Graph
312 Commits
Author SHA1 Message Date
Adrià f7e84c4cf1 Merge pull request #12426 from meh7an/fix/mingw-runtime-path-prx-loader-tests
test(libs): give the prx loader tests the MinGW runtime on their PATH
2026-10-29 10:41:49 +01:00
Dean e0a11b3fba Merge pull request #9515 from EagleBearerYS/fix/libkernel-getsockopt-net-sockets
fix(libkernel): getsockopt reads options of libSceNet sockets
2026-10-29 18:49:11 +13:00
MarcZX10 c1e321f26d feat(libSceNet): implement sceNetGetStatisticsInfo
sceNetGetStatisticsInfo threw NotImplemented_nid_no_patch. It now fills
the six 32-bit fields of the statistics block (kernel memory free and
minimum free, packet count, QoS packet count, library memory free and
minimum free) and fails with NET_EFAULT, setting errno, for a null
pointer. The layout and the "plenty free, nothing queued" answer follow
shadPS4's net.cpp and net_types.h; the host has no counter for the
console's network memory, so the values are not measured. The debt file
records this, and the test checks the null pointer, the field
invariants and that the flags argument is ignored.
2026-10-28 13:07:48 +00:00
MarcZX10 d7c13a621e feat(libSceNet): implement the pool-checked Show*WithMemory diagnostics
sceNetShowIfconfigWithMemory, sceNetShowPolicyWithMemory and
sceNetShowRoute6WithMemory threw NotImplemented_nid_no_patch. They now
behave like the existing sceNetShowRouteWithMemory: an unknown memory
pool id fails with NET_EBADF (errno set), a live pool returns success
without printing. The behaviour follows shadPS4's net.cpp, which does
the same for these three. The new silent stubs are listed in the
libSceNet technical debt file, and the tests cover the invalid id, live
pool and destroyed pool cases.
2026-10-28 13:07:48 +00:00
Mehran 90a9ab60c0 test(libs): give the prx loader tests the MinGW runtime on their PATH
guest_kernel_sys_threads_main, guest_kernel_sys_threads_main_patched and
net_ipv6only_patched link the MinGW runtime statically and load
libkernel_sys.prx or libSceNet.prx with LoadLibraryExW and
LOAD_WITH_ALTERED_SEARCH_PATH. Windows then looks for the libraries'
libstdc++-6.dll next to the .prx and on PATH, not next to the test
executable where the build copies the runtime. From Git Bash, whose PATH
starts with Git's mingw64/bin, the loader took Git's libstdc++-6.dll,
which lacks the std::__codecvt_utf8_utf16_base<wchar_t> members that
libkernel_sys, libkernel and libc import. The threads tests hung on an
"Entry Point Not Found" dialog until their 20 s timeout, and
net_ipv6only_patched, which suppresses the dialog, got error 127 and
aborted.

On MinGW, prepend the compiler's directory to their PATH, as
patched_libraries does since #10101.
2026-10-28 15:40:02 +03:00
frankea 2129d1f7b5 fix(libSceNet): print the interface and socket tables from sceNetShowIfconfig and sceNetShowNetstat
Since #9137 both throw after sceNetInit. A PS5 on firmware 13.40
returns 0 from each and prints plain-text tables to stdout. They now
print the console's layout with what the emulator knows: ifconfig an
eth0 block from the host interface sceNetCtlGetInfo reports (the same
MAC, address, netmask and MTU), the console's lo0 block and the DNS
servers; netstat the header and one entry per socket and epoll of the
title, with the self and non-blocking flags, addresses, buffer sizes and
the names given to sceNetSocket and sceNetEpollCreate, which are now
kept. The debt entry lists what the console prints that is left out.

guest_sce_net captures both outputs: the lo0 block and DNS section, a
named unbound UDP socket, a non-blocking listening TCP socket bound to
127.0.0.1, an epoll, a 40-character name cut to 31, and the entries gone
after close.
2026-10-28 09:05:58 +01:00
Yunus Shaikh 4432e8aa57 Merge main into fix/libkernel-getsockopt-net-sockets 2026-10-27 21:03:12 -07:00
Adrià 5c8beca92c Merge pull request #11676 from al3w0f205/test/net-getsockopt-null-and-bad-descriptor-coverage
test(libSceNet): cover null length pointer and invalid descriptor in socket option calls
2026-10-28 04:27:01 +01:00
Dean 9014065731 Merge pull request #9231 from Gonic0/fix/macos-sce-net-freebsd-errors
fix(libSceNet): match FreeBSD's inet_pton and socket errors on macOS
2026-10-28 12:59:52 +13:00
Adrià ddd72f488b Merge pull request #10628 from maximilianfv/fix/libscenet-macos-datagram-fionread
fix(libSceNet): count only datagram bytes in sceNetIoctl FIONREAD on macOS
2026-10-27 05:38:46 +01:00
al3w0f205 90b10d8b54 test(libSceNet): cover null length pointer and invalid descriptor in socket option calls 2026-10-26 22:17:55 -05:00
MaxandClaude Opus 5.5 ff5e67de15 fix(libSceNet): keep the iovec copy empty for a receive without iovecs
Copy the iovec table only when there is one, and receive a datagram
with no iovecs in guest_sce_net: it returns 0 with MSG_TRUNC and the
sender's address.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-10-27 00:21:05 +01:00
MaxandClaude Opus 5.5 3d2b723f71 fix(libSceNet): receive sceNetRecvmsg through the iovecs it had at entry
sceNetRecvmsg guarded the destinations of the iovec table it saw at
entry, then read the live table again to scatter the received bytes.
When an earlier destination overlapped a later iovec, the received
bytes replaced that iovec and the rest of the data went to an address
that was never guarded, which crashed the host when that address was
not writable. Copy the header and the iovec table once, as FreeBSD
11.4's sys_recvmsg does with copyin and copyiniov, use that copy for
the guards, the scatter and the address, and write the header back
from it as sys_recvmsg's copyout does.

Fixes #11610

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-10-26 23:53:11 +01:00
Dean abfa119d02 Merge pull request #11243 from parl0v/fix/getsockopt-kernel-sockets
fix(libSceNet): read an option of a libkernel socket through sceNetGetsockopt
2026-10-27 11:05:26 +13:00
Dean d9c7bb5ffe Merge pull request #11242 from parl0v/fix/epoll-kernel-sockets
fix(libSceNet): register libkernel sockets with sceNetEpollControl
2026-10-27 11:05:08 +13:00
Dean 998e9e5da4 Merge pull request #11037 from Bram910/fix/net-send-nosignal
fix(libSceNet): accept MSG_NOSIGNAL in send, sendto and sendmsg
2026-10-27 10:59:36 +13:00
Dean 77d9056574 Merge pull request #10949 from AZLisme/feat/net-ipv6only
feat(libSceNet): support IPv6 dual-stack socket options
2026-10-27 10:57:32 +13:00
Dean 43c0841507 Merge pull request #10881 from EagleBearerYS/feat/scenet-config-and-ether-calls
feat(libSceNet): implement sceNetInitParam and the loopback answer of sceNetConfigGetIfFlags
2026-10-27 09:07:50 +13:00
Queuze eebedb6427 feat(libSceNet): receive urgent TCP data inline 2026-10-26 14:03:15 +01:00
Adrià 0c6a6be7fe Merge pull request #9542 from Queuse/codex/net-boolean-readback
feat(libSceNet): read reuse and broadcast flags
2026-10-26 12:58:12 +01:00
AZLisme ada64cab1e fix(net): preserve IPv6 socket option bridges in patched modules 2026-10-26 19:16:52 +08:00
AZLisme e846e0c7b2 fix(libSceNet): guard socket option guest outputs 2026-10-26 19:16:52 +08:00
AZLisme 5f332dcaed feat(libSceNet): support IPv6-only socket configuration 2026-10-26 19:16:52 +08:00
Bram910 98c0bc2d4e Merge origin/main into fix/net-send-nosignal 2026-10-26 12:11:05 +01:00
Adrià 4b1a9a3b2f Merge pull request #9525 from Queuse/codex/net-socket-state
feat(libSceNet): expose socket type and listen state
2026-10-26 12:01:27 +01:00
Adrià 637575b493 Merge pull request #9733 from mugurc/fix/libscenet-stream-sends-macos
fix(libSceNet): keep MSG_DONTWAIT and aborted stream sends short on macOS hosts
2026-10-26 11:41:14 +01:00
Yunus Shaikh 6f3771820a fix(libSceNet): return -1 from sceNetConfigGetIfFlags for an interface number of 10 or more
Firmware 13.42's module looks the name up with sceNetGetIfName, which
has none past 9, then issues SIOCGIFFLAGS on the empty name. That ioctl
fails, and the call returns -1 with the flags untouched. Return the
same instead of throwing. Interfaces 1 to 9 still throw, and the test
no longer asserts that for 1 and 4, which the console answers from the
kernel.

Asked for in oneandonlydean's review, from BunnyFl's read of the
module.
2026-10-25 23:10:45 -07:00
Yunus Shaikh bf0f293edd Merge main into feat/scenet-config-and-ether-calls 2026-10-25 16:23:19 -07:00
Adrià b76f08cf33 Merge pull request #9727 from KernelPanicNT/fix/net-reject-unsupported-flags
fix(libSceNet): reject the flags and names the module rejects
2026-10-26 00:07:35 +01:00
Josip Parlov 6cbb4ff7fd fix(libSceNet): read an option of a libkernel socket through sceNetGetsockopt
Human Fall Flat (PPSA02429) opens its sockets with libkernel's socket()
and reads options of them with sceNetGetsockopt. libSceNet only looked
in its own socket table, so each call failed with SCE_NET_ERROR_EBADF.
On the console both calls work on the same kernel sockets, the position
sceNetSetsockopt already takes for MXGP 26 (PPSA30839).

A descriptor libSceNet does not own but libkernel has open as a socket
now goes to libkernel's getsockopt(), which answers the options it
models. Anything else still fails with EBADF. The fallback runs after
g_mutex is released.

guest_sce_net reads SO_SNDBUF and TCP_NODELAY of a libkernel TCP socket
through sceNetGetsockopt, checks that an unknown level fails with
EINVAL, and that the call fails with EBADF once the socket is closed.
2026-10-25 23:28:23 +01:00
Josip Parlov b0ab88d650 fix(libSceNet): register libkernel sockets with sceNetEpollControl
Human Fall Flat (PPSA02429) opens its sockets with libkernel's socket()
and registers them with sceNetEpollControl. libSceNet only looked in its
own socket table, so every ADD and DEL failed with SCE_NET_ERROR_EBADF.
The game retries without pause: on box 2 it made more than 1.6 million
failing calls on 14 descriptors in its first seconds, all of them
libkernel sockets.

sceNetEpollControl now accepts a descriptor libkernel has open as a
socket, as sceNetSocketClose and sceNetSetsockopt already do for MXGP 26
(PPSA30839). sceNetEpollWait looks up the host socket of such a
registration through libkernel after g_mutex is released, because that
lookup asks libSceNet's own table for descriptors libkernel does not
own, and keeps the owner alive across the host poll. libkernel's close()
retires the registrations of the closed socket; a wait drops a
registration whose socket is gone.

guest_sce_net registers a libkernel UDP socket, waits for it to become
readable and then writable, deletes it twice, closes registered sockets
through close() and sceKernelClose and waits again, and checks that a
descriptor that was never open still fails with EBADF.
2026-10-25 23:28:22 +01:00
Adrià 086ec0a79d Merge pull request #9523 from Queuse/codex/net-keepalive
feat(libSceNet): support SO_KEEPALIVE
2026-10-25 22:20:54 +01:00
mugurcandiamthehimansh 70b2e138bb fix(libSceNet): keep MSG_DONTWAIT and aborted stream sends short on macOS hosts
Two stream send behaviours of XNU differ from FreeBSD and Linux:

- MSG_DONTWAIT does not keep a stream send on a blocking socket from
  waiting for buffer space; XNU only skips the wait for the send buffer
  lock. A 16 MiB send to a slow peer blocked until the peer went away.
  A MSG_DONTWAIT transfer now also passes XNU's MSG_NBIO (0x20000), which
  makes one call non-blocking: the send queues what fits and returns that
  count, or EAGAIN when nothing fits.
- A blocking stream send that fails after queuing data, for example when
  sceNetSocketAbort shuts the socket down, returns only the error, where
  Linux returns the bytes queued. A blocking stream send now goes to the
  host in sends of 64 KiB and reports the bytes of the sends that
  completed when a later one fails, as #8658 does.

The debt entry records the undocumented flag and the bytes that a failing
64 KiB send queued but does not report.

Co-authored-by: iamthehimansh <[email protected]>
2026-10-25 20:11:31 +01:00
KernelPanicNT 6e8ec6d213 fix(libSceNet): reject the flags and names the module rejects
sceNetEpollCreate fails with EINVAL for a null name or non-zero flags,
sceNetResolverCreate and sceNetGetMacAddress for non-zero flags, and
sceNetResolverStartNtoa, before any other check, for a negative timeout
or retry count or a flag bit outside 0x10001, as prosper reads the
libSceNet module. The two accepted resolver flag bits are still ignored,
which the debt file now records.
2026-10-25 19:52:23 +01:00
Adrià FranchandClaude Sonnet 5.5 44393a3350 fix(net): reach the guest read through a _nid_no_patch export
Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
2026-10-25 18:56:25 +01:00
Braxton Atkinson 67c149465e feat(net): store DNS overrides and match firmware argument checks
Apply the firmware 13.42 module-probe report in PR #9506: all four DNS calls check initialization first; getters return EINVAL for null outputs or nonzero flags; setters reject flags before reading guest memory. Keep the checked input copy and document EFAULT as host safety, not firmware behavior. Use the current public Net.hpp declarations in the regression.

Rebased onto upstream e7e3e9c198. Ubuntu 24.04, GCC 13.3, Release: actual libc/libkernel/libSceNet libraries and both focused test executables built. guest_sce_net passes. A separate harness linked against those unmodified libraries passes initialization, errno, invalid flags, unreadable-input flag precedence, null clearing and unchanged-output checks. The full guest_net_dns_info test is blocked here: process_vm_readv is denied with EPERM by the execution environment. No full DNS regression pass is claimed. Public-header audit, conventions, test registration and whitespace checks pass.

The resolver still uses host DNS; IPv6 host-server discovery and firmware server-count behavior remain debt. Firmware evidence: https://github.com/boykopovar/AnyPS5/pull/9506#issuecomment-6390574180

AI-assisted: yes
2026-10-25 18:56:14 +01:00
Adrià f50caac5c2 Merge pull request #9494 from EagleBearerYS/fix/libscenet-inet-text-rules
fix(libSceNet): follow FreeBSD inet text rules for IPv6
2026-10-25 18:23:21 +01:00
Adrià 0c1563e357 Merge pull request #9493 from EagleBearerYS/fix/libscenet-closed-stream-readable
fix(libSceNet): report a stream whose peer closed as readable on Windows
2026-10-25 18:22:51 +01:00
Queuze ec47c9aa87 fix(net): preserve truncated option reads on sync 2026-10-25 14:18:39 -03:00
Queuze ea7109554c fix(net): retain protocol and socket state reads 2026-10-25 14:18:22 -03:00
Queuze 01b7dbaa7f fix(net): preserve short readback on main sync 2026-10-25 14:17:53 -03:00
Dean ee856eb7a0 Merge pull request #9931 from Queuse/codex/net-nodelay-short-readback
fix(net): truncate TCP_NODELAY readback
2026-10-26 04:45:18 +13:00
Bram910andClaude Opus 5.5 32744645c4 fix(libSceNet): accept MSG_NOSIGNAL in send, sendto and sendmsg
Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-10-25 15:21:43 +01:00
Yunus Shaikh fc881b9259 Merge main into fix/libscenet-inet-text-rules
Main's #10706 removes the local declarations at the top of libSceNet's
Export.cpp, where this branch had added __inet_pton and __inet_ntop.
libkernel's Api.hpp, which Export.cpp includes, now declares both, so the
merge takes main's side there.
2026-10-25 07:07:33 -07:00
Yunus Shaikh be3f208b02 fix(libSceNet): answer sceNetInitParam and a null sceNetConfigGetIfFlags as measured
BunnyFl measured both calls in firmware 13.42 libSceNet.sprx, run in an
emulator on the module itself. sceNetInitParam returns 0x80410116 for a
null parameter. The first non-null call copies the first 32 bytes of the
parameter and returns 0, and every later call returns 0x80410110, with a
null parameter and after sceNetTerm too, because the flag is never
cleared. sceNetConfigGetIfFlags returns 0x8041130E for a null flags
pointer before anything else. Both replace throws that stood in for the
unknown answers.

The first successful sceNetInitParam still marks the library initialized,
as sceNetInit does here, because the other calls check it. The module
reads only bit 0 of the stored copy's first word, to raise the pool limit
of sceNetPoolCreate from 32 to 128; that limit is recorded as not
modelled, as sceNetPoolCreate here has none.
2026-10-25 05:11:17 -07:00
Yunus Shaikh 00924d8f9f Merge main into fix/libkernel-getsockopt-net-sockets
Main extends the libkernel debt entry on libSceNet sockets with poll and
fcntl, where this branch adds getsockopt to the same entry; the merge keeps
both.
2026-10-25 03:59:43 -07:00
Queuze 58e7bf57fb chore: sync PR 9931 with current main 2026-10-25 07:28:28 -03:00
Queuze 449a6580dd chore: sync PR 9542 with current main 2026-10-25 07:27:26 -03:00
Queuze 843725faac chore: sync PR 9525 with current main 2026-10-25 07:27:01 -03:00
Queuze d73fc31f7b chore: sync PR 9523 with current main 2026-10-25 07:26:18 -03:00