用户是否需要更改套接字类型才能使用 XDP?

发布于 2025-01-12 02:34:37 字数 125 浏览 4 评论 0原文

如果我们想绕过内核网络堆栈,看起来我们必须使用 AF_XDP 套接字。

这是否意味着我们必须修改用户空间程序?

但是这么多APK,这么多APK配合修改是不是很困难呢?

个人感觉应用场景非常有限。

If we want to bypass the kernel network stack, it looks like we'll have to use AF_XDP sockets.

Does that mean we have to modify the user-space program ?

But with so many APKs, is it difficult for so many APKs to cooperate with modification?

Personally, I feel the application scenario is very limited.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

一张白纸 2025-01-19 02:34:37

确实可以使用 AF_XDP 套接字绕过内核。使用 XDP 的主要卖点是您可以有选择地绕过。例如,您的 XDP 程序可以选择仅绕过特定 IP+TCP 端口的流量,从而允许系统的其余部分正常运行。因此,您不需要修改所有应用程序,只需修改您想要使用内核绕过的应用程序即可。

绕过网络堆栈还意味着内核不再为您做任何事情(TCP 重传、数据包确认、重新排序、碎片整理)。因此,任何不想绕过内核的应用程序也必须实现自己的网络堆栈,才能像普通套接字一样使用它。如果这是您的用例,您可能需要研究 DPDK 它可以选择在底层使用 XDP,但会执行以下操作:还有更多给你。

至于典型用例:

  • 自定义协议实现
  • 块数据包捕获(在 DDoS 保护场景中,您可能希望通过 AF_XDP 转发 1000 个数据包中的 1 个,而不是出于检查目的而进行阻止
  • ) dpdk.org/" rel="nofollow noreferrer">DPDK 和 OvS 可以使用它
  • eBPF 之外的任何其他数据包处理(如果 eBPF 是作为限制,可以在用户空间中以很少的开销进行数据包处理,主要限制是您无法从用户空间发送到本地内核,但您可以修改数据包并做出 DROP 或重新传输决定)。

The kernel can indeed be bypassed using the AF_XDP sockets. The main selling point of using XDP is that you can selectively bypass. Your XDP program can for example chose to only bypass traffic for a specific IP+TCP port, allowing the rest of the system to run like normal. So you don't need to modify all applications, just the one you would like to use kernel bypassing for.

Bypassing the network stack also means that the kernels doesn't do anything for you anymore(TCP retransmission, packet acknowledgement, reordering, defragmentation). So any application which wan't to bypass the kernel must also implement its own network stack to use it like a normal socket. If that is your usecase, you might want to look into DPDK which optionally uses XDP under the hood but does a lot more for you.

As for typical use cases:

  • Custom protocol implementation
  • Packet capture of blocks(in an DDoS protection senario, you might want to forward 1 in a 1000 packets via AF_XDP instread of blocking for inspection purposes)
  • DPDK and OvS can use it
  • Any other packet processing outside of eBPF(if eBPF is to limiting, one can do packet processing in userspace with little overhead. The main limitation is that you can't TX to the local kernel from userspace, but you can modify the packet and make a DROP or re-transmit decision)
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文