Implement headroom by moving packet around #481
Closed
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Instead of mutating a pointer inside "struct packet" to do cheap
shiftleft/shiftright, this patch instead moves around the packet
pointer itself.
The only performance testing I did was "snabb lwaftr bench", where it
appears to be neutral-to-slight-win. I am hoping that the Hydra/R
scientists can help me out on this one.
This change to the packet structure does have a knock-on effect, in
two significant ways. One is that the shiftleft, shiftright, and
prepend functions now return a new packet pointer and silently
corrupt the old one (because probably they shifted around the data but
still had to update the new "length" pointer). That's somewhat OK
though.
The problem comes in the datagram library, which sometimes wants
to work on a user-supplied packet. The sequence was:
local dgram = datagram:new(pkt)
dgram:push(....)
dgram:free()
...
foo(pkt)
This pattern is no longer valid :( The reason is that the datagram
methods that mutate a packet often do so by packet.prepend(). The
datagram library updates its internal packet pointer, but the external
one that was initially passed in is no longer valid. So much of this
patch is visiting (hopefully) all of the uses/users and updating them.