Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add bind_addr for udp stream #2191

Closed
wants to merge 3 commits into from
Closed

Add bind_addr for udp stream #2191

wants to merge 3 commits into from

Conversation

hainesc
Copy link

@hainesc hainesc commented Apr 22, 2024

The bind_addr is missing recently, see #2190

@hainesc
Copy link
Author

hainesc commented Apr 22, 2024

ping @bluejekyll @djc, may you take a look? Thanks very much!

@djc
Copy link
Collaborator

djc commented Apr 22, 2024

ping @bluejekyll @djc, may you take a look? Thanks very much!

There's no need to ping us immediately after filing a PR.

Copy link
Member

@bluejekyll bluejekyll left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we need to decide if this needs any checks about the same socket address version being used for the name_server and the bind address. That, or let's document that we are relying on the OS to return a no route to host error on first send.

func: UdpCreator<S>,
) -> Self {
let bind_address = match bind_addr {
Some(ba) => *ba,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Personally, I prefer more expressive names to shortening them like this, Some(bind_addr) => *bind_addr, is more readable IMO.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looking at the logic below, do we need to check that the bind_addr matches the family of the name_server? That is, if this is a v4 address, but the name_server is a v6 address, than this UDP socket will either fail, or never get a response, maybe it will fail quickly with a "no route to host", though I'm not sure off the top of my head.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point, I will take a look what other(such as std lib) do on this problem.

@djc
Copy link
Collaborator

djc commented May 1, 2024

@bluejekyll see discussion in #2190 on whether this is the right solution.

@bluejekyll
Copy link
Member

@bluejekyll see discussion in #2190 on whether this is the right solution.

That's a good discussion, let's finish that out.

@@ -36,6 +36,7 @@ where
MF: MessageFinalizer,
{
name_server: SocketAddr,
bind_addr: Option<SocketAddr>,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Based on the discussion in #2190, this should probably be IPaddr instead. I do think we should still consider how we want to deal with IPv4 vs IPv6...

@hainesc hainesc closed this May 5, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants