Commit Graph

866 Commits (055d94f58be4f80ada416b99278a22f600c71285)
 

Author SHA1 Message Date
Michal Rostecki 3d592d0f29 aya: Raise the RLIMIT_MEMLOCK warning only if failed to create a map
Also, mention that setting the RLIMIT_MEMLOCK to a higher value is an
option.

Signed-off-by: Michal Rostecki <vadorovsky@gmail.com>
2 years ago
Dave Tucker a7fa938f1e
Merge pull request #342 from vadorovsky/rlimit
aya: Raise the warning when RMILIT_MEMLOCK is not RLIM_INFINITY
2 years ago
Michal Rostecki bebe98e670 aya: Raise the warning when RMILIT_MEMLOCK is not RLIM_INFINITY
Kernels before 5.11 don't use cgroup accounting, so they might reach the
RLIMIT_MEMLOCK when creating maps. After this change, we raise a warning
recommending to raise the RLIMIT_MEMLOCK.
2 years ago
Dave Tucker 555833a79a
Merge pull request #335 from dave-tucker/rust-runner
test: Replace RTF with Rust
2 years ago
Dave Tucker 79101e748a test: Replace RTF with Rust
This commit replaces the existing RTF test runner with a simple rust
binary package called - integration-test.

integration-test depends on integration-ebpf, which contains test eBPF
code written in Rust and C. `cargo xtask build-integration-test-ebpf`
can be used to build this code and supress rust-analyzer warnings. It
does require `bpf-linker`, but that is highly likely to be available to
developers of Aya. It also requires a checkout of `libbpf` to extract
headers like bpf-helpers.h.

Since everything is compiled into a single binary, it can be run
be run locally using `cargo xtask integration-test` or remotely using
`./run.sh` which re-uses the bash script from the old test framework
to spawn a VM in which to run the tests.

Signed-off-by: Dave Tucker <dave@dtucker.co.uk>
2 years ago
Dave Tucker 6188c9dee3
Merge pull request #336 from dave-tucker/clippy
clippy: Fix latest nightly lints
2 years ago
Dave Tucker 336faf553e clippy: Fix latest nightly lints
Signed-off-by: Dave Tucker <dave@dtucker.co.uk>
2 years ago
Dave Tucker 323170aa3f
Merge pull request #331 from joshiste/fix/compat-pre-5.5
aya-bpf: use bpf_read_probe for reading pt_regs
2 years ago
Johannes Edmeier 2d79f22b40 aya-bpf: use bpf_read_probe for reading pt_regs
Linux Kernels < 5.5 don't support bpf_probe_read_kernel. Therefore
bpf_probe_read must be used for compatibility reasons.
2 years ago
Dave Tucker f2fb211634
Merge pull request #330 from aya-rs/dependabot/cargo/object-0.29
build(deps): update object requirement from 0.28 to 0.29
2 years ago
Michal Rostecki 78e58b8960 bpf(helpers): Add *_str_bytes helpers
This change adds two new helpers:

* bpf_probe_read_user_str_bytes
* bpf_probe_read_kernel_str_bytes

Those new helpers are returning a bytes slice (`&[u8]`) with a length
equal to the length of probed, null-terminated string. When using those
helpers, users don't have to manually check for length and create such
slices themselves. They also make converting to `str` way more
convenient, for example:

```rust
let my_str = unsafe {
    core::str::from_utf8_unchecked(
        bpf_probe_read_user_str_bytes(user_ptr, &mut buf)?
    )
};
```

This change also deprecates the old helpers, since their names are
confusing (they have nothing to do with Rust `str`) and using them
requires writing boilerplate code (for checking the length and making
eBPF verifier happy):

* bpf_probe_read_user_str
* bpf_probe_read_kernel_str

Tested on:

516b29af68

Signed-off-by: Michal Rostecki <vadorovsky@gmail.com>
2 years ago
dependabot[bot] 661a21570f
build(deps): update object requirement from 0.28 to 0.29
Updates the requirements on [object](https://github.com/gimli-rs/object) to permit the latest version.
- [Release notes](https://github.com/gimli-rs/object/releases)
- [Changelog](https://github.com/gimli-rs/object/blob/master/CHANGELOG.md)
- [Commits](https://github.com/gimli-rs/object/compare/0.28.0...0.29.0)

---
updated-dependencies:
- dependency-name: object
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <support@github.com>
2 years ago
Alessandro Decina a301a56316
Merge pull request #328 from drewkett/map-update-no-key
Have bpf_map_update_elem take Option<&K> for key
2 years ago
Alessandro Decina e5f455f238
Merge pull request #282 from dave-tucker/bpfd
Add atomic replacement of XDP progs and multihoming of Extension progs
2 years ago
Dave Tucker 004f3dd664 aya: Improve Extension Docs
Signed-off-by: Dave Tucker <dave@dtucker.co.uk>
2 years ago
Dave Tucker 9e85b92323 aya: Add Extension::attach_to_program()
This allows for Extension programs already loaded to the kernel to be
attached to another program that is BTF-compatible with the one provided
at `load()` time

Signed-off-by: Dave Tucker <dave@dtucker.co.uk>
2 years ago
Dave Tucker b4413322e3 aya: Replace ProgramFd trait with struct
This removes the ProgramFd trait with a struct that wraps a RawFd.
Program::fd() has been implemented as well as fd() for each Program
Type. This allows for a better API than requiring the use of the
ProgramFd trait.

Signed-off-by: Dave Tucker <dave@dtucker.co.uk>
2 years ago
Dave Tucker fd52bfeadc aya: Implement attach_to_link for XDP
Signed-off-by: Dave Tucker <dave@dtucker.co.uk>
2 years ago
Dave Tucker ccb189784f aya: Add support for bpf_link_update
Signed-off-by: Dave Tucker <dave@dtucker.co.uk>
2 years ago
Andrew Burkett 36edf09254 Have bpf_map_update_elem take Option<&K> for key
bpf_map_update_elem is used in lieu of bpf_map_push_elem to maintain support for kernel version < 4.20. The kernel expects a null pointer for the key for this use case. With this change, if you pass None as key to `bpf_map_update_elem`, it will pass null as key.
2 years ago
Alessandro Decina 150dc1b610
Merge pull request #326 from NoneTirex/fix-map-delete-return-value
Change condititon for some bpf helpers
2 years ago
tirex caa66cabac Add missing inline macro to xdp methods 2 years ago
tirex 741c35f555 Restore previous check for bpf_get_stackid 2 years ago
tirex 42c4d5c3af Temporary change return value condition to avoid problems with possibly (not aware) cast from int to long 2 years ago
tirex 5b1a3ed866 Fix return value for map removing/deleting 2 years ago
Dave Tucker 623579a47f aya: Add Map::fd() function to return a MapFd
Signed-off-by: Dave Tucker <dave@dtucker.co.uk>
2 years ago
Dave Tucker 24597b15b7
Merge pull request #321 from davibe/fix-linting-issues
Fix linting issues
2 years ago
Davide Bertola 7f33d67e8c xtask: fix linting warnings on docs() 2 years ago
Davide Bertola 2680693783 xtask: fix lint errors due to clap changes 2 years ago
Davide Bertola cbf520934a aya-gen: fix lint errors 2 years ago
Dave Tucker ed3b690a6d
Merge pull request #320 from dave-tucker/moar-crabby-docs
Fix development docs build
2 years ago
Dave Tucker 2b98259be7 readme: Add crabby, sync with aya/README.md
Signed-off-by: Dave Tucker <dave@dtucker.co.uk>
2 years ago
Dave Tucker 67951cd2d7 xtask: Fix docs generation
Publish user/kernel space docs seperately.
Add an index.html at the root for navigation.
Ensure that search engines don't index these pages.

Signed-off-by: Dave Tucker <dave@dtucker.co.uk>
2 years ago
Dave Tucker 713cd4e858 docs: Add crabby logo
Signed-off-by: Dave Tucker <dave@dtucker.co.uk>
2 years ago
Davide Bertola 4f13576594
aya-gen: allow passing custom --ctypes-prefix to bindgen (#312)
Allows users to pass a custom --ctypes-prefix to bindgen #186
2 years ago
Alessandro Decina 7549eb979c
Merge pull request #315 from dave-tucker/sock
Add support for BPF_PROG_TYPE_CGROUP_SOCK
2 years ago
Dave Tucker 0786afa9ca
Merge pull request #319 from dave-tucker/moar-regs
bpf: bpf_probe_read_kernel fields in pt_regs
2 years ago
Dave Tucker cf3c8f355e ci: test aya-bpf-macros on nightly
Signed-off-by: Dave Tucker <dave@dtucker.co.uk>
2 years ago
Dave Tucker 05c1586202 bpf: bpf_probe_read_kernel fields in pt_regs
As it turns out, the verifier gets upset if you try to read the values
directly without using bpf_probe_read.

Signed-off-by: Dave Tucker <dave@dtucker.co.uk>
2 years ago
Dave Tucker f3574b0e70
Merge pull request #318 from ishitatsuyuki/patch-1
bpf: Remove unnecessary Sync bound on PerCpuArray<T>
2 years ago
Tatsuyuki Ishi 5e24cf7a29
bpf: Remove unnecessary Sync bound on PerCpuArray<T> 2 years ago
Alessandro Decina 82cd3e695a ebpf: PerCpuArray: remove get_mut() and add get_ptr() and get_ptr_mut()
get_mut() wasn't sound as it allowed creating multiple mutable
references.
2 years ago
Alessandro Decina 1eb9ef5488
Merge pull request #290 from ishitatsuyuki/immut-self
bpf: Replace map types to use &self, remove HashMap::get_mut
2 years ago
Dave Tucker 7b21a2d17e aya: Implement BPF_PROG_TYPE_CGROUP_SOCK
Signed-off-by: Dave Tucker <dave@dtucker.co.uk>
2 years ago
Dave Tucker 6f51b616e1 bpf: Implement BPF_PROG_TYPE_CGROUP_SOCK
Signed-off-by: Dave Tucker <dave@dtucker.co.uk>
2 years ago
Dave Tucker 3f6b2507b6
Merge pull request #314 from dave-tucker/sockops
bpf: Add accessors to SockOpsContext
2 years ago
Dave Tucker 9d18a48c3c bpf: Add accessors to SockOpsContext
Allow getting family, remote/local v4/v6 addresses and the remote and
local ports.

Signed-off-by: Dave Tucker <dave@dtucker.co.uk>
2 years ago
Dave Tucker 52eb6bd1ef
Merge pull request #313 from aya-rs/add-code-of-conduct
Add a Code of Conduct
2 years ago
Dave Tucker e752ffb3be
Add a Code of Conduct
Adapted from the contributor covenant template
2 years ago
Alessandro Decina cffff273a1 aya-gen: fix lint 👀 2 years ago