Comments (3)
@tw4452852 i think you should align you array of bytes.
Zero-copy buffer mode
bpf devices may also operate in the BPF_BUFMODE_ZEROCOPY mode, in which
packet data is written directly into two user memory buffers by the ker-
nel, avoiding both system call and copying overhead. Buffers are of
fixed (and equal) size, page-aligned, and an even multiple of the page
size. The maximum zero-copy buffer size is returned by the BIOCGETZMAX
ioctl. Note that an individual packet larger than the buffer size is
necessarily truncated.
https://www.freebsd.org/cgi/man.cgi?bpf(4)
What works for me:
macro_rules! include_bytes_align_as {
($align_ty:ty, $path:literal) => {{
#[repr(C)]
pub struct AlignedAs<Align, Bytes: ?Sized> {
pub _align: [Align; 0],
pub bytes: Bytes,
}
static ALIGNED: &AlignedAs<$align_ty, [u8]> = &AlignedAs {
_align: [],
bytes: *include_bytes!($path),
};
&ALIGNED.bytes
}};
}
static PROGRAM_DATA: &'static [u8] = include_bytes_align_as!(
u32,
"../../target/bpfel-unknown-none/release/libpq-tracer-bpf"
);
// ..
let mut bpf = Bpf::load(PROGRAM_DATA.into(), None)?;
I copied the include_bytes_align_as
macro from here.
from aya.
Wow, thanks @ecarrara , Now it's clear now.
from aya.
Just an FYI for folks coming here from their favourite search engine: As of #76 we will have aya::include_bytes_aligned
which can be used instead.
from aya.
Related Issues (20)
- BPF verify failed with "Permission denied (os error 13)" HOT 4
- unknown func bpf_get_current_pid_tgid - but it actually exists HOT 5
- Separate BpfContext from BpfSomethingContext HOT 2
- panic: enum relocation index out of bounds
- SockOpsLink is not exported
- XDP_TX isn't putting the packet back in the network.
- AYA tc classifier does not support using tc_classid
- Aya nightly crates HOT 4
- Error: error parsing BPF object: invalid program section `cgroup_skb` HOT 4
- Error: error parsing BPF object HOT 3
- Hashmap is not cleaned on every execution HOT 1
- integration-test: `rust-lld` invoked by `cargo xtask integration-test vm` fails to find libraries
- Dependency Hijacking risk due to Crate Name Change HOT 2
- ebpf obj isn't compatible with libbpf v1.0+
- Instructions on codegen HOT 1
- Add TCX link support
- Error: error relocating function
- Inside `aya-ebpf::programs` some `raw` pointers are having `pub` visibility.
- Bug on system suspend HOT 3
- error: failed to create `BPF_MAP_TYPE_ARRAY_OF_MAPS` of `BPF_MAP_TYPE_RINGBUF` HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from aya.