xdp-project / xdp-tools

Utilities and example programs for use with XDP

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

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;
        }
    }

thanks!