英文:
xdpoffload attach failed: Invalid argument
问题
当我尝试在XDP卸载模式下附加BPF程序时,我收到"Invalid argument"的错误。如果通过代码或使用"bpftool"进行附加,我会得到相同的错误。以下是我使用netlink进行附加的方式:
err = netlink.LinkSetXdpFdWithFlags(link, objects.CollectIpsProg.FD(), 8)
使用"bpftool"的方式如下:
# bpftool prog loadall collect_ips.o /sys/fs/bpf/collect_ips type xdp
# bpftool net attach xdpoffload id 106 dev public
Error: interface xdpoffload attach failed: Invalid argument
在驱动模式下加载程序时,我没有任何问题,其中"4"被传递给"LinkSetXdpFdWithFlags"。
我的网卡是Mellanox MT28800 Family [ConnectX-5 Ex],应该支持硬件卸载。
我的主要XDP程序调用了两个不同的尾部程序。我使用了"BPF_MAP_TYPE_RINGBUF"、"BPF_MAP_TYPE_PROG_ARRAY"和"BPF_MAP_TYPE_ARRAY"。
英文:
When I try to attach a BPF program in XDP offload mode, I get Invalid argument
. I get the same error if attach through code or by using bpftool
. Here's how I'm attaching using netlink:
err = netlink.LinkSetXdpFdWithFlags(link, objects.CollectIpsProg.FD(), 8)
And from using bpftool
:
# bpftool prog loadall collect_ips.o /sys/fs/bpf/collect_ips type xdp
# bpftool net attach xdpoffload id 106 dev public
Error: interface xdpoffload attach failed: Invalid argument
I don't have any issues loading the program in driver mode, where 4
is passed to LinkSetXdpFdWithFlags
.
My NIC, Mellanox MT28800 Family [ConnectX-5 Ex], should support HW offload.
My main XDP program makes calls to two different tail programs. I use BPF_MAP_TYPE_RINGBUF, BPF_MAP_TYPE_PROG_ARRAY, and BPF_MAP_TYPE_ARRAY
.
答案1
得分: 1
Mellanox卡支持一些硬件卸载(例如流量控制规则),但据我所知,不支持BPF程序的卸载。目前市面上唯一支持BPF卸载的以太网适配器是Netronome的卡。
检查这一点的一种方法是在Linux源代码中使用grep命令搜索XDP_SETUP_PROG_HW
BPF netdev命令:
$ git grep XDP_SETUP_PROG_HW
drivers/net/ethernet/netronome/nfp/nfp_net_common.c: case XDP_SETUP_PROG_HW:
drivers/net/netdevsim/bpf.c: if (bpf->command == XDP_SETUP_PROG_HW && !ns->bpf_xdpoffload_accept) {
drivers/net/netdevsim/bpf.c: if (bpf->command == XDP_SETUP_PROG_HW) {
drivers/net/netdevsim/bpf.c: case XDP_SETUP_PROG_HW:
include/linux/netdevice.h: XDP_SETUP_PROG_HW,
net/core/dev.c: xdp.command = mode == XDP_MODE_HW ? XDP_SETUP_PROG_HW : XDP_SETUP_PROG;
该命令用于通过ndo_bpf
回调函数告诉驱动程序将BPF程序卸载到硬件上。
英文:
Mellanox cards support some hardware offload (e.g., flow control rules), but not the offload of BPF programs as far as I know. The only Ethernet adapters out there that support BPF offloading are Netronome's cards.
One way to check this is to grep for the XDP_SETUP_PROG_HW
BPF netdev command in the Linux source code:
$ git grep XDP_SETUP_PROG_HW
drivers/net/ethernet/netronome/nfp/nfp_net_common.c: case XDP_SETUP_PROG_HW:
drivers/net/netdevsim/bpf.c: if (bpf->command == XDP_SETUP_PROG_HW && !ns->bpf_xdpoffload_accept) {
drivers/net/netdevsim/bpf.c: if (bpf->command == XDP_SETUP_PROG_HW) {
drivers/net/netdevsim/bpf.c: case XDP_SETUP_PROG_HW:
include/linux/netdevice.h: XDP_SETUP_PROG_HW,
net/core/dev.c: xdp.command = mode == XDP_MODE_HW ? XDP_SETUP_PROG_HW : XDP_SETUP_PROG;
That command is used to tell the driver to offload the BPF program to the hardware, via the ndo_bpf
callback function.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论