-
Notifications
You must be signed in to change notification settings - Fork 9
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
inlining for use with bpf/xdp? #1
Comments
I didn't even realize rebpf was using this, cool! I'd love for this crate to work for your usecase, but let me ask around and see if there's a better way than annotating everything with |
Hi! Sorry for going dark. I just pushed a branch: https://github.com/alexforster/pdu/tree/inline I asked/googled around and found that the following things are true:
So I had to use the brute-force method of applying Before I publish a new release, please try the branch when you get the chance and let me know how it works out. [dependencies]
pdu = { git = "https://github.com/alexforster/pdu", branch = "inline", default-features = false, features = ["inline"] } |
I'm working from some days to add a "bpf" features (in cargo.toml) to pdu, I want use pdu to parse packet in bpf programs with rebpf.. adding inline to all functions (I have made it with a simple bash script) in pdu is not enough because for some reason:
|
Oh cool, I'll defer to your branch then. I haven't used rebpf (clearly), but in general the verifier is the thing I was most concerned about, because we definitely jump backwards during IP and TCP options parsing and IPv6 extension header parsing. It's going to be tough to unroll those. |
That was about where I was when I opened the issue 😄 Since then I ran into a few issues which I could tell were related to the verifier, but wasn't yet sure why
that probably explains it, I was looking for bounds checks on array index but didn't consider loops very closely!
I'll take a look at your branch and see if I can find a good place to jump in 👍 |
Sorry for my later but i was busy with my work.. To do this I have added a bpf feature in my fork of pdu, I don't kwnow if this is a right way to add bpf support in pdu of if there is a better solution, @alexforster let me know what do you think about my solution, if you want I can do a pull request to pdu inline branch. |
Hi! 👋 I'm exploring using Rust to write bpf programs, and this package is a great fit for some of the networking usecases like xdp. I also found https://github.com/uccidibuti/rebpf/blob/37775452ca79b7c232d535e8c989f07d751a612e/examples/basic03_map_counter/src/kern.rs#L40-L57 which is a reflection of https://github.com/xdp-project/xdp-tutorial/tree/master/basic03-map-counter, and noticed rebpf is based on libbpf-sys which you also maintain 😄 thanks for the quality libraries.
If you look at the first link from rebpf, that example can't import pdu because it runs in a bpf context which requires function inlining for non-bpf code. This crate already works for no_std which is great. I've tested that slapping
#[inline]
everywhere makes some of the basics work properly in bpf programs.Would you consider a cargo feature or some other method of inlining every function so the crate can be used easily from bpf programs? Alternatively if you have some experience with this, do you know an easier approach to use pdu in that context?
I'm happy to help prepare a PR if you're on board, but I wasn't sure what the best approach would be other than manually adding conditional
#[inline]
everywhere (proc macro of some sort)?Appreciate your thoughts 😃
The text was updated successfully, but these errors were encountered: