百科.dev
全部条目在线工具AI 编程趋势榜开源项目技术资讯提交条目
登录
< 返回工具列表
R

rex

> 编程语言
开源

Rex 是一个安全且可用的内核扩展框架,它允许在 eBPF 的位置加载和执行 Rust 内核扩展程序。

555 stars0 点赞0 次浏览
访问官网GitHub

工具介绍

Rex 是一个安全且可用的内核扩展框架,它允许在 eBPF 的位置加载和执行 Rust 内核扩展程序。

 ____  _______  __  _____      _                 _
|  _ \| ____\ \/ / | ____|_  _| |_ ___ _ __  ___(_) ___  _ __  ___
| |_) |  _|  \  /  |  _| \ \/ / __/ _ \ '_ \/ __| |/ _ \| '_ \/ __|
|  _    Result {
    obj.bpf_get_current_task()
        .map(|t| t.get_pid())
        .and_then(|p| obj.bpf_map_lookup_elem(&pid_to_errno, &p).cloned())
        .map(|e| obj.bpf_override_return(ctx, e))
        .ok_or(0)
}

More sample programs can be found under samples.

Build and run

You can find the detailed guide here.

Documentations

Additional design documentations can be found under docs.

Why Rex

The existing eBPF extension relies on the in-kernel eBPF verifier to provide safety guarantees. This unfortunately leads to usability issues where safe programs are rejected by the verifier, including but not limited to:

  • programs may exceed the inherent complexity contraints of static verification
  • compilers may not generate verifier-friendly code
  • same logic may need to be implemented in a certain way to please the verifier

Rex aims to address these issues by directly leveraging the safety guarantee from safe Rust. Developers can implement their programs in any way that can be written in safe Rust with few restrictions, and no longer need to worry about program complexity, the code generator, or finding the (many time counter-intuitive) way of expressing the same logic to please the verifier.

We demonstrate this with the implementation of the BPF Memcached Cache (BMC), a state-of-the-art extension program for Memcached acceleration. As a complex eBPF program, BMC is forced to be splitted into several components connected by BPF tail-calls and use awkward loop/branch implementations to please the verifier, which are totally not needed in its Rex implementation.

For example, we show the code in cache invalidation logic of the BPF-BMC that searches for a SET command in the packet payload:

c
// Searches for SET command in payload
for (unsigned int off = 0;
     off < BMC_MAX_PACKET_LENGTH &&  payload + off + 1 <= data_end;
     off++) {
    if (set_found == 0 && payload[off] == 's' &&
        payload + off + 3 <= data_end && payload[off + 1] == 'e' &&
        payload[off + 2] == 't') {
            off += 3;
            set_found = 1;
    }
    ...
}

The code not only introduces an extra constraint in the loop (off < BMC_MAX_PACKET_LENGTH) solely for passing the verifier, but also employs repeated boilerplate code to check packet ends (data_end) and cumbersome logic to match the "set" string in the packet.

None of these burdens is needed with the power of safe Rust in Rex, which has no complexity limits and provides more freedom on the implementation:

rust
let set_iter = payload.windows(4).enumerate().filter_map(|(i, v)| {
    if v == b"set " {
      Some(i)
    } else {
      None
    }
});

The full implementation of BMC in Rex can be found at samples/bmc.

License

Rex is licensed under the GPLv2 license. The submodules (Linux, Rust, LLVM) in this repo are licensed under their own terms. Please see the corresponding license files for more details. Additionally, the memcached benchmark is licensed under the MIT license.

Talks

  • Open Source Summit North America 2025: https://youtu.be/4r7ECxEaGqM
  • USENIX ATC 2025: https://youtu.be/phJ-fb5lEA8
  • Linux Plumbers Conference 2025: https://youtu.be/ivcLS4LFfKE

Issues· 0 开放

查看全部 Issues在 GitHub 打开

暂无开放 Issues,或尚未同步最近议题。

> 标签

Rust

暂无评论,来聊聊你的看法吧

> 工具信息

发布日期2026年8月1日
最后更新2026年9月17日
分类编程语言
定价开源

> 相关工具

T
TypeScript
JavaScript 的超集,为前端与全栈提供静态类型
P
Python
通用编程语言,广泛用于 Web、数据与 AI
G
Go
Google 推出的简洁高效系统语言