-
Notifications
You must be signed in to change notification settings - Fork 369
aya: Set attach mode flag to 0 in bpf_link_create #1408
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
base: main
Are you sure you want to change the base?
Conversation
✅ Deploy Preview for aya-rs-docs ready!Built without sensitive environment variables
To edit notification comments on pull requests, go to your Netlify project configuration. |
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.
Pull request overview
This PR fixes issue #1078 by setting the attach mode flag to 0 when calling bpf_link_create for cgroup programs on kernels 5.7.0+. The kernel's bpf_link_create syscall does not support flags when attaching to cgroups and returns EINVAL for non-zero values, while defaulting to BPF_F_ALLOW_MULTI internally.
Key changes:
- Added
PartialEqderive toCgroupAttachModeenum for comparison operations - Updated all cgroup program types to pass
0instead ofmode.into()tobpf_link_create - Added runtime warnings when non-default attach modes are specified but cannot be honored
Reviewed changes
Copilot reviewed 8 out of 8 changed files in this pull request and generated 7 comments.
Show a summary per file
| File | Description |
|---|---|
| aya/src/programs/links.rs | Added PartialEq to CgroupAttachMode enum to enable comparison with default |
| aya/src/programs/sock_ops.rs | Updated to pass flag 0 to bpf_link_create with warning when non-default mode is used |
| aya/src/programs/cgroup_sysctl.rs | Updated to pass flag 0 to bpf_link_create with warning when non-default mode is used |
| aya/src/programs/cgroup_sockopt.rs | Updated to pass flag 0 to bpf_link_create with warning when non-default mode is used |
| aya/src/programs/cgroup_sock_addr.rs | Updated to pass flag 0 to bpf_link_create with warning when non-default mode is used |
| aya/src/programs/cgroup_sock.rs | Updated to pass flag 0 to bpf_link_create with warning when non-default mode is used |
| aya/src/programs/cgroup_skb.rs | Updated to pass flag 0 to bpf_link_create with warning when non-default mode is used |
| aya/src/programs/cgroup_device.rs | Updated to pass flag 0 to bpf_link_create with warning when non-default mode is used |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
e1b6de3 to
b1fea0f
Compare
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.
Pull request overview
Copilot reviewed 8 out of 8 changed files in this pull request and generated 4 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
b1fea0f to
959772a
Compare
959772a to
a4fa83b
Compare
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.
Pull request overview
Copilot reviewed 9 out of 9 changed files in this pull request and generated 7 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| })?; | ||
| if mode != CgroupAttachMode::default() { | ||
| warn!( | ||
| "CgroupAttachMode {:?} will not be passed on to bpf_link_create", |
Copilot
AI
Dec 4, 2025
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.
The phrase "passed on to" should be "passed to" for grammatical correctness.
| "CgroupAttachMode {:?} will not be passed on to bpf_link_create", | |
| "CgroupAttachMode {:?} will not be passed to bpf_link_create", |
| })?; | ||
| if mode != CgroupAttachMode::default() { | ||
| warn!( | ||
| "CgroupAttachMode {:?} will not be passed on to bpf_link_create", |
Copilot
AI
Dec 4, 2025
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.
The phrase "passed on to" should be "passed to" for grammatical correctness.
| "CgroupAttachMode {:?} will not be passed on to bpf_link_create", | |
| "CgroupAttachMode {:?} will not be passed to bpf_link_create", |
| })?; | ||
| if mode != CgroupAttachMode::default() { | ||
| warn!( | ||
| "CgroupAttachMode {:?} will not be passed on to bpf_link_create", |
Copilot
AI
Dec 4, 2025
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.
The phrase "passed on to" should be "passed to" for grammatical correctness.
| "CgroupAttachMode {:?} will not be passed on to bpf_link_create", | |
| "CgroupAttachMode {:?} will not be passed to bpf_link_create", |
| if KernelVersion::at_least(5, 7, 0) { | ||
| if mode != CgroupAttachMode::default() { | ||
| warn!( | ||
| "CgroupAttachMode {:?} will not be passed on to bpf_link_create", |
Copilot
AI
Dec 4, 2025
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.
The phrase "passed on to" should be "passed to" for grammatical correctness.
| "CgroupAttachMode {:?} will not be passed on to bpf_link_create", | |
| "CgroupAttachMode {:?} will not be passed to bpf_link_create", |
| })?; | ||
| if mode != CgroupAttachMode::default() { | ||
| warn!( | ||
| "CgroupAttachMode {:?} will not be passed on to bpf_link_create", |
Copilot
AI
Dec 4, 2025
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.
The phrase "passed on to" should be "passed to" for grammatical correctness.
| "CgroupAttachMode {:?} will not be passed on to bpf_link_create", | |
| "CgroupAttachMode {:?} will not be passed to bpf_link_create", |
| if KernelVersion::at_least(5, 7, 0) { | ||
| if mode != CgroupAttachMode::default() { | ||
| warn!( | ||
| "CgroupAttachMode {:?} will not be passed on to bpf_link_create", |
Copilot
AI
Dec 4, 2025
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.
The phrase "passed on to" should be "passed to" for grammatical correctness.
| "CgroupAttachMode {:?} will not be passed on to bpf_link_create", | |
| "CgroupAttachMode {:?} will not be passed to bpf_link_create", |
| })?; | ||
| if mode != CgroupAttachMode::default() { | ||
| warn!( | ||
| "CgroupAttachMode {:?} will not be passed on to bpf_link_create", |
Copilot
AI
Dec 4, 2025
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.
The phrase "passed on to" should be "passed to" for grammatical correctness.
| "CgroupAttachMode {:?} will not be passed on to bpf_link_create", | |
| "CgroupAttachMode {:?} will not be passed to bpf_link_create", |
Fixes #1078
This change sets the flag to 0 in
bpf_link_create(used in kernels 5.7+) and adds warning logs if any other attach mode is passed in.This change is