Commit Graph

8 Commits (3655cd1e02ce19520fce6363c6c83f7d3ea32413)

Author SHA1 Message Date
Dave Tucker 376c486400 aya-bpf: Add multibuffer support for XDP
Signed-off-by: Dave Tucker <dave@dtucker.co.uk>
2 years ago
Michal Rostecki 6ad2c3c373 aya-bpf-macros: Allow to make programs public
Allow to define programs as public functions (even in library crates)
and then import them.

For example, we can have library crate with `libfoo/src/lib.rs`
containing:

```rust
pub fn my_xdp_program(ctx: XdpContext) -> u32 {
    xdp_action::XDP_PASS
}
```

And then a binary importing it:

```rust
pub use libfoo::my_xdp_program;
```

This way, commonly used eBPF programs can be distributed as lib crates.

Tested with: https://github.com/vadorovsky/aya-examples/tree/main/pub-progs

Signed-off-by: Michal Rostecki <vadorovsky@gmail.com>
2 years ago
Milan 4b6d97e4db Fix CI, clippy and feedback
Signed-off-by: Milan <milan@mdaverde.com>
2 years ago
Milan 8f1163a400 Add support for BPF_PROG_TYPE_CGROUP_DEVICE
Kernel 4.15 added a new eBPF program that can
be used with cgroup v2 to control & observe device
access (e.g. read, write, mknod) - `BPF_PROG_TYPE_CGROUP_DEVICE`.

We add the ability to create these programs with the `cgroup_device`
proc macro which creates the `cgroup/dev` link section. Device
details are available to the eBPF program in `DeviceContext`.

The userspace representation is provided with the `CgroupDevice`
structure.

Fixes: #212
Signed-off-by: Milan <milan@mdaverde.com>
2 years ago
Dmitry Savintsev 055d94f58b fix uninlined_format_args clippy issues 2 years ago
Michal Rostecki 895f96e971 ebpf: Add TcContext for classifier programs
This change separates the previous `SkBuffContext` into three structs:

* `SkBuff` which is a wrapper around `__sk_buff` which contains all
  possible methods operating on it.
* `SkBuffContext` which is a program context for programs which
  **cannot** access `__sk_buff` directly and instead can only use
  `load_bytes`.
* `TcContext` which is a classifier context which can access `__sk_buff`
  directly, hence exposes `data` and `data_end`.

Signed-off-by: Michal Rostecki <vadorovsky@gmail.com>
2 years ago
Michal Rostecki 944d6b8a16 Change from Rust edition 2018 to 2021
Rust 2021 adds more core prelude imports, including `TryFrom` and
`TryInto`.

Signed-off-by: Michal Rostecki <vadorovsky@gmail.com>
2 years ago
Dave Tucker dc31e11691 Re-organize into a single workspace
This commit moves the aya-log projects from the subtree and adds them to
the main cargo workspace. It also brings the BPF crates into the
workspace and moves the macro crates up a level since they aren't BPF
code.

Miri was disabled for aya-bpf as the previous config wasn't actually
checking anything.

CI, clippy, fmt and release configurations have all been adjusted
appropriately.

CI was not properly running for other supported arches which was also
ixed here.

Signed-off-by: Dave Tucker <dave@dtucker.co.uk>
2 years ago