libkernel: sendto to port 0 from an unbound IPv4 datagram socket is sent where FreeBSD 11.4 fails with EADDRNOTAVAIL #8498
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
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 xXPBSXx on 2026-10-20T13:57:12Z.
Repro
Any host.
s = socket(AF_INET, SOCK_DGRAM, 0)(not bound, not connected),sendto(s, "x", 1, 0, {127.0.0.1, port 0}, 16).Expected (FreeBSD 11.4): -1/EADDRNOTAVAIL (49).
udp_outputhands the destination toin_pcbconnect_setupunless the socket is bound to a specific address and port and the destination is neither INADDR_ANY nor INADDR_BROADCAST;in_pcbconnect_setupfailssin_port == 0withEADDRNOTAVAIL(sys/netinet/in_pcb.c:1034).Actual: the datagram is sent (result 1).
connectto port 0 already fails with 49 (#6884); docs/dev/debt/libkernel.md lists thesendto/sendmsgcase as a known gap.Test:
core/libs/tests/GuestUdp.cpp(CheckSendToPortZero, new; aborts before the fix).Fix branch: https://github.com/xXPBSXx/AnyPS5/tree/fix/sendto-port-zero
AI-assisted (Claude Code).