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 SO_BINDTODEVICE sockopt #1233

Merged
merged 1 commit into from May 8, 2020

Conversation

jeandudey
Copy link
Contributor

This is available only on Linux as far I know, socket(7) has some information
about the SO_BINDTODEVICE sockopt. In simple words it binds a socket
to an specific network device (specified as an string like "wlo1",
"eth0", etc.), to only process packets from that device.

Note: this is untested (for now, i'll test it today), but should work out of the box.

@jeandudey
Copy link
Contributor Author

Tested on Linux 5.3.0-51-generic (Ubuntu 18.04), works like a charm. Requires root to use SO_BINDTODEVICE otherwise EPERM is returned.

@asomers
Copy link
Member

asomers commented May 8, 2020

All new features in Nix require a CHANGELOG and a test. Can you please add those?

@jeandudey
Copy link
Contributor Author

@asomers Yeah, I'll do it.

@jeandudey jeandudey force-pushed the 2020_05_08-so-bindtodevice branch from c33cfbb to 10ebf45 Compare May 8, 2020 20:35
@jeandudey
Copy link
Contributor Author

@asomers Changes addressed

test/sys/test_sockopt.rs Outdated Show resolved Hide resolved
src/sys/socket/sockopt.rs Outdated Show resolved Hide resolved
This is available only on Linux as far I know,
[socket(7)](https://linux.die.net/man/7/socket) has some information
about the `SO_BINDTODEVICE` sockopt. In simple words it binds a socket
to an specific network device (specified as an string like "wlo1",
"eth0", etc.), to only process packets from that device.

Signed-off-by: Jean Pierre Dudey <jeandudey@hotmail.com>
@jeandudey jeandudey force-pushed the 2020_05_08-so-bindtodevice branch from 10ebf45 to 1686f6d Compare May 8, 2020 21:16
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.

Thanks for your contribution.

bors r+

@jeandudey
Copy link
Contributor Author

Thanks for your review!

@bors
Copy link
Contributor

bors bot commented May 8, 2020

Build succeeded:

@bors bors bot merged commit 095b5be into nix-rust:master May 8, 2020
@jeandudey jeandudey deleted the 2020_05_08-so-bindtodevice branch May 8, 2020 23:14
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

2 participants