Add KASSERTs to M_ALIGN() and MH_ALIGN() to prevent usage on wrong

mbuf types.

Sponsored by:	TCP/IP Optimization Fundraise 2005
This commit is contained in:
Andre Oppermann 2005-11-18 14:40:43 +00:00
parent 6b84cd5819
commit 861daeff3a
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=152580

View File

@ -455,6 +455,10 @@ m_chtype(struct mbuf *m, short new_type)
* an object of the specified size at the end of the mbuf, longword aligned.
*/
#define M_ALIGN(m, len) do { \
KASSERT(!((m)->m_flags & (M_PKTHDR|M_EXT)), \
("%s: M_ALIGN not normal mbuf", __func__)); \
KASSERT((m)->m_data == (m)->m_dat, \
("%s: M_ALIGN not a virgin mbuf", __func__)); \
(m)->m_data += (MLEN - (len)) & ~(sizeof(long) - 1); \
} while (0)
@ -463,6 +467,10 @@ m_chtype(struct mbuf *m, short new_type)
* or initialized by M_COPY_PKTHDR.
*/
#define MH_ALIGN(m, len) do { \
KASSERT((m)->m_flags & M_PKTHDR && !((m)->m_flags & M_EXT), \
("%s: MH_ALIGN not PKTHDR mbuf", __func__)); \
KASSERT((m)->m_data == (m)->m_pktdat, \
("%s: MH_ALIGN not a virgin mbuf", __func__)); \
(m)->m_data += (MHLEN - (len)) & ~(sizeof(long) - 1); \
} while (0)