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

Introduce BPF Streams abstraction

Open etsal opened this issue 1 month ago • 4 comments

Add libbpf-rs support for interacting with BPF streams from Rust code. The interface provides the option to either directly specify the prog fd/stream id, or to hide the details behind a Stream abstraction.

etsal avatar Dec 09 '25 18:12 etsal

Thank you for the review, I will update the PR accordingly and post here to confirm it's ready for review. Ack to all comments, though I have a couple followup questions (inline).

etsal avatar Dec 10 '25 00:12 etsal

Updated the code and added tests. The interface now presents the streams only indirectly and without exposing the type itself unless the user opts to create an instance directly. I think the code now is more idiomatic and looks a lot less like C.

etsal avatar Dec 10 '25 20:12 etsal

The failing tests looks like are caused the test VMs' kernel being < 6.17?

etsal avatar Dec 10 '25 21:12 etsal

The failing tests looks like are caused the test VMs' kernel being < 6.17?

If that's the case you can mark them as ignored for now.

https://github.com/libbpf/libbpf-rs/blob/e0caff4e52982ff5eca8c0008af0e70fcc709580/libbpf-rs/tests/test.rs#L1702

At the moment we just use whatever kernel the Ubuntu image ships with. Right now that seems to be 6.11 (https://github.com/actions/runner-images/blob/main/images/ubuntu/Ubuntu2404-Readme.md)

danielocfb avatar Dec 10 '25 22:12 danielocfb

Clippy seems to be failing on unrelated code.

etsal avatar Dec 12 '25 18:12 etsal

Not sure why clippy is hitting these errors, they are for pre-existing code.

etsal avatar Dec 12 '25 18:12 etsal

It's failing because you don't use all functions provided by the common module, which your new test_stream module uses, so Rust complains about unused code.

I fixed it up and merged. Thanks for the pull request!

danielocfb avatar Dec 12 '25 22:12 danielocfb

Thank you for the detailed feedback!

etsal avatar Dec 12 '25 22:12 etsal