bpf: sk_buff: Add get_socket_uid method to SkBuffContext

This change exposes the BPF helper bpf_socket_get_uid as a public method
of SkBuffContext, which allows to get the owner UID of the socket
associated to the sk_buff stored in the context.

Signed-off-by: Michal Rostecki <vadorovsky@gmail.com>
pull/187/head
Michal Rostecki 3 years ago
parent 2a18239346
commit 34d74fcd3b

@ -4,8 +4,8 @@ use core::{
};
use aya_bpf_bindings::helpers::{
bpf_clone_redirect, bpf_l3_csum_replace, bpf_l4_csum_replace, bpf_skb_adjust_room,
bpf_skb_change_type, bpf_skb_load_bytes, bpf_skb_store_bytes,
bpf_clone_redirect, bpf_get_socket_uid, bpf_l3_csum_replace, bpf_l4_csum_replace,
bpf_skb_adjust_room, bpf_skb_change_type, bpf_skb_load_bytes, bpf_skb_store_bytes,
};
use aya_bpf_cty::c_long;
@ -41,6 +41,12 @@ impl SkBuffContext {
unsafe { &mut (*self.skb).cb }
}
/// Returns the owner UID of the socket associated to the SKB context.
#[inline]
pub fn get_socket_uid(&self) -> u32 {
unsafe { bpf_get_socket_uid(self.skb) }
}
#[inline]
pub fn load<T>(&self, offset: usize) -> Result<T, c_long> {
unsafe {

Loading…
Cancel
Save