[ip6] ensure to make room for new header at correct offset (#8717)

In `InsertMplOption()` we need to insert the Option at the original
end of Hop-by-hop Extension header which we track in `hbhSize`. Note
that the read `hbh` is updated (we increment the `Length` field which
increases the `hbh.GetSize()` by 8 bytes).

The code before this commit which inserted the header at the new
`hbh.GetSize()` offset still works correctly since we copy all the
bytes before the insertion offset back. It just copies more bytes than
necessary.
This commit is contained in:
Abtin Keshavarzian
2023-02-03 21:31:19 -08:00
committed by GitHub
parent 48128acb76
commit a3d353af8c
+1 -1
View File
@@ -268,7 +268,7 @@ Error Ip6::InsertMplOption(Message &aMessage, Header &aHeader)
aMessage.Write(0, hbh);
// make space for MPL Option + padding by shifting hop-by-hop option header
SuccessOrExit(error = aMessage.InsertHeader(hbh.GetSize(), 8));
SuccessOrExit(error = aMessage.InsertHeader(hbhSize, 8));
// insert MPL Option
mMpl.InitOption(mplOption, aHeader.GetSource());