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

Add atomic replacement of XDP progs and multihoming of Extension progs #282

Merged
merged 5 commits into from
Jun 25, 2022

Conversation

dave-tucker
Copy link
Member

@dave-tucker dave-tucker commented May 24, 2022

This PR adds:

  • bpf_link_update
  • Xdp::attach_to_link - which allows for atomic replacement of XDP programs
  • Extension::attach_to_program - which allows for an Extension program to be attached to a program other than the one provided at load() - which is required as the verifier needs to know where it will be attached. The program/function should be BTF compatible or the call will fail.

These changes are collected together to enable the following use case in bpfd

  1. Attach an Xdp dispatcher program to an interface with an Xdp program loaded as an Extension to func1.
  2. A user requests that a new Xdp extension be loaded at func2
  3. Create a new Xdp dispatcher program.
  4. Attach the existing extension to func1 - it is now attached to the old and new dispatcher simultaneously.
  5. Attach the new extension to func2
  6. Use Xdp::attach_to_link to perform atomic replacement of the dispatcher programs

@netlify
Copy link

netlify bot commented May 24, 2022

Deploy Preview for aya-rs ready!

Built without sensitive environment variables

Name Link
🔨 Latest commit 004f3dd
🔍 Latest deploy log https://app.netlify.com/sites/aya-rs/deploys/62b721987372ca00092f8364
😎 Deploy Preview https://deploy-preview-282--aya-rs.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site settings.

@dave-tucker dave-tucker marked this pull request as ready for review May 24, 2022 17:50
@dave-tucker dave-tucker added feature A PR that implements a new feature or enhancement aya This is about aya (userspace) labels May 24, 2022
@dave-tucker dave-tucker added this to the 0.11.1 milestone Jun 17, 2022
Copy link
Collaborator

@alessandrod alessandrod left a comment

Choose a reason for hiding this comment

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

This is looking great now! See comments

aya/src/maps/array/program_array.rs Show resolved Hide resolved
aya/src/programs/mod.rs Show resolved Hide resolved
aya/src/programs/xdp.rs Outdated Show resolved Hide resolved
aya/src/sys/bpf.rs Outdated Show resolved Hide resolved
Signed-off-by: Dave Tucker <dave@dtucker.co.uk>
Signed-off-by: Dave Tucker <dave@dtucker.co.uk>
This removes the ProgramFd trait with a struct that wraps a RawFd.
Program::fd() has been implemented as well as fd() for each Program
Type. This allows for a better API than requiring the use of the
ProgramFd trait.

Signed-off-by: Dave Tucker <dave@dtucker.co.uk>
This allows for Extension programs already loaded to the kernel to be
attached to another program that is BTF-compatible with the one provided
at `load()` time

Signed-off-by: Dave Tucker <dave@dtucker.co.uk>
Signed-off-by: Dave Tucker <dave@dtucker.co.uk>
@dave-tucker
Copy link
Member Author

@alessandrod comments addressed 👍

@alessandrod alessandrod merged commit e5f455f into aya-rs:main Jun 25, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
aya This is about aya (userspace) feature A PR that implements a new feature or enhancement
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants