Side effect of xdp_program__attach with XDP_MODE_HW?
ami-GS opened this issue · comments
I faced this and investigating. Just for heads up
I tried code below, once the xdp_program__attach failed with XDP_MODE_HW
, other mode also get failed with
libbpf: map 'xsks_map': failed to create: Invalid argument(-22)
If this code start iteration from i == 1, it works with XDP_MODE_SKB
after failing with XDP_MODE_NATIVE
static const struct AttachTypePair {
enum xdp_attach_mode mode;
unsigned int xdp_flag;
} AttachTypePairs[] = {
{ XDP_MODE_HW, XDP_FLAGS_HW_MODE },
{ XDP_MODE_NATIVE, XDP_FLAGS_DRV_MODE },
{ XDP_MODE_SKB, XDP_FLAGS_SKB_MODE },
};
for (uint32_t i = 0; i < ARRAYSIZE(AttachTypePairs); i++) {
err = xdp_program__attach(prog, ifIndex, AttachTypePairs[i].mode, 0);
if (!err) {
AttachMode = AttachTypePairs[i].mode;
break;
}
}
Right, yeah, attaching multiple times with different modes is not really
supported, since the attach involves loading the program. So the right
thing do to is to restart the operation entirely, reconstructing the
xdp_prog structure every time a load is attempted (when mixing modes).
thanks!