Aya, the first library to create eBPF controllers in Rust

Linus torvalds as well as many developers Kernel and different distributions have expressed their liking about Rust and even on more than one occasion the issue of the implementation of drivers in this programming language on the Linux Kernel has been presented.

And on this, various works have already been released, of which we have already mentioned here on the blog and we can mention for example experiment successful from the alternate set of utilities, coreutils, rewritten in Rust (This includes utilities like sort, cat, chmod, chown, chroot, cp, date, dd, echo, hostname, id, ln, and ls).

Given this, Linus torvalds has not fully given his point in favor of this initiative and has expressed the negative points (you can consult the details In the following link.)

Despite the harsh criticism from Linus, the works about implementation Rust in the Kernel have not stopped moving on and recently the first version of the Aya library was presented, which allows you to create eBPF drivers in Rust that run inside the Linux kernel in a special JIT virtual machine.

Unlike other EBPF development tools, Aya doesn't use libbpf and the BCC compiler, But offers its own implementation written in Rust which uses the libc drawer package to directly access kernel system calls. Building Aya does not require C language tools or kernel headers.

For whom it is are unaware of eBPF, they should know that this is a bytecode interpreter built into the Linux kernel that allows you to create network operations handlers, monitor system operation, intercept system calls, control access, process events with timing, calculate the frequency and time of operations, and track using kprobes / uprobes / tracepoints.

Thanks to JIT compilation, bytecode is translated into machine instructions on the fly and it runs with the performance of native code. XDP provides a means to run BPF programs at the network driver level, with direct access to the DMA packet buffer, allowing you to create high-performance drivers for high network load conditions.

About Aya

Of the key features mentioned from Aya we can find that has the support for BTF (BPF type format), which provides type information in BPF pseudocode to check and compare types provided by the current kernel. Using BTF makes it possible to create universal eBPF drivers that can be used without having to recompile them with different versions of the Linux kernel.

As well as the support for bpf-to-bpf calls, global variables and initializers, which allows to design programs for eBPF by analogy with conventional programs using aya as execution time, canceling functions taking into account the work in eBPF.

On the other hand, it also has the support for internal kernel types, including regular arrays, hashmaps, stacks, queues, stack traces, and structures for sockets and performance tracking.

Also has the ability to create various types of eBTF programs, including programs for filtering and traffic management, cgroup and various socket drivers, XDP programs and also platform support for asynchronous request processing in non-blocking tokyo mode and async-std.
Fast compilation, without being tied to kernel compilation or kernel headers.

It is important to mention that the project is still considered experimental as the API is not stabilized yet and continues to evolve. Also, not all the conceived functions have yet been implemented.

By the end of the year, the developers hope to bring Aya's functionality on par with libbpf and in January 2022 form the first stable version. It is also planned to combine the Aya parts needed to write Rust code for the Linux kernel with the user space components used to load, attach, and interact with eBPF programs.

Finally if you are interested in knowing more about it, you can check the details in the following link.


The content of the article adheres to our principles of editorial ethics. To report an error click here!.

Be the first to comment

Leave a Comment

Your email address will not be published. Required fields are marked with *

*

*

  1. Responsible for the data: AB Internet Networks 2008 SL
  2. Purpose of the data: Control SPAM, comment management.
  3. Legitimation: Your consent
  4. Communication of the data: The data will not be communicated to third parties except by legal obligation.
  5. Data storage: Database hosted by Occentus Networks (EU)
  6. Rights: At any time you can limit, recover and delete your information.