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 support for the IP_SENDSRCADDR control message #1776

Merged
merged 1 commit into from Aug 12, 2022

Conversation

matttpt
Copy link
Contributor

@matttpt matttpt commented Aug 1, 2022

This control message is available on FreeBSD, NetBSD, and OpenBSD. When used with sendmsg, it sets the IPv4 source address. This adds support through a new ControlMessage::Ipv4SendSrcAddr variant that complements ControlMessageOwned::Ipv4RecvDstAddr.

A few notes:

  • IP_SENDSRCADDR is actually just an alias for IP_RECVDSTADDR (though the code doesn't depend on this).
  • On NetBSD, IP_PKTINFO can be used to accomplish the same thing and is already supported by nix. On FreeBSD and OpenBSD, though, IP_SENDSRCADDR is the only method I'm aware of.
  • The accompanying test binds a UDP socket to all local interfaces (0.0.0.0). If this is not acceptable, please let me know; however, FreeBSD requires this to use IP_SENDSRCADDR.

I'll add a change-log entry once I see the PR number.

Thanks!

Copy link
Member

@asomers asomers left a comment

Choose a reason for hiding this comment

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

Looks like DragonflyBSD supports it too. Can you add that please? Also, the test failures should be fixed if you rebase.

This control message (actually just an alias for IP_RECVDSTADDR) sets
the IPv4 source address when used with sendmsg. It is available on
FreeBSD, NetBSD, OpenBSD, and DragonFlyBSD.
Copy link
Collaborator

@rtzoeller rtzoeller left a comment

Choose a reason for hiding this comment

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

bors r+

@bors bors bot merged commit ffc793e into nix-rust:master Aug 12, 2022
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