diff --git a/bpf/aya-bpf-macros/src/expand.rs b/bpf/aya-bpf-macros/src/expand.rs index 6861bff7..d079323f 100644 --- a/bpf/aya-bpf-macros/src/expand.rs +++ b/bpf/aya-bpf-macros/src/expand.rs @@ -205,7 +205,7 @@ impl SchedClassifier { #[no_mangle] #[link_section = #section_name] fn #fn_name(ctx: *mut ::aya_bpf::bindings::__sk_buff) -> i32 { - return #fn_name(::aya_bpf::programs::SkSkbContext::new(ctx)); + return #fn_name(::aya_bpf::programs::SkBuffContext::new(ctx)); #item } @@ -244,7 +244,7 @@ impl CgroupSkb { #[no_mangle] #[link_section = #section_name] fn #fn_name(ctx: *mut ::aya_bpf::bindings::__sk_buff) -> i32 { - return #fn_name(::aya_bpf::programs::SkSkbContext::new(ctx)); + return #fn_name(::aya_bpf::programs::SkBuffContext::new(ctx)); #item } @@ -484,7 +484,7 @@ impl SkSkb { #[no_mangle] #[link_section = #section_name] fn #fn_name(ctx: *mut ::aya_bpf::bindings::__sk_buff) -> u32 { - return #fn_name(::aya_bpf::programs::SkSkbContext::new(ctx)); + return #fn_name(::aya_bpf::programs::SkBuffContext::new(ctx)); #item } @@ -516,7 +516,7 @@ impl SocketFilter { #[no_mangle] #[link_section = #section_name] fn #fn_name(ctx: *mut ::aya_bpf::bindings::__sk_buff) -> i64 { - return #fn_name(::aya_bpf::programs::SkSkbContext::new(ctx)); + return #fn_name(::aya_bpf::programs::SkBuffContext::new(ctx)); #item } diff --git a/bpf/aya-bpf-macros/src/lib.rs b/bpf/aya-bpf-macros/src/lib.rs index bfa0b855..08d2748a 100644 --- a/bpf/aya-bpf-macros/src/lib.rs +++ b/bpf/aya-bpf-macros/src/lib.rs @@ -257,18 +257,18 @@ pub fn btf_tracepoint(attrs: TokenStream, item: TokenStream) -> TokenStream { /// # Examples /// /// ```no_run -/// use aya_bpf::{macros::stream_parser, programs::SkSkbContext}; +/// use aya_bpf::{macros::stream_parser, programs::SkBuffContext}; /// /// ///#[stream_parser] -///fn stream_parser(ctx: SkSkbContext) -> u32 { +///fn stream_parser(ctx: SkBuffContext) -> u32 { /// match { try_stream_parser(ctx) } { /// Ok(ret) => ret, /// Err(ret) => ret, /// } ///} /// -///fn try_stream_parser(ctx: SkSkbContext) -> Result { +///fn try_stream_parser(ctx: SkBuffContext) -> Result { /// Ok(ctx.len()) ///} /// ``` @@ -287,18 +287,18 @@ pub fn stream_parser(attrs: TokenStream, item: TokenStream) -> TokenStream { /// # Examples /// /// ```no_run -/// use aya_bpf::{macros::stream_verdict, programs::SkSkbContext, bindings::sk_action}; +/// use aya_bpf::{macros::stream_verdict, programs::SkBuffContext, bindings::sk_action}; /// /// ///#[stream_verdict] -///fn stream_verdict(ctx: SkSkbContext) -> u32 { +///fn stream_verdict(ctx: SkBuffContext) -> u32 { /// match { try_stream_verdict(ctx) } { /// Ok(ret) => ret, /// Err(ret) => ret, /// } ///} /// -///fn try_stream_verdict(_ctx: SkSkbContext) -> Result { +///fn try_stream_verdict(_ctx: SkBuffContext) -> Result { /// Ok(sk_action::SK_PASS) ///} /// ``` @@ -327,10 +327,10 @@ fn sk_skb(kind: SkSkbKind, attrs: TokenStream, item: TokenStream) -> TokenStream /// # Examples /// /// ```no_run -/// use aya_bpf::{macros::socket_filter, programs::SkSkbContext}; +/// use aya_bpf::{macros::socket_filter, programs::SkBuffContext}; /// /// #[socket_filter(name = "accept_all")] -/// pub fn accept_all(_ctx: SkSkbContext) -> i64 { +/// pub fn accept_all(_ctx: SkBuffContext) -> i64 { /// return 0 /// } /// ``` diff --git a/bpf/aya-bpf/src/maps/sock_hash.rs b/bpf/aya-bpf/src/maps/sock_hash.rs index 0f88c4ba..f99a9dc4 100644 --- a/bpf/aya-bpf/src/maps/sock_hash.rs +++ b/bpf/aya-bpf/src/maps/sock_hash.rs @@ -6,7 +6,7 @@ use crate::{ bindings::{bpf_map_def, bpf_map_type::BPF_MAP_TYPE_SOCKHASH, bpf_sock_ops}, helpers::{bpf_msg_redirect_hash, bpf_sk_redirect_hash, bpf_sock_hash_update}, maps::PinningType, - programs::{SkMsgContext, SkSkbContext}, + programs::{SkBuffContext, SkMsgContext}, BpfContext, }; @@ -75,7 +75,7 @@ impl SockHash { ) } - pub unsafe fn redirect_skb(&mut self, ctx: &SkSkbContext, key: &mut K, flags: u64) -> i64 { + pub unsafe fn redirect_skb(&mut self, ctx: &SkBuffContext, key: &mut K, flags: u64) -> i64 { bpf_sk_redirect_hash( ctx.as_ptr() as *mut _, &mut self.def as *mut _ as *mut _, diff --git a/bpf/aya-bpf/src/maps/sock_map.rs b/bpf/aya-bpf/src/maps/sock_map.rs index 6f73c8eb..7d546419 100644 --- a/bpf/aya-bpf/src/maps/sock_map.rs +++ b/bpf/aya-bpf/src/maps/sock_map.rs @@ -6,7 +6,7 @@ use crate::{ bindings::{bpf_map_def, bpf_map_type::BPF_MAP_TYPE_SOCKMAP, bpf_sock_ops}, helpers::{bpf_msg_redirect_map, bpf_sk_redirect_map, bpf_sock_map_update}, maps::PinningType, - programs::{SkMsgContext, SkSkbContext}, + programs::{SkBuffContext, SkMsgContext}, BpfContext, }; @@ -72,7 +72,7 @@ impl SockMap { ) } - pub unsafe fn redirect_skb(&mut self, ctx: &SkSkbContext, index: u32, flags: u64) -> i64 { + pub unsafe fn redirect_skb(&mut self, ctx: &SkBuffContext, index: u32, flags: u64) -> i64 { bpf_sk_redirect_map( ctx.as_ptr() as *mut _, &mut self.def as *mut _ as *mut _, diff --git a/bpf/aya-bpf/src/programs/mod.rs b/bpf/aya-bpf/src/programs/mod.rs index 5695cd15..097d428d 100644 --- a/bpf/aya-bpf/src/programs/mod.rs +++ b/bpf/aya-bpf/src/programs/mod.rs @@ -2,8 +2,8 @@ pub mod lsm; pub mod perf_event; pub mod probe; pub mod raw_tracepoint; +pub mod sk_buff; pub mod sk_msg; -pub mod sk_skb; pub mod sock_ops; pub mod tp_btf; pub mod tracepoint; @@ -13,8 +13,8 @@ pub use lsm::LsmContext; pub use perf_event::PerfEventContext; pub use probe::ProbeContext; pub use raw_tracepoint::RawTracePointContext; +pub use sk_buff::SkBuffContext; pub use sk_msg::SkMsgContext; -pub use sk_skb::SkSkbContext; pub use sock_ops::SockOpsContext; pub use tp_btf::BtfTracePointContext; pub use tracepoint::TracePointContext; diff --git a/bpf/aya-bpf/src/programs/sk_skb.rs b/bpf/aya-bpf/src/programs/sk_buff.rs similarity index 95% rename from bpf/aya-bpf/src/programs/sk_skb.rs rename to bpf/aya-bpf/src/programs/sk_buff.rs index dd0a2856..fea109a6 100644 --- a/bpf/aya-bpf/src/programs/sk_skb.rs +++ b/bpf/aya-bpf/src/programs/sk_buff.rs @@ -11,13 +11,13 @@ use aya_bpf_cty::c_long; use crate::{bindings::__sk_buff, BpfContext}; -pub struct SkSkbContext { +pub struct SkBuffContext { skb: *mut __sk_buff, } -impl SkSkbContext { - pub fn new(skb: *mut __sk_buff) -> SkSkbContext { - SkSkbContext { skb } +impl SkBuffContext { + pub fn new(skb: *mut __sk_buff) -> SkBuffContext { + SkBuffContext { skb } } #[allow(clippy::len_without_is_empty)] @@ -144,7 +144,7 @@ impl SkSkbContext { } } -impl BpfContext for SkSkbContext { +impl BpfContext for SkBuffContext { fn as_ptr(&self) -> *mut c_void { self.skb as *mut _ }