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:
parent
6b84cd5819
commit
861daeff3a
@ -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)
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user