alexcrichton requested wasmtime-wasi-reviewers for a review on PR #11384.
alexcrichton opened PR #11384 from alexcrichton:refactor-wasi-udp-socket to bytecodealliance:main:
This commit refactors the implementation of
wasi:socketsfor WASIp2 and WASIp3 to use the same underlying host data structure for theUdpSocketresource in WIT. Previously each version of WASI had its own socket which resulted in duplicated code. There's some minor differences between WASIp2 and WASIp3 but it's easy enough to paper over with the same socket type. This is intended to help with the maintainability of this going forward to only have one type to operate on rather than two (which also ensures that bugfixes for one should affect the other).One other change made in this commit is that sprinkled checks for whether or not UDP is allowed are all removed and canonicalized during UDP socket creation. This means that UDP socket creation is the only location that checks for whether UDP is allowed. Once a UDP socket is created it can be used freely regardless of whether the UDP setting is enabled or disabled. This is not intended to have a large practical effect but it does mean the behavior of hosts that deny UDP but manually give access to a UDP socket resource to a component may behave subtly differently.
<!--
Please make sure you include the following information:
If this work has been discussed elsewhere, please include a link to that
conversation. If it was discussed in an issue, just mention "issue #...".Explain why this change is needed. If the details are in an issue already,
this can be brief.Our development process is documented in the Wasmtime book:
https://docs.wasmtime.dev/contributing-development-process.htmlPlease ensure all communication follows the code of conduct:
https://github.com/bytecodealliance/wasmtime/blob/main/CODE_OF_CONDUCT.md
-->
rvolosatovs submitted PR review.
rvolosatovs created PR review comment:
Could we clone the "check" from context here and avoid having to
Arc::cloneon each p3 usage of it?
rvolosatovs created PR review comment:
socket.set_socket_addr_check(Some(check));
rvolosatovs edited PR review comment.
alexcrichton updated PR #11384.
alexcrichton updated PR #11384.
alexcrichton submitted PR review.
alexcrichton created PR review comment:
Unfortunately no because the check will live in the store no matter what and we can't borrow the store across awaits, so it's got to get moved out. This is mostly just here to handle how in WASIp2 the socket check is inherited from the
Networktype rather than unconditionally fromWasiCtx. While esoteric it's possible for embedders to push their ownNetworkwithout usingWasiCtxwhich has a distinct check than the one inWasiCtxitself, although we might want to remove such a feature eventually (which would remove the need for this field here)
alexcrichton has enabled auto merge for PR #11384.
alexcrichton requested pchickey for a review on PR #11384.
alexcrichton requested wasmtime-core-reviewers for a review on PR #11384.
alexcrichton updated PR #11384.
alexcrichton updated PR #11384.
rvolosatovs merged PR #11384.
Last updated: Dec 06 2025 at 06:05 UTC