[ip6] update HandlePayload() (avoid msg clone if not needed) (#8023)

This commit adds a smaller enhancement in `Ip6::HandlePayload()`. If
support for TCP `OPENTHREAD_CONFIG_TCP_ENABLE` is not enabled, we
exit early from this method before potentially creating a clone of
the message (to free later).
This commit is contained in:
Abtin Keshavarzian
2022-08-16 15:55:48 -07:00
committed by GitHub
parent 47e5277659
commit bbac0e7980
+12 -1
View File
@@ -950,7 +950,18 @@ Error Ip6::HandlePayload(Header & aIp6Header,
Error error = kErrorNone;
Message *message = (aMessageOwnership == Message::kTakeCustody) ? &aMessage : nullptr;
VerifyOrExit(aIpProto == kProtoTcp || aIpProto == kProtoUdp || aIpProto == kProtoIcmp6);
switch (aIpProto)
{
case kProtoUdp:
case kProtoIcmp6:
break;
#if OPENTHREAD_CONFIG_TCP_ENABLE
case kProtoTcp:
break;
#endif
default:
ExitNow();
}
if (aMessageOwnership == Message::kCopyToUse)
{