Commit Graph

4 Commits (accd9d2a2a8dc97576de2f6b002efe7b4a6d0811)

Author SHA1 Message Date
Michal Rostecki accd9d2a2a Add support for LSM programs attached to cgroups
Kernel 6.0 provides a new attachment type - `BPF_LSM_CGROUP`. When using
it, a program attaches to LSM hooks, but only within a cgroup.

`BPF_LSM_CGROUP` requires programs to we present in the `lsm_cgroup`
section, therefore we provide a new `cgroup_lsm` macro for defining such
programs in aya-bpf.

We also provide a new `CgroupLsm` structure in userspace aya, which uses
the new attachment type and stores the information about cgroup in
links.

Fixes: #423
Signed-off-by: Michal Rostecki <vadorovsky@gmail.com>
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