|
|
Subscribe / Log in / New account

Aya: writing BPF in Rust

The first release of the Aya BPF library has been announced; this project allows the writing of BPF programs in the Rust language. "Over the last year I've talked with many folks interested in using eBPF in the Rust community. My goal is to get as many of you involved in the project as possible! Now that the rustc target has been merged, it's time to build a solid foundation so that we can enable developers to write great eBPF enabled apps".

to post comments

Aya: writing BPF in Rust

Posted Jun 15, 2021 17:03 UTC (Tue) by danobi (subscriber, #102249) [Link] (7 responses)

A pure rust implementation is nice, but rust doesn't have issues with FFI like go does. I'm curious what the pure rust buys the user in this case. Looking forward to see some examples.

Aya: writing BPF in Rust

Posted Jun 15, 2021 18:50 UTC (Tue) by tialaramex (subscriber, #21167) [Link] (4 responses)

Pure Rust buys you a smaller surface area for certain types of bugs. In particular any memory safety bugs, because the compiler insists on seeing for itself why all the code you wrote doesn't have memory safety bugs *unless* you explicitly marked it as unsafe. So logically if you experience a memory safety bug, it's not hiding somewhere in apparently safe high-level stuff but must instead be in the (hopefully far smaller) unsafe part. Which also hopefully means the people who *wrote* that part were more careful when doing so.

That can translate into more courage to try things you otherwise wouldn't dare, and then when inevitably something goes wrong into more chance of figuring out where the actual bug is.

Also people really like Rust. I actually found I quite enjoy taking a C program and writing an equivalent Rust program, much more so than when I was learning Go for example.

Aya: writing BPF in Rust

Posted Jun 15, 2021 20:11 UTC (Tue) by danobi (subscriber, #102249) [Link] (3 responses)

> Pure Rust buys you a smaller surface area for certain types of bugs. In particular any memory safety bugs, because the compiler insists on seeing for itself why all the code you wrote doesn't have memory safety bugs *unless* you explicitly marked it as unsafe.

Yes, for sure. But I don't think it's a pure win. BPF has a huge surface area and libbpf handles lots of crazy features and edge cases. The tradeoff is that a re-implementation not only has to stay "within spec" (which there currently is none) but also keep up with new developments. And that has its own source of fun bugs.

> Also people really like Rust. I actually found I quite enjoy taking a C program and writing an equivalent Rust program, much more so than when I was learning Go for example.

I do as well :). Disclosure: I wrote most of libbpf-rs (the rust wrappers around libbpf): https://github.com/libbpf/libbpf-rs .

Aya: writing BPF in Rust

Posted Jun 17, 2021 5:36 UTC (Thu) by xinitrc (subscriber, #126452) [Link] (2 responses)

still not a single driver on rust

Aya: writing BPF in Rust

Posted Jun 17, 2021 8:50 UTC (Thu) by farnz (subscriber, #17727) [Link] (1 responses)

Apart from the ixy network driver, you mean?

Aya: writing BPF in Rust

Posted Jun 17, 2021 23:43 UTC (Thu) by xinitrc (subscriber, #126452) [Link]

Havn't seen this one.
Hopefully it will be marked as production ready.

Aya: writing BPF in Rust

Posted Jun 18, 2021 3:54 UTC (Fri) by mkj (subscriber, #85885) [Link] (1 responses)

Pure Rust crates mean you can very easily cross compile to any Rust-supported platform without having to find suitable libbpf etc to match. You can just copy a static binary (musl) to a beagleboard or raspberry pi and be done with it.

Aya: writing BPF in Rust

Posted Jun 20, 2021 16:39 UTC (Sun) by notriddle (subscriber, #130608) [Link]

It also means you get to use Cargo for everything, instead of having to staple together multiple build systems.


Copyright © 2021, Eklektix, Inc.
Comments and public postings are copyrighted by their creators.
Linux is a registered trademark of Linus Torvalds