-
Notifications
You must be signed in to change notification settings - Fork 57
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 a builder for route messages #57
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please also fix examples/add_route.rs
In general, I like the idea of |
Hi, I'm jumping into the discussion here on request of @cathay4t in response to my PR number #53 . Our product uses rtnetlink quite extensively to configure the host's networking. In principle, I would much rather use Builder's that make the intent of the netlink command we issue clear from the code. However I've sturggled a bit with understanding how to achieve my desired results by reading the netlink documentation. My dev loop often involved I'm also specifically concerned about the message header flags. In my PR, I was not able to achieve the desired result with a set link message - I needed to issue an 'add' link message with the correct flags even though I was updating an existing object. I'm not sure how to design a clean API for this other than by exposing API to manipulate the flags directly. I'm happy to make another attempt at that PR in line with the builder approach, along with type-safe setters for the flags. What do you think? |
There is no good netlink document except kernel code. I also use
I will tag new release to
Sure, but please wait If @little-dude does not have time to move this PR forward, I will append my patches to this PR to get it merged next week. |
@little-dude Do you mind If pick up your work here? |
I'll try to fix this up today @cathay4t. Sorry, it's still busy at work, and I'm working on netlink by spikes |
55038f6
to
ef77d05
Compare
Done, @cathay4t |
7c8a388
to
ef77d05
Compare
We currently have `RouteAddRequest<Ipv4Addr>` and `RouteAddRequest<Ipv6Addr>`. But when working on codebases that mostly deal with `IpAddr`, this is an inconvenient API because we have to match on every address, and are forced to write the same code twice. The new impl makes working with `IpAddr` much more convenient, with the downside that the requests are validated at runtime instead of compile time.
For both the `RouteAddRequest` and `RouteDelRequest`, we need to build a route message. However only the former provides helper methods to do so. Instead of duplicating code, create a separate builder, and use it for both request types.
ef77d05
to
9049f59
Compare
Hello @cathay4t, would it be possible to get this merged within the next couple weeks by any chance? |
Please give me 2 days to review it. |
LGTM. Merged. Thanks for the efforts! |
Thanks @cathay4t ! |
@cathay4t would it be possible to make a release with these changes? I haven't done a release in a while, and with all the inter-dependencies between the crates I'm a bit scared of making one. |
@cathay4t would you be able to make a release? If not I'll give it a try. |
Can we use this builder to other component(addr, link, rule, rc)also before release? And I am also considering to |
I will create a PR tomorrow for expanding building to crate wide. After that, I can make a release. Meanwhile, please also vote on #66 |
I just realized I'd also need a netlink-packet-route release to get rust-netlink/netlink-packet-route#98 if you don't mind |
netlink-packet-route 0.20.1 released. Working on expanding the use of builder. |
Thanks a ton @cathay4t ! |
I am currently work on creating builder for link: |
For both the
RouteAddRequest
andRouteDelRequest
, we need to builda route message. However only the former provides helper methods to do
so. Instead of duplicating code, create a separate builder, and use it for
both request types.
This MR also allows building route requests parametrized by
IpAddr
, inaddition to the existing
Ipv4Addr
andIpv6Addr
implementations.This is a non-backward compatible change.