libbpf / libbpf-rs

Minimal and opinionated eBPF tooling for the Rust ecosystem
Other
782 stars 138 forks source link

Suggestions on how to get started integrating the new TC Hooks into libbpf-rs #133

Closed mimullin-bbry closed 3 years ago

mimullin-bbry commented 3 years ago

Hello. I'd like to try my hand at integrating the new TC hooks into libbpf-rs.

This seems like a very daunting task for me though. @danobi Do you have suggestions on how to tackle this project?

mimullin-bbry commented 3 years ago

https://github.com/alexforster/libbpf-sys/blob/master/src/bindings.rs#L3754

danobi commented 3 years ago

Sorry about the delay.

First, let's decide if adding the hooks makes sense. Seems fine to me. @anakryiko had plans to move some networking stuff out of libbpf -- does TC apply here?

I think the next logical step would be to draft up the API additions/changes. Like what new enums/structs we need to create. Once we agree on an API implementing should be relatively straight forward.

anakryiko commented 3 years ago

@mimullin-bbry which part is a daunting part? libbpf already has TC-related APIs (https://github.com/libbpf/libbpf/blob/e671a47bc279c6a73d1fee5aa522b0979fd1a33a/src/libbpf.h#L652-L693), are you saying "projecting" that to Rust would be hard? Or there are some other challenges?

mimullin-bbry commented 3 years ago

@danobi @anakryiko No worries on the delay. I too am swamped at my day job right now and haven't been given time to 'play'

When I get some time, my 'method of attacking' the issue will be to play with libbpf in C, then learn how to do it in libbpf_sys then see how to integrate that into the libbpf-rs project.

W.R.T. moving networking (I am assuming both TC and XDP fall into this statement) out of libbpf_sys (and thus libbpf-rs). What is the motivation for doing that?

anakryiko commented 3 years ago

only the AF_XDP parts are being moved into libxdp, as they have little to do with BPF per se, and it's mostly user-space setup of everything, including custom ring buffers and stuff. But all the BPF APIs to attach to XDP, TC and stuff like that stay in libbpf. Basically, if you look at libbpf source code, xsk.c and xsk.h will be moved, everything else stays.