Commit Graph

233 Commits (dependabot/github_actions/github-actions-47e489e734)

Author SHA1 Message Date
Alessandro Decina 0f6a734392 aya: perf_event: add inherit argument to attach() 8 months ago
Alessandro Decina 92b1947885 aya: add StackTraceMap::remove() 8 months ago
Tamir Duberstein 057f27dc20 public-api: regenerate
StructuralEq has been removed.

See 0df7810734.
8 months ago
Tamir Duberstein 1edd42aa0a
public-api: regenerate
`Send + Sync` became `Sync + Send` for reasons I don't understand.
9 months ago
Alessandro Decina e1aefa4e87 aya: bless API change 9 months ago
Tamir Duberstein 1e99ac9323
Merge pull request #853 from tamird/public-api-mac
xtask: allow public-api regen on aarch64-apple-darwin
9 months ago
dependabot[bot] b3ec33e763
build(deps): update public-api requirement from 0.32.0 to 0.33.1
Updates the requirements on [public-api](https://github.com/Enselic/cargo-public-api) to permit the latest version.
- [Release notes](https://github.com/Enselic/cargo-public-api/releases)
- [Changelog](https://github.com/Enselic/cargo-public-api/blob/main/rustdoc-json/CHANGELOG.md)
- [Commits](https://github.com/Enselic/cargo-public-api/compare/v0.32.0...v0.32.0)

---
updated-dependencies:
- dependency-name: public-api
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <support@github.com>
9 months ago
Tamir Duberstein 5041aa41de
xtask: allow public-api regen on aarch64-apple-darwin
```
CARGO_CFG_BPF_TARGET_ARCH=x86_64 cargo +nightly xtask public-api --bless --target x86_64-unknown-linux-gnu
```
9 months ago
Tamir Duberstein 7a4c6153a0
xtask: terminate QEMU on "RCU grace-period kthread stack dump"
See
https://github.com/aya-rs/bpf-linker/actions/runs/7067897954/job/19241830198
10 months ago
astoycos b1769678f4 aya/maps: pin for (async)perf_event_array
Implement pinning for perf_event_array and async_perf_event_array.
Additionally make the core MapData.pin method operate on a reference
rather than a mutable reference.

Signed-off-by: astoycos <astoycos@redhat.com>
10 months ago
Andrew Werner c06fcc3eda maps/ringbuf: make RingBuf: Send + Sync
There was no reason for them not to be -- the APIs all require mutable
references and hold onto mutable references, so there cannot be internal
concurrency. The !Send + !Sync came from the MMap, but not for any good
reason.
10 months ago
Adam Preuss 4d24d1cfe8 aya: add MapInfo struct following the same pattern as ProgramInfo
This makes the APIs for loading maps and programs more similar.
10 months ago
Adam Preuss 36420d9297 aya: support loading a map by fd
This adds support to loading maps by fd similarly to the way programs
can be loaded by fd.
10 months ago
Andrés Medina 68ba02002f aya: make KernelVersion::code public 10 months ago
Tamir Duberstein 42cc175aeb
xtask: attempt to open /dev/kvm
We're seeing test failures where KVM is present but we aren't able to use it.

See https://github.com/actions/runner-images/issues/7670#issuecomment-1760184162.
11 months ago
Tamir Duberstein 6e256fad5b public-api: bless with new nightly
See https://github.com/rust-lang/rust/commit/58a80c85b9323e59e1b7e744d6.
11 months ago
dependabot[bot] c89b2d156d
build(deps): update async-io requirement from 1.3 to 2.0
Updates the requirements on [async-io](https://github.com/smol-rs/async-io) to permit the latest version.
- [Release notes](https://github.com/smol-rs/async-io/releases)
- [Changelog](https://github.com/smol-rs/async-io/blob/master/CHANGELOG.md)
- [Commits](https://github.com/smol-rs/async-io/compare/v1.3.0...v1.13.0)

---
updated-dependencies:
- dependency-name: async-io
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <support@github.com>
11 months ago
Andrew Werner e2cf734490 aya: Implement RingBuf
This implements the userspace binding for RingBuf.

Instead of streaming the samples as heap buffers, the process_ring
function takes a callback to which we pass the event's byte region,
roughly following [libbpf]'s API design. This avoids a copy and allows
marking the consumer pointer in a timely manner.

[libbpf]: https://github.com/libbpf/libbpf/blob/master/src/ringbuf.c

Additionally, integration tests are added to demonstrate the usage
of the new APIs and to ensure that they work end-to-end.

Co-authored-by: William Findlay <william@williamfindlay.com>
Co-authored-by: Tatsuyuki Ishi <ishitatsuyuki@gmail.com>
11 months ago
Andrew Werner b73c0a46f5
aya: impl From<obj::InvalidMapTypeError> for MapTypeError 11 months ago
Tamir Duberstein 5cdd1baf29
aya: import types from std::ffi rather than libc 11 months ago
astoycos 7b71c7e1cd aya/maps: add pin() api
- Adds new `maps_mut()` API to the BpfManager to allow us to iterate though
and pin all of maps at the same time.

- Adds new pin(Path)/unpin(Path) api to Maps so they
can be generically pinned AFTER load.

- Adds macro for pinning explicit map types in aya.
Convert all explicit map types "inner" field to be
pub crate in order to facilitate this.

Signed-off-by: astoycos <astoycos@redhat.com>
12 months ago
Tamir Duberstein 5392f9821d
xtask: terminate QEMU on "BUG: soft lockup"
See
https://github.com/aya-rs/aya/actions/runs/6329828507/job/17190931752.

Unlike on kernel panic this message prints periodically so it is
permitted to print twice before QEMU is killed.
12 months ago
Tamir Duberstein d16e607fd4
rustfmt: group_imports = "StdExternalCrate"
High time we stop debating this; let the robots do the work.
12 months ago
Tamir Duberstein fe13b2eb41
xtask: remove useless copy
/tmp/initrd.img is unused.
12 months ago
Tamir Duberstein cbe9cd9133
xtask: appease new clippy warning
```
warning: unnecessary hashes around raw string literal
  --> xtask/src/docs.rs:70:17
   |
70 |           indoc! {r#"
   |  _________________^
71 | |     User-Agent:*
72 | |     Disallow: /
73 | |     "#},
   | |______^
   |
   = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_raw_string_hashes
   = note: `#[warn(clippy::needless_raw_string_hashes)]` on by default
help: remove all the hashes around the literal
   |
70 ~         indoc! {r"
71 |     User-Agent:*
72 |     Disallow: /
73 ~     "},
   |
```

This false negative was fixed in
https://github.com/rust-lang/rust-clippy/pull/11518 (the title
incorrectly says false positive).
12 months ago
Tuetuopay 0edc13b4d4 bpf: add a shared try_redirect_map function for XDP maps 1 year ago
Tuetuopay 579e3cee22 aya, bpf: misc fixes following review comments 1 year ago
Tuetuopay 46551de3e7 xtask: bless public-api 1 year ago
Dave Tucker 42fd82e32b
Merge pull request #790 from dave-tucker/no-map-pinned 1 year ago
Dave Tucker 938f979fe7 aya: Make MapData::pin pub
This is to solve a use-case where a user (in this case bpfd) may want
to:

- MapData::from_pin to open a pinned map from bpffs
- MapData::pin to pin that object into another bpffs

Both operations should be easily accomplished without needing to cast
a MapData into a concrete Map type - e.g aya::maps::HashMap.

Signed-off-by: Dave Tucker <dave@dtucker.co.uk>
1 year ago
Dave Tucker 0f4021ec89 aya: Remove MapData::pinned
BPF objects can be pinned multiple times, to multiple different places.
Tracking whether or not a map is pinned in a bool is therefore not sufficient.
We could track this in a HashSet<PathBuf>, but there is really no reason
to track it at all.

Signed-off-by: Dave Tucker <dave@dtucker.co.uk>
1 year ago
Andrew Stoycos 0b6ea313de
Merge pull request #782 from astoycos/prog-info
aya: add program_info() api to `Program`
1 year ago
Tamir Duberstein f41592663c
maps: `MapFd` and `SockMapFd` are owned
`MapData::fd` is now a `MapFd`. This means that `MapData` now closes the
file descriptor on drop. In the future we might consider making `MapFd`
hold a `BorrowedFd` but this requires API design work due to overlapping
borrows.

Since `SockMapFd` is no longer `Copy`, attach methods to take it by
reference to allow callers to use it multiple times as they are
accustomed to doing.

`SockMapFd` implements `try_clone`. `MapFd` and `SockMapFd` are now
returned by reference to allow callers to avoid file descriptor cloning
when desired.

This is an API breaking change.

Updates #612.
1 year ago
astoycos 6ab7475fa6 aya: add program_info() api to program
Add a new api to the outer level `Program` structure which
allows users to get the program's kernel info before casting
it to an explicit program variant.

Signed-off-by: astoycos <astoycos@redhat.com>
1 year ago
Tamir Duberstein 92d3056db3
Merge pull request #775 from aya-rs/perf-as-raw-fd
async_perf_event_array: access inner through async
1 year ago
Andrew Werner 2a1bf609b2 aya/maps: rework TryFrom macros
The old macros were repetitive and inflexible. This unifies the various
macros used to generate TryFrom implementations for map implementations
from the relevant map enum variants.

Cleanup in anticipation of fixing #636.

The API changes are just about renaming the return to Self and
Self::Error; they are not real changes.
1 year ago
Tamir Duberstein 8b0c7f1204
async_perf_event_array: access inner through async
Avoid holding onto raw file descriptors.

Remove some implied bounds (BorrowMut implies Borrow).
1 year ago
Andrés Medina 6895b1e2ed
aya: Use AsFd when attaching fds to programs
This is a breaking change but adds another level of safety to ensure
the file descriptor we receive is valid. Additionally, this allows
aya to internally easily duplicate this file descriptor using std
library methods instead of manually calling `dup` which doesn't
duplicate with the CLOSE_ON_EXEC flag that is standard pratice to
avoid leaking the file descriptor when exec'ing.
1 year ago
Tamir Duberstein 782eb85d4a
xtask: extract `Errors` type
This produces better errors in `cargo xtask public-api` because before
this change we'd print errors as display, which didn't show context.

Before:
```
Error: public API errors:
aya failed to check public API: public_api::Builder::build
aya-obj failed to check public API: public_api::Builder::build
aya-log failed to check public API: public_api::Builder::build
aya-log-common failed to check public API: public_api::Builder::build
aya-log-parser failed to check public API: public_api::Builder::build
aya-tool failed to check public API: public_api::Builder::build
aya-bpf failed to check public API: public_api::Builder::build
aya-bpf-bindings failed to check public API: public_api::Builder::build
aya-bpf-cty failed to check public API: public_api::Builder::build
aya-bpf-macros failed to check public API: public_api::Builder::build
aya-log-ebpf-macros failed to check public API: public_api::Builder::build
```

After:
```
Error: aya failed to check public API

Caused by:
    0: public_api::Builder::build
    1: unknown variant `type_alias`, expected one of `module`, `extern_crate`, `import`, `struct`, `struct_field`, `union`, `enum`, `variant`, `function`, `typedef`, `opaque_ty`, `constant`, `trait`, `trait_alias`, `impl`, `static`, `foreign_type`, `macro`, `proc_attribute`, `proc_derive`, `assoc_const`, `assoc_type`, `primitive`, `keyword` at line 1 column 3082463
aya-obj failed to check public API

Caused by:
    0: public_api::Builder::build
    1: unknown variant `type_alias`, expected one of `module`, `extern_crate`, `import`, `union`, `struct`, `struct_field`, `enum`, `variant`, `function`, `trait`, `trait_alias`, `impl`, `typedef`, `opaque_ty`, `constant`, `static`, `foreign_type`, `macro`, `proc_macro`, `primitive`, `assoc_const`, `assoc_type` at line 1 column 129355
aya-log failed to check public API

Caused by:
    0: public_api::Builder::build
    1: unknown variant `type_alias`, expected one of `module`, `extern_crate`, `import`, `struct`, `struct_field`, `union`, `enum`, `variant`, `function`, `typedef`, `opaque_ty`, `constant`, `trait`, `trait_alias`, `impl`, `static`, `foreign_type`, `macro`, `proc_attribute`, `proc_derive`, `assoc_const`, `assoc_type`, `primitive`, `keyword` at line 1 column 311910
aya-log-common failed to check public API

Caused by:
    0: public_api::Builder::build
    1: unknown variant `type_alias`, expected one of `module`, `extern_crate`, `import`, `union`, `struct`, `struct_field`, `enum`, `variant`, `function`, `trait`, `trait_alias`, `impl`, `typedef`, `opaque_ty`, `constant`, `static`, `foreign_type`, `macro`, `proc_macro`, `primitive`, `assoc_const`, `assoc_type` at line 1 column 130456
aya-log-parser failed to check public API

Caused by:
    0: public_api::Builder::build
    1: unknown variant `type_alias`, expected one of `module`, `extern_crate`, `import`, `struct`, `struct_field`, `union`, `enum`, `variant`, `function`, `typedef`, `opaque_ty`, `constant`, `trait`, `trait_alias`, `impl`, `static`, `foreign_type`, `macro`, `proc_attribute`, `proc_derive`, `assoc_const`, `assoc_type`, `primitive`, `keyword` at line 1 column 204930
aya-tool failed to check public API

Caused by:
    0: public_api::Builder::build
    1: unknown variant `type_alias`, expected one of `module`, `extern_crate`, `import`, `struct`, `struct_field`, `union`, `enum`, `variant`, `function`, `typedef`, `opaque_ty`, `constant`, `trait`, `trait_alias`, `impl`, `static`, `foreign_type`, `macro`, `proc_attribute`, `proc_derive`, `assoc_const`, `assoc_type`, `primitive`, `keyword` at line 1 column 234519
aya-bpf failed to check public API

Caused by:
    0: public_api::Builder::build
    1: unknown variant `type_alias`, expected one of `module`, `extern_crate`, `import`, `struct`, `struct_field`, `union`, `enum`, `variant`, `function`, `typedef`, `opaque_ty`, `constant`, `trait`, `trait_alias`, `impl`, `static`, `foreign_type`, `macro`, `proc_attribute`, `proc_derive`, `assoc_const`, `assoc_type`, `primitive`, `keyword` at line 1 column 741697
aya-bpf-bindings failed to check public API

Caused by:
    0: public_api::Builder::build
    1: unknown variant `type_alias`, expected one of `module`, `extern_crate`, `import`, `union`, `struct`, `struct_field`, `enum`, `variant`, `function`, `trait`, `trait_alias`, `impl`, `typedef`, `opaque_ty`, `constant`, `static`, `foreign_type`, `macro`, `proc_macro`, `primitive`, `assoc_const`, `assoc_type` at line 1 column 112445
aya-bpf-cty failed to check public API

Caused by:
    0: public_api::Builder::build
    1: unknown variant `type_alias`, expected one of `module`, `extern_crate`, `import`, `union`, `struct`, `struct_field`, `enum`, `variant`, `function`, `trait`, `trait_alias`, `impl`, `typedef`, `opaque_ty`, `constant`, `static`, `foreign_type`, `macro`, `proc_macro`, `primitive`, `assoc_const`, `assoc_type` at line 1 column 315
aya-bpf-macros failed to check public API

Caused by:
    0: public_api::Builder::build
    1: unknown variant `type_alias`, expected one of `module`, `extern_crate`, `import`, `struct`, `struct_field`, `union`, `enum`, `variant`, `function`, `typedef`, `opaque_ty`, `constant`, `trait`, `trait_alias`, `impl`, `static`, `foreign_type`, `macro`, `proc_attribute`, `proc_derive`, `assoc_const`, `assoc_type`, `primitive`, `keyword` at line 1 column 186226
aya-log-ebpf-macros failed to check public API

Caused by:
    0: public_api::Builder::build
    1: unknown variant `type_alias`, expected one of `module`, `extern_crate`, `import`, `struct`, `struct_field`, `union`, `enum`, `variant`, `function`, `typedef`, `opaque_ty`, `constant`, `trait`, `trait_alias`, `impl`, `static`, `foreign_type`, `macro`, `proc_attribute`, `proc_derive`, `assoc_const`, `assoc_type`, `primitive`, `keyword` at line 1 column 158055
```
1 year ago
Tamir Duberstein 1ccfdbc175
aya: support non-UTF8 probing
Fixes #751.
1 year ago
Tamir Duberstein 0bba9b14b0
maps,programs: avoid path UTF-8 assumptions 1 year ago
Tamir Duberstein ff8c124770
Merge pull request #763 from aya-rs/lints
aya: deny various allow-by-default lints
1 year ago
Tamir Duberstein ca2e43d318
integration-test: Remove cargo symlink workaround
https://github.com/rust-lang/cargo/pull/12369 fixed this bug and was
picked up in https://github.com/rust-lang/rust/pull/114027.
1 year ago
Tamir Duberstein abda239d63
aya: deny various allow-by-default lints
Notably:
- clippy::use_self: replaced many T with Self.
- single_use_lifetimes: removed some single use lifetimes.
- unreachable_pub: removed some unreachable pub items.
- unused_crate_dependencies: removed unused futures,parking_lot deps.
- unused_qualifications: found a potential `crate` vs `$crate` bug.
- let_underscore_drop: not enabled, seems to trigger false positives.
- missing_copy_implementations: not enabled, unclear if we want this.
- unsafe_op_in_unsafe_fn: not enabled, unclear if we want this.
- unused_results: not enabled, needs many fixes (but I think wanted).
1 year ago
Tamir Duberstein a31544b6e7
maps: BloomFilter::insert takes &mut self
This is consistent with all the other maps.
1 year ago
Tamir Duberstein 89bc255f1d
aya: MapData::fd is non-optional
The primary driver of change here is that `MapData::create` is now a
factory function that returns `Result<Self, _>` rather than mutating
`&mut self`. The remaining changes are consequences of that change, the
most notable of which is the removal of several errors which are no
longer possible.
1 year ago
Tamir Duberstein ae6526e59b
programs: `ProgramData::attach_prog_fd` is owned
This prevents a file descriptor leak when extensions are used.

This is an API breaking change.

Updates #612.
1 year ago
Tamir Duberstein 8b3a93161d
xtask: bless API with new nightly 1 year ago
Tamir Duberstein 504fd1df0a
programs: `ProgramFd` is owned
`ProgramData::fd` is now a `ProgramFd`. This means that `ProgramData`
now closes the file descriptor on drop. In the future we might consider
making `ProgramFd` hold a `BorrowedFd` but this requires API design work
due to overlapping borrows.

Since `ProgramFd` is no longer `Copy`, update methods to take it by
reference to allow callers to use it multiple times as they are
accustomed to doing.

`ProgramFd` is now returned by reference and implements `try_clone` to
allow callers to avoid file descriptor cloning when desired.

This is an API breaking change.

Updates #612.
1 year ago
Andrew Stoycos bcc9743254
Merge pull request #637 from astoycos/helpers
Add more helpful methods to `ProgramInfo`
1 year ago
Andrew Stoycos e1a556894c
aya: add helper methods for ProgramInfo
- Add helper methods to get useful information from the ProgramInfo
object which is returned by the `loaded_programs()` API.  Specifically
this code mirrors the `bpftool prog` command in terms of useful fields.
- Add a new API macro to each aya `Program` type to allow us to fetch
its accompanying `ProgramInfo` metadata after its been loaded.
- Add a new ProgramInfo constructor that builds a new instance using
a raw fd.
- Add a smoke test for the loaded_programs() API as well as
all the relevant methods on the ProgramInfo type.

Signed-off-by: Andrew Stoycos <astoycos@redhat.com>
1 year ago
Dave Tucker db975e9778 aya: Don't store bpf_fd in MapData
This is only used in create and therefore can be passed
as a parameter.

Signed-off-by: Dave Tucker <dave@dtucker.co.uk>
1 year ago
Dave Tucker d85afe78f9 xtask: Fix aya public-api
Changes to the bitflags crate changed some of our public api signature.

Signed-off-by: Dave Tucker <dave@dtucker.co.uk>
1 year ago
Tamir Duberstein 7e14214f47
xtask: add noapic to kernel parameters
This might prevent some kernel panics.
1 year ago
Tamir Duberstein de65ba0067
xtask: watch for kernel panic in stdout too
Seems unclear whether kernel panics go to stdout or stderr, so do them
both.
1 year ago
Addison Crump ed777273b1
nuclear option: no symbol resolution in the crate 1 year ago
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