-
Notifications
You must be signed in to change notification settings - Fork 1k
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
Netlink support for FreeBSD 13.2 #3201
base: main
Are you sure you want to change the base?
Conversation
Thanks for the pull request, and welcome! The Rust team is excited to review your changes, and you should hear from @JohnTitor (or someone else) soon. Please see the contribution instructions for more information. Namely, in order to ensure the minimum review times lag, PR authors and assigned reviewers should ensure that the review label (
|
I can't find a description of what the failing test does; obviously it's compiling some C code (I infer it's to check that the Rust-level definition is compatible with the C definition) and was never told to use the proper C header. This seems to hint that we don't want those definitions exposed for versions which don't implement them, that is FreeBSD 13.1 and earlier. For the tests themselves:
This also seems to hint that more CI configs will be needed. |
4714e89
to
f64ef18
Compare
The freebsd14 warning about |
Because it's already defined: libc/src/unix/bsd/freebsdlike/freebsd/mod.rs Line 3342 in 0b758af
|
I see it's already defined. The problem is, FreeBSD has 2 defines with same name and different values, each for a different API and defined in their own header file. The separate header files allow this to work for C by creating a poor man's namespacing, but how are we to handle that in the Rust case? Some options I can see include:
What do you think? |
Regarding NETLINK_GENERIC, ask @GuillaumeGomez . He's the one who added the definition from if_mib.h . Also, grep.app shows that his sysinfo crate is the only one that's using it as he intended. There are many more that try to use your version. Including https://github.com/bytecodealliance/rustix/blob/db143034d80dbe2dc62368b732378c89f16e7569/src/net/types.rs#L800 , which seems to be confused by the definition in libc. One version or the other will have to change. I suspect that the least overall pain to the community would come by removing or renaming the definition from if_mib.h Also, you should move your definitions out of the freebsd13 and freebsd14 modules and into the freebsd/mod.rs file. The former two should only be used for stuff that changes between versions. Symbols that newly appear in a newer version of FreeBSD can safely be defined by libc in for all OS versions. For example, |
FreeBSD and its handling of APIs is a nightmare. They don't care about compatibility, they change types/constants instead of creating new ones. So if |
What do you mean @GuillaumeGomez ? This problem is caused by if anything too much backwards-compatibility, not too little. The NETLINK_GENERIC mib that you're using was added in 1996, and it still works. The NETLINK_GENERIC that @ydirson wants, by contrast, is based on an RFC written in 2003. By then it was too late to change the name of the old constant, but changing the name of the new constant would break programs' cross-platform compatibility. Hence isolating them in separate headers. Is there any precedent for adding submodules to libc? |
I mean that if they wanted to change the value of
No clue but if there is a good enough reason, I think it could be ok (up to them though!). |
Are you talking about stuff like
I don't see why it couldn't be done. I think it's preferable to move the NETLINK_GENERIC mib into a submodule, because unlink the NETLINK_GENERIC protocol family it is platform-specific. If we do that, what do you think the submodule should be named, and what other symbols should go with it? |
I don't know enough about this to comment. From my understanding, having multiple types depending on which minimum version you support is much better and simpler. Anyway, there is no point debating over whether or not FreeBSD took the right decision here. |
f64ef18
to
017fb07
Compare
Pushed this, but:
|
You will have to add an exception in libc-test. See copy_file_range for an example. |
e5c9518
to
9afbd10
Compare
Starting to introduce namespaces in libc will have an impact on those generated tests, we'll likely need someone mastering this part? |
4d98ade
to
d5d2b59
Compare
d5d2b59
to
f9bc95e
Compare
☔ The latest upstream changes (presumably #3341) made this pull request unmergeable. Please resolve the merge conflicts. |
f9bc95e
to
d3b0e4e
Compare
7eda3b0
to
6d0e369
Compare
// sys/net/if_mib.h | ||
|
||
/// non-interface-specific | ||
pub const IFMIB_SYSTEM: ::c_int = 1; |
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.
This is a breaking change btw (moving a constant to a different module).
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.
Yes, this is handled separately as #3367, on which this PR is based
Rebased onto 0.2.151. Now forks for real in xen-guest-agent. |
Since 0.2 was branched out I cannot really rebase this branch any more to keep it usable (rustix just pushed a new version demanding libc 0.2.152), so I pushed the new rebased version to https://github.com/xcp-ng/rust-libc/tree/freebsd-netlink-0.2 |
6d0e369
to
4aaaed1
Compare
This last push removes the pcap/nflog part, which is indeed not directly related, and not necessary for our use case. That removed part is at https://github.com/xcp-ng/rust-libc/tree/freebsd-pcap-nflog in case it is useful for a new PR. |
4aaaed1
to
7d1e36e
Compare
... and rebased to avoid failure of obsolete freebsd12 build job |
☔ The latest upstream changes (presumably #3587) made this pull request unmergeable. Please resolve the merge conflicts. |
7d1e36e
to
58662d1
Compare
To allow the "Netlink on FreeBSD" feature to be usable before 0.3 gets released, this builds on top of both the netlink feature patch from rust-lang#3201 if explicitely requested through a feature flag, but by default provides the ifmib constants where they are located in previous 0.2 releases. Since this relies on creating the netlink constants in a separate module, and it seems we cannot check those automatically, avoids testing them. Signed-off-by: Yann Dirson <[email protected]>
To allow the "Netlink on FreeBSD" feature to be usable before 0.3 gets released, this builds on top of both the netlink feature patch from rust-lang#3201 if explicitely requested through a feature flag, but by default provides the ifmib constants where they are located in previous 0.2 releases. Since this relies on creating the netlink constants in a separate module, and it seems we cannot check those automatically, avoids testing them. Signed-off-by: Yann Dirson <[email protected]>
@tgross35 What does this |
It just means that something needs to happen, like prerequisite work or a policy decision, before this can move forward. In this case I believe that is #3367. |
There is a conflict of NETLINK_GENERIC definitions between net/if_mib.h and netlink/netlink.h. netlink.h is already exported in the crate root for Linux (and those definitions are already used by at least crates neli and netlink-packet-route), and if_mib is not much used yet, so this moves if_mib contents into its own namespace to leave place for netlink support on FreeBSD (rust-lang#3194). Module definition moved to the end of file to avoid cryptic style.rs error "constant found after module when it belongs before". ctest as of 0.22 cannot be told a given header's symbols live in a submodule, so let the tests ignore all of them. Signed-off-by: Yann Dirson <[email protected]>
This is an early subset of the Netlink interface, but it proves sufficient for monitoring changes in IP addresses, the coverage can be extended later as needed. Signed-off-by: Yann Dirson <[email protected]>
Makes sense, and now I realize that #3367 is itself blocked, and indeed needs a rebase (and maybe it should be added to the 1.0 milestone too) - but I only saw it by chance because of your post in #3248, received no notification of the tag change, and @bors did not report the need to rebase either 🤷 |
58662d1
to
98d71b4
Compare
No need to rebase just yet, I need to read into things better and figure out what series of events needs to happen. I'll post an update when I figure that out. |
Closes #3194, to the point that Xen Guest Agent can works on FreeBSD.
Requires breaking-change #3367.
Downstream support in
rust-netlink
:netlink-packet-route
: FreeBSD support available since v0.18rtnetlink
: FreeBSD support available since v0.14.1 (from FreeBSD support rust-netlink/rtnetlink#49)Also see #3555 for a backport to
libc-0.2
branch using a feature flag to avoid the breaking change by default.