Adapt to removal of `async_tokio` feature

See https://github.com/aya-rs/aya/commit/35332f2288b0bbb8981233ae464715.
pull/152/head
Tamir Duberstein 5 days ago
parent 71c366d943
commit 8789ae4f08
No known key found for this signature in database

@ -11,11 +11,11 @@ default-members = ["{{project-name}}", "{{project-name}}-common"]
license = "MIT OR Apache-2.0"
[workspace.dependencies]
aya = { version = "0.13.1", default-features = false }
aya-build = { version = "0.1.2", default-features = false }
aya-ebpf = { version = "0.1.1", default-features = false }
aya-log = { version = "0.2.1", default-features = false }
aya-log-ebpf = { version = "0.1.1", default-features = false }
aya = { git = "https://github.com/aya-rs/aya", default-features = false }
aya-build = { git = "https://github.com/aya-rs/aya", default-features = false }
aya-ebpf = { git = "https://github.com/aya-rs/aya", default-features = false }
aya-log = { git = "https://github.com/aya-rs/aya", default-features = false }
aya-log-ebpf = { git = "https://github.com/aya-rs/aya", default-features = false }
anyhow = { version = "1", default-features = false }
# `std` feature is currently required to build `clap`.

@ -325,6 +325,6 @@ fn panic(_info: &core::panic::PanicInfo) -> ! {
loop {}
}
#[link_section = "license"]
#[no_mangle]
#[unsafe(link_section = "license")]
#[unsafe(no_mangle)]
static LICENSE: [u8; 13] = *b"Dual MIT/GPL\0";

@ -1,5 +1,5 @@
use anyhow::{anyhow, Context as _};
use aya_build::cargo_metadata;
use aya_build::{cargo_metadata, Toolchain};
fn main() -> anyhow::Result<()> {
let cargo_metadata::Metadata { packages, .. } = cargo_metadata::MetadataCommand::new()
@ -8,7 +8,7 @@ fn main() -> anyhow::Result<()> {
.context("MetadataCommand::exec")?;
let ebpf_package = packages
.into_iter()
.find(|cargo_metadata::Package { name, .. }| name == "{{project-name}}-ebpf")
.find(|cargo_metadata::Package { name, .. }| name.as_str() == "aya-test-crate-ebpf")
.ok_or_else(|| anyhow!("{{project-name}}-ebpf package not found"))?;
aya_build::build_ebpf([ebpf_package])
aya_build::build_ebpf([ebpf_package], Toolchain::default())
}

@ -96,9 +96,22 @@ async fn main() -> anyhow::Result<()> {
env!("OUT_DIR"),
"/{{project-name}}"
)))?;
if let Err(e) = aya_log::EbpfLogger::init(&mut ebpf) {
// This can happen if you remove all log statements from your eBPF program.
warn!("failed to initialize eBPF logger: {e}");
match aya_log::EbpfLogger::init(&mut ebpf) {
Err(e) => {
// This can happen if you remove all log statements from your eBPF program.
warn!("failed to initialize eBPF logger: {e}");
}
Ok(logger) => {
let mut logger =
tokio::io::unix::AsyncFd::with_interest(logger, tokio::io::Interest::READABLE)?;
tokio::task::spawn(async move {
loop {
let mut guard = logger.readable_mut().await.unwrap();
guard.get_inner_mut().flush();
guard.clear_ready();
}
});
}
}
{%- case program_type -%}
{%- when "kprobe", "kretprobe" %}
@ -119,7 +132,7 @@ async fn main() -> anyhow::Result<()> {
let Opt { pid } = opt;
let program: &mut UProbe = ebpf.program_mut("{{crate_name}}").unwrap().try_into()?;
program.load()?;
program.attach(Some("{{uprobe_fn_name}}"), 0, "{{uprobe_target}}", pid)?;
program.attach("{{uprobe_fn_name}}", "{{uprobe_target}}", pid, None /* cookie */)?;
{%- when "sock_ops", "cgroup_skb", "cgroup_sysctl", "cgroup_sockopt" %}
let Opt { cgroup_path } = opt;
let cgroup =

Loading…
Cancel
Save