Commit Graph

149 Commits (81f634abc688fc72dafd2ee379d763a663d0d33d)

Author SHA1 Message Date
Tamir Duberstein b86d42d1b0
xtask: remove assumptions from docs command
This slightly changes the site layout: crate documentation is now flat
rather than being nested under "user" and  "bpf".

- Run `cargo clean --doc` before generating docs to ensure hermiticity.
- Generate header.html into a temporary directory.
- Remove "site" on each run to ensure hermiticity.
- Invoke cargo only once.
- Avoid editing sources.
1 year ago
Tamir Duberstein 6ac1320707
integration-test: build "fake" by default
Use the environment variable AYA_BUILD_INTEGRATION_BPF to indicate to
the build script that it should *actually* build bpf, otherwise emitting
empty files.

This allows metadata builds to skip costly build steps without
sacrificing ergonomics; all compile-time tools such as cargo clippy work
out of the box.

Cargo even gives each of these builds (depending on the value of the
environment variable) its own cache key, so they do not invalidate each
other when the user alternates between metadata and real builds.

This allows the lint action to move out of the VM.
1 year ago
Tamir Duberstein 9086265ac0
xtask: reimplement build-integration-test
This command builds the integration test binaries and prints their paths
to stdout.
1 year ago
Tamir Duberstein 3d463a3610
integration-test: compile Rust probes using build.rs 1 year ago
Tamir Duberstein bc9f059d53
xtask: inline build_ebpf 1 year ago
Tamir Duberstein 8c61fc9ea6
integration-test: compile C probes using build.rs
- Add libbpf as a submodule. This prevents having to plumb its location
  around (which can't be passed to Cargo build scripts) and also
  controls the version against which codegen has run.
- Move bpf written in C to the integration-test crate and define
  constants for each probe.
- Remove magic; each C source file must be directly enumerated in the
  build script and in lib.rs.
1 year ago
Tamir Duberstein e621a09181
Clippy over tests and integration-ebpf
Replace all `assert!(matches!(..))` with `assert_matches!(..)`.

Remove the now-unused build-integration-test xtask command whose logic
doesn't match that of the build-and-run command.
1 year ago
Tamir Duberstein b0a4ab5f20
xtask: Standardize command logging
Don't run `cargo build --verbose`; it's too noisy.
1 year ago
Tamir Duberstein 27120b328a
aya: don't allocate static strings 1 year ago
Tamir Duberstein 9ca0af1a79
integration-test: Remove integration-test-macros
This doesn't add any value; use `cargo build --tests` with
`--message-format=json` instead; parse the output using `cargo_metadata`
to discover the location of the test binary.

Move test/integration-test/src/tests -> test/integration-test/tests to
conform to
https://doc.rust-lang.org/book/ch11-03-test-organization.html#integration-tests.
1 year ago
Tamir Duberstein ecc03ecfad
xtask: destructure 1 year ago
Tamir Duberstein de1fe1f5e1
xtask: Avoid lossy conversions, spurious vectors 1 year ago
Tamir Duberstein 25859e4e33
xtask: emit clang command on failure 1 year ago
Tamir Duberstein 7067db450a
xtask: Avoid lossy string conversion 1 year ago
Tamir Duberstein 5a2906a6c9
test,xtask: Replace lazy_static with OnceCell
This doesn't affect MSRV because this is testing code.
1 year ago
Tamir Duberstein ff86f1385c
Remove dependency on bpftool in integration tests 1 year ago
vadorovsky a06a5ae07e
Merge pull request #598 from nak3/add-user_regs_strct
xtask: codegen: generate bindings for user_regs_struct
1 year ago
Kenjiro Nakayama 8c8d236f42 xtask: codegen: generate bindings for user_regs_struct
This patch adds `user_regs_struct`.

riscv provides struct user_regs_struct instead of struct pt_regs to userspace.
After bindings generates the code, adding the riscv support in `bpf/aya-bpf/src/args.rs`
then aya-bpf can be built for riscv.
1 year ago
dependabot[bot] 45072c0789 build(deps): update syn requirement from 1.0 to 2.0
Updates the requirements on [syn](https://github.com/dtolnay/syn) to permit the latest version.
- [Release notes](https://github.com/dtolnay/syn/releases)
- [Commits](https://github.com/dtolnay/syn/compare/1.0.0...2.0.3)

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

Signed-off-by: dependabot[bot] <support@github.com>
1 year ago
Michal Rostecki ed9c2a1780 integration-tests: Build eBPF programs always with release profile
Also, add the `codegen-unit` option to the profile.
1 year ago
Tuetuopay 23e7c65244 xtask: generate userspace bindings for bpf_{cpu,dev}map_val 2 years ago
dependabot[bot] 912ee06f39
build(deps): update indoc requirement from 1.0 to 2.0
Updates the requirements on [indoc](https://github.com/dtolnay/indoc) to permit the latest version.
- [Release notes](https://github.com/dtolnay/indoc/releases)
- [Commits](https://github.com/dtolnay/indoc/compare/1.0.0...2.0.0)

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

Signed-off-by: dependabot[bot] <support@github.com>
2 years ago
Alessandro Decina 455cc95e8f integration-tests: run on macos to get nested virtualization
Switch integration-test host to macos as only macos runners support nested
virtualization. Adjust integration test runner accordingly.
2 years ago
Michal Rostecki 7d19bde66b Unpin Rust nightly
The issues with core::sync::atomic got fixed.

Signed-off-by: Michal Rostecki <vadorovsky@gmail.com>
2 years ago
Alessandro Decina d33ed21fc4 Pin nightly to nightly-2023-01-10
This until https://github.com/rust-lang/rust/pull/106796 gets fixed
2 years ago
Matteo Nardi 3000949bcc Remove libbpf dependency from relocation tests
Simplifiy the relocation tests build process by removing the need for libbpf
at runtime. Its usage is replaced with local `__builtin_*` attributes.
This removes the need for the `LIBBPF_INCLUDE` env variable.
2 years ago
Matteo Nardi 702f77b565 tests: explain libbpf env variable 2 years ago
Matteo Nardi 7e6a7d9005 btf: add integration tests for relocations
Add new integrations tests for BTF relocations.
2 years ago
Shenghui Ye 81bc307dce aya-obj: migrate bindgen destination
Aya::obj depends on bindgen generated files, and we start
by migrating bindgen generated files.

This commit adds the new aya-obj crate to the workplace
and migrates generated files into the crate. We use core
instead of std in an effort to make the final crate no_std.

Bindgen was run against libbpf v1.0.1.

Refs: #473
2 years ago
Alessandro Decina 63bbef46da Fix lints 2 years ago
Dmitry Savintsev 055d94f58b fix uninlined_format_args clippy issues 2 years ago
Dmitry Savintsev 22340764a3 upgrade clap to 4.x 2 years ago
Alessandro Decina 832bdd280c {{crate_name}}: release version 0.1.13 2 years ago
Dmitry Savintsev d0424fb091 fix clippy needless_borrow warning 2 years ago
Andrew Stoycos 82edd681c3 Fix doc links, update rustdoc args
Fix some broken rust doc links.

Make sure rustdoc build fail on warnings
so we catch these broken links in CI.

Signed-off-by: Andrew Stoycos <astoycos@redhat.com>
2 years ago
Dave Tucker ec2bd69053 cargo: Remove unused dependencies
Signed-off-by: Dave Tucker <dave@dtucker.co.uk>
2 years ago
Dave Tucker 95e8c78db8 docs: Add labels for optional features
Following the lead of crates like tokio and nix, we now annotate APIs
that require optional features. This helps in cases where a user wants
to have an `AsyncPerfEventArray` which is documented on crates.io, but
it's not obvious that you have to enable the `async` feature.

Signed-off-by: Dave Tucker <dave@dtucker.co.uk>
2 years ago
Dave Tucker a8eef00595 clippy: Fix latest nightly lints
Signed-off-by: Dave Tucker <dave@dtucker.co.uk>
2 years ago
Dave Tucker bc088921b8 codgen: Add bpf_link_type
Signed-off-by: Dave Tucker <dave@dtucker.co.uk>
2 years ago
Dave Tucker a0641c15e4 codegen: Add bpf_map_info and bpf_link_info
Signed-off-by: Dave Tucker <dave@dtucker.co.uk>
2 years ago
Dave Tucker aaa20cc1fd aya-gen: Rename to aya-tool
Signed-off-by: Dave Tucker <dave@dtucker.co.uk>
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 5e6b75a29a xtask: Fix integration-test command
Signed-off-by: Dave Tucker <dave@dtucker.co.uk>
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
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
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
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
Davide Bertola cda9ab4f66 upgrade from structopt to clap 3 2 years ago
crabby-the-crab de4e97aa51
Revert "docs: Merge search indexes" 2 years ago
Dave Tucker a00d16dc0e docs: Merge search indexes
Signed-off-by: Dave Tucker <dave@dtucker.co.uk>
2 years ago
William Findlay 777e6a2a5d xtask/codegen: generate bindings for BPF_RINGBUF types 2 years ago
Dave Tucker 9a33b6b654 aya-gen: Remove getters
Signed-off-by: Dave Tucker <dave@dtucker.co.uk>
2 years ago
gianluigi d35680f30c Add riscv64 architecture support to xtask/codegen 2 years ago
Dave Tucker ba312c48d5 xtask: Add all crates to sidebar
Signed-off-by: Dave Tucker <dave@dtucker.co.uk>
2 years ago
Kenjiro Nakayama 42baf1c074 Remove bpf_adj_room_mode 2 years ago
Kenjiro Nakayama 200d42e414 xtask: Add `bpf_.*` instead of `bpf_map_.*` to allowed type
This patch replaces `bpf_map_.*` with `bpf_.*`.

Currently some types that are not used in helper functions are not generated for bindings - e.g. `bpf_sk_lookup`, `bpf_sockopt` and etc.
This patch replaces `bpf_map_.*` with `bpf_.*`.

Note, this PR does not include bindings files as it would be better to be created by auto script.
The missing bindings can be created by `cargo xtask codegen --libbpf-dir /<PATH_TO>/libbp`.
2 years ago
Dave Tucker 8205bee930 xtask: Add docs build
Signed-off-by: Dave Tucker <dave@dtucker.co.uk>
2 years ago
Dave Tucker 19af687480 codegen: add btf_decl_tag
This is required to add support for BTF_KIND_DECL_TAG

Signed-off-by: Dave Tucker <dave@dtucker.co.uk>
3 years ago
Ubuntu 0beb0c501f Add bpf_lpm_trie_key to aya codegen to generate bindings 3 years ago
Dave Tucker f8021c33fc codegen: Add bindings for BPF_F flags
Signed-off-by: Dave Tucker <dave@dtucker.co.uk>
3 years ago
Dave Tucker 23d1920854 codegen: add bindings for btf structs
This adds `bpf_btf_info` which can be used to get BPF information via a
syscall. It also adds `btf_line_info` and `btf_func_info` which are
required to parse the line and func info sections of BTF

Signed-off-by: Dave Tucker <dave@dtucker.co.uk>
3 years ago
Alessandro Decina d341b58293 xtask: codegen: generate bindings for user_pt_regs
user_pt_regs is used in aarch64 instead of pt_regs
3 years ago
Alessandro Decina eb654d1e3e xtask: codegen: fix bindings for archs other than x86 3 years ago
Alessandro Decina 75acbe1455 xtask: fix clippy warning 3 years ago
alessandrod 03e9935358 Bump libbpf to 92c1e61a605410b16d6330fdd4a7a4e03add86d4
Signed-off-by: Dave Tucker <dave@dtucker.co.uk>
3 years ago
Alessandro Decina 7af1cf136c aya: generate bindings for more perf types 3 years ago
Alessandro Decina 4fcb1d75b9 aya-gen: bump bindgen to 0.59 3 years ago
Alessandro Decina ca14306860 aya-gen: use aya_bpf::cty instead of aya_bpf_cty
This avoids having to add an explicit extra dep on aya-bpf-cty in ebpf
programs
3 years ago
Alessandro Decina 2d16843d5d xtask: clippy warnings 3 years ago
Simone Margaritelli 8311abfdcb
added support for armv7-unknown-linux-gnueabi and armv7-unknown-linux-gnueabihf
* new: added support for armv7-unknown-linux-gnueabi (closes alessandrod/aya/issues/22)

* fix: replaced custom type defintions with proper libc types

* fix: fixed pointless parameter binding

* new: added linker for armv7-unknown-linux-gnueabihf to cargo config
3 years ago
Alessandro Decina 35e9b4e639 bpf: don't generate bpf_map_def and fix aya_bpf::bindings overrides 3 years ago
Alessandro Decina a847d6d53b xtask: aya-bpf-bindings: add bpf_adj_room_mode 3 years ago
Alessandro Decina 8cd669ca9a xtask: fix include paths for kernel headers bundled with libbpf 3 years ago
Arnabjyoti Kalita 6974d349e8
programs: add support for attaching and detaching TC programs
This change adds support for attaching TC programs directly from aya, without
having to use iproute2/tc.
3 years ago
Alessandro Decina 157c0e2831 bpf: generate bindings for SOL_SOCKET and SO_* socket options
This is needed for bpf_getsockopt() and bpf_setsockopt()
3 years ago
Alessandro Decina 5effc972ac aya: add support for BPF_PROG_TYPE_SCHED_CLS programs 3 years ago
Alessandro Decina c44393d59b xtask: codegen: use uapi kernel headers from libbpf
libbpf periodically syncs uapi headers from the kernel. Use those to
generate bindings so that we don't have to rely on distro packages
when we cut releases.
3 years ago
Alessandro Decina dda8534d9d xtask: aya-bpf-bindings: generate bindings for xdp_action 3 years ago
Alessandro Decina 696ca1ffa8 aya-bpf-bindings: generate bindings for pt_regs and sk_action 4 years ago
Alessandro Decina d9634ae945 aya: add maps::StackTraceMap
Map type for BPF_MAP_TYPE_STACK_TRACE.
4 years ago
Alessandro Decina f9554d6db5 aya: fix bindings for PERF_EVENT_IOC_{ENABLE|DISABLE|SET_BPF} 4 years ago
Alessandro Decina 92b4ed2664 aya: add support for function calls 4 years ago
Alessandro Decina 29f2d9b2d9 aya: switch to rustified enums 4 years ago
Alessandro Decina bdca32cebf aya-bpf-bindings: fix anonymous enums 4 years ago
Alessandro Decina f0444233b3 xtask: rework command line
xtask codegen --libbpf-dir <libbpf-dir> [SUBCOMMAND]

If SUBCOMMAND (eg aya or aya-bpf-bindings) is not given, codegen
everything.
4 years ago
Alessandro Decina 9d112c35c7 xtask: aya-bpf-bindings: generate bindings for aarch64 4 years ago
Alessandro Decina fb0c8f0bc9 xtask: add code generator for aya 4 years ago
Alessandro Decina d9c3489165 aya-gen: rename probe_read_getter to read_getter
The same code can be used to wrap with preserve_access_index()
4 years ago
Alessandro Decina 9cd04a79e7 xtask: use more aya-gen 4 years ago
Alessandro Decina 16975e87d8 xtask: rework code generator for bpf helpers 4 years ago
Alessandro Decina 7ae3ddf2fa xtask: use aya-gen to generate the getters 4 years ago
Alessandro Decina 7815711196 bpf: add aya-bpf-bindings
Move the generated bindings to aya-bpf-bindings.
4 years ago
Alessandro Decina b5cb1f479f xask: add bindings::write 4 years ago
Alessandro Decina ee205627b7 xtask: rename bindgen module to bindings 4 years ago
Alessandro Decina 1bb3846071 xtask: fix getters source order
Generate getters in the same order as the fields they access. Avoids git
noise and makes for better docs.
4 years ago
Alessandro Decina 25170a539b xtask: start moving bindgen to its own module 4 years ago
Alessandro Decina dc15c978f5 aya-bpf: generate bpf_probe_read getters for kernel types 4 years ago
Alessandro Decina cdf960aaa1 bpf: initial bpf bindings 4 years ago