用户是否需要更改套接字类型才能使用 XDP?
如果我们想绕过内核网络堆栈,看起来我们必须使用 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 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
确实可以使用 AF_XDP 套接字绕过内核。使用 XDP 的主要卖点是您可以有选择地绕过。例如,您的 XDP 程序可以选择仅绕过特定 IP+TCP 端口的流量,从而允许系统的其余部分正常运行。因此,您不需要修改所有应用程序,只需修改您想要使用内核绕过的应用程序即可。
绕过网络堆栈还意味着内核不再为您做任何事情(TCP 重传、数据包确认、重新排序、碎片整理)。因此,任何不想绕过内核的应用程序也必须实现自己的网络堆栈,才能像普通套接字一样使用它。如果这是您的用例,您可能需要研究 DPDK 它可以选择在底层使用 XDP,但会执行以下操作:还有更多给你。
至于典型用例:
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: