aboutsummaryrefslogtreecommitdiff
path: root/sys/sys/mbuf.h
diff options
context:
space:
mode:
authorRandall Stewart <rrs@FreeBSD.org>2023-04-01 05:46:38 +0000
committerRandall Stewart <rrs@FreeBSD.org>2023-04-01 05:46:38 +0000
commit73ee5756dee6b2110eb6fb2b2ef3cde39a1fcb4f (patch)
tree32251ae7fe68feb89a31e29ff45abcaba7750f1a /sys/sys/mbuf.h
parent63b113af5706420b149b5b8b2189d1e4d0b9782d (diff)
downloadsrc-73ee5756dee6b2110eb6fb2b2ef3cde39a1fcb4f.tar.gz
src-73ee5756dee6b2110eb6fb2b2ef3cde39a1fcb4f.zip
Diffstat (limited to 'sys/sys/mbuf.h')
-rw-r--r--sys/sys/mbuf.h14
1 files changed, 11 insertions, 3 deletions
diff --git a/sys/sys/mbuf.h b/sys/sys/mbuf.h
index a6a28291123d..4798c9c2a9ab 100644
--- a/sys/sys/mbuf.h
+++ b/sys/sys/mbuf.h
@@ -1236,6 +1236,16 @@ m_align(struct mbuf *m, int len)
(M_WRITABLE(m) ? ((m)->m_data - M_START(m)) : 0)
/*
+ * So M_TRAILINGROOM() is for when you want to know how much space
+ * would be there if it was writable. This can be used to
+ * detect changes in mbufs by knowing the value at one point
+ * and then being able to compare it later to the current M_TRAILINGROOM().
+ * The TRAILINGSPACE() macro is not suitable for this since an mbuf
+ * at one point might not be writable and then later it becomes writable
+ * even though the space at the back of it has not changed.
+ */
+#define M_TRAILINGROOM(m) ((M_START(m) + M_SIZE(m)) - ((m)->m_data + (m)->m_len))
+/*
* Compute the amount of space available after the end of data in an mbuf.
*
* The M_WRITABLE() is a temporary, conservative safety measure: the burden
@@ -1245,9 +1255,7 @@ m_align(struct mbuf *m, int len)
* for mbufs with external storage. We now allow mbuf-embedded data to be
* read-only as well.
*/
-#define M_TRAILINGSPACE(m) \
- (M_WRITABLE(m) ? \
- ((M_START(m) + M_SIZE(m)) - ((m)->m_data + (m)->m_len)) : 0)
+#define M_TRAILINGSPACE(m) (M_WRITABLE(m) ? M_TRAILINGROOM(m) : 0)
/*
* Arrange to prepend space of size plen to mbuf m. If a new mbuf must be