Repository navigation
Report UDP pending errors only when asked - #1895
Draft
Weidong Cui (wdcui) wants to merge 4 commits into
Draft
Weidong Cui (wdcui) wants to merge 4 commits into
Weidong Cui (wdcui) wants to merge 4 commits into
Conversation
A UDP send took the socket's pending error before checking its destination, so a send that its destination fails, such as a broadcast or a policy-denied one, reported and lost the error. Linux checks the destination and route first, and keeps the error. Check them first, and refuse the broadcast address with PolicyDenied (EACCES, as Linux without SO_BROADCAST) rather than InvalidArgument, for sends and connects. Check a broadcast sendto and connect in udp_broker.c in place of the port-0 sendto, which the shim refuses before the broker. Drop the unit check of a failed send while the error is with the transport, which the new order makes no different. Rebuild the Windows runner's udp_broker. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: f5406de6-bab4-4f3b-b232-ae238032c2c2
A UDP send took the socket's pending error once its destination was checked, which is one guest OS's rule; others report it at another point or only on receive. Make datagram sends leave pending errors pending unless the new SendFlags::REPORT_PENDING_ERROR asks for one to be reported in place of sending, once the destination is checked and before a write shutdown is. The rule binds the socket providers too: the userland and smoltcp ones take their own cached errors only with the flag, and where a host send takes the host socket's error, as a Linux host's does, the userland one takes it first and keeps it. Stream sends, which have no destination to check first, reject the flag. The Linux shim sets it on UDP sends, so Linux guests see no change. Check that sends without the flag leave the error for a take or a receive, in the core and in both providers. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: f5406de6-bab4-4f3b-b232-ae238032c2c2
A UDP endpoint was not watched again while it had an error pending. A send that would block while the endpoint kept an error, as a send without REPORT_PENDING_ERROR leaves one, then never learned that the host could send until a call took the error. Only an error the host socket still holds must stop the watch, which would report it again at once. Watch again while the endpoint keeps the error, and take an error that reaches the host socket meanwhile, coalescing it into the kept one, so that the watch does not report it over and over. Check that such a send learns when it can send, with the error kept, and that a later host error is taken at once. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: f5406de6-bab4-4f3b-b232-ae238032c2c2
A UDP socket connected to itself refuses datagrams only on Linux, so use refusing_udp_address() and keep Windows coverage of the fix. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: f5406de6-bab4-4f3b-b232-ae238032c2c2
|
ℹ️ Note: This semver check was run against the 🤖 SemverChecks 🤖 No breaking API changes detected Note: this does not mean API is unchanged, or even that there are no breaking changes; simply, none of the detections triggered. |
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.
This PR makes UDP pending-error reporting in the broker guest-neutral. A UDP send checks its destination, policy and source first, and refuses broadcast with EACCES. It reports a pending error only when the sender sets the new
REPORT_PENDING_ERRORflag, which the Linux shim does; otherwise the error stays pending for a later receive orSO_ERROR. On Linux hosts, a send without the flag first takes the host socket's error and keeps it, and the socket can still wait for writes while it keeps one.