Commit Graph

120 Commits

Author SHA1 Message Date
Tamir Duberstein
2f8759cc62 Dial the lints to 100 2026-01-29 10:02:48 -05:00
Tamir Duberstein
e746618143 enable unused_qualifications lint 2026-01-23 11:03:26 -05:00
Ignacio Espósito
ac85ad27df Symlink licenses into aya log (#1428)
Added symlinks to licences in aya-log in order for it to be packaged into fedora.
2025-12-26 01:27:42 +01:00
Tamir Duberstein
d238b2ea6f Release crates
- aya v0.13.2
- aya-build v0.1.3
- aya-ebpf v0.1.2
- aya-ebpf-bindings v0.1.2
- aya-ebpf-cty v0.2.3
- aya-ebpf-macros v0.1.2
- aya-log v0.2.2
- aya-log-common v0.1.16
- aya-log-ebpf v0.1.2
- aya-log-ebpf-macros v0.1.1
- aya-log-parser v0.1.14
- aya-obj v0.2.2

Signed-off-by: Tamir Duberstein <tamird@gmail.com>
2025-11-17 14:51:14 -05:00
Andrew Werner
03e8487177 aya: rename set_ methods on EbpfLoader
This loader is more of a builder, so these `set_` methods didn't
quite fit. See [this discussion][1] for the motivation.

[1]: https://reviewable.io/reviews/aya-rs/aya/1318#gh-2384180366
2025-10-22 00:05:20 -04:00
Christian A. Jacobsen
a98b638fa9 feat(log): add support for logging raw pointer types
* Requires the usage of `:p` display hint.
* Will, like stdlib, log with `0x` prefix.
2025-10-16 05:22:10 -04:00
Tamir Duberstein
5f5305c2a8 lint all crates; enable strict pointer lints 2025-09-29 05:19:23 -04:00
Thomas Eizinger
e2a68ee384 aya-log: add #[must_use] attribute to EbpfLogger 2025-09-23 17:19:40 +09:00
Tamir Duberstein
353b83383d aya-log-ebpf: zero copy! 2025-09-09 06:28:43 -04:00
Tamir Duberstein
b36cbc3eb8 implement load-time log level mask 2025-09-04 21:08:34 -04:00
Xiaobo Liu
44ec978bd3 aya-log: Implement AsFd for EbpfLogger
This change implements the `AsFd` trait for the `EbpfLogger` struct.
This allows obtaining a `BorrowedFd` from an `EbpfLogger` instance, which is safer than using `AsRawFd`.

This improves the ergonomics of using `EbpfLogger` with APIs that accept file descriptors.

Signed-off-by: Xiaobo Liu <cppcoffee@gmail.com>
2025-07-20 10:25:13 -04:00
Xiaobo Liu
0b732c3d46 aya-log: simplify map name matching using direct Option comparison
Replace match statement with direct Option comparison for cleaner code

Signed-off-by: Xiaobo Liu <cppcoffee@gmail.com>
2025-07-17 09:50:43 -04:00
Xiaobo Liu
cab559b9d9 aya-log: Use None instead of wildcard in Format impls
The `Format` implementations for various types were using a wildcard `_`
to match the `None` case on `Option<DisplayHint>`.

This is incorrect as it would also match any `Some(...)` variants that
were not explicitly handled, leading to unexpected behavior.

This commit changes the wildcard `_` to an explicit `None` match to
ensure that only the `None` case is handled, making the matching more
explicit and correct.

Signed-off-by: Xiaobo Liu <cppcoffee@gmail.com>
2025-07-17 09:50:31 -04:00
Tamir Duberstein
61376c4608 aya-log: Remove tokio dep
Require the caller to provide their own executor.
2025-07-08 06:07:56 -04:00
Tamir Duberstein
9be2d723ce aya-log: Replace AsyncPerfEventArray with RingBuf
This doesn't get us to zero copy because the reserve/submit APIs do not
support DSTs for reasons I don't remember.

Now that it is unused in userspace, move `LOG_BUF_CAPACITY` to
`aya-log-ebpf` by making its type `LogValueLength` which obviates the
need for `log_value_length_sufficient`.
2025-07-07 09:33:52 -04:00
Tamir Duberstein
87188f621a Remove pointless map_err calls 2025-07-07 09:31:23 -04:00
Tamir Duberstein
30d5c9f53e Remove dead code expectation fixed upstream
See https://github.com/rust-lang/rust/commit/c93fac7d64394c6b926d863c19.
2025-06-22 08:24:08 -04:00
Tamir Duberstein
583709f6a0 appease clippy::uninlined-format-args 2025-04-24 06:42:21 -04:00
Dave Tucker
f6c5cb2ad2 chore(*): set clippy unused_trait_names = warn
We have previously tried to import traits anonymously where possible but
enforcing this manually was hard.

Since Rust 1.83 clippy can now enforce this for us.

Signed-off-by: Dave Tucker <dave@dtucker.co.uk>
2025-03-20 15:16:11 +00:00
Tamir Duberstein
49a828ec56 taplo: reorder-keys
Group non-workspace keys before workspace ones for readability.
2025-03-17 11:38:09 -04:00
Tamir Duberstein
a43e40ae1d introduce workspace lints, warn on unused crates
In practice this will forbid unused dependencies because we run clippy
with `--deny warnings`.

Workspace lints is a nice place to ratchet up lints through the codebase
all at once and consistently.
2025-03-06 14:46:03 -05:00
Tamir Duberstein
f0a9f19ddc Bump edition to 2024
Change FromRawTracepointArgs::arg to return T rather than *const T which
seems to have been returning a dangling pointer.

Arguably this is not strictly necessary; edition 2024 seems to be
focused on increased strictness around unsafe code which doesn't unlock
new functionality for our users. That said, this work revealed an
apparent bug (see above) that we wouldn't otherwise catch due to
allow-by-default lints.
2025-03-04 10:43:56 -05:00
Tamir Duberstein
4101a5a55d Use #[expect(...)] rather than #[allow(...)]
This is stricter, and revealed a few unused allowances.
2025-03-04 10:43:56 -05:00
Tamir Duberstein
bdd8ae2d0b *: avoid _
This can silently discard information, so we shouldn't do it.
2025-03-03 11:28:34 -05:00
Tamir Duberstein
b500a6326b tests: use cfg! to tidy up 2025-03-03 08:29:13 -05:00
Dave Tucker
2791badd94 Release aya v0.13.1
Signed-off-by: Dave Tucker <dave@dtucker.co.uk>
2024-11-01 15:30:23 +00:00
Dave Tucker
0e70838b0f Release aya-log v0.2.1
Signed-off-by: Dave Tucker <dave@dtucker.co.uk>
2024-10-09 12:04:12 +01:00
Dave Tucker
04bbbccffa Release aya-log-common v0.1.15, aya-log-ebpf v0.1.1 2024-10-09 11:56:59 +01:00
Dave Tucker
c169b727e6 Release aya-obj v0.2.0, aya v0.13.0, safety bump aya v0.13.0
Signed-off-by: Dave Tucker <dave@dtucker.co.uk>
2024-10-09 11:02:08 +01:00
GrigorenkoPV
55ed9e0546 fix(aya-log): print &[u8] using full width (#1008)
Otherwise `&[1u8, 0u8]` cannot be distinguished from `&[0x10u8]` (they both become 10)
2024-10-04 09:26:14 +02:00
Tamir Duberstein
f3b2744072 Reduce duplication in {nr,possible}_cpus 2024-10-02 14:00:13 -04:00
tyrone-wu
02d1db5fc0 aya: remove unwrap and NonZero* in info
Addresses the feedback from #1007:
- remove panic from `unwrap` and `expect`
- Option<NonZero*> => Option<int> with `0` mapping to `None`

Refs: #1007
2024-09-08 12:46:02 +00:00
tyrone-wu
fbb09304a2 aya,int-test: revamp MapInfo be more friendly with older kernels
Adds detection for whether a field is available in `MapInfo`:
- For `map_type()`, we treturn new enum `MapType` instead of the integer
  representation.
- For fields that can't be zero, we return `Option<NonZero*>` type.
- For `name_as_str()`, it now uses the feature probe `bpf_name()` to
  detect if field is available.
  Although the feature probe checks for program name, it can also be
  used for map name since they were both introduced in the same commit.
2024-09-02 15:48:59 +00:00
tyrone-wu
88f5ac3114 aya,obj,int-test: revamp ProgramInfo be more friendly with older kernels
Purpose of this commit is to add detections for whether a field is
available in `ProgramInfo`.
- For `program_type()`, we return the new enum `ProgramType` instead of
  the integer representation.
- For fields that we know cannot be zero, we return `Option<NonZero*>`
  type.
- For `name_as_str()`, it now also uses the feature probe `bpf_name()`
  to detect if field is available or not.
- Two additional feature probes are added for the fields:
  - `prog_info_map_ids()` probe -> `map_ids()` field
  - `prog_info_gpl_compatible()` probe -> `gpl_compatible()` field

With the `prog_info_map_ids()` probe, the previous implementation that
I had for `bpf_prog_get_info_by_fd()` is shortened to use the probe
instead of having to make 2 potential syscalls.

The `test_loaded_at()` test is also moved into info tests since it is
better related to the info tests.

`aya::programs::Programs::prog_type(&self)` now returns `ProgramType`
instead of the generated FFI from aya-obj.

Also previously, `loaded_programs()` could be accessed either through
`aya` or `aya::programs`. To avoid confusion and duplicate export of
the item, the function should now only be exposed through
`aya::programs`.
2024-09-02 15:48:58 +00:00
Billy McFall
eef7346fb2 test: adjust test byte arrays for big endian
Adding support for s390x (big endian architecture) and found that some
of the unit tests have structures and files implemented as byte arrays.
They are all coded as little endian and need a bug endian version to
work properly.

Signed-off-by: Billy McFall <22157057+Billy99@users.noreply.github.com>
2024-08-26 12:35:19 -04:00
Tamir Duberstein
41619933d6 Revert "Remove unused allow(dead_code)"
This reverts commit 5397c1ca4b.
2024-08-14 15:06:02 -04:00
Tamir Duberstein
5397c1ca4b Remove unused allow(dead_code)
See 31fe9628cf.
2024-07-18 08:18:43 -04:00
Michal Rostecki
a75fc2f769 aya-log: Allow logging core::net::Ipv4Addr and core::net::Ipv6Addr
IP address types are available in `core`, so they can be used also in
eBPF programs. This change adds support of these types in aya-log.

* Add implementation of `WriteTuBuf` to these types.
* Support these types in `Ipv4Formatter` and `Ipv6Formatter`.
* Support them with `DisplayHint::Ip`.
* Add support for formatting `[u8; 4]`, to be able to handle
  `Ipv4Addr::octets`.
2024-07-17 15:16:20 -04:00
Alessandro Decina
8830c0bc20 docs(aya-log): reword rustdocs a bit 2024-04-25 11:01:02 +10:00
Catalin Horghidan
e66f9540c9 aya-log: allow re-attach and read previously created logs
This feature is useful if someone wants to view the log contents
of a program that is already running. For e.g. a pinned program
or an XDP program attached to a net interface.
2024-04-25 11:01:02 +10:00
Dave Tucker
8c79b71bd5 feat(aya): Rename Bpf to Ebpf
And BpfLoader to EbpfLoader.
This also adds type aliases to preserve the use of the old names, making
updating to a new Aya release less of a burden. These aliases are marked
as deprecated since we'll likely remove them in a later release.

Signed-off-by: Dave Tucker <dave@dtucker.co.uk>
2024-03-05 11:53:12 +00:00
Dave Tucker
a93e354620 feat(aya-log): Rename BpfLogger to EbpfLogger
Signed-off-by: Dave Tucker <dave@dtucker.co.uk>
2024-03-05 11:53:12 +00:00
Dave Tucker
41c61560ea chore(aya-ebpf): Rename bpf -> ebpf
Signed-off-by: Dave Tucker <dave@dtucker.co.uk>
2024-03-05 11:53:12 +00:00
Dave Tucker
b6a84b658a Release aya-log-common v0.1.14, aya-log v0.2.0 2024-02-28 12:39:13 +00:00
Dave Tucker
9abb7160e5 docs(aya-log): Add CHANGELOG
Signed-off-by: Dave Tucker <dave@dtucker.co.uk>
2024-02-28 12:38:58 +00:00
Dave Tucker
c22a6963d4 Release aya-log-common v0.1.14, aya-log v0.2.0 2024-02-28 12:38:19 +00:00
Dave Tucker
0e99fa0f34 Release aya-obj v0.1.0, aya v0.12.0, safety bump aya-log v0.2.0 2024-02-28 12:14:58 +00:00
Dave Tucker
13b1fc63ef chore: Don't use path deps in workspace
This moves the path dependencies back into the per-crate Cargo.toml.
It is required such that the release tooling can correctly calculate
which version constraints require changing when we perform a release.

Signed-off-by: Dave Tucker <dave@dtucker.co.uk>
2024-02-28 12:13:15 +00:00
Dave Tucker
b3e7ef741c chore: Use the cargo workspace package table
This allows for inheritance of common fields from the workspace root.
The following fields have been made common:

- authors
- license
- repository
- homepage
- edition

Signed-off-by: Dave Tucker <dave@dtucker.co.uk>
2024-02-22 16:58:01 +00:00
Tamir Duberstein
963dd13219 Appease rustc dead_code lint
Some of these are legit, others are false positives. I've filed
https://github.com/rust-lang/rust/issues/120770 for the latter.
2024-02-08 11:23:37 +01:00