pull/949/merge
Abhijit Gadgil 2 months ago committed by GitHub
commit 1a1c9d10be
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

@ -1,6 +1,10 @@
use core::ffi::c_void;
use crate::{bindings::xdp_md, EbpfContext};
use crate::{
bindings::xdp_md,
helpers::{bpf_xdp_adjust_head, bpf_xdp_adjust_meta, bpf_xdp_adjust_tail},
EbpfContext,
};
pub struct XdpContext {
pub ctx: *mut xdp_md,
@ -38,6 +42,42 @@ impl XdpContext {
pub fn metadata_end(&self) -> usize {
self.data()
}
/// Adjusts the head of the Packet by given 'delta' (both positive and negative values are
/// possible.)
#[inline(always)]
pub fn adjust_head(&mut self, delta: crate::cty::c_int) -> Result<(), ()> {
unsafe {
match bpf_xdp_adjust_head(self.ctx, delta) {
0 => Ok(()),
_ => Err(()),
}
}
}
/// Adjusts the tail of the Packet by given 'delta' (both positive and negative values are
/// possible.)
#[inline(always)]
pub fn adjust_tail(&mut self, delta: crate::cty::c_int) -> Result<(), ()> {
unsafe {
match bpf_xdp_adjust_tail(self.ctx, delta) {
0 => Ok(()),
_ => Err(()),
}
}
}
/// Adjusts the tail of the Packet by given 'delta' (both positive and negative values are
/// possible.)
#[inline(always)]
pub fn adjust_metadata(&mut self, delta: crate::cty::c_int) -> Result<(), ()> {
unsafe {
match bpf_xdp_adjust_meta(self.ctx, delta) {
0 => Ok(()),
_ => Err(()),
}
}
}
}
impl EbpfContext for XdpContext {

@ -2018,6 +2018,9 @@ pub mod aya_ebpf::programs::xdp
pub struct aya_ebpf::programs::xdp::XdpContext
pub aya_ebpf::programs::xdp::XdpContext::ctx: *mut aya_ebpf_bindings::x86_64::bindings::xdp_md
impl aya_ebpf::programs::xdp::XdpContext
pub fn aya_ebpf::programs::xdp::XdpContext::adjust_head(&mut self, delta: aya_ebpf_cty::ad::c_int) -> core::result::Result<(), ()>
pub fn aya_ebpf::programs::xdp::XdpContext::adjust_metadata(&mut self, delta: aya_ebpf_cty::ad::c_int) -> core::result::Result<(), ()>
pub fn aya_ebpf::programs::xdp::XdpContext::adjust_tail(&mut self, delta: aya_ebpf_cty::ad::c_int) -> core::result::Result<(), ()>
pub fn aya_ebpf::programs::xdp::XdpContext::data(&self) -> usize
pub fn aya_ebpf::programs::xdp::XdpContext::data_end(&self) -> usize
pub fn aya_ebpf::programs::xdp::XdpContext::ingress_ifindex(&self) -> usize
@ -2632,6 +2635,9 @@ pub fn aya_ebpf::programs::tracepoint::TracePointContext::from(t: T) -> T
pub struct aya_ebpf::programs::XdpContext
pub aya_ebpf::programs::XdpContext::ctx: *mut aya_ebpf_bindings::x86_64::bindings::xdp_md
impl aya_ebpf::programs::xdp::XdpContext
pub fn aya_ebpf::programs::xdp::XdpContext::adjust_head(&mut self, delta: aya_ebpf_cty::ad::c_int) -> core::result::Result<(), ()>
pub fn aya_ebpf::programs::xdp::XdpContext::adjust_metadata(&mut self, delta: aya_ebpf_cty::ad::c_int) -> core::result::Result<(), ()>
pub fn aya_ebpf::programs::xdp::XdpContext::adjust_tail(&mut self, delta: aya_ebpf_cty::ad::c_int) -> core::result::Result<(), ()>
pub fn aya_ebpf::programs::xdp::XdpContext::data(&self) -> usize
pub fn aya_ebpf::programs::xdp::XdpContext::data_end(&self) -> usize
pub fn aya_ebpf::programs::xdp::XdpContext::ingress_ifindex(&self) -> usize

Loading…
Cancel
Save