Merge pull request #187 from vadorovsky/sk-buff-socket-uid

bpf: sk_buff: Add get_socket_uid method to SkBuffContext
pull/239/head
Alessandro Decina 3 years ago committed by GitHub
commit 5390fb1ee1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -4,8 +4,8 @@ use core::{
}; };
use aya_bpf_bindings::helpers::{ use aya_bpf_bindings::helpers::{
bpf_clone_redirect, bpf_l3_csum_replace, bpf_l4_csum_replace, bpf_skb_adjust_room, bpf_clone_redirect, bpf_get_socket_uid, bpf_l3_csum_replace, bpf_l4_csum_replace,
bpf_skb_change_type, bpf_skb_load_bytes, bpf_skb_store_bytes, bpf_skb_adjust_room, bpf_skb_change_type, bpf_skb_load_bytes, bpf_skb_store_bytes,
}; };
use aya_bpf_cty::c_long; use aya_bpf_cty::c_long;
@ -41,6 +41,12 @@ impl SkBuffContext {
unsafe { &mut (*self.skb).cb } 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] #[inline]
pub fn load<T>(&self, offset: usize) -> Result<T, c_long> { pub fn load<T>(&self, offset: usize) -> Result<T, c_long> {
unsafe { unsafe {

Loading…
Cancel
Save