libkernel: sendto with an address on a connected UDP socket succeeds where FreeBSD returns EISCONN; fix branch ready #5374

Closed
opened 2026-10-13 18:16:10 +00:00 by husseinkad · 2 comments
husseinkad commented 2026-10-13 18:16:10 +00:00 (Migrated from github.com)
Contributor

Imported from boykopovar/AnyPS5. Originally posted by husseinkad on 2026-10-13T18:16:10Z.


sendto and sendmsg with a destination address on a connected UDP socket succeed. FreeBSD 11.4 udp_output fails that call with EISCONN (56): a connected datagram socket must be sent with send, or with sendto and a NULL address. A guest that sends addressed datagrams from a connected socket (and expects the error to find its mistake, or relies on the console's behaviour) gets silent success here.

Fix branch: https://github.com/husseinkad/AnyPS5/tree/fix/kernel-udp-sendto-eisconn (one commit on a recent main: Socket/src/Udp.cpp, tests/GuestUdpSendtoConnected.cpp, and a debt entry in docs/dev/debt/libkernel.md). sendto_nid_postfix uses getpeername to detect a connected datagram socket and returns EISCONN when an address is given; sendmsg_nid_postfix calls sendto_nid_postfix, so it gets the same check. The existing GuestUdp.cpp sent addressed datagrams from a connected socket, so that part of the test now uses an unconnected socket for those sends.

Checks:

  • The new test (IPv4 and IPv6, sendto and sendmsg, and sending again after disconnect) fails on main ("sendto with an address on a connected socket must fail with EISCONN (56)") and passes with the change; the 27-test socket group passes.
  • About 4,490 matrix cases plus 5,000 fuzz cases per variant on IPv4 and IPv6, UDP and TCP, against main (two runs of main differ only in noise): the only changed results are sendto and sendmsg with a family-valid address on an already connected UDP socket, which now return 56 where main returned success (or 49 or 13). Unchanged: unconnected UDP, send, write, a NULL address, wrong-family or short addresses (still 47) and every TCP result. Delivery payloads all matched.
  • Two independent reviews found nothing wrong. check_conventions.py is clean and pr_overlap.py finds no overlap.

Not covered: the check adds one getpeername call per addressed UDP send, and a failing getpeername falls through to the normal send. The family check (47) runs before EISCONN here, and FreeBSD's order is not verified. sceNetSendto is unchanged, sendmmsg is not exported, and the behaviour comes from the FreeBSD source, not a console run. Only Windows was built and run.

AI-assisted: yes

<!-- greyfinch-sync:boykopovar/AnyPS5:issue:5835422757 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/issues/5374). Originally posted by [husseinkad](https://github.com/husseinkad) on 2026-10-13T18:16:10Z. --- `sendto` and `sendmsg` with a destination address on a connected UDP socket succeed. FreeBSD 11.4 `udp_output` fails that call with `EISCONN` (56): a connected datagram socket must be sent with `send`, or with `sendto` and a NULL address. A guest that sends addressed datagrams from a connected socket (and expects the error to find its mistake, or relies on the console's behaviour) gets silent success here. Fix branch: https://github.com/husseinkad/AnyPS5/tree/fix/kernel-udp-sendto-eisconn (one commit on a recent main: `Socket/src/Udp.cpp`, `tests/GuestUdpSendtoConnected.cpp`, and a debt entry in `docs/dev/debt/libkernel.md`). `sendto_nid_postfix` uses `getpeername` to detect a connected datagram socket and returns `EISCONN` when an address is given; `sendmsg_nid_postfix` calls `sendto_nid_postfix`, so it gets the same check. The existing `GuestUdp.cpp` sent addressed datagrams from a connected socket, so that part of the test now uses an unconnected socket for those sends. Checks: - The new test (IPv4 and IPv6, `sendto` and `sendmsg`, and sending again after disconnect) fails on main ("sendto with an address on a connected socket must fail with EISCONN (56)") and passes with the change; the 27-test socket group passes. - About 4,490 matrix cases plus 5,000 fuzz cases per variant on IPv4 and IPv6, UDP and TCP, against main (two runs of main differ only in noise): the only changed results are `sendto` and `sendmsg` with a family-valid address on an already connected UDP socket, which now return 56 where main returned success (or 49 or 13). Unchanged: unconnected UDP, `send`, `write`, a NULL address, wrong-family or short addresses (still 47) and every TCP result. Delivery payloads all matched. - Two independent reviews found nothing wrong. `check_conventions.py` is clean and `pr_overlap.py` finds no overlap. Not covered: the check adds one `getpeername` call per addressed UDP send, and a failing `getpeername` falls through to the normal send. The family check (47) runs before `EISCONN` here, and FreeBSD's order is not verified. `sceNetSendto` is unchanged, `sendmmsg` is not exported, and the behaviour comes from the FreeBSD source, not a console run. Only Windows was built and run. AI-assisted: yes
MarcZX10 commented 2026-10-13 18:33:25 +00:00 (Migrated from github.com)
Author
Contributor

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-13T18:33:25Z.


I opened #5388 carrying your commit onto current main, with your original commit author preserved. On Linux GCC 12.2/Ninja Release, guest_udp_sendto_connected_tests and guest_udp_tests built; the seven socket/UDP CTests passed (7/7), covering IPv4 and IPv6 in the new regression. One initial grouped run had a transient abort in the existing guest_udp; it passed on direct rerun and on the subsequent full group rerun without a source change. Conventions passed. No console run was performed.

AI-assisted: yes; reviewed and tested by MarcZX100.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6152474643 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/issues/5374#issuecomment-6152474643). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-10-13T18:33:25Z. --- I opened #5388 carrying your commit onto current `main`, with your original commit author preserved. On Linux GCC 12.2/Ninja Release, `guest_udp_sendto_connected_tests` and `guest_udp_tests` built; the seven socket/UDP CTests passed (7/7), covering IPv4 and IPv6 in the new regression. One initial grouped run had a transient abort in the existing `guest_udp`; it passed on direct rerun and on the subsequent full group rerun without a source change. Conventions passed. No console run was performed. AI-assisted: yes; reviewed and tested by MarcZX100.
oneandonlydean commented 2026-10-14 06:55:00 +00:00 (Migrated from github.com)
Author
Contributor

Imported from boykopovar/AnyPS5. Originally posted by oneandonlydean on 2026-10-14T06:55:00Z.


Closing: no title is known to reach this, and functions are only changed when a title needs them. #5388 is closed for the same reason. If a title stops on or misbehaves because of it on current main, comment here with the title ID and the log line.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6162721099 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/issues/5374#issuecomment-6162721099). Originally posted by [oneandonlydean](https://github.com/oneandonlydean) on 2026-10-14T06:55:00Z. --- Closing: no title is known to reach this, and functions are only changed when a title needs them. #5388 is closed for the same reason. If a title stops on or misbehaves because of it on current main, comment here with the title ID and the log line.
Sign in to join this conversation.
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#5374
No description provided.