rpkt: A Generic, Safe, and Efficient Userspace Packet Processing Library in Rust
摘要
Userspace packet processing applications need to balance high-performance with strong memory safety, making Rust a suitable choice for implementing such applications. But Rust has not been a mainstream choice for implementing userspace packet processing applications, due to the lack of a well-designed Packet Processing Library (PPL) that can efficiently handle non-contiguous memory buffers and achieve high-performance without breaking Rust’s memory safety guarantees. This paper presents the design of rpkt, a new Rust PPL that is designed to systematically address the problems faced by existing Rust PPLs. At the center of rpkt lies a novel packet buffer abstraction which is compatible with different memory buffer types. rpkt provides safe packet processing APIs and customizes efficient packet buffer implementations for different memory buffer types. In this way, rpkt establishes an efficient and safe way to process packets, regardless of whether the underlying memory buffer is contiguous or not. We compare rpkt with state-of-the-art Rust PPLs. The results show that rpkt achieves better packet processing performance and can leverage various Network Interface Card (NIC) offloading features that require non-contiguous memory buffers.