Skip to content

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.

3 participants