bpf | eXpress Data Path| XDP

2022-04-18 19:35:18 浏览数 (1)

Introduction to XDP

XDP or eXpress Data Path provides a high performance, programmable network data path in the Linux kernel as part of the IO Visor Project. XDP provides bare metal packet processing at the lowest point in the software stack which makes it ideal for speed without compromising programmability. Furthermore, new functions can be implemented dynamically with the integrated fast path without kernel modification. Other key benefits of XDP includes the following:

XDP 或 eXpress 数据路径在 Linux 内核中提供高性能、可编程的网络数据路径,作为 IO Visor 项目的一部分。XDP 在软件堆栈的最低点提供裸机数据包处理,这使其成为速度的理想选择,而不会影响可编程性。此外,新功能可以通过集成的快速路径动态实现,而无需修改内核。XDP 的其他主要优点包括:

It does not require any specialized hardware 它不需要任何专用硬件

It does not required kernel bypass 它不需要内核绕过

It does not replace the TCP/IP stack 它不会替换 TCP/IP 堆栈

It works in concert with TCP/IP stack along with all the benefits of BPF 它与 TCP/IP 堆栈以及 BPF 的所有优点协同工作

XDP Packet Processing Overview

The XDP packet process includes an in kernel component that processes RX packet-pages directly out of driver via a functional interface without early allocation of skbuff’s or software queues. Normally, one CPU is assigned to each RX queue but in this model, there is no locking RX queue, and CPU can be dedicated to busy poll or interrupt model. BPF programs performs processing such as packet parsing, table look ups, creating/managing stateful filters, encap/decap packets, etc.

XDP 数据包进程包括一个内核组件,该组件通过功能接口直接从驱动程序中处理 RX 数据包页,而无需提前分配 skbuff 或软件队列。通常,每个 RX 队列分配一个 CPU,但在此模型中,没有锁定 RX 队列,CPU 可以专用于忙轮询或中断模型。BPF 程序执行数据包解析、表查找、创建/管理有状态筛选器、封装/取消封装数据包等处理。

The extensibility of BPF is kept intact with packet inspection and manipulation functions, flow and table lookups, and application processing leveraging BPF programs which are portable to userspace and other operating systems.

通过数据包检查和操作功能、流和表查找以及利用可移植到用户空间和其他操作系统的 BPF 程序的应用程序处理,BPF 的可扩展性保持不变。

Use Cases

Use cases for XDP include the following:

  1. Pre-stack processing like filtering to support DDoS mitigation 预堆栈处理(如过滤)以支持 DDoS 缓解
  2. Forwarding and load balancing 转发和负载平衡
  3. Batching techniques such as in Generic Receive Offload 批处理技术,如通用接收卸载
  4. Flow sampling, monitoring 流量采样、监测
  5. ULP processing (i.e. message delineation) ULP 处理(即消息描述)

XDP and DPDK

XDP is sometimes juxtaposed with DPDK when both are perfectly fine approaches. XDP offers another option for users who want performance while still leveraging the programmability of the kernel. Some of the functions that XDP delivers include the following:

  1. Removes the need for 3rd party code and licensing 无需第三方代码和许可
  2. Allows option of busy polling or interrupt driven networking 允许选择繁忙的轮询或中断驱动的网络
  3. Removes the need to allocate large pages 无需分配大页
  4. Removes the need for dedicated CPUs as users have more options on structuring work between CPUs 消除了对专用 CPU 的需求,因为用户在构建 CPU 之间的工作方面有更多选择
  5. Removes the need to inject packets into the kernel from a 3rd party user space application 无需从第三方用户空间应用程序将数据包注入内核
  6. Removes the need to define a new security model for accessing networking hardware 无需定义用于访问网络硬件的新安全模型
  7. https://www.iovisor.org/technology/xdp
  8. https://developers.redhat.com/blog/2018/12/06/achieving-high-performance-low-latency-networking-with-xdp-part-1?extIdCarryOver=true&sc_cid=701f2000001OH6fAAG#some_rough_edges

0 人点赞