You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
Go to file
Tamir Duberstein 0429ed2fa2 Appease clippy
```
error: manual implementation of `ok`
   --> aya/src/util.rs:261:28
    |
261 |                   let addr = match u64::from_str_radix(addr, 16) {
    |  ____________________________^
262 | |                     Ok(addr) => Some(addr),
263 | |                     Err(ParseIntError { .. }) => None,
264 | |                 }?;
    | |_________________^ help: replace with: `u64::from_str_radix(addr, 16).ok()`
    |
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#manual_ok_err

error: struct pattern is not needed for a unit variant
    --> aya-obj/src/obj.rs:1705:44
     |
1705 |             section: ProgramSection::KProbe { .. },
     |                                            ^^^^^^^ help: remove the struct pattern
     |
     = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#unneeded_struct_pattern
note: the lint level is defined here
    --> aya-obj/src/lib.rs:68:9
     |
68   | #![deny(clippy::all, missing_docs)]
     |         ^^^^^^^^^^^
     = note: `#[deny(clippy::unneeded_struct_pattern)]` implied by `#[deny(clippy::all)]`

error: struct pattern is not needed for a unit variant
    --> aya-obj/src/obj.rs:1769:44
     |
1769 |             section: ProgramSection::KProbe { .. },
     |                                            ^^^^^^^ help: remove the struct pattern
     |
     = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#unneeded_struct_pattern

error: struct pattern is not needed for a unit variant
    --> aya-obj/src/obj.rs:1787:44
     |
1787 |             section: ProgramSection::KProbe { .. },
     |                                            ^^^^^^^ help: remove the struct pattern
     |
     = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#unneeded_struct_pattern

error: struct pattern is not needed for a unit variant
    --> aya-obj/src/obj.rs:1919:48
     |
1919 |                 section: ProgramSection::KProbe { .. },
     |                                                ^^^^^^^ help: remove the struct pattern
     |
     = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#unneeded_struct_pattern

error: struct pattern is not needed for a unit variant
    --> aya-obj/src/obj.rs:2041:52
     |
2041 |                 section: ProgramSection::TracePoint { .. },
     |                                                    ^^^^^^^ help: remove the struct pattern
     |
     = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#unneeded_struct_pattern

error: struct pattern is not needed for a unit variant
    --> aya-obj/src/obj.rs:2058:52
     |
2058 |                 section: ProgramSection::TracePoint { .. },
     |                                                    ^^^^^^^ help: remove the struct pattern
     |
     = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#unneeded_struct_pattern

error: struct pattern is not needed for a unit variant
    --> aya-obj/src/obj.rs:2081:54
     |
2081 |                 section: ProgramSection::SocketFilter { .. },
     |                                                      ^^^^^^^ help: remove the struct pattern
     |
     = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#unneeded_struct_pattern

error: struct pattern is not needed for a unit variant
    --> aya-obj/src/obj.rs:2151:55
     |
2151 |                 section: ProgramSection::RawTracePoint { .. },
     |                                                       ^^^^^^^ help: remove the struct pattern
     |
     = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#unneeded_struct_pattern

error: struct pattern is not needed for a unit variant
    --> aya-obj/src/obj.rs:2168:55
     |
2168 |                 section: ProgramSection::RawTracePoint { .. },
     |                                                       ^^^^^^^ help: remove the struct pattern
     |
     = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#unneeded_struct_pattern

error: struct pattern is not needed for a unit variant
    --> aya-obj/src/obj.rs:2243:55
     |
2243 |                 section: ProgramSection::BtfTracePoint { .. },
     |                                                       ^^^^^^^ help: remove the struct pattern
     |
     = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#unneeded_struct_pattern

error: struct pattern is not needed for a unit variant
    --> aya-obj/src/obj.rs:2266:59
     |
2266 |                 section: ProgramSection::SkSkbStreamParser { .. },
     |                                                           ^^^^^^^ help: remove the struct pattern
     |
     = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#unneeded_struct_pattern

error: struct pattern is not needed for a unit variant
    --> aya-obj/src/obj.rs:2289:59
     |
2289 |                 section: ProgramSection::SkSkbStreamParser { .. },
     |                                                           ^^^^^^^ help: remove the struct pattern
     |
     = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#unneeded_struct_pattern

error: struct pattern is not needed for a unit variant
    --> aya-obj/src/obj.rs:2410:58
     |
2410 |                 section: ProgramSection::CgroupSkbIngress { .. },
     |                                                          ^^^^^^^ help: remove the struct pattern
     |
     = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#unneeded_struct_pattern

error: struct pattern is not needed for a unit variant
    --> aya-obj/src/obj.rs:2433:58
     |
2433 |                 section: ProgramSection::CgroupSkbIngress { .. },
     |                                                          ^^^^^^^ help: remove the struct pattern
     |
     = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#unneeded_struct_pattern

error: struct pattern is not needed for a unit variant
    --> aya-obj/src/obj.rs:2456:51
     |
2456 |                 section: ProgramSection::CgroupSkb { .. },
     |                                                   ^^^^^^^ help: remove the struct pattern
     |
     = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#unneeded_struct_pattern

error: struct pattern is not needed for a unit variant
    --> aya-obj/src/obj.rs:2479:51
     |
2479 |                 section: ProgramSection::CgroupSkb { .. },
     |                                                   ^^^^^^^ help: remove the struct pattern
     |
     = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#unneeded_struct_pattern

error: manual implementation of `ok`
   --> aya-log-common/src/lib.rs:168:36
    |
168 |       let wire_len: LogValueLength = match value.len().try_into() {
    |  ____________________________________^
169 | |         Ok(wire_len) => Some(wire_len),
170 | |         Err(TryFromIntError { .. }) => None,
171 | |     }?;
    | |_____^ help: replace with: `value.len().try_into().ok()`
    |
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#manual_ok_err

error: manual implementation of `err`
   --> init/src/main.rs:141:30
    |
141 |           .filter_map(|result| match result {
    |  ______________________________^
142 | |             Ok(()) => None,
143 | |             Err(err) => Some(err),
144 | |         })
    | |_________^ help: replace with: `result.err()`
    |
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#manual_ok_err

error: manual implementation of `err`
  --> xtask/src/public_api.rs:80:30
   |
80 |           .filter_map(|result| match result {
   |  ______________________________^
81 | |             Ok(()) => None,
82 | |             Err(err) => Some(err),
83 | |         })
   | |_________^ help: replace with: `result.err()`
   |
   = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#manual_ok_err
```
1 day ago
.cargo aya: add archs powerpc64 and s390x to aya 5 months ago
.github ci: add ARM runner 2 days ago
.vim Re-organize into a single workspace 3 years ago
.vscode vscode: exclude public-api fixtures from search 2 years ago
assets readme: Add crabby, sync with aya/README.md 3 years ago
aya Appease clippy 1 day ago
aya-build aya-build: add explicit irrefutable pattern 2 months ago
aya-ebpf-macros Replace proc-macro-error with proc-macro2-diagnostics 2 months ago
aya-log Release aya v0.13.1 3 months ago
aya-log-common Appease clippy 1 day ago
aya-log-ebpf-macros Release aya-log-ebpf-macros v0.1.0 10 months ago
aya-log-parser Narrow clippy allowances 1 month ago
aya-obj Appease clippy 1 day ago
aya-tool aya-tool: enable clang_macro_fallback 3 weeks ago
ebpf Fix aya-ebpf-* riscv64 build (#1139) 1 week ago
init Appease clippy 1 day ago
test aya::programs::uprobe: add support for cookies 3 weeks ago
xtask Appease clippy 1 day ago
.gitignore xtask: remove assumptions from docs command 2 years ago
.gitmodules xtask: move libbpf submodule 2 years ago
.markdownlint-cli2.yaml chore: Disable markdownlint for generated files 11 months ago
.mergify.yml chore: Fix Mergify configuration 11 months ago
.taplo.toml fix: fix rustdocs-args ordering in taplo to -D warnings 8 months ago
CODE_OF_CONDUCT.md .github: Add markdownlint 1 year ago
CONTRIBUTING.md .github: Add markdownlint 1 year ago
Cargo.toml Update public-api to 0.43.0 4 days ago
LICENSE-APACHE Add license files 4 years ago
LICENSE-MIT Add license files 4 years ago
README.md Introducing Aya Guru on Gurubase.io (#1085) 2 months ago
clippy.sh Extract integration-common for shared types 2 months ago
netlify.toml toml: add formatter and check in CI 2 years ago
release.toml chore: Fix release.toml 11 months ago
rustfmt.toml rustfmt: group_imports = "StdExternalCrate" 1 year ago

README.md

Aya

Crates.io License Build status Book Gurubase

API Documentation

Unreleased Documentation Documentaiton

Community

Discord Awesome

Join the conversation on Discord to discuss anything related to Aya or discover and contribute to a list of Awesome Aya projects.

Overview

eBPF is a technology that allows running user-supplied programs inside the Linux kernel. For more info see What is eBPF.

Aya is an eBPF library built with a focus on operability and developer experience. It does not rely on libbpf nor bcc - it's built from the ground up purely in Rust, using only the libc crate to execute syscalls. With BTF support and when linked with musl, it offers a true compile once, run everywhere solution, where a single self-contained binary can be deployed on many linux distributions and kernel versions.

Some of the major features provided include:

  • Support for the BPF Type Format (BTF), which is transparently enabled when supported by the target kernel. This allows eBPF programs compiled against one kernel version to run on different kernel versions without the need to recompile.
  • Support for function call relocation and global data maps, which allows eBPF programs to make function calls and use global variables and initializers.
  • Async support with both tokio and async-std.
  • Easy to deploy and fast to build: aya doesn't require a kernel build or compiled headers, and not even a C toolchain; a release build completes in a matter of seconds.

Example

Aya supports a large chunk of the eBPF API. The following example shows how to use a BPF_PROG_TYPE_CGROUP_SKB program with aya:

use std::fs::File;
use aya::Ebpf;
use aya::programs::{CgroupSkb, CgroupSkbAttachType};

// load the BPF code
let mut ebpf = Ebpf::load_file("ebpf.o")?;

// get the `ingress_filter` program compiled into `ebpf.o`.
let ingress: &mut CgroupSkb = ebpf.program_mut("ingress_filter")?.try_into()?;

// load the program into the kernel
ingress.load()?;

// attach the program to the root cgroup. `ingress_filter` will be called for all
// incoming packets.
let cgroup = File::open("/sys/fs/cgroup/unified")?;
ingress.attach(cgroup, CgroupSkbAttachType::Ingress)?;

Contributing

Please see the contributing guide.

License

Aya is distributed under the terms of either the MIT license or the Apache License (version 2.0), at your option.

Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in this crate by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.