Commit Graph

414 Commits (d43879d99177c33c5d33827d8a3c7572841dd9df)

Author SHA1 Message Date
Andre Fredette d43879d991 Updates after rebase due to changes in define_link_wrapper
Signed-off-by: Andre Fredette <afredette@redhat.com>
2 years ago
Andre Fredette 6766532341 Remove SchedClassifierLink description
It was redundant with the one provided in define_link_wrapper

Signed-off-by: Andre Fredette <afredette@redhat.com>
2 years ago
Andre Fredette 2972d462a5 Address review comments
- Rename `new_tc_link` to `attached`
- Simplified example for `attached`

The following was not requested in reviews:
- Moved example from `SchedClassifierLink` tor
  `SchedClassifierLink::attached' since we're only showing an
  example of that one method

Signed-off-by: Andre Fredette <afredette@redhat.com>
2 years ago
Andre Fredette 65f5b76593 Address review comments
Signed-off-by: Andre Fredette <afredette@redhat.com>
2 years ago
Andre Fredette 849796c420 rename SchedClassifierLink:new() to new_tc_link()
Avoids name confilct with pr #462

Signed-off-by: Andre Fredette <afredette@redhat.com>
2 years ago
Andre Fredette 67efc33414 Additional edits to SchedClassifierLink documentation.
Signed-off-by: Andre Fredette <afredette@redhat.com>
2 years ago
Andre Fredette 6563e6cc06 Combine updates to SchedClassifierLink example made by Dave Tucker
Co-authored-by: Dave Tucker <dave@dtucker.co.uk>
Signed-off-by: Andre Fredette <afredette@redhat.com>
2 years ago
Andre Fredette c3a8400e4d Add example for SchedClassifierLink::new()
Also modified the impl a bit to work as described in the example.

Signed-off-by: Andre Fredette <afredette@redhat.com>
2 years ago
Andre Fredette f46fd17cc3 Support reconstruction of `SchedClassifierLink`
This is the proposed solution for Step 2 of issue #414

“For cases where you have done program.take_link() to manage
ownership of TcLink we need an API similar to PinnedLink::from_pin
that can reconstruct a TcLink”

As long as a user application continues to run after executing
`take_link()`, the `SchedClassifierLink` returned can be used to
detach the program.  However, if we want to handle cases where the
application exits or crashes, we need a way to save and reconstruct
the link, and to do that, we also need to know the information
required for the reconstruction -- namely, the `interface`,
`attach_type`, `priority`, and `handle`.  The user knows the first
two because they are required to execute `attach()` in the first
place; however, the user will not know the others if they let the
system choose them.

This pr solves the problems by adding an `impl` for
`SchedClassifierLink` with an accessor for `tc_options` and a `new()`
function.

Signed-off-by: Andre Fredette <afredette@redhat.com>
2 years ago
Andrew Stoycos 1899d5f4fd Expose inner errors
Currently aya will just report a standard outer level
error on failure.  Ensure that we also report the inner
error condition back to the user

Signed-off-by: Andrew Stoycos <astoycos@redhat.com>
2 years ago
Michal Rostecki dad75f45ac Update Tokio and inventory
Signed-off-by: Michal Rostecki <vadorovsky@gmail.com>
2 years ago
Shenghui Ye 9c451a3357 aya-obj: update documentation and versioning info
- Set the version number of `aya-obj` to `0.1.0`.
- Update the description of the `aya-obj` crate.
- Add a section in README and rustdoc warning about the unstable API.
2 years ago
Shenghui Ye e52497cb9c aya-obj: add basic documentation to public members
Types relevant to maps are moved into aya_obj::maps.
Some members are marked `pub(crate)` again.

Refs: #473
2 years ago
Shenghui Ye ac49827e20 aya-obj: migrate aya::obj into a separate crate
To split the crate into two, several changes were made:
1. Most `pub(crate)` are now `pub` to allow access from Aya;
2. Parts of BpfError are merged into, for example, RelocationError;
3. BTF part of Features is moved into the new crate;
4. `#![deny(missing_docs)]` is removed temporarily;
5. Some other code gets moved into the new crate, mainly:
   - aya::{bpf_map_def, BtfMapDef, PinningType},
   - aya::programs::{CgroupSock*AttachType},

The new crate is currenly allowing missing_docs. Member visibility
will be adjusted later to minimize exposure of implementation details.

Refs: #473
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 c6f93b1775 btf relocs: don't panic on failed relocation
Error out instead of panicing when we can't find a compatible target
candidate for a relocation.
2 years ago
Alessandro Decina aba99ea4b1 btf: make btf::RelocationError private
BpfError::RelocationError type erases the inner error so no need to
export the type.
2 years ago
Alessandro Decina 12e422b211 btf: fix regression computing pointer sizes
Computing pointer sizes was broken in #285
2 years ago
ajwerner 1a22792ee7 Resolve symbol address for PIE executables
See https://github.com/foniod/redbpf/pull/308 for a similar change.
2 years ago
Alessandro Decina b3ae7786d3 aya: fix detaching links on drop
https://github.com/aya-rs/aya/pull/366 broke detaching links on drop for
everything but FdLink. This restores detach on drop for all links.
2 years ago
Michal Rostecki 9f5d157628
Merge pull request #461 from FallingSnow/main
Add ability to iterate over LpmTrie keys and matches
2 years ago
Ayrton Sparling 10ac5957c1
Fix LpnTrieKeys -> LpmTrieKeys typo 2 years ago
Milan 925504f230 Fix doctest issue 2 years ago
Milan 4b6d97e4db Fix CI, clippy and feedback
Signed-off-by: Milan <milan@mdaverde.com>
2 years ago
Milan 8f1163a400 Add support for BPF_PROG_TYPE_CGROUP_DEVICE
Kernel 4.15 added a new eBPF program that can
be used with cgroup v2 to control & observe device
access (e.g. read, write, mknod) - `BPF_PROG_TYPE_CGROUP_DEVICE`.

We add the ability to create these programs with the `cgroup_device`
proc macro which creates the `cgroup/dev` link section. Device
details are available to the eBPF program in `DeviceContext`.

The userspace representation is provided with the `CgroupDevice`
structure.

Fixes: #212
Signed-off-by: Milan <milan@mdaverde.com>
2 years ago
Ayrton Sparling a44f054bec fix formatting 2 years ago
Ayrton Sparling 1368eb94e7 Remove old test 2 years ago
Ayrton Sparling 9a3682e793 Add ability to iterate over lpmtrie key matches 2 years ago
Ayrton Sparling 8fe64aef1f Fix lpmtrie iter returning nothing 2 years ago
Alexis Bauvin 51bb50ed8e maps: add missing TryFrom<Map> for HashMap, PerCpuHashMap and LpmTrie 2 years ago
Ayrton Sparling e4182a9eab Iterate lpmtrie 2 years ago
Dmitry Savintsev 055d94f58b fix uninlined_format_args clippy issues 2 years ago
dependabot[bot] 1fe7bba070
build(deps): update object requirement from 0.29 to 0.30
Updates the requirements on [object](https://github.com/gimli-rs/object) to permit the latest version.
- [Release notes](https://github.com/gimli-rs/object/releases)
- [Changelog](https://github.com/gimli-rs/object/blob/master/CHANGELOG.md)
- [Commits](https://github.com/gimli-rs/object/compare/0.29.0...0.30.0)

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

Signed-off-by: dependabot[bot] <support@github.com>
2 years ago
Michal Rostecki 9382de75cc
Merge pull request #452 from vadorovsky/fix-lint
Fix clippy error
2 years ago
Michal Rostecki 176d61ae23 Fix clippy error
`'local` lifetime can be elided to `'_` which triggers:

https://rust-lang.github.io/rust-clippy/master/index.html#needless_lifetimes

Signed-off-by: Michal Rostecki <vadorovsky@gmail.com>
2 years ago
Alessandro Decina 7fef833e3a
Merge pull request #418 from anfredette/tc-handle
Support using handle in tc programs
2 years ago
Andre Fredette abb75ba029 Make doc fixes
Signed-off-by: Andre Fredette <afredette@redhat.com>
2 years ago
Alessandro Decina 88d7777553
Merge pull request #431 from 0b01/refs
aya: use impl Borrow<T> instead of T for maps
2 years ago
0b01 76e417a474 Fix formatting 2 years ago
Andre Fredette a3e3e80698 Support both attach() and attach_with_options() for SchedClassifier
Signed-off-by: Andre Fredette <afredette@redhat.com>
2 years ago
Michal Rostecki e0a9895260 maps: Fix the error message in `MapData::pin()`
The syscall name is `BPF_OBJ_PIN`, not `BPF_OBJ_GET`.

Signed-off-by: Michal Rostecki <vadorovsky@gmail.com>
2 years ago
Ricky Han 6ce60ad21d make sure everything is marked correctly 2 years ago
Ricky Han 9525b1a370 fix array 2 years ago
Ricky Han 575fea4cb9 fix wrong bounds 2 years ago
Ricky Han fbfbedb6a8 cargo fmt 2 years ago
Ricky Han 9991ffb093 Use & 2 years ago
Ricky Han e9ec257328 Add test case 2 years ago
Ricky Han 1247ffc19b Use Borrow<T> instead 2 years ago
Andre Fredette af3de84b08 Use a struct for setting priority and handle in SchedClassfier attach
Use a struct called TcOptions for setting priority and handle in SchedClassifier attach

struct TcOptions implements the Default trait, so for the simple use
case in which the defaults are acceptable, we can call attach as
follows:
attach(“eth0”, TcAttachType::Ingress, TcOptions::default())

To specify all options:
attach(“eth0”, TcAttachType::Ingress, TcOptions { priority: (50), handle: (3) })

Or, some options:
attach(“eth0”, TcAttachType::Ingress, TcOptions { priority: (50), ..Default::default() })

Signed-off-by: Andre Fredette <afredette@redhat.com>
2 years ago
Andre Fredette ac07608b79 Support using handle in tc programs
Implements step 1 of https://github.com/aya-rs/aya/issues/414.

- Adds handle to the SchedClassifier attach API
- Saves handle in the TcLink sruct and uses it when detaching programs

NOTE: this changes the API, so it will require a bump in the Aya version.

Signed-off-by: Andre Fredette <afredette@redhat.com>
2 years ago