-
Notifications
You must be signed in to change notification settings - Fork 9
mctp-estack: Support vectored payloads in fragmenter #36
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
base: main
Are you sure you want to change the base?
Conversation
Signed-off-by: Marvin Gudel <marvin.gudel@9elements.com>
Signed-off-by: Marvin Gudel <marvin.gudel@9elements.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, it was on the todo list, good to avoid that buffer. fragment()
can be replaced with a call to fragment_vectored()
too.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
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 |
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.