Commit Graph

6 Commits (f0444233b32256c90c12eb6f2e68d2c5f34cebdf)

Author SHA1 Message Date
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
Alessandro Decina cdf960aaa1 bpf: initial bpf bindings 4 years ago
Alessandro Decina af8f769b50 Turn the project into a workspace, move code under aya/ 4 years ago
Alessandro Decina c110394aaa xdp: add netlink based implementation for kernels < 5.7
bpf_link_create was introduced in linux 5.7, so use netlink to configure
XDP on older kernels.
4 years ago
Alessandro Decina 5b8def7b69 Refactor ELF parser a bit and add more tests 4 years ago
Alessandro Decina 15be301f8c Initial commit 4 years ago