diff options
author | andre <andre@FreeBSD.org> | 2005-11-18 14:40:43 +0000 |
---|---|---|
committer | andre <andre@FreeBSD.org> | 2005-11-18 14:40:43 +0000 |
commit | ae3ca56f7b626f72c9ab7bf852f4733ec10a7f8e (patch) | |
tree | 946ac4f096d2950e5cfad8accccfabaa57607d06 /sys/sys | |
parent | 6e1cf27cb48aebb9cc1c1b5eac813a0f4952825e (diff) | |
download | FreeBSD-src-ae3ca56f7b626f72c9ab7bf852f4733ec10a7f8e.zip FreeBSD-src-ae3ca56f7b626f72c9ab7bf852f4733ec10a7f8e.tar.gz |
Add KASSERTs to M_ALIGN() and MH_ALIGN() to prevent usage on wrong
mbuf types.
Sponsored by: TCP/IP Optimization Fundraise 2005
Diffstat (limited to 'sys/sys')
-rw-r--r-- | sys/sys/mbuf.h | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/sys/sys/mbuf.h b/sys/sys/mbuf.h index 4a28e02..08dfb60 100644 --- a/sys/sys/mbuf.h +++ b/sys/sys/mbuf.h @@ -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) |