Swift IPv6 Outbound Fragmentation support - #68
Conversation
| let fragmentLength = UInt16(chunkLength + IPv6Instance.fragmentExtensionHeaderLength) | ||
| // Fragment offset flags | ||
| let offsetFlags = UInt16(cursor) | (isLast ? 0 : UInt16(IPv6Instance.ip6fMoreFragmentMask)) | ||
| var fragmentFrame = Frame(count: ipv6CompleteHeaderLength + chunkLength) |
There was a problem hiding this comment.
Hm, this seems concerning — I don't think we can just do this, since we would need to get the frame from the protocol below in cases where the frames aren't allocated to just be unique arrays, but have other backing.
There was a problem hiding this comment.
Yep, that makes sense. It was a bit more complex than I expected to adopt getDatagramsToSend because IPv4 and IPv6 instances cannot call this function directly on the instance. I added a callback though that gave writeOutboundFrames access to this function. Adopted in 212cfbb
| let selfReference = self.effectiveSelfReference | ||
| IPInstance.processOutbound( | ||
| &self.instanceType, | ||
| getDatagramsToSend: { maxCount, minSize in |
There was a problem hiding this comment.
If this is being marked on every IP packet send, I worry that passing a new block every time is too heavy. Why not just pass the reference to lower and self reference?
There was a problem hiding this comment.
We should not incur any performance hit here unless the block is actually called. Switching to using lower though is a straightforward change so addressed in e3cf0f6
| var fragmentFrame = Frame(count: IPv4Instance.headerLength + chunkLength) | ||
| let fragmentFrameSize = IPv4Instance.headerLength + chunkLength | ||
| guard | ||
| var allocatedFrames = try? lower.invokeGetDatagramsToSend( |
There was a problem hiding this comment.
Looks good overall. This could probably be optimized by having it batch the get datagrams call to get all of the datagrams it will need if it is more than one, but this is unlikely and probably not a key thing to optimize.
There was a problem hiding this comment.
That's a good idea. Addressed in b8b408b
Adds outbound fragmentation support for Swift IPv6.
IPv6 takes the same approach that IPv4 takes in that it will only attempt to handle fragmentation if needed, otherwise it will use the standard path.