-
Notifications
You must be signed in to change notification settings - Fork 400
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?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -6,6 +6,7 @@ use aya_obj::generated::{ | |||||
| bpf_attach_type::{BPF_CGROUP_INET_EGRESS, BPF_CGROUP_INET_INGRESS}, | ||||||
| bpf_prog_type::BPF_PROG_TYPE_CGROUP_SKB, | ||||||
| }; | ||||||
| use log::warn; | ||||||
|
|
||||||
| use crate::{ | ||||||
| VerifierLogLevel, | ||||||
|
|
@@ -86,6 +87,11 @@ impl CgroupSkb { | |||||
| /// Attaches the program to the given cgroup. | ||||||
| /// | ||||||
| /// The returned value can be used to detach, see [CgroupSkb::detach]. | ||||||
| /// | ||||||
| /// # Warning | ||||||
| /// | ||||||
| /// On kernels 5.7.0 and later, attach modes other than `CgroupAttachMode::default()` are not passed to `bpf_link_create`. | ||||||
| /// On older kernels (using `bpf_prog_attach`), the attach mode is honored. | ||||||
| pub fn attach<T: AsFd>( | ||||||
| &mut self, | ||||||
| cgroup: T, | ||||||
|
|
@@ -101,17 +107,17 @@ impl CgroupSkb { | |||||
| CgroupSkbAttachType::Egress => BPF_CGROUP_INET_EGRESS, | ||||||
| }; | ||||||
| if KernelVersion::at_least(5, 7, 0) { | ||||||
| let link_fd = bpf_link_create( | ||||||
| prog_fd, | ||||||
| LinkTarget::Fd(cgroup_fd), | ||||||
| attach_type, | ||||||
| mode.into(), | ||||||
| None, | ||||||
| ) | ||||||
| .map_err(|io_error| SyscallError { | ||||||
| call: "bpf_link_create", | ||||||
| io_error, | ||||||
| })?; | ||||||
| if mode != CgroupAttachMode::default() { | ||||||
| warn!( | ||||||
| "CgroupAttachMode {:?} will not be passed on to bpf_link_create", | ||||||
|
||||||
| "CgroupAttachMode {:?} will not be passed on to bpf_link_create", | |
| "CgroupAttachMode {:?} will not be passed to bpf_link_create", |
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -4,6 +4,7 @@ use std::{hash::Hash, os::fd::AsFd, path::Path}; | |||||
|
|
||||||
| use aya_obj::generated::bpf_prog_type::BPF_PROG_TYPE_CGROUP_SOCK; | ||||||
| pub use aya_obj::programs::CgroupSockAttachType; | ||||||
| use log::warn; | ||||||
|
|
||||||
| use crate::{ | ||||||
| VerifierLogLevel, | ||||||
|
|
@@ -70,6 +71,11 @@ impl CgroupSock { | |||||
| /// Attaches the program to the given cgroup. | ||||||
| /// | ||||||
| /// The returned value can be used to detach, see [CgroupSock::detach]. | ||||||
| /// | ||||||
| /// # Warning | ||||||
| /// | ||||||
| /// On kernels 5.7.0 and later, attach modes other than `CgroupAttachMode::default()` are not passed to `bpf_link_create`. | ||||||
| /// On older kernels (using `bpf_prog_attach`), the attach mode is honored. | ||||||
| pub fn attach<T: AsFd>( | ||||||
| &mut self, | ||||||
| cgroup: T, | ||||||
|
|
@@ -80,17 +86,17 @@ impl CgroupSock { | |||||
| let cgroup_fd = cgroup.as_fd(); | ||||||
| let attach_type = self.data.expected_attach_type.unwrap(); | ||||||
| if KernelVersion::at_least(5, 7, 0) { | ||||||
| let link_fd = bpf_link_create( | ||||||
| prog_fd, | ||||||
| LinkTarget::Fd(cgroup_fd), | ||||||
| attach_type, | ||||||
| mode.into(), | ||||||
| None, | ||||||
| ) | ||||||
| .map_err(|io_error| SyscallError { | ||||||
| call: "bpf_link_create", | ||||||
| io_error, | ||||||
| })?; | ||||||
| if mode != CgroupAttachMode::default() { | ||||||
| warn!( | ||||||
| "CgroupAttachMode {:?} will not be passed on to bpf_link_create", | ||||||
|
||||||
| "CgroupAttachMode {:?} will not be passed on to bpf_link_create", | |
| "CgroupAttachMode {:?} will not be passed to bpf_link_create", |
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -4,6 +4,7 @@ use std::{hash::Hash, os::fd::AsFd, path::Path}; | |||||
|
|
||||||
| use aya_obj::generated::bpf_prog_type::BPF_PROG_TYPE_CGROUP_SOCK_ADDR; | ||||||
| pub use aya_obj::programs::CgroupSockAddrAttachType; | ||||||
| use log::warn; | ||||||
|
|
||||||
| use crate::{ | ||||||
| VerifierLogLevel, | ||||||
|
|
@@ -71,6 +72,11 @@ impl CgroupSockAddr { | |||||
| /// Attaches the program to the given cgroup. | ||||||
| /// | ||||||
| /// The returned value can be used to detach, see [CgroupSockAddr::detach]. | ||||||
| /// | ||||||
| /// # Warning | ||||||
| /// | ||||||
| /// On kernels 5.7.0 and later, attach modes other than `CgroupAttachMode::default()` are not passed to `bpf_link_create`. | ||||||
| /// On older kernels (using `bpf_prog_attach`), the attach mode is honored. | ||||||
| pub fn attach<T: AsFd>( | ||||||
| &mut self, | ||||||
| cgroup: T, | ||||||
|
|
@@ -81,17 +87,17 @@ impl CgroupSockAddr { | |||||
| let cgroup_fd = cgroup.as_fd(); | ||||||
| let attach_type = self.data.expected_attach_type.unwrap(); | ||||||
| if KernelVersion::at_least(5, 7, 0) { | ||||||
| let link_fd = bpf_link_create( | ||||||
| prog_fd, | ||||||
| LinkTarget::Fd(cgroup_fd), | ||||||
| attach_type, | ||||||
| mode.into(), | ||||||
| None, | ||||||
| ) | ||||||
| .map_err(|io_error| SyscallError { | ||||||
| call: "bpf_link_create", | ||||||
| io_error, | ||||||
| })?; | ||||||
| if mode != CgroupAttachMode::default() { | ||||||
| warn!( | ||||||
| "CgroupAttachMode {:?} will not be passed on to bpf_link_create", | ||||||
|
||||||
| "CgroupAttachMode {:?} will not be passed on to bpf_link_create", | |
| "CgroupAttachMode {:?} will not be passed to bpf_link_create", |
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -4,6 +4,7 @@ use std::{hash::Hash, os::fd::AsFd, path::Path}; | |||||
|
|
||||||
| use aya_obj::generated::bpf_prog_type::BPF_PROG_TYPE_CGROUP_SOCKOPT; | ||||||
| pub use aya_obj::programs::CgroupSockoptAttachType; | ||||||
| use log::warn; | ||||||
|
|
||||||
| use crate::{ | ||||||
| VerifierLogLevel, | ||||||
|
|
@@ -68,6 +69,11 @@ impl CgroupSockopt { | |||||
| /// Attaches the program to the given cgroup. | ||||||
| /// | ||||||
| /// The returned value can be used to detach, see [CgroupSockopt::detach]. | ||||||
| /// | ||||||
| /// # Warning | ||||||
| /// | ||||||
| /// On kernels 5.7.0 and later, attach modes other than `CgroupAttachMode::default()` are not passed to `bpf_link_create`. | ||||||
| /// On older kernels (using `bpf_prog_attach`), the attach mode is honored. | ||||||
| pub fn attach<T: AsFd>( | ||||||
| &mut self, | ||||||
| cgroup: T, | ||||||
|
|
@@ -78,17 +84,17 @@ impl CgroupSockopt { | |||||
| let cgroup_fd = cgroup.as_fd(); | ||||||
| let attach_type = self.data.expected_attach_type.unwrap(); | ||||||
| if KernelVersion::at_least(5, 7, 0) { | ||||||
| let link_fd = bpf_link_create( | ||||||
| prog_fd, | ||||||
| LinkTarget::Fd(cgroup_fd), | ||||||
| attach_type, | ||||||
| mode.into(), | ||||||
| None, | ||||||
| ) | ||||||
| .map_err(|io_error| SyscallError { | ||||||
| call: "bpf_link_create", | ||||||
| io_error, | ||||||
| })?; | ||||||
| if mode != CgroupAttachMode::default() { | ||||||
| warn!( | ||||||
| "CgroupAttachMode {:?} will not be passed on to bpf_link_create", | ||||||
|
||||||
| "CgroupAttachMode {:?} will not be passed on to bpf_link_create", | |
| "CgroupAttachMode {:?} will not be passed to bpf_link_create", |
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -5,6 +5,7 @@ use std::{hash::Hash, os::fd::AsFd}; | |||||
| use aya_obj::generated::{ | ||||||
| bpf_attach_type::BPF_CGROUP_SYSCTL, bpf_prog_type::BPF_PROG_TYPE_CGROUP_SYSCTL, | ||||||
| }; | ||||||
| use log::warn; | ||||||
|
|
||||||
| use crate::{ | ||||||
| programs::{ | ||||||
|
|
@@ -66,6 +67,11 @@ impl CgroupSysctl { | |||||
| /// Attaches the program to the given cgroup. | ||||||
| /// | ||||||
| /// The returned value can be used to detach, see [CgroupSysctl::detach]. | ||||||
| /// | ||||||
| /// # Warning | ||||||
| /// | ||||||
| /// On kernels 5.7.0 and later, attach modes other than `CgroupAttachMode::default()` are not passed to `bpf_link_create`. | ||||||
| /// On older kernels (using `bpf_prog_attach`), the attach mode is honored. | ||||||
| pub fn attach<T: AsFd>( | ||||||
| &mut self, | ||||||
| cgroup: T, | ||||||
|
|
@@ -76,11 +82,17 @@ impl CgroupSysctl { | |||||
| let cgroup_fd = cgroup.as_fd(); | ||||||
|
|
||||||
| if KernelVersion::at_least(5, 7, 0) { | ||||||
| if mode != CgroupAttachMode::default() { | ||||||
| warn!( | ||||||
| "CgroupAttachMode {:?} will not be passed on to bpf_link_create", | ||||||
|
||||||
| "CgroupAttachMode {:?} will not be passed on to bpf_link_create", | |
| "CgroupAttachMode {:?} will not be passed to bpf_link_create", |
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -4,6 +4,7 @@ use std::os::fd::AsFd; | |||||
| use aya_obj::generated::{ | ||||||
| bpf_attach_type::BPF_CGROUP_SOCK_OPS, bpf_prog_type::BPF_PROG_TYPE_SOCK_OPS, | ||||||
| }; | ||||||
| use log::warn; | ||||||
|
|
||||||
| use crate::{ | ||||||
| programs::{ | ||||||
|
|
@@ -65,6 +66,11 @@ impl SockOps { | |||||
| /// Attaches the program to the given cgroup. | ||||||
| /// | ||||||
| /// The returned value can be used to detach, see [SockOps::detach]. | ||||||
| /// | ||||||
| /// # Warning | ||||||
| /// | ||||||
| /// On kernels 5.7.0 and later, attach modes other than `CgroupAttachMode::default()` are not passed to `bpf_link_create`. | ||||||
| /// On older kernels (using `bpf_prog_attach`), the attach mode is honored. | ||||||
| pub fn attach<T: AsFd>( | ||||||
| &mut self, | ||||||
| cgroup: T, | ||||||
|
|
@@ -75,17 +81,17 @@ impl SockOps { | |||||
| let cgroup_fd = cgroup.as_fd(); | ||||||
| let attach_type = BPF_CGROUP_SOCK_OPS; | ||||||
| if KernelVersion::at_least(5, 7, 0) { | ||||||
| let link_fd = bpf_link_create( | ||||||
| prog_fd, | ||||||
| LinkTarget::Fd(cgroup_fd), | ||||||
| attach_type, | ||||||
| mode.into(), | ||||||
| None, | ||||||
| ) | ||||||
| .map_err(|io_error| SyscallError { | ||||||
| call: "bpf_link_create", | ||||||
| io_error, | ||||||
| })?; | ||||||
| if mode != CgroupAttachMode::default() { | ||||||
| warn!( | ||||||
| "CgroupAttachMode {:?} will not be passed on to bpf_link_create", | ||||||
|
||||||
| "CgroupAttachMode {:?} will not be passed on to bpf_link_create", | |
| "CgroupAttachMode {:?} will not be passed to bpf_link_create", |
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.