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 Netlink Protocol Families to SockProtocol enum #1289

Merged
merged 1 commit into from
Aug 22, 2020

Conversation

sinkingpoint
Copy link
Contributor

@sinkingpoint sinkingpoint commented Aug 8, 2020

Currently the SockProtocol enum is rather scarce. This commit adds the Netlink protocols
defined in netlink(7) to the SockProtocol enum allowing us to use the Nix socket library for
more in-depth Netlink work.

Because of the way libc sockets work, this is a bit more annoying than it has any right to be - the Socket Family and the Socket protocol are intertwined in that a given c_int protocol can represent different things depending on the family. This means that as we add values to this enum we're going to get collisions (Indeed, I've left out a few values that collided with the existing TCP/UDP Protocols). I'm not sure how we would want to handle this going forward - maybe different Protocol enums for different Familys, with Into<SockProtocol> methods?

I followed the existing pattern in this file when adding these, but perhaps as this enum gets bigger, we should use the libc_enum macro for cleanliness?

@sinkingpoint
Copy link
Contributor Author

Addresses #1288

@asomers
Copy link
Member

asomers commented Aug 17, 2020

This seems simple enough. And yes, libc_enum is certainly a better way to do this. Could you add a CHANGELOG entry?

Currently the SockProtocol enum is rather scarce. This commit adds the Netlink protocols
defined in netlink(7) to the SockProtocol enum allowing us to use the Nix socket library for
more indepth Netlink work
@sinkingpoint
Copy link
Contributor Author

Done @asomers - I figure changing to libc_enum involves changing the enum members names (Making them conform with libc naming standards) so would be a breaking change. Better to leave it out of this PR I think and address in a major release at some point. 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.

Oof, good point. Yes, it probably isn't worth the small amount of incompatibility just for that.

bors r+

@bors
Copy link
Contributor

bors bot commented Aug 22, 2020

Build succeeded:

@bors bors bot merged commit 1203d6c into nix-rust:master Aug 22, 2020
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