You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: aya/src/programs/cgroup_sock.rs
+16-11Lines changed: 16 additions & 11 deletions
Original file line number
Diff line number
Diff line change
@@ -1,5 +1,6 @@
1
1
//! Cgroup socket programs.
2
2
3
+
use log::warn;
3
4
use std::{hash::Hash, os::fd::AsFd, path::Path};
4
5
5
6
use aya_obj::generated::bpf_prog_type::BPF_PROG_TYPE_CGROUP_SOCK;
@@ -70,6 +71,10 @@ impl CgroupSock {
70
71
/// Attaches the program to the given cgroup.
71
72
///
72
73
/// The returned value can be used to detach, see [CgroupSock::detach].
74
+
///
75
+
/// # Warning
76
+
///
77
+
/// On kernels 5.7.0 and later, attach modes other than CgroupAttachMode::default() are not passed to bpf_link_create. On older kernels that use bpf_prog_attach, the attach mode is still honored.
73
78
pubfnattach<T:AsFd>(
74
79
&mutself,
75
80
cgroup:T,
@@ -80,17 +85,17 @@ impl CgroupSock {
80
85
let cgroup_fd = cgroup.as_fd();
81
86
let attach_type = self.data.expected_attach_type.unwrap();
82
87
ifKernelVersion::at_least(5,7,0){
83
-
let link_fd = bpf_link_create(
84
-
prog_fd,
85
-
LinkTarget::Fd(cgroup_fd),
86
-
attach_type,
87
-
mode.into(),
88
-
None,
89
-
)
90
-
.map_err(|io_error| SyscallError{
91
-
call:"bpf_link_create",
92
-
io_error,
93
-
})?;
88
+
if mode != CgroupAttachMode::default(){
89
+
warn!(
90
+
"CgroupAttachMode {:?} will not be passed on to bpf_link_create",
91
+
mode
92
+
);
93
+
}
94
+
let link_fd = bpf_link_create(prog_fd,LinkTarget::Fd(cgroup_fd), attach_type,0,None)
0 commit comments