aya icon indicating copy to clipboard operation
aya copied to clipboard

Add an ARCHITECTURE.md

Open willfindlay opened this issue 4 years ago • 2 comments

I think an ARCHITECTURE.md would also go a long way for getting new contributors up to speed. Even something simple that describes what each crate is for, etc. This looks like an awesome (and very promising) project, and I would love to contribute, but the number of crates and subcrates in this workspace can be a bit overwhelming at first glance. Thanks a lot for your work on the library :)

willfindlay avatar Jun 19 '21 01:06 willfindlay

Oh absolutely! Docs - both on how to contribute and how to use the library - are my personal #1 priority right now.

In the meantime:

  • the aya crate includes the user space library, that is what is used to load and attach eBPF programs
  • the xtask crate is an internal crate used to automate some tasks, see https://github.com/matklad/cargo-xtask
  • aya-gen is a crate (and a binary) used to generate rust bindings from BTF debug info. It's used to generate some internal bindings used by the aya crate, and for some bindings exported by aya-bpf.
  • aya-bpf is a crate you can use from eBPF programs (so kernel side). It provides a high level API for maps and programs similar to the API aya exports in userspace. It also exports proc_macros you can use to simplify defining programs, eg:
#[classifier(name = "ingress_filter")]
fn tc_cls_ingress_proxy(skb: SkSkbContext) -> i32 {
    match try_tc_cls_ingress_filter(skb) {
        Ok(ret) => ret,
        Err(_) => TC_ACT_OK as i32,
    }
}
  • aya-bpf-bindings includes generated bindings for bpf-helpers and some common eBPF kernel structs, it's re-exported by aya-bpf.
  • aya-bpf-macros includes the proc_macros used to define eBPF programs. Also re-exported by aya-bpf.

alessandrod avatar Jun 19 '21 01:06 alessandrod

Thanks for the high-level explanation, that helps quite a lot. :)

willfindlay avatar Jun 19 '21 12:06 willfindlay