summaryrefslogtreecommitdiff
path: root/sys/kern/uipc_mbuf.c
diff options
context:
space:
mode:
authorDavid Gwynne <dlg@cvs.openbsd.org>2016-10-10 00:34:51 +0000
committerDavid Gwynne <dlg@cvs.openbsd.org>2016-10-10 00:34:51 +0000
commit76c17bda4c0ad4a0f6af48a307d0712e1b27e0da (patch)
tree96d341848c6de4858d96e4bf8ff7e36e15ffea5e /sys/kern/uipc_mbuf.c
parentd42f248ed31d32f2600749c3be4667b687bb42a8 (diff)
copy the offset of data inside mbufs in m_copym().
this is cheap since it is basic math. it also means that payloads which have been aligned carefully will also be aligned in their copy. ok yasuoka@ claudio@
Diffstat (limited to 'sys/kern/uipc_mbuf.c')
-rw-r--r--sys/kern/uipc_mbuf.c8
1 files changed, 6 insertions, 2 deletions
diff --git a/sys/kern/uipc_mbuf.c b/sys/kern/uipc_mbuf.c
index d6b248f4713..7706dfb7e70 100644
--- a/sys/kern/uipc_mbuf.c
+++ b/sys/kern/uipc_mbuf.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: uipc_mbuf.c,v 1.231 2016/09/15 02:00:16 dlg Exp $ */
+/* $OpenBSD: uipc_mbuf.c,v 1.232 2016/10/10 00:34:50 dlg Exp $ */
/* $NetBSD: uipc_mbuf.c,v 1.15.4.1 1996/06/13 17:11:44 cgd Exp $ */
/*
@@ -603,9 +603,13 @@ m_copym(struct mbuf *m0, int off, int len, int wait)
n->m_data = m->m_data + off;
n->m_ext = m->m_ext;
MCLADDREFERENCE(m, n);
- } else
+ } else {
+ n->m_data += m->m_data -
+ (m->m_flags & M_PKTHDR ? m->m_pktdat : m->m_dat);
+ n->m_data += off;
memcpy(mtod(n, caddr_t), mtod(m, caddr_t) + off,
n->m_len);
+ }
if (len != M_COPYALL)
len -= n->m_len;
off += n->m_len;