Commit Graph

127 Commits (fbbf191bd3b12fafd2fb17a527c4855277df5869)

Author SHA1 Message Date
Tamir Duberstein 58ba66c003
xtask: watch for kernel panics on stderr
It seems these go to stderr, not stdout. Use `Ctrl-A x` to shut QEMU
down if a panic is seen.
1 year ago
Tamir Duberstein ca3f70b16a
aya-log: s/Result<usize, ()>/Option<NonZeroUsize>/
`Option<NonZeroUsize>` is guaranteed to have the same size as `usize`,
which is not guarnateed for `Result`. This is a minor optimization, but
also results in simpler code.
1 year ago
Tamir Duberstein 82a77bc83d
integration-test: Implement running on VMs
Implements running integration tests on multiple VMs with arbitrary
kernel images using `cargo xtask integration-test vm ...`.

This changes our coverage from 6.2 to 6.1 and 6.4.
1 year ago
Tamir Duberstein 84d5791d4e
Merge pull request #729 from aya-rs/logs-inline-always
log: annotate logging functions inlining
1 year ago
Dave Tucker e38e2566e3 aya, aya-obj: Implement ENUM64 fixups
This commit adds:

- A probe to see if the ENUM64 feature is supported
- Fixups for the use of signed enums, or enum64 types
  on systems where enum64 is not supported

Signed-off-by: Dave Tucker <dave@dtucker.co.uk>
1 year ago
Tamir Duberstein fe047d79a3
aya-log-common: Simplify
- Remove `TagLenValue`; this type has a single method, which is now a
  function.
- Remove generics from `TagLenValue::write` (now `write`). The tag is
  always `u8`, and the value is always a sequence of bytes.
- Replace slicing operations which can panic with calls to `get` which
  explicit check bounds.
1 year ago
Tamir Duberstein dc9f72adf0
test,xtask: Simplify ExitStatus handling 1 year ago
Tamir Duberstein bcbb7e08fa
Cargo.toml: Remove default-features settings
These are all set to false at the root.
1 year ago
Andrés Medina 8ebf0ac327
aya: Use OwnedFd in FdLink. 1 year ago
Dave Tucker e9153792f1
Merge pull request #720 from dave-tucker/programsection-noname
aya-obj: Remove name from ProgramSection
1 year ago
Addison Crump d8709de9f2
Extract trait SymbolResolver 1 year ago
Dave Tucker cca9b8f1a7 aya-obj: Remove name from ProgramSection
The name here is never used as we get the program name from the symbol
table instead.

Signed-off-by: Dave Tucker <dave@dtucker.co.uk>
1 year ago
Dave Tucker 77e9603976
Merge pull request #711 from dave-tucker/sleepable
Tidy up aya-bpf-macros (again)
1 year ago
Dave Tucker 677e7bda4a aya-obj: Propagate sleepable into ProgramSection
Signed-off-by: Dave Tucker <dave@dtucker.co.uk>
1 year ago
Tamir Duberstein a0af7e0b2f
programs: make `loaded_programs` opaque 1 year ago
Tamir Duberstein de8519a380
sys: extract common SyscallError
We currently have 4 copies of this.
1 year ago
Dave Tucker bf7fdff1ce aya: Find programs using the symbol table
This makes a few changes to the way that Aya reads the ELF object
files.

1. To find programs in a section, we use the symbols table. This allows
   for cases where multiple programs could appear in the same section.
2. When parsing our ELF file we build symbols_by_section_index as an
   optimization as we use it for legacy maps, BTF maps and now programs.

As a result of theses changes the "NAME" used in `bpf.prog_mut("NAME")`
is now ALWAYS the same as the function name in the eBPF code, making the
user experience more consistent.

Signed-off-by: Dave Tucker <dave@dtucker.co.uk>
1 year ago
Tamir Duberstein 8961be9526
Do not escape newlines on Err(LoadError).unwrap()
Wrap verifier logs in a newtype whose `Debug` impl emits unescaped
newlines. This improves ergonomics in tests where we `Result::unwrap()`
those load errors; when these fail today they emit the errors with
newlines escaped, making them incredibly difficult to read.
1 year ago
Tamir Duberstein 8d7545aff8
xtask: reverse public API diff direction
This is currently producing inverse diffs.
1 year ago
Tamir Duberstein 321bda7539
public-api: simplify and improve output 1 year ago
Dave Tucker f833f1fc1d xtask: Add cargo-public-api
Adds cargo-public-api. This allows for public API changes to get caught
in CI, requiring new changes to be "blessed" by using:

  cargo xtask public-api --bless

When this file is changed for aya, Alessandro will need to review the PR.

Signed-off-by: Dave Tucker <dave@dtucker.co.uk>
1 year ago
Tamir Duberstein a6b1fb9a1e xtask: allow arbitrary flags to cargo build 1 year ago
Tamir Duberstein 74fc50bf7e
integration-test: shuttle stdio to user
Trampoline cargo-in-cargo stdio through cargo:warning to ensure the user
sees all the output.

Use bpf-linker from git in CI so we can see what's going on there.
1 year ago
Mike Rostecki 96fa08bd82 cargo: Define dependencies on the workspace level
This way we will avoid version mismatches and make differences in
features across our crates clearer.
1 year ago
Tamir Duberstein e276c07f73
integration-ebpf: invalidate on bpf-linker
Extract the symlink-to-bpf-linker logic from integration-test to xtask
and use it in a new build script in integration-ebpf, causing ebpf
probes to be rebuilt when bpf-linker changes. Previously bpf-linker
changes would rebuild integration-test, but not integration-ebpf,
resulting in stale tests.

Note that this still doesn't address the possibility that a new
bpf-linker is added to the PATH ahead of the cached one. Solving this in
the general case would require rebuild-if-changed-env=PATH *and*
rebuild-if-changed={every-directory-in-PATH} which would likely mean far
too much cache invalidation.
1 year ago
Andrew Werner d5259ce789 xtask: move libbpf submodule 1 year ago
Andrew Werner 15b3c459ae xtask: ensure libbpf submodule is initialized
Libbpf is used by xtasks, in the command, ensure that the submodules
are initialized. This eases the user-experience so that users don't
need to think about the submodule, while retaining all the benefits
of using a submodule vs forcing the user to manually check out libbpf
and stick it in some pre-defined place.

We use the symbol pointing to libbpf in xtask in the build script
to avoid repeating this constant.

Also, we install git in the vm so that we can init the submodule
when we build in the vm.
1 year ago
Tamir Duberstein 40f24fe8e1
site: generate docs for logging crates 1 year ago
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