Commit Graph

1495 Commits (8462b69716d5918a599933bb9688fa7f57b8ee1d)
 

Author SHA1 Message Date
Tuetuopay 139f382638 aya: add support for map-bound XDP programs
Such programs are to be bound to cpumap or devmap instead of the usual
network interfaces.
1 year ago
Tuetuopay 4452364c41 macros: add 'map' option to xdp macro
This option allows to place the program in the specific sections to
chain programs with devmaps and cpumaps.
1 year ago
Tuetuopay ad3087d7eb bpf: Update XDP maps implementation
The implementation changed since the original commit was written, and
some mistakes went in:
- missing bpf_redirect_map wrapper
- extra bpf_map_lookup_elem on maps for which it is forbidden
1 year ago
Tuetuopay ede3e91014 aya: Update XDP maps implementations
Map impls changed since this was first written.

Fixes: 2b726c8 ("aya: Implement XDP Map Types")
1 year ago
Dave Tucker e90d521a21 bpf: Implement XDP maps
Signed-off-by: Dave Tucker <dave@dtucker.co.uk>
1 year ago
Dave Tucker ec8293ab86 aya: Implement XDP Map Types
This commit adds implementations for:
- xskmap
- devmap
- devmap_hash
- cpumap

Which can all be used to redirect XDP packets to various different
locations

Signed-off-by: Dave Tucker <dave@dtucker.co.uk>
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 41d01f638b
Merge pull request #770 from aya-rs/mapfd-is-owned
maps: `MapFd` and `SockMapFd` are owned
1 year ago
Tamir Duberstein 0dacb34d44
maps: fix typos, avoid fallible conversions 1 year ago
Tamir Duberstein b4d5a1e8db
maps: MapData::{obj, fd} are private 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
dependabot[bot] 33018c16f4
Merge pull request #788 from aya-rs/dependabot/cargo/cargo_metadata-0.18.0 1 year ago
dependabot[bot] e0880316c3
build(deps): update cargo_metadata requirement from 0.17.0 to 0.18.0
Updates the requirements on [cargo_metadata](https://github.com/oli-obk/cargo_metadata) to permit the latest version.
- [Release notes](https://github.com/oli-obk/cargo_metadata/releases)
- [Changelog](https://github.com/oli-obk/cargo_metadata/blob/main/CHANGELOG.md)
- [Commits](https://github.com/oli-obk/cargo_metadata/compare/0.17.0...0.17.0)

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

Signed-off-by: dependabot[bot] <support@github.com>
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
dependabot[bot] 96c8bc9fa5
Merge pull request #784 from aya-rs/dependabot/cargo/bindgen-0.68 1 year ago
Tamir Duberstein 5691829fcf
Merge pull request #786 from aya-rs/no-sleep
integration-test: remove all sleeps
1 year ago
dependabot[bot] 9686092280
build(deps): update bindgen requirement from 0.66 to 0.68
Updates the requirements on [bindgen](https://github.com/rust-lang/rust-bindgen) to permit the latest version.
- [Release notes](https://github.com/rust-lang/rust-bindgen/releases)
- [Changelog](https://github.com/rust-lang/rust-bindgen/blob/main/CHANGELOG.md)
- [Commits](https://github.com/rust-lang/rust-bindgen/compare/v0.66.0...v0.66.1)

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

Signed-off-by: dependabot[bot] <support@github.com>
1 year ago
Tamir Duberstein 0a144a0e69
integration-test: remove all sleeps 1 year ago
Andrew Stoycos 80d187d66d
Merge pull request #785 from astoycos/fix-ci
aya/ci: fixup broken debian kernel image url
1 year ago
astoycos 81f634abc6 aya/ci: fixup broken debian kernel image url
Signed-off-by: astoycos <astoycos@redhat.com>
1 year ago
Tamir Duberstein f0f09ac16e
Merge pull request #781 from aya-rs/build-badge
README: fix build badge
1 year ago
Tamir Duberstein 1aa1dc53db
README: fix build badge
Make it a link while I'm here.
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
dependabot[bot] 18c7235dba
Merge pull request #780 from aya-rs/dependabot/github_actions/actions/checkout-4 1 year ago
dependabot[bot] 385b04c12b
build(deps): bump actions/checkout from 3 to 4
Bumps [actions/checkout](https://github.com/actions/checkout) from 3 to 4.
- [Release notes](https://github.com/actions/checkout/releases)
- [Changelog](https://github.com/actions/checkout/blob/main/CHANGELOG.md)
- [Commits](https://github.com/actions/checkout/compare/v3...v4)

---
updated-dependencies:
- dependency-name: actions/checkout
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
1 year ago
ajwerner 8d3fc49d68
Merge pull request #774 from ajwerner/try_from_LruHash
aya/maps: allow constructing HashMaps from LruHashMap
1 year ago
Andrew Werner 172859c66b aya/maps: support TryFrom for LRU hash maps
The macro to implement TryFrom for MapData didn't have the ability to
specify that more than one variant of MapData can be valid for a single
map implementation. Support for new syntax was added to the macro so that
the implementation can succeed for both valid variants in the HashMap
and PerCpuHashMap impl.

Fixes #636
1 year ago
ajwerner 792f467d40
Merge pull request #777 from ajwerner/ajwerner/TryFrom-macros
aya/maps: rework TryFrom macros
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
Tamir Duberstein 8668436787
Merge pull request #772 from aya-rs/link-owned
programs: ProgAttachLink and LircLink hold owned FDs
1 year ago
Tamir Duberstein c4d1d1086a
Merge pull request #771 from aya-rs/xdp-raw
netlink: use OwnedFd
1 year ago
Tamir Duberstein 204d02022a
programs: ProgAttachLink and LircLink hold owned FDs
Updates #612.
1 year ago
Tamir Duberstein cee0265b52
netlink: use OwnedFd
Updates #612.
1 year ago
Tamir Duberstein c4643b395f
Merge pull request #723 from nrxus/map-program-owned-fd
File descriptor safety for program fd + prog attaching
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
Andrés Medina d2e74e562d
aya: Use BorrowedFd when using the program fd in sys/bpf.rs
This commit reveals but does not address a file descriptor leak in
LircLink2::query. This function returns a list of `LircLink`s where
each of them have a program file descriptor that is not going to be
closed. This commit does not add this leak; it merely makes it louder
in the code.
1 year ago
dependabot[bot] 4567c351fe
Merge pull request #768 from aya-rs/dependabot/cargo/nix-0.27.0 1 year ago
dependabot[bot] a38dc057b4
build(deps): update nix requirement from 0.26.2 to 0.27.0
Updates the requirements on [nix](https://github.com/nix-rust/nix) to permit the latest version.
- [Changelog](https://github.com/nix-rust/nix/blob/master/CHANGELOG.md)
- [Commits](https://github.com/nix-rust/nix/compare/v0.26.2...v0.26.3)

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

Signed-off-by: dependabot[bot] <support@github.com>
1 year ago
Tamir Duberstein e9690df834
Merge pull request #766 from aya-rs/obj-better-sense
aya-obj: reduce indirection in section parsing
1 year ago
Tamir Duberstein c139627f8f aya-obj: reduce indirection in section parsing
Remove repetition of permitted cgroup attach types. Make optionality of
name more explicit rather than pretending both kind and name are equal
to section.
1 year ago
Tamir Duberstein 116ddbd18d
Merge pull request #767 from aya-rs/fix-ci-again
github: fix CI
1 year ago
Tamir Duberstein 7803db22a0
github: remove symlinks to apple-provided python
See https://github.com/actions/setup-python/issues/577.
1 year ago
Tamir Duberstein f988e97b5f
Upgrade public-api
This fixes `cargo xtask public-api` by picking up
https://github.com/aDotInTheVoid/rustdoc-types/commit/577a774c2433beda6.
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 c0bc1866d8
github: update 6.4.0 URLs
Seems the previous spin was pulled.
1 year ago
Tamir Duberstein 461c2759c5
Merge pull request #765 from aya-rs/more-utf8-fixes
aya: support non-UTF8 probing
1 year ago