I made the modifications you suggested but am holding off on a pull request to get your thoughts about a point for removing the asserts entirely. The default settings in place in FreeRTOSIPConfigDefaults.h and in FreeRTOS_IP.h make sure the settings are ideal so it seems that there’s no point in checking it. A user that modifies ipconfigPACKET_FILLER_SIZE is clearly on their own.
To further the point, ipconfigPACKET_FILLER_SIZE defined in FreeRTOSIPConfigDefaults.h defaults to the ideal value if it is not defined in an applications FreeRTOSIPConfig.h. The comments and checks imply that 0 is a valid value to set it to.
/*
* ipconfigPACKET_FILLER_SIZE
*
* Type: size_t
* Unit: bytes
* Minimum: 0
*
* In most projects, network buffers are 32-bit aligned plus 16 bits.
* The two extra bytes are called "filler bytes". They make sure that the
* IP-header starts at a 32-bit aligned address. That makes the code
* very efficient and easy to maintain. An 'uint32_t' can be assigned/
* changed without having to worry about alignment.
*
* See ipconfigBUFFER_PADDING.
*/
#ifndef ipconfigPACKET_FILLER_SIZE
#define ipconfigPACKET_FILLER_SIZE ( 2 )
#endif
#if ( ipconfigPACKET_FILLER_SIZE < 0 )
#error ipconfigPACKET_FILLER_SIZE must be at least 0
#endif
#if ( ipconfigPACKET_FILLER_SIZE > SIZE_MAX )
#error ipconfigPACKET_FILLER_SIZE overflows a size_t
#endif
Comments for that configuration setting in FreeRTOS-Plus-TCP source at some point prior (pre AWS) are shown below. I copied them from FreeRTOS-Plus-TCP to my configuration file years ago when I ported the stack to our application. The default value was still 2 at the time but I defined it as 0 then as it is today.
Note that I’m not sure if the comments were for the original macro name, ipFILLER_SIZE and what version of FreeRTOS-Plus-TCP it was originally in. Possibly zero copy demo code, I’m not sure.
/* Advanced only: in order to access 32-bit fields in the IP packets with
32-bit memory instructions, all packets will be stored 32-bit-aligned, plus
16-bits. This has to do with the contents of the IP-packets: all 32-bit fields
are 32-bit-aligned, plus 16-bit(!). */
My point is that putting a warning in comments for ipconfigPACKET_FILLER_SIZE and removing the asserts may be a better approach.
I also realized that I could have defined ipconfigBUFFER_PADDING as:
#define ipBUFFER_PADDING ( 12U + ipconfigPACKET_FILLER_SIZE )
to avoid the assert although the extra memory would be unused.
What are your thoughts?