Merge pull request #119 from eero-thia/thia/xdp_metadata

aya-bpf: expose xdp_md of XdpContext and add metadata functions.
pull/125/head
Alessandro Decina 3 years ago committed by GitHub
commit 61299e128e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -3,7 +3,7 @@ use core::ffi::c_void;
use crate::{bindings::xdp_md, BpfContext}; use crate::{bindings::xdp_md, BpfContext};
pub struct XdpContext { pub struct XdpContext {
ctx: *mut xdp_md, pub ctx: *mut xdp_md,
} }
impl XdpContext { impl XdpContext {
@ -18,6 +18,18 @@ impl XdpContext {
pub fn data_end(&self) -> usize { pub fn data_end(&self) -> usize {
unsafe { (*self.ctx).data_end as usize } unsafe { (*self.ctx).data_end as usize }
} }
/// Return the raw address of the XdpContext metadata.
#[inline(always)]
pub fn metadata(&self) -> usize {
unsafe { (*self.ctx).data_meta as usize }
}
/// Return the raw address immediately after the XdpContext's metadata.
#[inline(always)]
pub fn metadata_end(&self) -> usize {
self.data()
}
} }
impl BpfContext for XdpContext { impl BpfContext for XdpContext {

Loading…
Cancel
Save