From 5700f90590b0ad4f63b3ea5b75bdcd621d1ae9d5 Mon Sep 17 00:00:00 2001 From: Eduardo Montoya Date: Mon, 8 Aug 2022 20:06:59 +0200 Subject: [PATCH] [message] document buffer size needs (#7998) With changes in #7554 the `Metadata` stuct size in `Message` increased, leading to unsufficient message buffer size when the maximum number of children is configured, due to the variable size of `ChildMask`. Furthermore, enabling CoAP Blockwise option also extends the message buffer size requirements. This commit documents those cases and makes it clearer for users how to overcome the possible building issues. --- src/core/coap/coap_message.hpp | 2 +- src/core/common/message.hpp | 3 ++- src/core/config/misc.h | 3 +++ 3 files changed, 6 insertions(+), 2 deletions(-) diff --git a/src/core/coap/coap_message.hpp b/src/core/coap/coap_message.hpp index 1f4a86b06..0687201eb 100644 --- a/src/core/coap/coap_message.hpp +++ b/src/core/coap/coap_message.hpp @@ -951,7 +951,7 @@ private: const HelpData &GetHelpData(void) const { static_assert(sizeof(HelpData) + kHelpDataAlignment <= kHeadBufferDataSize, - "Insufficient buffer size for CoAP processing!"); + "Insufficient buffer size for CoAP processing! Increase OPENTHREAD_CONFIG_MESSAGE_BUFFER_SIZE."); return *static_cast(OT_ALIGN(GetFirstData(), kHelpDataAlignment)); } diff --git a/src/core/common/message.hpp b/src/core/common/message.hpp index 78adcee48..060171a8f 100644 --- a/src/core/common/message.hpp +++ b/src/core/common/message.hpp @@ -252,7 +252,8 @@ private: } mBuffer; }; -static_assert(sizeof(Buffer) >= kBufferSize, "Buffer size if not valid"); +static_assert(sizeof(Buffer) >= kBufferSize, + "Buffer size is not valid. Increase OPENTHREAD_CONFIG_MESSAGE_BUFFER_SIZE."); /** * This class represents a message. diff --git a/src/core/config/misc.h b/src/core/config/misc.h index e29bcb50d..e915a0acc 100644 --- a/src/core/config/misc.h +++ b/src/core/config/misc.h @@ -181,6 +181,9 @@ * to that on 32bit system. As a result, the first message always have some * bytes left for small packets. * + * Some configuration options can increase the buffer size requirments, including + * OPENTHREAD_CONFIG_MLE_MAX_CHILDREN and OPENTHREAD_CONFIG_COAP_BLOCKWISE_TRANSFER_ENABLE. + * */ #ifndef OPENTHREAD_CONFIG_MESSAGE_BUFFER_SIZE #define OPENTHREAD_CONFIG_MESSAGE_BUFFER_SIZE (sizeof(void *) * 32)