chore(aya-ebpf): Rename BpfContext -> EbpfContext

Signed-off-by: Dave Tucker <dave@dtucker.co.uk>
pull/528/head
Dave Tucker 8 months ago
parent a93e354620
commit d7af6acb42

@ -36,7 +36,7 @@ use helpers::{bpf_get_current_comm, bpf_get_current_pid_tgid, bpf_get_current_ui
pub const TASK_COMM_LEN: usize = 16; pub const TASK_COMM_LEN: usize = 16;
pub trait BpfContext { pub trait EbpfContext {
fn as_ptr(&self) -> *mut c_void; fn as_ptr(&self) -> *mut c_void;
#[inline] #[inline]

@ -4,7 +4,7 @@ use crate::{
bindings::{bpf_map_def, bpf_map_type::BPF_MAP_TYPE_PERF_EVENT_ARRAY, BPF_F_CURRENT_CPU}, bindings::{bpf_map_def, bpf_map_type::BPF_MAP_TYPE_PERF_EVENT_ARRAY, BPF_F_CURRENT_CPU},
helpers::bpf_perf_event_output, helpers::bpf_perf_event_output,
maps::PinningType, maps::PinningType,
BpfContext, EbpfContext,
}; };
#[repr(transparent)] #[repr(transparent)]
@ -50,11 +50,11 @@ impl<T> PerfEventArray<T> {
} }
} }
pub fn output<C: BpfContext>(&self, ctx: &C, data: &T, flags: u32) { pub fn output<C: EbpfContext>(&self, ctx: &C, data: &T, flags: u32) {
self.output_at_index(ctx, BPF_F_CURRENT_CPU as u32, data, flags) self.output_at_index(ctx, BPF_F_CURRENT_CPU as u32, data, flags)
} }
pub fn output_at_index<C: BpfContext>(&self, ctx: &C, index: u32, data: &T, flags: u32) { pub fn output_at_index<C: EbpfContext>(&self, ctx: &C, index: u32, data: &T, flags: u32) {
let flags = u64::from(flags) << 32 | u64::from(index); let flags = u64::from(flags) << 32 | u64::from(index);
unsafe { unsafe {
bpf_perf_event_output( bpf_perf_event_output(

@ -4,7 +4,7 @@ use crate::{
bindings::{bpf_map_def, bpf_map_type::BPF_MAP_TYPE_PERF_EVENT_ARRAY, BPF_F_CURRENT_CPU}, bindings::{bpf_map_def, bpf_map_type::BPF_MAP_TYPE_PERF_EVENT_ARRAY, BPF_F_CURRENT_CPU},
helpers::bpf_perf_event_output, helpers::bpf_perf_event_output,
maps::PinningType, maps::PinningType,
BpfContext, EbpfContext,
}; };
#[repr(transparent)] #[repr(transparent)]
@ -47,11 +47,11 @@ impl PerfEventByteArray {
} }
} }
pub fn output<C: BpfContext>(&self, ctx: &C, data: &[u8], flags: u32) { pub fn output<C: EbpfContext>(&self, ctx: &C, data: &[u8], flags: u32) {
self.output_at_index(ctx, BPF_F_CURRENT_CPU as u32, data, flags) self.output_at_index(ctx, BPF_F_CURRENT_CPU as u32, data, flags)
} }
pub fn output_at_index<C: BpfContext>(&self, ctx: &C, index: u32, data: &[u8], flags: u32) { pub fn output_at_index<C: EbpfContext>(&self, ctx: &C, index: u32, data: &[u8], flags: u32) {
let flags = u64::from(flags) << 32 | u64::from(index); let flags = u64::from(flags) << 32 | u64::from(index);
unsafe { unsafe {
bpf_perf_event_output( bpf_perf_event_output(

@ -6,7 +6,7 @@ use crate::{
bindings::{bpf_map_def, bpf_map_type::BPF_MAP_TYPE_PROG_ARRAY}, bindings::{bpf_map_def, bpf_map_type::BPF_MAP_TYPE_PROG_ARRAY},
helpers::bpf_tail_call, helpers::bpf_tail_call,
maps::PinningType, maps::PinningType,
BpfContext, EbpfContext,
}; };
/// A BPF map that stores an array of program indices for tail calling. /// A BPF map that stores an array of program indices for tail calling.
@ -81,7 +81,7 @@ impl ProgramArray {
/// On success, this function **does not return** into the original program. /// On success, this function **does not return** into the original program.
/// On failure, a negative error is returned, wrapped in `Err()`. /// On failure, a negative error is returned, wrapped in `Err()`.
#[cfg(not(unstable))] #[cfg(not(unstable))]
pub unsafe fn tail_call<C: BpfContext>(&self, ctx: &C, index: u32) -> Result<(), c_long> { pub unsafe fn tail_call<C: EbpfContext>(&self, ctx: &C, index: u32) -> Result<(), c_long> {
let res = bpf_tail_call(ctx.as_ptr(), self.def.get() as *mut _, index); let res = bpf_tail_call(ctx.as_ptr(), self.def.get() as *mut _, index);
if res != 0 { if res != 0 {
Err(res) Err(res)
@ -104,7 +104,7 @@ impl ProgramArray {
/// On success, this function **does not return** into the original program. /// On success, this function **does not return** into the original program.
/// On failure, a negative error is returned, wrapped in `Err()`. /// On failure, a negative error is returned, wrapped in `Err()`.
#[cfg(unstable)] #[cfg(unstable)]
pub unsafe fn tail_call<C: BpfContext>(&self, ctx: &C, index: u32) -> Result<!, c_long> { pub unsafe fn tail_call<C: EbpfContext>(&self, ctx: &C, index: u32) -> Result<!, c_long> {
let res = bpf_tail_call(ctx.as_ptr(), self.def.get() as *mut _, index); let res = bpf_tail_call(ctx.as_ptr(), self.def.get() as *mut _, index);
if res != 0 { if res != 0 {
Err(res) Err(res)

@ -10,7 +10,7 @@ use crate::{
}, },
maps::PinningType, maps::PinningType,
programs::{SkBuffContext, SkLookupContext, SkMsgContext}, programs::{SkBuffContext, SkLookupContext, SkMsgContext},
BpfContext, EbpfContext,
}; };
#[repr(transparent)] #[repr(transparent)]

@ -10,7 +10,7 @@ use crate::{
}, },
maps::PinningType, maps::PinningType,
programs::{SkBuffContext, SkLookupContext, SkMsgContext}, programs::{SkBuffContext, SkLookupContext, SkMsgContext},
BpfContext, EbpfContext,
}; };
#[repr(transparent)] #[repr(transparent)]

@ -4,7 +4,7 @@ use crate::{
bindings::{bpf_map_def, bpf_map_type::BPF_MAP_TYPE_STACK_TRACE}, bindings::{bpf_map_def, bpf_map_type::BPF_MAP_TYPE_STACK_TRACE},
helpers::bpf_get_stackid, helpers::bpf_get_stackid,
maps::PinningType, maps::PinningType,
BpfContext, EbpfContext,
}; };
#[repr(transparent)] #[repr(transparent)]
@ -45,7 +45,7 @@ impl StackTrace {
} }
} }
pub unsafe fn get_stackid<C: BpfContext>(&self, ctx: &C, flags: u64) -> Result<i64, i64> { pub unsafe fn get_stackid<C: EbpfContext>(&self, ctx: &C, flags: u64) -> Result<i64, i64> {
let ret = bpf_get_stackid(ctx.as_ptr(), self.def.get() as *mut _, flags); let ret = bpf_get_stackid(ctx.as_ptr(), self.def.get() as *mut _, flags);
if ret < 0 { if ret < 0 {
Err(ret) Err(ret)

@ -1,6 +1,6 @@
use core::ffi::c_void; use core::ffi::c_void;
use crate::{bindings::bpf_cgroup_dev_ctx, BpfContext}; use crate::{bindings::bpf_cgroup_dev_ctx, EbpfContext};
pub struct DeviceContext { pub struct DeviceContext {
pub device: *mut bpf_cgroup_dev_ctx, pub device: *mut bpf_cgroup_dev_ctx,
@ -12,7 +12,7 @@ impl DeviceContext {
} }
} }
impl BpfContext for DeviceContext { impl EbpfContext for DeviceContext {
fn as_ptr(&self) -> *mut c_void { fn as_ptr(&self) -> *mut c_void {
self.device as *mut _ self.device as *mut _
} }

@ -1,6 +1,6 @@
use core::ffi::c_void; use core::ffi::c_void;
use crate::{args::FromBtfArgument, BpfContext}; use crate::{args::FromBtfArgument, EbpfContext};
pub struct FEntryContext { pub struct FEntryContext {
ctx: *mut c_void, ctx: *mut c_void,
@ -36,7 +36,7 @@ impl FEntryContext {
} }
} }
impl BpfContext for FEntryContext { impl EbpfContext for FEntryContext {
fn as_ptr(&self) -> *mut c_void { fn as_ptr(&self) -> *mut c_void {
self.ctx self.ctx
} }

@ -1,6 +1,6 @@
use core::ffi::c_void; use core::ffi::c_void;
use crate::{args::FromBtfArgument, BpfContext}; use crate::{args::FromBtfArgument, EbpfContext};
pub struct FExitContext { pub struct FExitContext {
ctx: *mut c_void, ctx: *mut c_void,
@ -36,7 +36,7 @@ impl FExitContext {
} }
} }
impl BpfContext for FExitContext { impl EbpfContext for FExitContext {
fn as_ptr(&self) -> *mut c_void { fn as_ptr(&self) -> *mut c_void {
self.ctx self.ctx
} }

@ -1,6 +1,6 @@
use core::ffi::c_void; use core::ffi::c_void;
use crate::{args::FromBtfArgument, BpfContext}; use crate::{args::FromBtfArgument, EbpfContext};
pub struct LsmContext { pub struct LsmContext {
ctx: *mut c_void, ctx: *mut c_void,
@ -55,7 +55,7 @@ impl LsmContext {
} }
} }
impl BpfContext for LsmContext { impl EbpfContext for LsmContext {
fn as_ptr(&self) -> *mut c_void { fn as_ptr(&self) -> *mut c_void {
self.ctx self.ctx
} }

@ -1,6 +1,6 @@
use core::ffi::c_void; use core::ffi::c_void;
use crate::BpfContext; use crate::EbpfContext;
pub struct PerfEventContext { pub struct PerfEventContext {
ctx: *mut c_void, ctx: *mut c_void,
@ -12,7 +12,7 @@ impl PerfEventContext {
} }
} }
impl BpfContext for PerfEventContext { impl EbpfContext for PerfEventContext {
fn as_ptr(&self) -> *mut c_void { fn as_ptr(&self) -> *mut c_void {
self.ctx self.ctx
} }

@ -6,7 +6,7 @@ use crate::bindings::pt_regs;
use crate::bindings::user_pt_regs as pt_regs; use crate::bindings::user_pt_regs as pt_regs;
#[cfg(bpf_target_arch = "riscv64")] #[cfg(bpf_target_arch = "riscv64")]
use crate::bindings::user_regs_struct as pt_regs; use crate::bindings::user_regs_struct as pt_regs;
use crate::{args::FromPtRegs, BpfContext}; use crate::{args::FromPtRegs, EbpfContext};
pub struct ProbeContext { pub struct ProbeContext {
pub regs: *mut pt_regs, pub regs: *mut pt_regs,
@ -64,7 +64,7 @@ impl ProbeContext {
} }
} }
impl BpfContext for ProbeContext { impl EbpfContext for ProbeContext {
fn as_ptr(&self) -> *mut c_void { fn as_ptr(&self) -> *mut c_void {
self.regs as *mut c_void self.regs as *mut c_void
} }

@ -1,6 +1,6 @@
use core::ffi::c_void; use core::ffi::c_void;
use crate::BpfContext; use crate::EbpfContext;
pub struct RawTracePointContext { pub struct RawTracePointContext {
ctx: *mut c_void, ctx: *mut c_void,
@ -12,7 +12,7 @@ impl RawTracePointContext {
} }
} }
impl BpfContext for RawTracePointContext { impl EbpfContext for RawTracePointContext {
fn as_ptr(&self) -> *mut c_void { fn as_ptr(&self) -> *mut c_void {
self.ctx self.ctx
} }

@ -10,7 +10,7 @@ use aya_ebpf_bindings::helpers::{
}; };
use aya_ebpf_cty::c_long; use aya_ebpf_cty::c_long;
use crate::{bindings::__sk_buff, BpfContext}; use crate::{bindings::__sk_buff, EbpfContext};
pub struct SkBuff { pub struct SkBuff {
pub skb: *mut __sk_buff, pub skb: *mut __sk_buff,
@ -430,7 +430,7 @@ impl SkBuffContext {
} }
} }
impl BpfContext for SkBuffContext { impl EbpfContext for SkBuffContext {
fn as_ptr(&self) -> *mut c_void { fn as_ptr(&self) -> *mut c_void {
self.skb.as_ptr() self.skb.as_ptr()
} }

@ -1,6 +1,6 @@
use core::ffi::c_void; use core::ffi::c_void;
use crate::{bindings::bpf_sk_lookup, BpfContext}; use crate::{bindings::bpf_sk_lookup, EbpfContext};
pub struct SkLookupContext { pub struct SkLookupContext {
pub lookup: *mut bpf_sk_lookup, pub lookup: *mut bpf_sk_lookup,
@ -12,7 +12,7 @@ impl SkLookupContext {
} }
} }
impl BpfContext for SkLookupContext { impl EbpfContext for SkLookupContext {
fn as_ptr(&self) -> *mut c_void { fn as_ptr(&self) -> *mut c_void {
self.lookup as *mut _ self.lookup as *mut _
} }

@ -3,7 +3,7 @@ use core::ffi::c_void;
use crate::{ use crate::{
bindings::sk_msg_md, bindings::sk_msg_md,
helpers::{bpf_msg_pop_data, bpf_msg_push_data}, helpers::{bpf_msg_pop_data, bpf_msg_push_data},
BpfContext, EbpfContext,
}; };
pub struct SkMsgContext { pub struct SkMsgContext {
@ -46,7 +46,7 @@ impl SkMsgContext {
} }
} }
impl BpfContext for SkMsgContext { impl EbpfContext for SkMsgContext {
fn as_ptr(&self) -> *mut c_void { fn as_ptr(&self) -> *mut c_void {
self.msg as *mut _ self.msg as *mut _
} }

@ -1,6 +1,6 @@
use core::ffi::c_void; use core::ffi::c_void;
use crate::{bindings::bpf_sock, BpfContext}; use crate::{bindings::bpf_sock, EbpfContext};
pub struct SockContext { pub struct SockContext {
pub sock: *mut bpf_sock, pub sock: *mut bpf_sock,
@ -12,7 +12,7 @@ impl SockContext {
} }
} }
impl BpfContext for SockContext { impl EbpfContext for SockContext {
fn as_ptr(&self) -> *mut c_void { fn as_ptr(&self) -> *mut c_void {
self.sock as *mut _ self.sock as *mut _
} }

@ -1,6 +1,6 @@
use core::ffi::c_void; use core::ffi::c_void;
use crate::{bindings::bpf_sock_addr, BpfContext}; use crate::{bindings::bpf_sock_addr, EbpfContext};
pub struct SockAddrContext { pub struct SockAddrContext {
pub sock_addr: *mut bpf_sock_addr, pub sock_addr: *mut bpf_sock_addr,
@ -12,7 +12,7 @@ impl SockAddrContext {
} }
} }
impl BpfContext for SockAddrContext { impl EbpfContext for SockAddrContext {
fn as_ptr(&self) -> *mut c_void { fn as_ptr(&self) -> *mut c_void {
self.sock_addr as *mut _ self.sock_addr as *mut _
} }

@ -2,7 +2,7 @@ use core::ffi::c_void;
use aya_ebpf_bindings::helpers::bpf_sock_ops_cb_flags_set; use aya_ebpf_bindings::helpers::bpf_sock_ops_cb_flags_set;
use crate::{bindings::bpf_sock_ops, BpfContext}; use crate::{bindings::bpf_sock_ops, EbpfContext};
pub struct SockOpsContext { pub struct SockOpsContext {
pub ops: *mut bpf_sock_ops, pub ops: *mut bpf_sock_ops,
@ -63,7 +63,7 @@ impl SockOpsContext {
} }
} }
impl BpfContext for SockOpsContext { impl EbpfContext for SockOpsContext {
fn as_ptr(&self) -> *mut c_void { fn as_ptr(&self) -> *mut c_void {
self.ops as *mut _ self.ops as *mut _
} }

@ -1,6 +1,6 @@
use core::ffi::c_void; use core::ffi::c_void;
use crate::{bindings::bpf_sockopt, BpfContext}; use crate::{bindings::bpf_sockopt, EbpfContext};
pub struct SockoptContext { pub struct SockoptContext {
pub sockopt: *mut bpf_sockopt, pub sockopt: *mut bpf_sockopt,
@ -12,7 +12,7 @@ impl SockoptContext {
} }
} }
impl BpfContext for SockoptContext { impl EbpfContext for SockoptContext {
fn as_ptr(&self) -> *mut c_void { fn as_ptr(&self) -> *mut c_void {
self.sockopt as *mut _ self.sockopt as *mut _
} }

@ -1,6 +1,6 @@
use core::ffi::c_void; use core::ffi::c_void;
use crate::{bindings::bpf_sysctl, BpfContext}; use crate::{bindings::bpf_sysctl, EbpfContext};
pub struct SysctlContext { pub struct SysctlContext {
pub sysctl: *mut bpf_sysctl, pub sysctl: *mut bpf_sysctl,
@ -12,7 +12,7 @@ impl SysctlContext {
} }
} }
impl BpfContext for SysctlContext { impl EbpfContext for SysctlContext {
fn as_ptr(&self) -> *mut c_void { fn as_ptr(&self) -> *mut c_void {
self.sysctl as *mut _ self.sysctl as *mut _
} }

@ -1,6 +1,6 @@
use aya_ebpf_cty::{c_long, c_void}; use aya_ebpf_cty::{c_long, c_void};
use crate::{bindings::__sk_buff, programs::sk_buff::SkBuff, BpfContext}; use crate::{bindings::__sk_buff, programs::sk_buff::SkBuff, EbpfContext};
pub struct TcContext { pub struct TcContext {
pub skb: SkBuff, pub skb: SkBuff,
@ -187,7 +187,7 @@ impl TcContext {
} }
} }
impl BpfContext for TcContext { impl EbpfContext for TcContext {
fn as_ptr(&self) -> *mut c_void { fn as_ptr(&self) -> *mut c_void {
self.skb.as_ptr() self.skb.as_ptr()
} }

@ -1,6 +1,6 @@
use core::ffi::c_void; use core::ffi::c_void;
use crate::{args::FromBtfArgument, BpfContext}; use crate::{args::FromBtfArgument, EbpfContext};
pub struct BtfTracePointContext { pub struct BtfTracePointContext {
ctx: *mut c_void, ctx: *mut c_void,
@ -45,7 +45,7 @@ impl BtfTracePointContext {
} }
} }
impl BpfContext for BtfTracePointContext { impl EbpfContext for BtfTracePointContext {
fn as_ptr(&self) -> *mut c_void { fn as_ptr(&self) -> *mut c_void {
self.ctx self.ctx
} }

@ -1,6 +1,6 @@
use core::ffi::c_void; use core::ffi::c_void;
use crate::{helpers::bpf_probe_read, BpfContext}; use crate::{helpers::bpf_probe_read, EbpfContext};
pub struct TracePointContext { pub struct TracePointContext {
ctx: *mut c_void, ctx: *mut c_void,
@ -16,7 +16,7 @@ impl TracePointContext {
} }
} }
impl BpfContext for TracePointContext { impl EbpfContext for TracePointContext {
fn as_ptr(&self) -> *mut c_void { fn as_ptr(&self) -> *mut c_void {
self.ctx self.ctx
} }

@ -1,6 +1,6 @@
use core::ffi::c_void; use core::ffi::c_void;
use crate::{bindings::xdp_md, BpfContext}; use crate::{bindings::xdp_md, EbpfContext};
pub struct XdpContext { pub struct XdpContext {
pub ctx: *mut xdp_md, pub ctx: *mut xdp_md,
@ -34,7 +34,7 @@ impl XdpContext {
} }
} }
impl BpfContext for XdpContext { impl EbpfContext for XdpContext {
fn as_ptr(&self) -> *mut c_void { fn as_ptr(&self) -> *mut c_void {
self.ctx as *mut _ self.ctx as *mut _
} }

Loading…
Cancel
Save