-
Notifications
You must be signed in to change notification settings - Fork 50
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
[API break] link: Reorganize the code base #56
Conversation
810c921
to
81f213b
Compare
Codecov Report
@@ Coverage Diff @@
## main #56 +/- ##
==========================================
+ Coverage 51.40% 55.40% +3.99%
==========================================
Files 76 86 +10
Lines 6744 6328 -416
==========================================
+ Hits 3467 3506 +39
+ Misses 3277 2822 -455
📣 Codecov offers a browser extension for seamless coverage viewing on GitHub. Try it in Chrome or Firefox today! |
81f213b
to
bae588d
Compare
@little-dude @JohnTitor Please take a look when you have time. I am planning to do 1.0 release before end of 2024. I am still adding more test cases to make sure this fundamental network crate is trustable. |
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.
Didn't check the diff exhaustively (it's huge!) but the summary on OP sounds good to me.
988f109
to
7f9f79b
Compare
7f9f79b
to
b58f2e7
Compare
Patch is ready for review. I will create new PRs for follow up works:
|
b58f2e7
to
bc39833
Compare
I'm not convinced it is a good idea to remove the dependency on libc and duplicate here the job of maintaining mappings for address families and other things. Portability-wise, where the current implementation makes the compiler point to places where work is needed, this proposal just pretends the Linux constants are the truth, bypassing the value checks done by the libc crate's tests. This would effectively make this crate Linux-only. |
Indeed, not having individual reworks separated does not help to investigate alternative changes. |
Regarding this libc dependency, I actually got email requesting support on FreeBSD which suggest me to remove the dependency on libc as FreeBSD does not have libc constants we depend on, These netlink crates are mainly developed and tested on Linux, and I don't have resource to test or maintain it on other platforms. In stead of future use case, so if you have proof that Unix and Linux holding different integer on constants used by this crate, please state them, we can discuss in new thread on whether bring libc dependency back or use conditional compiling. Regarding the large patch, I have tried my best to refrain myself on changing more codes. Sorry. Mostly the code changes is just moving code around. |
@ydirson Oh, just realize it is you who requested FreeBSD support. Could you state which constants has conflicts between Unix and Linux and protected by libc? |
Well, my suggestion was not to remove the dependency on libc, rather to decorrelate the
The main problem was not that of differing values, but as you mentioned earlier of not all constants not being available on FreeBSD. However, now that you mention it, even though the NETLINK values present today on FreeBSD are the same as on Linux, netlink has to manipulate eg. address families, and we have for example:
That's the case for lots of software. It would be one more reason to rely on the work done in the What I think would be a good solution would look like:
This would allow something like:
Now there is extra maintenance work with this, especially as more OS will gain Netlink support, and their protocol coverage changes over time. So maybe something more clever could be done, like having |
Thanks for the suggestions. It seems the way we are handling |
bc39833
to
fb8e1a2
Compare
@ydirson New patch uploaded for the cross-platform supports:
|
2a7df8b
to
9a76d2d
Compare
* This patch is first preparation on stable release 1.0 for submodule link. The detailed checklist for developer is stated in README.md file. * Stored constants into where it been used. Will remove `constants.rs` once all components finished. * Replace `pub use self::*` to explicit expose. * Removed `data` folder, `README.md` file has expanded to hold steps to capture netlink packets. * Removed `Unspec` as kernel not use it. * Removed `benches` folder as never used. * Removed dependency on `lazy_static`. * Added dependency on `log`. Considering `rtnetlink` also has it, no burden added to end user. * Many member of `InfoVxlan` changed from u8 to bool after confirmed with kernel code. * Changed API: * Rename: * `link::Nla` to `link::LinkAttribute` because `Nla` is a trait * `link:Info` to `link::LinkInfo` * `link::VethInfo` to `link::InfoVeth` * `link::InfoXfrmTun` to `link::InfoXfrm` * The AfSpec for ipv4 and ipv6 is rework. Please check `AfSpecUnspec` * Removed `link::Nla::AltIfName`. Use `link::LinkAttribute::PropList<vec![link::Prop::AltIfName]>` instead. * Changed `InfoVlan::Protocol<u16>` to `InfoVlan::Protocol<VlanProtocol>`. * `LinkHeader` changed to use enum instead raw integer on flags, address family and link layer type. * Change `LinkMessage.nlas` to `LinkMessage.attributes`. * Added: * `link::LinkFlag` and `LinkFlags` for `IFF_UP` and etc * `link::LinkLayerType` for `ARPHRD_ETHER` and etc * `crate::AddressFamily` for `AF_UNSPEC` and etc Unit test cases included. Signed-off-by: Gris Ge <[email protected]>
9a76d2d
to
9e9b73f
Compare
@cathay4t that looks great! Eager to see libc 0.3 debut so this can be applied to the netlink constants too! I guess that to be able to try that on |
I have waited long enough for reviews. Let's move on and fix issue in new PR. |
This patch is first preparation on stable release 1.0 for submodule
link. The detailed checklist for developer is stated in
README.md file.
Stored constants into where it been used. Will remove
constants.rs
once all components finished.
Replace
pub use self::*
to explicit expose.Removed
data
folder,README.md
file has expanded to hold steps tocapture netlink packets.
Removed
Unspec
as kernel not use it.Removed
benches
folder as never used.Removed dependency on
lazy_static
.Added dependency on
log
. Consideringrtnetlink
also has it, noburden added to end user.
Many member of
InfoVxlan
changed from u8 to bool after confirmedwith kernel code.
Changed API:
link::Nla
tolink::LinkAttribute
becauseNla
is a traitlink:Info
tolink::LinkInfo
link::VethInfo
tolink::InfoVeth
link::InfoXfrmTun
tolink::InfoXfrm
AfSpecUnspec
link::Nla::AltIfName
. Uselink::LinkAttribute::PropList<vec![link::Prop::AltIfName]>
instead.
InfoVlan::Protocol<u16>
toInfoVlan::Protocol<VlanProtocol>
.LinkHeader
changed to use enum instead raw integer on flags,address family and link layer type.
LinkMessage.nlas
toLinkMessage.attributes
.Added:
link::LinkFlag
andLinkFlags
forIFF_UP
and etclink::LinkLayerType
forARPHRD_ETHER
and etccrate::AddressFamily
forAF_UNSPEC
and etc