[ip6] restrict MPL option processing to Hop-by-Hop header (#13055)

RFC 7731 Section 4 specifies that the MPL Option MUST only reside
within a Hop-by-Hop Options extension header. However, previously,
Ip6::HandleOptions processed MplOption::kType regardless of whether the
enclosing header was Hop-by-Hop or Destination Options.

This commit fixes the issue by adding a boolean parameter to
Ip6::HandleOptions indicating if the enclosing header is Hop-by-Hop.
MplOption::kType is now only processed if this parameter is true.
If the MPL Option is encountered in a Destination Options header,
it is treated as unrecognized, and because its type action mandates
discarding the packet, the datagram is dropped safely.
This commit is contained in:
Jonathan Hui
2026-05-06 10:36:56 -07:00
committed by GitHub
parent 430034214e
commit 2dfac4d545
2 changed files with 6 additions and 5 deletions
+5 -4
View File
@@ -489,7 +489,7 @@ exit:
return error;
}
Error Ip6::HandleOptions(Message &aMessage, const Header &aHeader, bool &aReceive)
Error Ip6::HandleOptions(Message &aMessage, const Header &aHeader, bool &aReceive, bool aIsHopByHop)
{
Error error = kErrorNone;
bool hasMplOption = false;
@@ -516,7 +516,7 @@ Error Ip6::HandleOptions(Message &aMessage, const Header &aHeader, bool &aReceiv
continue;
}
if (option.GetType() == MplOption::kType)
if (aIsHopByHop && (option.GetType() == MplOption::kType))
{
VerifyOrExit(!hasMplOption, error = kErrorDrop);
hasMplOption = true;
@@ -817,10 +817,11 @@ Error Ip6::HandleExtensionHeaders(OwnedPtr<Message> &aMessagePtr,
{
case kProtoHopOpts:
VerifyOrExit(first, error = kErrorDrop);
OT_FALL_THROUGH;
SuccessOrExit(error = HandleOptions(*aMessagePtr, aHeader, aReceive, /* aIsHopByHop */ true));
break;
case kProtoDstOpts:
SuccessOrExit(error = HandleOptions(*aMessagePtr, aHeader, aReceive));
SuccessOrExit(error = HandleOptions(*aMessagePtr, aHeader, aReceive, /* aIsHopByHop */ false));
break;
case kProtoFragment:
+1 -1
View File
@@ -363,7 +363,7 @@ private:
Error PrepareMulticastToLargerThanRealmLocal(Message &aMessage, const Header &aHeader);
Error InsertMplOption(Message &aMessage, Header &aHeader);
Error RemoveMplOption(Message &aMessage);
Error HandleOptions(Message &aMessage, const Header &aHeader, bool &aReceive);
Error HandleOptions(Message &aMessage, const Header &aHeader, bool &aReceive, bool aIsHopByHop);
Error Receive(Header &aIp6Header,
OwnedPtr<Message> &aMessagePtr,
uint8_t aIpProto,