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

Linux: update and add missing AF_XDP API #3956

Merged
merged 2 commits into from
Nov 20, 2024
Merged

Conversation

arctic-alpaca
Copy link
Contributor

Description

This PR adds missing structs/constants from the if_xdp.h header and updates the xdp_umem_reg struct. Due to the added field in xdp_umem_reg, this is a breaking change from the 0.2 branch.

Ideally, I would like to include all the changes in the 0.2 branch. Would it be possible to add a xdp_umem_reg_v3 to not break the current xdp_umem_reg?
If not, how would deprecating a struct to change it work? Just add a deprecation notice, wait for X amount of time, add the field?

Sources

AF_XDP documentation: https://docs.kernel.org/networking/af_xdp.html
Header file: https://github.com/torvalds/linux/blob/v6.11/include/uapi/linux/if_xdp.h

Checklist

  • Relevant tests in libc-test/semver have been updated
  • No placeholder or unstable values like *LAST or *MAX are
    included (see #3131)
  • Tested locally (cd libc-test && cargo test --target mytarget);
    especially relevant for platforms that may not be checked in CI

I could not test the the changes locally due to the error described in #3865 (comment)

@rustbot
Copy link
Collaborator

rustbot commented Oct 1, 2024

r? @JohnTitor

rustbot has assigned @JohnTitor.
They will have a look at your PR within the next two weeks and either review your PR or reassign to another reviewer.

Use r? to explicitly pick a reviewer

@tgross35 tgross35 added the stable-nominated This PR should be considered for cherry-pick to libc's stable release branch label Nov 6, 2024
@tgross35
Copy link
Contributor

tgross35 commented Nov 6, 2024

Thanks for the PR, I'm taking a look at this. Where is xsk_tx_metadata_completion defined? I can't seem to find it anywhere.

Ideally, I would like to include all the changes in the 0.2 branch. Would it be possible to add a xdp_umem_reg_v3 to not break the current xdp_umem_reg?

The kernel removed the old interface because it was buggy, right? If the kernel made the decision to do a breaking change here then I think we can just do the same.

@tgross35 tgross35 changed the title update/add missing AF_XDP structs & constants Linux: update and add missing AF_XDP API Nov 6, 2024
@arctic-alpaca
Copy link
Contributor Author

I'm taking a look at this.

Thank you!

Where is xsk_tx_metadata_completion defined?

xsk_tx_metadata_completion and xsk_tx_metadata_request are the two possible variants of the anonymous union in xsk_tx_metadata.

The kernel removed the old interface because it was buggy, right?

Correct, the issue was initially reported here with the fix removing the xdp_umem_reg_v2 struct. The current situation is either the new (xdp_umem_reg) struct is used or the kernel falls back to using xdp_umem_reg_v1, which silently ignores the flags field (source). Silently ignoring the flags field being a breaking change in the kernel.

@bors
Copy link
Contributor

bors commented Nov 7, 2024

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

@bors
Copy link
Contributor

bors commented Nov 19, 2024

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

@@ -433,6 +434,15 @@ s! {
pub options: ::__u32,
}

pub struct xsk_tx_metadata_completion {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Everything added here is uapi right? It should probably go in src/unix/linux_like/linux/mod.rs rather than duplicating into gnu and musl. (The existing xdp types could probably move as well? Not in this PR though.)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Everything added here is uapi right?

Yes.

The existing xdp types could probably move as well?

I think so, I wasn't sure where to put them when I initially added them. I'll create a PR after this one is merged to move the rest too.

Copy link
Contributor

@tgross35 tgross35 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I did a bit of looking and it seems like rustix is about the only consumer of the specific type that would break. I asked about possible fallout here bytecodealliance/rustix#1221, if they say they can work around us breaking things then that is much easier than figuring out the best mitigation here.

In any case we can get this merged to main, left a comment about deduplicating gnu and musl.

@rustbot author

@arctic-alpaca
Copy link
Contributor Author

Everything that was added in this PR (besides the field addition) is moved to src/unix/linux_like/linux/mod.rs now.

@rustbot review

@tgross35 tgross35 added this pull request to the merge queue Nov 20, 2024
@tgross35
Copy link
Contributor

Thanks for moving things. I'll merge this now but hold off for a few more days on the backport to hear back from rustix (I am leaning toward just doing the backport, we can't reasonably do a major release in every case where the API we bind breaks).

Merged via the queue into rust-lang:main with commit 52ccb98 Nov 20, 2024
45 checks passed
tgross35 pushed a commit to tgross35/rust-libc that referenced this pull request Nov 25, 2024
tgross35 pushed a commit to tgross35/rust-libc that referenced this pull request Nov 25, 2024
@tgross35 tgross35 mentioned this pull request Nov 25, 2024
@tgross35 tgross35 added stable-applied This PR has been cherry-picked to libc's stable release branch and removed stable-nominated This PR should be considered for cherry-pick to libc's stable release branch labels Nov 25, 2024
@arctic-alpaca arctic-alpaca deleted the af_xdp branch November 27, 2024 19:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
O-gnu O-linux O-musl O-unix S-waiting-on-review stable-applied This PR has been cherry-picked to libc's stable release branch
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants