bpf: Add bindings for uid and gid

pull/329/merge
tiann 2 years ago committed by Alessandro Decina
parent 3e089a61d1
commit 49404367d8

@ -25,7 +25,7 @@ pub use aya_bpf_cty as cty;
use core::ffi::c_void;
use cty::{c_int, c_long};
use helpers::{bpf_get_current_comm, bpf_get_current_pid_tgid};
use helpers::{bpf_get_current_comm, bpf_get_current_pid_tgid, bpf_get_current_uid_gid};
pub use aya_bpf_macros as macros;
@ -46,6 +46,14 @@ pub trait BpfContext {
fn tgid(&self) -> u32 {
(bpf_get_current_pid_tgid() >> 32) as u32
}
fn uid(&self) -> u32 {
bpf_get_current_uid_gid() as u32
}
fn gid(&self) -> u32 {
(bpf_get_current_uid_gid() >> 32) as u32
}
}
#[no_mangle]

Loading…
Cancel
Save