summaryrefslogtreecommitdiffstats
path: root/sys/kern/uipc_mbuf.c
diff options
context:
space:
mode:
authorluigi <luigi@FreeBSD.org>2001-02-20 08:23:41 +0000
committerluigi <luigi@FreeBSD.org>2001-02-20 08:23:41 +0000
commitce685a3e045aa8ba84f60a0a1b99166f97d5d09f (patch)
tree16902639b91e3b327770458236240d94e3465ef6 /sys/kern/uipc_mbuf.c
parentb25611e2cfb89c2245e9125afac2aa24cdab61b9 (diff)
downloadFreeBSD-src-ce685a3e045aa8ba84f60a0a1b99166f97d5d09f.zip
FreeBSD-src-ce685a3e045aa8ba84f60a0a1b99166f97d5d09f.tar.gz
Preserve alignment of first mbuf in m_copypacket.
This is useful when doing copies of packet where some leading space has been preallocated to insert protocol headers. Note that there are in fact almost no users of m_copypacket. MFC candidate.
Diffstat (limited to 'sys/kern/uipc_mbuf.c')
-rw-r--r--sys/kern/uipc_mbuf.c4
1 files changed, 4 insertions, 0 deletions
diff --git a/sys/kern/uipc_mbuf.c b/sys/kern/uipc_mbuf.c
index c8cf25c..84d68ef 100644
--- a/sys/kern/uipc_mbuf.c
+++ b/sys/kern/uipc_mbuf.c
@@ -697,6 +697,9 @@ nospace:
* An optimization of the common case `m_copym(m, 0, M_COPYALL, how)'.
* Note that the copy is read-only, because clusters are not copied,
* only their reference counts are incremented.
+ * Preserve alignment of the first mbuf so if the creator has left
+ * some room at the beginning (e.g. for inserting protocol headers)
+ * the copies still have the room available.
*/
struct mbuf *
m_copypacket(struct mbuf *m, int how)
@@ -716,6 +719,7 @@ m_copypacket(struct mbuf *m, int how)
n->m_flags |= M_EXT;
MEXT_ADD_REF(m);
} else {
+ n->m_data = n->m_pktdat + (m->m_data - m->m_pktdat );
bcopy(mtod(m, char *), mtod(n, char *), n->m_len);
}
OpenPOWER on IntegriCloud