Commit Graph

21 Commits (628b473e0937eef94b0b337608a5d6c51ad2fd2a)

Author SHA1 Message Date
Dave Tucker 336faf553e clippy: Fix latest nightly lints
Signed-off-by: Dave Tucker <dave@dtucker.co.uk>
2 years ago
Davide Bertola cbf520934a aya-gen: fix lint errors 2 years ago
Davide Bertola 4f13576594
aya-gen: allow passing custom --ctypes-prefix to bindgen (#312)
Allows users to pass a custom --ctypes-prefix to bindgen #186
2 years ago
Alessandro Decina cffff273a1 aya-gen: fix lint 👀 2 years ago
Alessandro Decina e675e51bd9 aya-gen: re-export generate::{InputFile, generate} 2 years ago
Davide Bertola 68bc11e42c
aya-gen cli rework (#297)
* update aya-gen from structopt to clap 3

* aya-gen: add --header option

* aya-gen: run bindgen as a child process

* aya-gen: add support for passing additional bindgen args
2 years ago
dependabot[bot] ddf26300c8 build(deps): update bindgen requirement from 0.59 to 0.60
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/master/CHANGELOG.md)
- [Commits](https://github.com/rust-lang/rust-bindgen/compare/v0.59.0...v0.60.1)

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

Signed-off-by: dependabot[bot] <support@github.com>
2 years ago
Dave Tucker 9a33b6b654 aya-gen: Remove getters
Signed-off-by: Dave Tucker <dave@dtucker.co.uk>
2 years ago
Michal Rostecki bd336acb02 aya-gen: Disable Debug derive for BTF types
It's a workaround for the upstream bindgen issue:

https://github.com/rust-lang/rust-bindgen/issues/2083

tl;dr: Rust nightly complains about #[repr(packed)] structs deriving
Debug without Copy.

It needs to be fixed properly upstream, but for now we have to disable
Debug derive here.

Signed-off-by: Michal Rostecki <vadorovsky@gmail.com>
2 years ago
Alessandro Decina 37afde3fca aya-gen: fix lint error 3 years ago
Alessandro Decina 4fcb1d75b9 aya-gen: bump bindgen to 0.59 3 years ago
Alessandro Decina ca14306860 aya-gen: use aya_bpf::cty instead of aya_bpf_cty
This avoids having to add an explicit extra dep on aya-bpf-cty in ebpf
programs
3 years ago
Alessandro Decina 1159741eda aya-gen: fix clippy warnings 3 years ago
Alessandro Decina 9595bd4571 aya-gen: don't generate doc comments 3 years ago
Alessandro Decina 4dccd840ca aya-gen: rename binary from main to aya-gen 3 years ago
Alessandro Decina 29f2d9b2d9 aya: switch to rustified enums 4 years ago
Alessandro Decina bdca32cebf aya-bpf-bindings: fix anonymous enums 4 years ago
Alessandro Decina 08d4b1aeda aya-gen: add bindgen builder for userspace code 4 years ago
Alessandro Decina d9c3489165 aya-gen: rename probe_read_getter to read_getter
The same code can be used to wrap with preserve_access_index()
4 years ago
Alessandro Decina 99447bcc0d aya-gen: add bindgen module and utils to write to file 4 years ago
Alessandro Decina b66a73f6c7 Add aya-gen
aya-gen can be used to generate bindings for kernel types, eg:

	aya-gen btf-types ethhdr --probe-read-getters

Will generate:

	// ...

	#[repr(C)]
	#[derive(Debug, Copy, Clone)]
	pub struct ethhdr {
	    pub h_dest: [::aya_bpf_cty::c_uchar; 6usize],
	    pub h_source: [::aya_bpf_cty::c_uchar; 6usize],
	    pub h_proto: __be16,
	}

	impl ethhdr {
	    pub fn h_dest(&self) -> Option<[::aya_bpf_cty::c_uchar; 6usize]> {
		unsafe { ::aya_bpf::helpers::bpf_probe_read(&self.h_dest) }.ok()
	    }
	    pub fn h_source(&self) -> Option<[::aya_bpf_cty::c_uchar; 6usize]> {
		unsafe { ::aya_bpf::helpers::bpf_probe_read(&self.h_source) }.ok()
	    }
	    pub fn h_proto(&self) -> Option<__be16> {
		unsafe { ::aya_bpf::helpers::bpf_probe_read(&self.h_proto) }.ok()
	    }
	}
4 years ago