aya: Set attach mode flag to 0 in bpf_link_create#1408
aya: Set attach mode flag to 0 in bpf_link_create#1408mehnazyunus wants to merge 1 commit intoaya-rs:mainfrom
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.
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.
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.
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", |
There was a problem hiding this comment.
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", |
There was a problem hiding this comment.
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", |
There was a problem hiding this comment.
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", |
There was a problem hiding this comment.
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", |
There was a problem hiding this comment.
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", |
There was a problem hiding this comment.
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", |
There was a problem hiding this comment.
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