Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

XDP Support #208

Closed
huseyinsaatci opened this issue May 26, 2023 · 5 comments
Closed

XDP Support #208

huseyinsaatci opened this issue May 26, 2023 · 5 comments

Comments

@huseyinsaatci
Copy link
Contributor

I was using ebpf_exporter in my project and realized that there is no XDP support in the project. I forked the project and edited it to support XDP programs. I used libbpfgo's AttachXDP function to attach the XDP program to the required interface.

My edit contains two new fields in YAML files: is_xdp to indicate if the metric has an XDP program, and interfaces is an array with interfaces to attach the XDP program. And usage is like:

is_xdp: true
interfaces: ["enp8s0", "docker0"]

If you consider it worth adding support for XDP programs I can open a PR.

@bobrik
Copy link
Contributor

bobrik commented Jun 15, 2023

What do you think about using SEC("xdp/enp8s0") instead (see: #154)? The downside is that the interface is hardcoded in a program, but the upside is that it's consistent with other SEC setups.

In your setup I don't think there's a need for is_xdp. You can detect it from SEC("xdp"). Having interfaces set in the config means that you attach all programs to all interfaces. I can imagine cases where you'd want to have different programs on different interfaces as a part of the same config.

@huseyinsaatci
Copy link
Contributor Author

Makes sense but when I try to use SEC("xdp/enp8s0") in my program I get this error:

missing BPF prog type, check ELF section name 'xdp/enp8s0
failed to load: -22
Error attaching exporter: error loading bpf object from "src/xdp.bpf.o" for config "xdp": failed to load BPF object: invalid argument'

I don't think it recognizes 'xdp/enp8s0' as an XDP program.
It is possible to get the interface from the SEC part but only if this problem can be solved.

@bobrik
Copy link
Contributor

bobrik commented Jun 19, 2023

I linked #154 because it implemented SEC("perf_event/type=0,config=3,frequency=99").

You can do a similar thing here to implement SEC("xdp/enp8s0").

@huseyinsaatci
Copy link
Contributor Author

Okay, I will examine the codes and try to implement a similar one. I hope it's not a problem if I ask questions about the codes if I have problems.

@bobrik
Copy link
Contributor

bobrik commented Jun 30, 2023

I merged #215, thanks!

@bobrik bobrik closed this as completed Jun 30, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants