From bbac0e79809da36228d36a16dadc3ac7b23e022a Mon Sep 17 00:00:00 2001 From: Abtin Keshavarzian Date: Tue, 16 Aug 2022 15:55:48 -0700 Subject: [PATCH] [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). --- src/core/net/ip6.cpp | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/src/core/net/ip6.cpp b/src/core/net/ip6.cpp index f7d1e65ae..5ed12028d 100644 --- a/src/core/net/ip6.cpp +++ b/src/core/net/ip6.cpp @@ -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) {