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

Adding set_route to sys::unix::net #255

Open
devnexen opened this issue Jul 31, 2023 · 5 comments
Open

Adding set_route to sys::unix::net #255

devnexen opened this issue Jul 31, 2023 · 5 comments
Labels
api-change-proposal A proposal to add or alter unstable APIs in the standard libraries T-libs-api

Comments

@devnexen
Copy link

devnexen commented Jul 31, 2023

Proposal

Problem statement

Adding a separated set_route call from the existing set_mark.

Motivating examples or use cases

set_mark is more appropriate to assign an ID to a socket that a route can use, whereas set_route would set the route ID the socket is going to be bound to. The actual set_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

@devnexen devnexen added api-change-proposal A proposal to add or alter unstable APIs in the standard libraries T-libs-api labels Jul 31, 2023
@workingjubilee
Copy link
Member

Are there any existing libraries which have modeled this sort of binding? It's hard to judge whether this is appropriate, here.

@workingjubilee
Copy link
Member

Alternatively, is there a particular reason std should do the bindings, instead of allowing such to live in a library?

@devnexen
Copy link
Author

devnexen commented Aug 1, 2023

Are there any existing libraries which have modeled this sort of binding? It's hard to judge whether this is appropriate, here.

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.

@devnexen
Copy link
Author

devnexen commented Aug 1, 2023

Alternatively, is there a particular reason std should do the bindings, instead of allowing such to live in a library?

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 :-)

@asomers
Copy link

asomers commented Nov 8, 2024

IMHO this is out-of-scope for the standard library. I think it would best live in a separate crate.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
api-change-proposal A proposal to add or alter unstable APIs in the standard libraries T-libs-api
Projects
None yet
Development

No branches or pull requests

3 participants