summaryrefslogtreecommitdiffstats
path: root/sys
diff options
context:
space:
mode:
Diffstat (limited to 'sys')
-rw-r--r--sys/kern/uipc_mbuf.c8
-rw-r--r--sys/sys/mbuf.h9
2 files changed, 16 insertions, 1 deletions
diff --git a/sys/kern/uipc_mbuf.c b/sys/kern/uipc_mbuf.c
index 98ec889..8e278a4 100644
--- a/sys/kern/uipc_mbuf.c
+++ b/sys/kern/uipc_mbuf.c
@@ -85,6 +85,14 @@ SYSCTL_INT(_kern_ipc, OID_AUTO, m_defragrandomfailures, CTLFLAG_RW,
#endif
/*
+ * Ensure the correct size of various mbuf parameters. It could be off due
+ * to compiler-induced padding and alignment artifacts.
+ */
+CTASSERT(sizeof(struct mbuf) == MSIZE);
+CTASSERT(MSIZE - offsetof(struct mbuf, m_dat) == MLEN);
+CTASSERT(MSIZE - offsetof(struct mbuf, m_pktdat) == MHLEN);
+
+/*
* m_get2() allocates minimum mbuf that would fit "size" argument.
*/
struct mbuf *
diff --git a/sys/sys/mbuf.h b/sys/sys/mbuf.h
index ce19715..7e8f427 100644
--- a/sys/sys/mbuf.h
+++ b/sys/sys/mbuf.h
@@ -53,6 +53,10 @@
* externally and attach it to the mbuf in a way similar to that of mbuf
* clusters.
*
+ * NB: These calculation do not take actual compiler-induced alignment and
+ * padding inside the complete struct mbuf into account. Appropriate
+ * attention is required when changing members of struct mbuf.
+ *
* MLEN is data length in a normal mbuf.
* MHLEN is data length in an mbuf with pktheader.
* MINCLSIZE is a smallest amount of data that should be put into cluster.
@@ -84,7 +88,7 @@ struct mb_args {
/*
* Header present at the beginning of every mbuf.
- * Size ILP32: 20
+ * Size ILP32: 24
* LP64: 32
*/
struct m_hdr {
@@ -94,6 +98,9 @@ struct m_hdr {
int32_t mh_len; /* amount of data in this mbuf */
uint32_t mh_type:8, /* type of data in this mbuf */
mh_flags:24; /* flags; see below */
+#if !defined(__LP64__)
+ uint32_t mh_pad; /* pad for 64bit alignment */
+#endif
};
/*
OpenPOWER on IntegriCloud