-
Notifications
You must be signed in to change notification settings - Fork 19
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
Adding set_route
to sys::unix::net
#255
Comments
Are there any existing libraries which have modeled this sort of binding? It's hard to judge whether this is appropriate, here. |
Alternatively, is there a particular reason std should do the bindings, instead of allowing such to live in a library? |
Apps tend to reimplement it each on their own, pretty straightforwardly for most since they do not necessarily need to be multi platform. I'd say setting the route it s a bit advanced usage but useful if you want the socket reaching it. And the necessary code is relatively simple. |
That's a fair point, I'd say this kind of feature is kind of the limit of being relevant/irrelevant on being in rust std. If we were talking about Linux's BPF filter it would be clearly a bit much :-) |
IMHO this is out-of-scope for the standard library. I think it would best live in a separate crate. |
Proposal
Problem statement
Adding a separated
set_route
call from the existingset_mark
.Motivating examples or use cases
set_mark
is more appropriate to assign an ID to a socket that a route can use, whereasset_route
would set the route ID the socket is going to be bound to. The actualset_mark
alone conflates a bit the two notions, thus adding FreeBSD's SO_SETFIB and OpenBSD's SO_RTABLE ought to migrate to the new call whereas Linux' SO_MARK (which the set_mark's idea generates from) and FreeBSD's SO_USER_COOKIE should remain.Solution sketch
#[cfg(any(target_os("openbsd"), target_os("freebsd")))] pub fn set_route(&self, route: i32) -> io::Result<()> { ... <setsockopt with the platform specific constant> }
Alternatives
Links and related work
ref PR.
What happens now?
Possible responses
The text was updated successfully, but these errors were encountered: