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 UDP multicast simulation #223

Merged
merged 1 commit into from
Mar 5, 2025
Merged

Conversation

manifest
Copy link
Contributor

No description provided.

@manifest
Copy link
Contributor Author

manifest commented Mar 1, 2025

I’ve fixed clippy warnings and simplified tests for leaving multicast group.

@manifest manifest force-pushed the udp-multicast branch 2 times, most recently from c0dcf7d to 1d2ee20 Compare March 1, 2025 21:19
Copy link
Collaborator

@jlizen jlizen left a comment

Choose a reason for hiding this comment

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

Core approach seems reasonable to me.

Mostly my comments were nits around clarity of error messages and/or doc comments. Take them or leave them, none are blocking.

The only substantive thing I have questions about is, why aren't we verifying the bind addresses for ipv6 (only for ipv4 currently)?

Copy link
Collaborator

@jlizen jlizen left a comment

Choose a reason for hiding this comment

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

Thanks for fixing all the nits.

Had a follow-up question on the verify_*_bind_interface method, sorry for the churn

Ok(())
}

fn verify_ipv6_bind_interface(interface: u32) -> Result<()> {
Copy link
Collaborator

@jlizen jlizen Mar 5, 2025

Choose a reason for hiding this comment

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

Is there a reason this can't just be combined into a verify_bind_interface check? Given that we are already using it to verify ipv6 for the bind() method? Anyway we still want to validate the protocol version matches? And we still want to validate that the interface is unspecified or loopback since Turmoil isn't doing anything with them so accepting anything else would be misleading callers?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I believe there are few reasons why we can’t combine those functions. I've changed argument names of the verify_ipv4_bind_interface() to make that clear.

The first argument of the verify_ipv4_bind_interface() function is an interface address. We verify that it is unspecified or loopback, and test the fact that its protocol version matches the protocol version of the second argument, which is destination address (or host address, different names for the same address). We do not test the second argument (destination address).

The first argument of verify_ipv6_bind_interface() function has type u32. It’s not an IP address. We can’t test it for being unspecified or loopback, or for protocol version.

Copy link
Collaborator

Choose a reason for hiding this comment

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

IE, I'm having trouble understanding enforcing 0 rather than the Ipv6Addr::UNSPECIFIED or Ipv6Addr::LOCALHOST

Copy link
Collaborator

Choose a reason for hiding this comment

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

Ah, comment race, sorry... digesting your response, thanks

Copy link
Collaborator

Choose a reason for hiding this comment

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

Thanks for your clarification. I see, the APIs are just different across ipv4 and ipv6 for UDP socket - https://doc.rust-lang.org/std/net/struct.UdpSocket.html#method.join_multicast_v6

The address must be a valid multicast address, and interface is the index of the interface to join/leave (or 0 to indicate any interface).

A bit awkward, but totally outside of the scope of this CR. Your decision makes sense in that context, thanks for your patience.

Copy link
Collaborator

Choose a reason for hiding this comment

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

I've changed argument names of the verify_ipv4_bind_interface() to make that clear.

Thanks for this change, added clarity

@jlizen jlizen merged commit 8d1aba9 into tokio-rs:main Mar 5, 2025
4 checks passed
@jlizen
Copy link
Collaborator

jlizen commented Mar 5, 2025

Thanks for the quick turnaround on review feedback!

Will move conversation back to the issue: #208

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.

2 participants