mctp-estack: Support vectored payloads in fragmenter#36
mctp-estack: Support vectored payloads in fragmenter#36mkj merged 5 commits intoCodeConstruct:mainfrom
Conversation
Signed-off-by: Marvin Gudel <marvin.gudel@9elements.com>
Signed-off-by: Marvin Gudel <marvin.gudel@9elements.com>
mkj
left a comment
There was a problem hiding this comment.
Thanks, it was on the todo list, good to avoid that buffer. fragment() can be replaced with a call to fragment_vectored() too.
mctp-estack/src/fragment.rs
Outdated
| let remaining_payload_len = total_payload_len - self.payload_used; | ||
| let l = remaining_payload_len.min(rest.len()); | ||
| let (d, rest) = rest.split_at_mut(l); | ||
| crate::util::copy_vectored(payload, self.payload_used, d); |
There was a problem hiding this comment.
There seems to be a lot of conversion back and forth between total length/offset and slice indices/offsets.
It might simplify the code to remove total_payload_len and payload_used, and instead store current input slice index and offset in Fragmenter? get_sub_slice() wouldn't be needed.
There was a problem hiding this comment.
Was thinking something similar while implementing, but just continued bending the existing code until it worked to get a poc.
A "VectorReader" that holds the state and has all of the clean methods like read(), is_at_end(), ... could be nice.
I'll try to come up with something.
There was a problem hiding this comment.
Worked out as I intended.
I'm happy how the Fragmenter looks now.
Maybe there are some nits how to make the reader implementation a bit cleaner, but finding the best way is hard with all the available stuff to access slices.
Signed-off-by: Marvin Gudel <marvin.gudel@9elements.com>
Signed-off-by: Marvin Gudel <marvin.gudel@9elements.com>
|
Noticed, that my code was missing the check for All the tests seem to just check with |
Signed-off-by: Marvin Gudel <marvin.gudel@9elements.com>
55294db to
793949a
Compare
Yes, the better code coverage would certainly be worth adding. For checking locally I've been using In this specific case I think it'd be difficult to notice that no tests match on |
Add a method to fragment vectored payloads directly.
This eliminates the need to copy vectored payloads to a buffer that can hold the largest possible payload and instead copies the data directly to the packet buffer while fragmenting.