libbpf-rs icon indicating copy to clipboard operation
libbpf-rs copied to clipboard

Attach mode parameter to function attach_xdp

Open Rei-Tw opened this issue 3 years ago • 2 comments

Hi,

Is there any way to specify the attach mode for XDP ? The current function to attach an XDP program only has the interface index as parameter (https://docs.rs/libbpf-rs/latest/libbpf_rs/struct.Program.html#method.attach_xdp).

Available attach modes are :

  • XDP_FLAGS_SKB_MODE
  • XDP_FLAGS_DRV_MODE
  • XDP_FLAGS_HW_MODE

Rei-Tw avatar Sep 02 '22 09:09 Rei-Tw

You can use libbpf_sys::bpf_xdp_attach.

chenhengqi avatar Sep 03 '22 04:09 chenhengqi

bpf_xdp_attach() supports this in libbpf but we haven't yet added bpf_xdp_attach() support for libbpf-rs. It's on the list of features missing for feature-parity with libbpf 1.0.

insearchoflosttime avatar Sep 08 '22 21:09 insearchoflosttime

In general I think we lack support for attachment flags?

The use case I ran into was trying to attach (directly, not through a link) a bpf program to a cgroup but needing to set ALLOW_MULTI to the attachment flags.

mdaverde avatar Nov 18 '22 17:11 mdaverde

@Rei-Tw @mdaverde If this is still an issue for you, please feel free to introduce an attach_xdp_* variant that accepts flags in a pull request. We have done something similar for uprobe attachment with de00fbe4097ebcf1f53a9f6867695093f6327e92, for example.

danielocfb avatar Jun 27 '23 22:06 danielocfb

It's an issue for me. I'll give this a go either tomorrow or next week.

Noah-Kennedy avatar Aug 06 '23 03:08 Noah-Kennedy

Fixed by https://github.com/libbpf/libbpf-rs/pull/625

danielocfb avatar Jan 16 '24 17:01 danielocfb