[PHP] fix: preserve socket identity and routing semantics#754
Merged
brandonpayton merged 8 commits intoJul 11, 2026
Conversation
This was referenced Jul 10, 2026
(cherry picked from commit 274a2ca)
(cherry picked from commit 05d6970)
(cherry picked from commit ea7c94c)
(cherry picked from commit cfa1cff)
Preserve logical binding owners, durable fork state, IPv6 and Unix socket identity, and bounded socket-option marshalling. Reject stale or unsupported datagram peers instead of silently redirecting data; machine-wide host-backed datagram routing remains a separate aggregate follow-up.
Apply one bounded decimal-IPv4 and ASCII hostname contract across Node TCP, browser Fetch/TLS, and local virtual networking. Keep browser DNS synthesis explicit and restrict virtual-network resolution to registered aliases.
f41e20d to
e492f5d
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Purpose
PHP's ordinary stream and socket tests exposed platform-level gaps in Kandelo's socket model: address-family handling, datagram routing, multicast, socket-option layouts, inherited ownership, and host hostname parsing. These fixes belong in the shared kernel and host networking layers rather than in PHP-specific shims.
This PR retains the original six socket/network commits and adds two review-repair commits needed for truthful process, ABI, and Node/browser behavior.
What changed
The original commits add:
::/::1stream and datagram support, completesockaddr_in6results, IPv4-mapped peers for dual-stack listeners, and pre-bindIPV6_V6ONLY.SO_LINGER,SO_BINDTODEVICE, andTCP_CONGESTIONhandling.Review found and repaired several correctness problems:
fork, spawn, close, and process cleanup. Closing a parent no longer unregisters a binding still inherited by a child, including paired dual-stack reservations.ECONNREFUSED; the exported connect path preserves that errno.MSG_OOBcannot target an unrelated replacement socket; a missing OOB peer returnsEPIPEand raisesSIGPIPEunless suppressed.accept()no longer inheritsO_NONBLOCK;accept4()validates flags before consuming a pending connection.SO_BINDTODEVICE, and cubic-onlyTCP_CONGESTIONbehavior were made consistent with the modeled routes.getsockopt()structured, string, timeval, and integer results share bounded, unaligned-safe copy handling, including null and short-length rejection.EPIPE/MSG_NOSIGNALbehavior are consistent across IPv4, IPv6, and Unix sockets.Integration provenance
The previous live source head was
f41e20dd9e03e68690b82c4a2dfda77f87bd6579. Its six logical commits were replayed onto the Batch 2 integration tip as:ac682923fcbf148fb6078b20bc7e80cf4e61516313e6237edf7298The replay conflict preserved #753's pathname-socket mode of
0777 & ~umaskwhile retaining abstract sockets' no-inode behavior. Review repairs were appended ase5e1c99c8ande492f5df7rather than folded into those six commits. The source branch was updated under an exact--force-with-leaseagainstf41e20dd....ABI and landing boundary
bash scripts/check-abi-version.shpasses structurally at ABI 16: the snapshot, C header, and generated TypeScript constants agree. That is not a semantic compatibility clearance.This PR changes observable errno, fd-inheritance, blocking, ownership, fork-wire, and pointer-copy behavior. It is therefore accepted only as a quarantined Batch 2 constituent, not as an independently mergeable or publishable branch. The final aggregate must perform the planned ABI 16→17 reconciliation and regenerate
abi/snapshot.json,host/src/generated/abi.ts, andlibc/glue/abi_constants.htogether before Batch 2 can advance.Validation
Run through
scripts/dev-shell.shon the final repaired source tree:cargo test -p kandelo --target aarch64-apple-darwin --lib: 1,005 passed, 0 failed.cargo check -p kandelo --target wasm64-unknown-unknown --lib -Z build-std=core,alloc.bash build.shpassed after rebuilding the final kernel, host package, examples, and rootfs.cd host && npx vitest run: 114 files passed, 16 skipped; 919 tests passed, 2 expected failures, 51 skipped.npm run typecheckinhost/passed.bash scripts/check-abi-version.shpassed at the structural ABI-16 level described above.test/network.spec.ts: 1 passed. The three-machine lab exercised UDP, TCP, and curl and asserted no console or page errors.The canonical
./run.sh browser --host 127.0.0.1 --port 57459path rebuilt/resolved 64 of 66 package targets and all #754 network-lab assets, then stopped while preinstalling the WordPress image because repaired #740's PHP artifact importsenv.__wasm_posix_vm_interrupt_after, intentionally supplied only by later constituent #757. The same known dependency also caused nginx/PHP opcache prewarm to skip. This is recorded as a failed aggregate startup attempt, not passing browser evidence and not a #754 socket regression.Per the batching agreement, the constituent did not run the full libc, POSIX, Sortix, or PHP PHPT suites. Those remain mandatory on the exact final Batch 2 aggregate.
Known boundaries and follow-ups
SO_LINGERhas the correct layout and survives fork, but nondefault linger does not yet affect close timing; repaired [PHP] fix: preserve orderly TCP close across bridges #755 must implement or truthfully reject enabled linger.MSG_TRUNCbehavior still require post-[PHP] fix: preserve socket identity and routing semantics #754 adaptations.View
Accept into stacked Batch 2 PR #871 only. Do not land this branch independently or merge Batch 2 until the ABI-17 reconciliation, remaining networking work, full aggregate gate, and PHP browser PHPT evidence are complete.