[ip6] enforce single Hop-by-Hop Options header rule (#12896)

RFC 8200 states that the Hop-by-Hop Options header MUST be the first
extension header and can only occur once in a packet. This commit
updates HandleExtensionHeaders to enforce this rule.

This fix prevents a potential infinite loop or exponential growth of
messages when multiple Hop-by-Hop headers (each containing an MPL
option) are processed. Previously, each MPL option could trigger its
own retransmission, and if these options were evicted from the MPL
SeedSet, they would be re-processed as new messages upon loopback,
leading to exponential growth and eventually a timeout.
This commit is contained in:
Jonathan Hui
2026-04-14 23:25:42 -05:00
committed by GitHub
parent 0a38d5f97b
commit 7829782b06
+5
View File
@@ -809,6 +809,7 @@ Error Ip6::HandleExtensionHeaders(OwnedPtr<Message> &aMessagePtr,
{
Error error = kErrorNone;
ExtensionHeader extHeader;
bool first = true;
while (aReceive || aNextHeader == kProtoHopOpts)
{
@@ -817,6 +818,9 @@ Error Ip6::HandleExtensionHeaders(OwnedPtr<Message> &aMessagePtr,
switch (aNextHeader)
{
case kProtoHopOpts:
VerifyOrExit(first, error = kErrorDrop);
OT_FALL_THROUGH;
case kProtoDstOpts:
SuccessOrExit(error = HandleOptions(*aMessagePtr, aHeader, aReceive));
break;
@@ -838,6 +842,7 @@ Error Ip6::HandleExtensionHeaders(OwnedPtr<Message> &aMessagePtr,
}
aNextHeader = extHeader.GetNextHeader();
first = false;
}
exit: