-
Notifications
You must be signed in to change notification settings - Fork 2k
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
net/gnrc/pktbuf: Add gnrc_pktbuf_merge #6487
Conversation
A few questions:
|
Actually i don't know of any, at least RIOT's crypto module doesn't allow this. Even more i guess it would still be useful to be able to use external crypto lib's functions.
I actually tried this first by just changing their pointers to the right position in the new data segment, it all worked well but test cases showed some problems after releasing the packets. As far as i got it the reason was _pktbuf_free assuming every data block is aligned, which is obviously not possible without having a bunch of 0s in your data block, so i decided the easiest solution would be to treat it as a single pktsnip. |
I don't see the benefits of this - actually I think it might also be problematic to merge and remove snips afterwards, @miri64 seems to be skeptical, too . If such functionality is really needed by some crypto libraries, I'd rather have an intermediate function to merge the buffers into a single buffer (without destroying the snips), something like
|
Thanks for sharing your thoughts @smlng
I do understand your worries, but i don't actually think there should be a problem. The tests cases show no technical problems, so i guess the thing you're worried about is the loss of Information(please correct me if I got that wrong), which might seem strange or unnecessary on the first sight, but if you think about it at the point where you are hashing or encrypting that packet you cannot change anything in that chunk of data anyway without rendering your hash or cipher obsolete.
I think you got that wrong from my previous comment, what i was saying was it would still be useful if it was just some, but actually right now we're talking about every single crypto library that i know of that it's available on riot[1][2][3][4], the only exception which uses update is RIOT's hashes module [5]
The main problem i see here is the need to manage another buffer for a packet whose size might not be static so you would have to just allocate the maximum possible size, while the pktbuf is there too, already allocated but not used, made especially for this. So it's just quite memory efficient to not use the packetbuffer in my opinion. References: |
I'm supervising @tobhe on this project. I believe the pktbuf should allow crypto-functions on the packet, regardless how. @tobhe showed one way to do that, which doesn't impact the current pktbuf a lot. Just for interest: Is there a certain reason for the 32bit alignment in the pktbuf? Without this, keeping the snips would be easy, as @miri64 mentioned. |
Yes, on some of our supported platforms (e.g. all Cortex-M0+ platforms) accessing |
Accidental close... |
@miri64 how do you think about having a |
+1 Whatever comes next, this would probably be an intermediate step anyways. If the pktbuf cannot hold the whole flattened packet as one piece, merging the snips fails anyways. |
@kaspar030: good point, and maybe the real issue here. Could be worth investigating the fragmentation of the packet buffer over time (in a realistic scenario) and how likely (or unlikely) it is to find a large enough section to fit a merged (full) packet. |
Well |
This is also true for
+1 |
As discussed F2F, I don't see, why this needs to be implemented in |
Ping @tobhe? |
@miri64: I'm still there, I just didn't find time for this yet. |
from the discussion I take it this needs some work, hence won't make it for release 2018.01 |
Good to hear, sounds awesome! Yes, I think in any case it makes sense to put it with the other helpers as there are no direct dependencies on the static part, I even think i have some local branch somewhere where I already did this. The thing that stopped me was the tests if i remember correctly 😄 |
@tobhe any plans to return to this? |
@tcschmidt i am still planning to finish this, but i don't know when i will find the time. We can close it down for now and i will just open a new request once i got something. |
Closed until author will take up. |
This adds a
gnrc_pktbuf_merge(gnrc_pktsnip_t *pkt)
function.It's main use is pulling data together in the memory to be able to use hash or crypto functions on the packet which take consecutive byte arrays as an input. This should make it easier to implement protocols like IKE, ESP, DTLS and others using MAC.