Commit Graph

714 Commits (526493b444ed91f1c315ace494b41b8f4178fe65)
 

Author SHA1 Message Date
Dave Tucker 526493b444 aya-log, aya-log-common: start next development iteration 0.1.11-dev.0
Dave Tucker 3abd97307e aya-log, aya-log-common: release version 0.1.10
dependabot[bot] 060ba45153 Update aya requirement from 0.10.7 to 0.11.0
Updates the requirements on [aya](https://github.com/aya-rs/aya) to permit the latest version.
- [Release notes](https://github.com/aya-rs/aya/releases)
- [Commits](https://github.com/aya-rs/aya/compare/aya-v0.10.7...aya-v0.11.0)

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

Signed-off-by: dependabot[bot] <support@github.com>
Dave Tucker 0038b43627 Add CI
Signed-off-by: Dave Tucker <dave@dtucker.co.uk>
Dave Tucker c1bb790c0d Add vim/vscode rust-analyzer settings
Signed-off-by: Dave Tucker <dave@dtucker.co.uk>
Dave Tucker 3f0085195f Add rustfmt.toml
Signed-off-by: Dave Tucker <dave@dtucker.co.uk>
Dave Tucker 5789585994 ebpf: Add example
This ensures that macro expansion works properly and that expanded code
compiles

Signed-off-by: Dave Tucker <dave@dtucker.co.uk>
Dave Tucker 5d82d9a73e Add Tests
This moves a large chunk of code from ebpf to shared so we can re-use
write_record_header and write_record_message and friends so that we
can write test cases to ensure that logs are properly formatted
given certain input.

Signed-off-by: Dave Tucker <dave@dtucker.co.uk>
Michal Rostecki 628b473e09 ebpf: Ensure the bounds of log buffer
eBPF verifier rejects programs which are not checking the bounds of the
log buffer before writing any arguments. This change ensures that
written log arguments.

In practice, it means that doing this kind of checks is not going to be
needed in eBPF program code anymore:

33a1aee2ea/echo-ebpf/src/main.rs (L47)

Tested on:

876f8b4551

Signed-off-by: Michal Rostecki <vadorovsky@gmail.com>
Michal Rostecki 70b4e68130 common: Bump the buffer size
1024 is too small for many kernel string limits (i.e. PATH_MAX, which is
4096).

Signed-off-by: Michal Rostecki <vadorovsky@gmail.com>
Alessandro Decina bd9a5c8fdf aya-log, aya-log-common: start next development iteration 0.1.10-dev.0
Alessandro Decina 8bc1bbb3ab aya-log, aya-log-common: release version 0.1.9
Alessandro Decina a8d133f6b0 Add cargo-release config
Alessandro Decina d1a0ce51ee xtask: do not release
Alessandro Decina c4d89fa13c aya-log: use stricter version for the aya-log-common dep
Alessandro Decina bdb2750e66 ebpf: inline write_record_header
This seems to help the verifier keep track of where we're writing into
LOG_BUF
Michal Rostecki 81befa0661 Update aya to 0.10.7
Signed-off-by: Michal Rostecki <vadorovsky@gmail.com>
Michal Rostecki ca1fe7e05f Format arguments in userspace
This change moves away argument formatting from eBPF to the userspace.
eBPF part of aya-log writes unformatted log message and all arguments to
the perf buffer and the userspace part of aya-log is formatting the
message after receiving all arguments.

Aya-based project to test this change:

https://github.com/vadorovsky/aya-log-example

Fixes: 
Signed-off-by: Michal Rostecki <vadorovsky@gmail.com>
Signed-off-by: Tuetuopay <tuetuopay@me.com>
Co-authored-by: Tuetuopay <tuetuopay@me.com>
Alessandro Decina 9b229d00e1 Don't recompute the record length
Alessandro Decina 7f8d7057df ebpf: initialize AYA_LOGS with max_entries=0
This way aya will create one perf buffer for each cpu
Alessandro Decina 2800454763 Fix clippy warning
Alessandro Decina 8bde15dad7 Add copy of README.md inside aya-log/
Needed for crates.io
Alessandro Decina 5e18a715b2 Add missing manifest fields
Alessandro Decina 31e71f8db5 (cargo-release) version 0.1.1
Alessandro Decina 29955b2287 (cargo-release) version 0.1.1
Alessandro Decina 6d14a16d8e git add .cargo and xtask
Alessandro Decina cced3da5c8 Update to aya 0.10.5
Alessandro Decina 9ab9c80183 Simplify BpfLogger::init
Make BpfLogger::init(bpf) log using the default logger. Add
BpfLoger::init_with_logger(bpf, logger) for logging using a custom
logger instance.
Alessandro Decina 2ac433449c Minor tweaks to make the verifier's job easier
Alessandro Decina b14d4bab2f Switch to aya-ufmt
Alessandro Decina 22d8f86fbb Use aya_bpf::maps::PerfEventByteArray to output logs
Alessandro Decina 741957f945 Use aya_log_ebpf::ufmt instead of ::ufmt
Alessandro Decina 0d7ac3eb3e Add ufmt to readme
Alessandro Decina 5df853cfb0 Update readme
Alessandro Decina b29a061bce Initial commit
Alessandro Decina f9588a9daa
Merge pull request from athre0z/printk
bpf: add `bpf_printk!` helper
Joel Höner bfb5536f12 bpf: avoid stack-alloc for `fmt` in `bpf_printk!`
Joel Höner da13143c05 bpf: add `bpf_printk!` helper
The `bpf_printk!` macro is a helper providing a convenient way to invoke the
`bpf_trace_printk` and `bpf_trace_vprintk` BPF helpers. It is implemented as
a macro because it requires variadic arguments.
Michal Rostecki 6c9d814860
Merge pull request from vadorovsky/bpf-get-current-comm-u8
bpf: Change the result type of bpf_get_current_comm helper
Dave Tucker 73ee3cff70
Merge pull request from dave-tucker/btf-maps
Support Parsing of BTF Maps
Dave Tucker f976229477 Support BTF Maps
This commit allows for BTF maps in the .maps ELF section to be parsed.
It reads the necessary information from the BTF section of the ELF file.
While the btf_ids of Keys and Values types are stored, they are not (yet)
used.

When creating a BTF map, we pass the btf_key_type_id and
btf_value_type_id.

Signed-off-by: Dave Tucker <dave@dtucker.co.uk>
Michal Rostecki 480f6180f5
Merge pull request from vadorovsky/skb-load-bytes
bpf: Add `load_bytes` method to SKB context
Michal Rostecki c6e1d56684 bpf: Add `load_bytes` method to SKB context
This new method allows to load bytes into the given bytes slice, not
requiring to alloate the memory on stack. It can be used with
PerCpuArrays.

Example:

https://github.com/vadorovsky/aya-examples/blob/main/tc-bytes/tc-bytes-ebpf/src/main.rs

Signed-off-by: Michal Rostecki <vadorovsky@gmail.com>
Michal Rostecki f08bb022f7
Merge pull request from vadorovsky/fix-lint
bpf: Use `then_some` instead of `then(|| [...])`
Michal Rostecki ee15fbbbc5 bpf: Use `then_some` instead of `then(|| [...])`
This change fixes the `unnecessary_lazy_evaluations` clippy warning.

Signed-off-by: Michal Rostecki <vadorovsky@gmail.com>
Michal Rostecki a3a96b8415 bpf: Change the result type of bpf_get_current_comm helper
Change it from `[i8; 16]` to `[u8; 18]`. `i8` arrays cannot be easily used in
Rust for converting to string (i.e. with `core::str::from_utf8_unchecked`)
and developers have to convert them themselves with unsafe code.

Using u8 arrays lets developers to just convert it with
`core::str::from_utf8_unchecked` without any limitations.

Example:

https://github.com/vadorovsky/aya-examples/blob/main/clone/clone-ebpf/src/main.rs

Signed-off-by: Michal Rostecki <vadorovsky@gmail.com>
Alessandro Decina 6f301ac9ca
Merge pull request from vadorovsky/str
bpf(helpers): Add *_str_bytes helpers
Alessandro Decina fa4347aae4
Merge pull request from vadorovsky/rlimit-v2
aya: Raise the RLIMIT_MEMLOCK warning only if failed to create a map
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>
Dave Tucker a7fa938f1e
Merge pull request from vadorovsky/rlimit
aya: Raise the warning when RMILIT_MEMLOCK is not RLIM_INFINITY