|
|
|
@ -37,7 +37,6 @@ use lsm::Lsm;
|
|
|
|
|
use map::Map;
|
|
|
|
|
use perf_event::PerfEvent;
|
|
|
|
|
use proc_macro::TokenStream;
|
|
|
|
|
use proc_macro_error::{abort, proc_macro_error};
|
|
|
|
|
use raw_tracepoint::RawTracePoint;
|
|
|
|
|
use sk_lookup::SkLookup;
|
|
|
|
|
use sk_msg::SkMsg;
|
|
|
|
@ -48,83 +47,69 @@ use tc::SchedClassifier;
|
|
|
|
|
use tracepoint::TracePoint;
|
|
|
|
|
use uprobe::{UProbe, UProbeKind};
|
|
|
|
|
use xdp::Xdp;
|
|
|
|
|
#[proc_macro_error]
|
|
|
|
|
|
|
|
|
|
#[proc_macro_attribute]
|
|
|
|
|
pub fn map(attrs: TokenStream, item: TokenStream) -> TokenStream {
|
|
|
|
|
match Map::parse(attrs.into(), item.into()) {
|
|
|
|
|
Ok(prog) => prog
|
|
|
|
|
.expand()
|
|
|
|
|
.unwrap_or_else(|err| abort!(err.span(), "{}", err))
|
|
|
|
|
.into(),
|
|
|
|
|
Err(err) => abort!(err.span(), "{}", err),
|
|
|
|
|
Ok(prog) => prog.expand(),
|
|
|
|
|
Err(err) => err.into_compile_error(),
|
|
|
|
|
}
|
|
|
|
|
.into()
|
|
|
|
|
}
|
|
|
|
|
#[proc_macro_error]
|
|
|
|
|
#[proc_macro_attribute]
|
|
|
|
|
pub fn kprobe(attrs: TokenStream, item: TokenStream) -> TokenStream {
|
|
|
|
|
match KProbe::parse(KProbeKind::KProbe, attrs.into(), item.into()) {
|
|
|
|
|
Ok(prog) => prog
|
|
|
|
|
.expand()
|
|
|
|
|
.unwrap_or_else(|err| abort!(err.span(), "{}", err))
|
|
|
|
|
.into(),
|
|
|
|
|
Err(err) => abort!(err.span(), "{}", err),
|
|
|
|
|
Ok(prog) => prog.expand(),
|
|
|
|
|
Err(err) => err.emit_as_expr_tokens(),
|
|
|
|
|
}
|
|
|
|
|
.into()
|
|
|
|
|
}
|
|
|
|
|
#[proc_macro_error]
|
|
|
|
|
#[proc_macro_attribute]
|
|
|
|
|
pub fn kretprobe(attrs: TokenStream, item: TokenStream) -> TokenStream {
|
|
|
|
|
match KProbe::parse(KProbeKind::KRetProbe, attrs.into(), item.into()) {
|
|
|
|
|
Ok(prog) => prog
|
|
|
|
|
.expand()
|
|
|
|
|
.unwrap_or_else(|err| abort!(err.span(), "{}", err))
|
|
|
|
|
.into(),
|
|
|
|
|
Err(err) => abort!(err.span(), "{}", err),
|
|
|
|
|
Ok(prog) => prog.expand(),
|
|
|
|
|
Err(err) => err.emit_as_expr_tokens(),
|
|
|
|
|
}
|
|
|
|
|
.into()
|
|
|
|
|
}
|
|
|
|
|
#[proc_macro_error]
|
|
|
|
|
#[proc_macro_attribute]
|
|
|
|
|
pub fn uprobe(attrs: TokenStream, item: TokenStream) -> TokenStream {
|
|
|
|
|
match UProbe::parse(UProbeKind::UProbe, attrs.into(), item.into()) {
|
|
|
|
|
Ok(prog) => prog
|
|
|
|
|
.expand()
|
|
|
|
|
.unwrap_or_else(|err| abort!(err.span(), "{}", err))
|
|
|
|
|
.into(),
|
|
|
|
|
Err(err) => abort!(err.span(), "{}", err),
|
|
|
|
|
Ok(prog) => match prog.expand() {
|
|
|
|
|
Ok(tokens) => tokens,
|
|
|
|
|
Err(err) => err.emit_as_expr_tokens(),
|
|
|
|
|
},
|
|
|
|
|
Err(err) => err.emit_as_expr_tokens(),
|
|
|
|
|
}
|
|
|
|
|
.into()
|
|
|
|
|
}
|
|
|
|
|
#[proc_macro_error]
|
|
|
|
|
#[proc_macro_attribute]
|
|
|
|
|
pub fn uretprobe(attrs: TokenStream, item: TokenStream) -> TokenStream {
|
|
|
|
|
match UProbe::parse(UProbeKind::URetProbe, attrs.into(), item.into()) {
|
|
|
|
|
Ok(prog) => prog
|
|
|
|
|
.expand()
|
|
|
|
|
.unwrap_or_else(|err| abort!(err.span(), "{}", err))
|
|
|
|
|
.into(),
|
|
|
|
|
Err(err) => abort!(err.span(), "{}", err),
|
|
|
|
|
Ok(prog) => match prog.expand() {
|
|
|
|
|
Ok(tokens) => tokens,
|
|
|
|
|
Err(err) => err.emit_as_expr_tokens(),
|
|
|
|
|
},
|
|
|
|
|
Err(err) => err.emit_as_expr_tokens(),
|
|
|
|
|
}
|
|
|
|
|
.into()
|
|
|
|
|
}
|
|
|
|
|
#[proc_macro_error]
|
|
|
|
|
#[proc_macro_attribute]
|
|
|
|
|
pub fn sock_ops(attrs: TokenStream, item: TokenStream) -> TokenStream {
|
|
|
|
|
match SockOps::parse(attrs.into(), item.into()) {
|
|
|
|
|
Ok(prog) => prog
|
|
|
|
|
.expand()
|
|
|
|
|
.unwrap_or_else(|err| abort!(err.span(), "{}", err))
|
|
|
|
|
.into(),
|
|
|
|
|
Err(err) => abort!(err.span(), "{}", err),
|
|
|
|
|
Ok(prog) => prog.expand(),
|
|
|
|
|
Err(err) => err.emit_as_expr_tokens(),
|
|
|
|
|
}
|
|
|
|
|
.into()
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#[proc_macro_error]
|
|
|
|
|
#[proc_macro_attribute]
|
|
|
|
|
pub fn sk_msg(attrs: TokenStream, item: TokenStream) -> TokenStream {
|
|
|
|
|
match SkMsg::parse(attrs.into(), item.into()) {
|
|
|
|
|
Ok(prog) => prog
|
|
|
|
|
.expand()
|
|
|
|
|
.unwrap_or_else(|err| abort!(err.span(), "{}", err))
|
|
|
|
|
.into(),
|
|
|
|
|
Err(err) => abort!(err.span(), "{}", err),
|
|
|
|
|
Ok(prog) => prog.expand(),
|
|
|
|
|
Err(err) => err.emit_as_expr_tokens(),
|
|
|
|
|
}
|
|
|
|
|
.into()
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// Marks a function as an eBPF XDP program that can be attached to a network interface.
|
|
|
|
@ -149,60 +134,46 @@ pub fn sk_msg(attrs: TokenStream, item: TokenStream) -> TokenStream {
|
|
|
|
|
/// XDP_PASS
|
|
|
|
|
/// }
|
|
|
|
|
/// ```
|
|
|
|
|
#[proc_macro_error]
|
|
|
|
|
#[proc_macro_attribute]
|
|
|
|
|
pub fn xdp(attrs: TokenStream, item: TokenStream) -> TokenStream {
|
|
|
|
|
match Xdp::parse(attrs.into(), item.into()) {
|
|
|
|
|
Ok(prog) => prog
|
|
|
|
|
.expand()
|
|
|
|
|
.unwrap_or_else(|err| abort!(err.span(), "{}", err))
|
|
|
|
|
.into(),
|
|
|
|
|
Err(err) => abort!(err.span(), "{}", err),
|
|
|
|
|
Ok(prog) => prog.expand(),
|
|
|
|
|
Err(err) => err.emit_as_expr_tokens(),
|
|
|
|
|
}
|
|
|
|
|
.into()
|
|
|
|
|
}
|
|
|
|
|
#[proc_macro_error]
|
|
|
|
|
#[proc_macro_attribute]
|
|
|
|
|
pub fn classifier(attrs: TokenStream, item: TokenStream) -> TokenStream {
|
|
|
|
|
match SchedClassifier::parse(attrs.into(), item.into()) {
|
|
|
|
|
Ok(prog) => prog
|
|
|
|
|
.expand()
|
|
|
|
|
.unwrap_or_else(|err| abort!(err.span(), "{}", err))
|
|
|
|
|
.into(),
|
|
|
|
|
Err(err) => abort!(err.span(), "{}", err),
|
|
|
|
|
Ok(prog) => prog.expand(),
|
|
|
|
|
Err(err) => err.emit_as_expr_tokens(),
|
|
|
|
|
}
|
|
|
|
|
.into()
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#[proc_macro_attribute]
|
|
|
|
|
pub fn cgroup_sysctl(attrs: TokenStream, item: TokenStream) -> TokenStream {
|
|
|
|
|
match CgroupSysctl::parse(attrs.into(), item.into()) {
|
|
|
|
|
Ok(prog) => prog
|
|
|
|
|
.expand()
|
|
|
|
|
.unwrap_or_else(|err| abort!(err.span(), "{}", err))
|
|
|
|
|
.into(),
|
|
|
|
|
Err(err) => abort!(err.span(), "{}", err),
|
|
|
|
|
Ok(prog) => prog.expand(),
|
|
|
|
|
Err(err) => err.emit_as_expr_tokens(),
|
|
|
|
|
}
|
|
|
|
|
.into()
|
|
|
|
|
}
|
|
|
|
|
#[proc_macro_error]
|
|
|
|
|
#[proc_macro_attribute]
|
|
|
|
|
pub fn cgroup_sockopt(attrs: TokenStream, item: TokenStream) -> TokenStream {
|
|
|
|
|
match CgroupSockopt::parse(attrs.into(), item.into()) {
|
|
|
|
|
Ok(prog) => prog
|
|
|
|
|
.expand()
|
|
|
|
|
.unwrap_or_else(|err| abort!(err.span(), "{}", err))
|
|
|
|
|
.into(),
|
|
|
|
|
Err(err) => abort!(err.span(), "{}", err),
|
|
|
|
|
Ok(prog) => prog.expand(),
|
|
|
|
|
Err(err) => err.emit_as_expr_tokens(),
|
|
|
|
|
}
|
|
|
|
|
.into()
|
|
|
|
|
}
|
|
|
|
|
#[proc_macro_error]
|
|
|
|
|
#[proc_macro_attribute]
|
|
|
|
|
pub fn cgroup_skb(attrs: TokenStream, item: TokenStream) -> TokenStream {
|
|
|
|
|
match CgroupSkb::parse(attrs.into(), item.into()) {
|
|
|
|
|
Ok(prog) => prog
|
|
|
|
|
.expand()
|
|
|
|
|
.unwrap_or_else(|err| abort!(err.span(), "{}", err))
|
|
|
|
|
.into(),
|
|
|
|
|
Err(err) => abort!(err.span(), "{}", err),
|
|
|
|
|
Ok(prog) => prog.expand(),
|
|
|
|
|
Err(err) => err.emit_as_expr_tokens(),
|
|
|
|
|
}
|
|
|
|
|
.into()
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// Marks a function as a [`CgroupSockAddr`] eBPF program.
|
|
|
|
@ -239,51 +210,39 @@ pub fn cgroup_skb(attrs: TokenStream, item: TokenStream) -> TokenStream {
|
|
|
|
|
/// Ok(0)
|
|
|
|
|
/// }
|
|
|
|
|
/// ```
|
|
|
|
|
#[proc_macro_error]
|
|
|
|
|
#[proc_macro_attribute]
|
|
|
|
|
pub fn cgroup_sock_addr(attrs: TokenStream, item: TokenStream) -> TokenStream {
|
|
|
|
|
match CgroupSockAddr::parse(attrs.into(), item.into()) {
|
|
|
|
|
Ok(prog) => prog
|
|
|
|
|
.expand()
|
|
|
|
|
.unwrap_or_else(|err| abort!(err.span(), "{}", err))
|
|
|
|
|
.into(),
|
|
|
|
|
Err(err) => abort!(err.span(), "{}", err),
|
|
|
|
|
Ok(prog) => prog.expand(),
|
|
|
|
|
Err(err) => err.emit_as_expr_tokens(),
|
|
|
|
|
}
|
|
|
|
|
.into()
|
|
|
|
|
}
|
|
|
|
|
#[proc_macro_error]
|
|
|
|
|
#[proc_macro_attribute]
|
|
|
|
|
pub fn cgroup_sock(attrs: TokenStream, item: TokenStream) -> TokenStream {
|
|
|
|
|
match CgroupSock::parse(attrs.into(), item.into()) {
|
|
|
|
|
Ok(prog) => prog
|
|
|
|
|
.expand()
|
|
|
|
|
.unwrap_or_else(|err| abort!(err.span(), "{}", err))
|
|
|
|
|
.into(),
|
|
|
|
|
Err(err) => abort!(err.span(), "{}", err),
|
|
|
|
|
Ok(prog) => prog.expand(),
|
|
|
|
|
Err(err) => err.emit_as_expr_tokens(),
|
|
|
|
|
}
|
|
|
|
|
.into()
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#[proc_macro_error]
|
|
|
|
|
#[proc_macro_attribute]
|
|
|
|
|
pub fn tracepoint(attrs: TokenStream, item: TokenStream) -> TokenStream {
|
|
|
|
|
match TracePoint::parse(attrs.into(), item.into()) {
|
|
|
|
|
Ok(prog) => prog
|
|
|
|
|
.expand()
|
|
|
|
|
.unwrap_or_else(|err| abort!(err.span(), "{}", err))
|
|
|
|
|
.into(),
|
|
|
|
|
Err(err) => abort!(err.span(), "{}", err),
|
|
|
|
|
Ok(prog) => prog.expand(),
|
|
|
|
|
Err(err) => err.emit_as_expr_tokens(),
|
|
|
|
|
}
|
|
|
|
|
.into()
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#[proc_macro_error]
|
|
|
|
|
#[proc_macro_attribute]
|
|
|
|
|
pub fn perf_event(attrs: TokenStream, item: TokenStream) -> TokenStream {
|
|
|
|
|
match PerfEvent::parse(attrs.into(), item.into()) {
|
|
|
|
|
Ok(prog) => prog
|
|
|
|
|
.expand()
|
|
|
|
|
.unwrap_or_else(|err| abort!(err.span(), "{}", err))
|
|
|
|
|
.into(),
|
|
|
|
|
Err(err) => abort!(err.span(), "{}", err),
|
|
|
|
|
Ok(prog) => prog.expand(),
|
|
|
|
|
Err(err) => err.emit_as_expr_tokens(),
|
|
|
|
|
}
|
|
|
|
|
.into()
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// Marks a function as a raw tracepoint eBPF program that can be attached at a
|
|
|
|
@ -314,16 +273,13 @@ pub fn perf_event(attrs: TokenStream, item: TokenStream) -> TokenStream {
|
|
|
|
|
/// Ok(0)
|
|
|
|
|
/// }
|
|
|
|
|
/// ```
|
|
|
|
|
#[proc_macro_error]
|
|
|
|
|
#[proc_macro_attribute]
|
|
|
|
|
pub fn raw_tracepoint(attrs: TokenStream, item: TokenStream) -> TokenStream {
|
|
|
|
|
match RawTracePoint::parse(attrs.into(), item.into()) {
|
|
|
|
|
Ok(prog) => prog
|
|
|
|
|
.expand()
|
|
|
|
|
.unwrap_or_else(|err| abort!(err.span(), "{}", err))
|
|
|
|
|
.into(),
|
|
|
|
|
Err(err) => abort!(err.span(), "{}", err),
|
|
|
|
|
Ok(prog) => prog.expand(),
|
|
|
|
|
Err(err) => err.into_compile_error(),
|
|
|
|
|
}
|
|
|
|
|
.into()
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// Marks a function as an LSM program that can be attached to Linux LSM hooks.
|
|
|
|
@ -361,16 +317,13 @@ pub fn raw_tracepoint(attrs: TokenStream, item: TokenStream) -> TokenStream {
|
|
|
|
|
/// Ok(0)
|
|
|
|
|
/// }
|
|
|
|
|
/// ```
|
|
|
|
|
#[proc_macro_error]
|
|
|
|
|
#[proc_macro_attribute]
|
|
|
|
|
pub fn lsm(attrs: TokenStream, item: TokenStream) -> TokenStream {
|
|
|
|
|
match Lsm::parse(attrs.into(), item.into()) {
|
|
|
|
|
Ok(prog) => prog
|
|
|
|
|
.expand()
|
|
|
|
|
.unwrap_or_else(|err| abort!(err.span(), "{}", err))
|
|
|
|
|
.into(),
|
|
|
|
|
Err(err) => abort!(err.span(), "{}", err),
|
|
|
|
|
Ok(prog) => prog.expand(),
|
|
|
|
|
Err(err) => err.into_compile_error(),
|
|
|
|
|
}
|
|
|
|
|
.into()
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// Marks a function as a [BTF-enabled raw tracepoint][1] eBPF program that can be attached at
|
|
|
|
@ -403,16 +356,13 @@ pub fn lsm(attrs: TokenStream, item: TokenStream) -> TokenStream {
|
|
|
|
|
/// ```
|
|
|
|
|
///
|
|
|
|
|
/// [1]: https://github.com/torvalds/linux/commit/9e15db66136a14cde3f35691f1d839d950118826
|
|
|
|
|
#[proc_macro_error]
|
|
|
|
|
#[proc_macro_attribute]
|
|
|
|
|
pub fn btf_tracepoint(attrs: TokenStream, item: TokenStream) -> TokenStream {
|
|
|
|
|
match BtfTracePoint::parse(attrs.into(), item.into()) {
|
|
|
|
|
Ok(prog) => prog
|
|
|
|
|
.expand()
|
|
|
|
|
.unwrap_or_else(|err| abort!(err.span(), "{}", err))
|
|
|
|
|
.into(),
|
|
|
|
|
Err(err) => abort!(err.span(), "{}", err),
|
|
|
|
|
Ok(prog) => prog.expand(),
|
|
|
|
|
Err(err) => err.into_compile_error(),
|
|
|
|
|
}
|
|
|
|
|
.into()
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// Marks a function as a SK_SKB Stream Parser eBPF program that can be attached
|
|
|
|
@ -440,7 +390,6 @@ pub fn btf_tracepoint(attrs: TokenStream, item: TokenStream) -> TokenStream {
|
|
|
|
|
/// Ok(ctx.len())
|
|
|
|
|
///}
|
|
|
|
|
/// ```
|
|
|
|
|
#[proc_macro_error]
|
|
|
|
|
#[proc_macro_attribute]
|
|
|
|
|
pub fn stream_parser(attrs: TokenStream, item: TokenStream) -> TokenStream {
|
|
|
|
|
sk_skb(SkSkbKind::StreamParser, attrs, item)
|
|
|
|
@ -471,7 +420,6 @@ pub fn stream_parser(attrs: TokenStream, item: TokenStream) -> TokenStream {
|
|
|
|
|
/// Ok(sk_action::SK_PASS)
|
|
|
|
|
///}
|
|
|
|
|
/// ```
|
|
|
|
|
#[proc_macro_error]
|
|
|
|
|
#[proc_macro_attribute]
|
|
|
|
|
pub fn stream_verdict(attrs: TokenStream, item: TokenStream) -> TokenStream {
|
|
|
|
|
sk_skb(SkSkbKind::StreamVerdict, attrs, item)
|
|
|
|
@ -479,12 +427,10 @@ pub fn stream_verdict(attrs: TokenStream, item: TokenStream) -> TokenStream {
|
|
|
|
|
|
|
|
|
|
fn sk_skb(kind: SkSkbKind, attrs: TokenStream, item: TokenStream) -> TokenStream {
|
|
|
|
|
match SkSkb::parse(kind, attrs.into(), item.into()) {
|
|
|
|
|
Ok(prog) => prog
|
|
|
|
|
.expand()
|
|
|
|
|
.unwrap_or_else(|err| abort!(err.span(), "{}", err))
|
|
|
|
|
.into(),
|
|
|
|
|
Err(err) => abort!(err.span(), "{}", err),
|
|
|
|
|
Ok(prog) => prog.expand(),
|
|
|
|
|
Err(err) => err.emit_as_expr_tokens(),
|
|
|
|
|
}
|
|
|
|
|
.into()
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// Marks a function as a eBPF Socket Filter program that can be attached to
|
|
|
|
@ -504,16 +450,13 @@ fn sk_skb(kind: SkSkbKind, attrs: TokenStream, item: TokenStream) -> TokenStream
|
|
|
|
|
/// return 0
|
|
|
|
|
/// }
|
|
|
|
|
/// ```
|
|
|
|
|
#[proc_macro_error]
|
|
|
|
|
#[proc_macro_attribute]
|
|
|
|
|
pub fn socket_filter(attrs: TokenStream, item: TokenStream) -> TokenStream {
|
|
|
|
|
match SocketFilter::parse(attrs.into(), item.into()) {
|
|
|
|
|
Ok(prog) => prog
|
|
|
|
|
.expand()
|
|
|
|
|
.unwrap_or_else(|err| abort!(err.span(), "{}", err))
|
|
|
|
|
.into(),
|
|
|
|
|
Err(err) => abort!(err.span(), "{}", err),
|
|
|
|
|
Ok(prog) => prog.expand(),
|
|
|
|
|
Err(err) => err.emit_as_expr_tokens(),
|
|
|
|
|
}
|
|
|
|
|
.into()
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// Marks a function as a fentry eBPF program that can be attached to almost
|
|
|
|
@ -548,16 +491,13 @@ pub fn socket_filter(attrs: TokenStream, item: TokenStream) -> TokenStream {
|
|
|
|
|
/// Ok(0)
|
|
|
|
|
/// }
|
|
|
|
|
/// ```
|
|
|
|
|
#[proc_macro_error]
|
|
|
|
|
#[proc_macro_attribute]
|
|
|
|
|
pub fn fentry(attrs: TokenStream, item: TokenStream) -> TokenStream {
|
|
|
|
|
match FEntry::parse(attrs.into(), item.into()) {
|
|
|
|
|
Ok(prog) => prog
|
|
|
|
|
.expand()
|
|
|
|
|
.unwrap_or_else(|err| abort!(err.span(), "{}", err))
|
|
|
|
|
.into(),
|
|
|
|
|
Err(err) => abort!(err.span(), "{}", err),
|
|
|
|
|
Ok(prog) => prog.expand(),
|
|
|
|
|
Err(err) => err.into_compile_error(),
|
|
|
|
|
}
|
|
|
|
|
.into()
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// Marks a function as a fexit eBPF program that can be attached to almost
|
|
|
|
@ -593,16 +533,13 @@ pub fn fentry(attrs: TokenStream, item: TokenStream) -> TokenStream {
|
|
|
|
|
/// Ok(0)
|
|
|
|
|
/// }
|
|
|
|
|
/// ```
|
|
|
|
|
#[proc_macro_error]
|
|
|
|
|
#[proc_macro_attribute]
|
|
|
|
|
pub fn fexit(attrs: TokenStream, item: TokenStream) -> TokenStream {
|
|
|
|
|
match FExit::parse(attrs.into(), item.into()) {
|
|
|
|
|
Ok(prog) => prog
|
|
|
|
|
.expand()
|
|
|
|
|
.unwrap_or_else(|err| abort!(err.span(), "{}", err))
|
|
|
|
|
.into(),
|
|
|
|
|
Err(err) => abort!(err.span(), "{}", err),
|
|
|
|
|
Ok(prog) => prog.expand(),
|
|
|
|
|
Err(err) => err.into_compile_error(),
|
|
|
|
|
}
|
|
|
|
|
.into()
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// Marks a function as an eBPF Socket Lookup program that can be attached to
|
|
|
|
@ -623,16 +560,13 @@ pub fn fexit(attrs: TokenStream, item: TokenStream) -> TokenStream {
|
|
|
|
|
/// return 0
|
|
|
|
|
/// }
|
|
|
|
|
/// ```
|
|
|
|
|
#[proc_macro_error]
|
|
|
|
|
#[proc_macro_attribute]
|
|
|
|
|
pub fn sk_lookup(attrs: TokenStream, item: TokenStream) -> TokenStream {
|
|
|
|
|
match SkLookup::parse(attrs.into(), item.into()) {
|
|
|
|
|
Ok(prog) => prog
|
|
|
|
|
.expand()
|
|
|
|
|
.unwrap_or_else(|err| abort!(err.span(), "{}", err))
|
|
|
|
|
.into(),
|
|
|
|
|
Err(err) => abort!(err.span(), "{}", err),
|
|
|
|
|
Ok(prog) => prog.expand(),
|
|
|
|
|
Err(err) => err.emit_as_expr_tokens(),
|
|
|
|
|
}
|
|
|
|
|
.into()
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// Marks a function as a cgroup device eBPF program that can be attached to a
|
|
|
|
@ -656,14 +590,11 @@ pub fn sk_lookup(attrs: TokenStream, item: TokenStream) -> TokenStream {
|
|
|
|
|
/// return 0;
|
|
|
|
|
/// }
|
|
|
|
|
/// ```
|
|
|
|
|
#[proc_macro_error]
|
|
|
|
|
#[proc_macro_attribute]
|
|
|
|
|
pub fn cgroup_device(attrs: TokenStream, item: TokenStream) -> TokenStream {
|
|
|
|
|
match CgroupDevice::parse(attrs.into(), item.into()) {
|
|
|
|
|
Ok(prog) => prog
|
|
|
|
|
.expand()
|
|
|
|
|
.unwrap_or_else(|err| abort!(err.span(), "{}", err))
|
|
|
|
|
.into(),
|
|
|
|
|
Err(err) => abort!(err.span(), "{}", err),
|
|
|
|
|
Ok(prog) => prog.expand(),
|
|
|
|
|
Err(err) => err.emit_as_expr_tokens(),
|
|
|
|
|
}
|
|
|
|
|
.into()
|
|
|
|
|
}
|
|
|
|
|