Skip to content

freebsd(13.2): add net/netlink.h support - #5326

Open
dybucc wants to merge 2 commits into
rust-lang:mainfrom
dybucc:freebsd-netlink
Open

freebsd(13.2): add net/netlink.h support#5326
dybucc wants to merge 2 commits into
rust-lang:mainfrom
dybucc:freebsd-netlink

Conversation

@dybucc

@dybucc dybucc commented Jul 24, 2026

Copy link
Copy Markdown
Contributor

Description

This PR updates #3201 with merge conflicts resolved and follows the new plan at
1.

The patch adds support for netlink.h interfaces in OpenBSD, where there's an
item resolution conflict if we expose the Rust bindings alongside those of
if_mib.h. This set of APIs is "scoped" in C because they live on separate
headers. In rust-lang/libc, we reexport all items at the root crate level, which
makes item resolution fail.

Note this depends on #5325. It won't pass tests but it will build. This is
because the test templates will gather all items in a single file, so item
resolution fails. We can't really skip these items altogether from the tests, so
it may just be necessary to extend ctest to allow skipping module-specific
Rust items.

Checklist

  • Relevant tests in libc-test/semver have been updated
  • Commit messages permalink to headers for added or changed API
  • Placeholder or unstable values like *LAST or *MAX have the standard
    doc comment
  • Tested locally (cargo test -p libc-test --target mytarget); especially
    relevant for platforms that may not be checked in CI

@rustbot label +stable-nominated

Footnotes

  1. https://github.com/rust-lang/libc/pull/3201#issuecomment-4736374182

@rustbot rustbot added O-bsd O-freebsd S-waiting-on-review stable-nominated This PR should be considered for cherry-pick to libc's stable release branch labels Jul 24, 2026
@dybucc dybucc mentioned this pull request Jul 24, 2026
2 tasks
@dybucc
dybucc force-pushed the freebsd-netlink branch from f53fbf1 to c7886ff Compare July 27, 2026 06:28
@rustbot rustbot added the A-CI Area: CI-related items label Jul 27, 2026
@rustbot

This comment has been minimized.

@dybucc
dybucc force-pushed the freebsd-netlink branch 2 times, most recently from 6e16b1d to 05fae27 Compare July 28, 2026 11:27
This is an early subset of the Netlink interface, but it proves
sufficient for monitoring changes in IP addresses. Coverage can be
extended later as needed. See [^1] and [^2].

[^1]:
https://github.com/freebsd/freebsd-src/blob/df9d6403caa6426e92f5e100602f4d2be474bbae/sys/netlink/netlink.h
[^2]:
https://github.com/freebsd/freebsd-src/blob/df9d6403caa6426e92f5e100602f4d2be474bbae/sys/netlink/netlink_generic.h

Signed-off-by: Yann Dirson <yann.dirson@vates.fr>

Co-authored-by: Adam Martinez <149513579+dybucc@users.noreply.github.com>
@dybucc
dybucc force-pushed the freebsd-netlink branch from 653f197 to 0b6bb29 Compare July 29, 2026 07:34
@rustbot

rustbot commented Jul 29, 2026

Copy link
Copy Markdown
Collaborator

This PR was rebased onto a different main commit. Here's a range-diff highlighting what actually changed.

Rebasing is a normal part of keeping PRs up to date, so no action is needed—this note is just to help reviewers.

Change ctest-generated test routine and special-case SemVer tests when
targetting FreeBSD systems.

The situation is fairly exceptional in that we now have a public
submodule. This is not ideal for ctest, as it `#include`s or `use`s all
symbols (irrespective of header conflicts or item resolution conflicts.)

The solution has been implemented in such way that we can fairly easily
remove it from the build script once we settle on which of the
interfaces to keep post-1.0.

The ctest-generated tests now take an input variable that is used to
check if we're testing the `net/if_mib.h` header file or the
`netlink/netlink.h` header file. This does mean that we currently are
running the whole test suite twice, even when only a small subset of the
bindings actually differ across runs.

The SemVer tests also needed some tweaking. The routine in charge of
building up the string that gets written onto the import-only test file
had to be expanded with a special case when running the tests for
FreeBSD targets. Before just writing out the import as if it were
reexported at the crate root level, we check if the line of the plain
text file corresponds with any one of the symbols in a hardcoded list of
symbols that exist under the `netlink::netlink` public submodule. If so,
we instead write out a string that includes a more fine-grained path to
that module.
@tgross35

Copy link
Copy Markdown
Contributor

The API looks fine from a quick skim, but since there is no hurry, I think it may be worth trying to add support to ctest first so the tricky test setup isn't needed. (It's useful otherwise too.)

Sketched some of that up at #5344

@dybucc

dybucc commented Jul 31, 2026

Copy link
Copy Markdown
Contributor Author

Noted. Since you already pinged some contributor on that issue, I'll wait and
see whether they want to implement it. Otherwise, I'll do it.

@tgross35

tgross35 commented Aug 4, 2026

Copy link
Copy Markdown
Contributor

Could you try adding a separate TestGenerator instance like @mbyx recommended in that issue? Since it's split off, that should avoid the need to reexport libc::netlink at test root too.

@tgross35

tgross35 commented Aug 4, 2026

Copy link
Copy Markdown
Contributor

Either author or blocked, depending on whether that works.

@rustbot author

@rustbot

rustbot commented Aug 4, 2026

Copy link
Copy Markdown
Collaborator

Reminder, once the PR becomes ready for a review, use @rustbot ready.

@rustbot

rustbot commented Aug 4, 2026

Copy link
Copy Markdown
Collaborator

☔ The latest upstream changes (possibly #5370) made this pull request unmergeable. Please resolve the merge conflicts.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-CI Area: CI-related items O-bsd O-freebsd S-waiting-on-author stable-nominated This PR should be considered for cherry-pick to libc's stable release branch

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants