[PR #1761] [MERGED] Only retry UDP socket bind if it returned EADDRINUSE #2586

Closed
opened 2026-03-16 10:43:18 +03:00 by kerem · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/hickory-dns/hickory-dns/pull/1761
Author: @peterthejohnston
Created: 8/8/2022
Status: Merged
Merged: 8/8/2022
Merged by: @bluejekyll

Base: mainHead: propagate-bind-error


📝 Commits (1)

  • be0cbce Only retry UDP socket bind if returned EADDRINUSE

📊 Changes

1 file changed (+9 additions, -3 deletions)

View changed files

📝 crates/proto/src/udp/udp_stream.rs (+9 -3)

📄 Description

Currently, the NextRandomUdpSocket picks a random port in the ephemeral
port range and attempts to bind a UDP socket to it. If that bind
operation fails, it indiscriminately retries several times before
allowing the caller to poll again, assuming that it failed because the
randomly selected port was in use.

However, this means that if bind fails for another reason than the
requested port being unavailable, such as insufficient capabilities to
bind a socket, this error will not be propagated to the caller. Instead,
with this change, NextRandomUdpSocket immediately returns any error
returned from bind unless it is EADDRINUSE, in which case, it picks
another random port and tries again as before.

This was observed in a test on Fuchsia because, if the DNS resolver does not
have access to the capability required from the network stack to create and bind
sockets, it will see an EPIPE (broken pipe) error on bind.


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/hickory-dns/hickory-dns/pull/1761 **Author:** [@peterthejohnston](https://github.com/peterthejohnston) **Created:** 8/8/2022 **Status:** ✅ Merged **Merged:** 8/8/2022 **Merged by:** [@bluejekyll](https://github.com/bluejekyll) **Base:** `main` ← **Head:** `propagate-bind-error` --- ### 📝 Commits (1) - [`be0cbce`](https://github.com/hickory-dns/hickory-dns/commit/be0cbce3aae4a593b92374edbbb633e527a70a3c) Only retry UDP socket bind if returned EADDRINUSE ### 📊 Changes **1 file changed** (+9 additions, -3 deletions) <details> <summary>View changed files</summary> 📝 `crates/proto/src/udp/udp_stream.rs` (+9 -3) </details> ### 📄 Description Currently, the NextRandomUdpSocket picks a random port in the ephemeral port range and attempts to bind a UDP socket to it. If that bind operation fails, it indiscriminately retries several times before allowing the caller to poll again, assuming that it failed because the randomly selected port was in use. However, this means that if `bind` fails for another reason than the requested port being unavailable, such as insufficient capabilities to bind a socket, this error will not be propagated to the caller. Instead, with this change, NextRandomUdpSocket immediately returns any error returned from `bind` unless it is EADDRINUSE, in which case, it picks another random port and tries again as before. This was observed in a test on Fuchsia because, if the DNS resolver does not have access to the capability required from the network stack to create and bind sockets, it will see an `EPIPE` (broken pipe) error on `bind`. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
kerem 2026-03-16 10:43:18 +03:00
Sign in to join this conversation.
No milestone
No project
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.

Dependencies

No dependencies set.

Reference
starred/hickory-dns#2586
No description provided.