Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/kern Adjust alignment in m_pulldown().



details:   https://anonhg.NetBSD.org/src/rev/54546e706395
branches:  trunk
changeset: 365137:54546e706395
user:      msaitoh <msaitoh%NetBSD.org@localhost>
date:      Thu Aug 02 04:28:56 2018 +0000

description:
Adjust alignment in m_pulldown().

 IP6_EXTHDR_GET() and M_REGION_GET() do m_pulldown(). When m_pulldown() copies
data into M_TRAILINGSPACE, the alignment might be changed. There are a lot of
IP6_EXTHDR_GET() calls, so I think it's not good to check the alignment after
every IP6_EXTHDR_GET() call. This change fixes this problem in m_pulldown().
In this commit, the next mbuf are 4 byte aligned. For networking, I've never
heard that 64bit alignment is required, so I think it would be OK.

 I don't know this is the best solution, but it's better than nothing.

 OK'd by maxv@.

 After committing this change, the workaround code for PR#50776 can be removed.

diffstat:

 sys/kern/uipc_mbuf2.c |  12 ++++++++++--
 1 files changed, 10 insertions(+), 2 deletions(-)

diffs (41 lines):

diff -r 313052619ad2 -r 54546e706395 sys/kern/uipc_mbuf2.c
--- a/sys/kern/uipc_mbuf2.c     Thu Aug 02 03:40:51 2018 +0000
+++ b/sys/kern/uipc_mbuf2.c     Thu Aug 02 04:28:56 2018 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: uipc_mbuf2.c,v 1.32 2018/04/29 07:13:10 maxv Exp $     */
+/*     $NetBSD: uipc_mbuf2.c,v 1.33 2018/08/02 04:28:56 msaitoh Exp $  */
 /*     $KAME: uipc_mbuf2.c,v 1.29 2001/02/14 13:42:10 itojun Exp $     */
 
 /*
@@ -62,7 +62,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: uipc_mbuf2.c,v 1.32 2018/04/29 07:13:10 maxv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: uipc_mbuf2.c,v 1.33 2018/08/02 04:28:56 msaitoh Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -118,7 +118,12 @@
         * The target data is on <n, off>. If we got enough data on the mbuf
         * "n", we're done.
         */
+#ifdef __NO_STRICT_ALIGNMENT
        if ((off == 0 || offp) && len <= n->m_len - off && !sharedcluster)
+#else
+       if ((off == 0 || offp) && len <= n->m_len - off && !sharedcluster &&
+           ALIGNED_POINTER((mtod(n, char *) + off), uint32_t))
+#endif
                goto ok;
 
        /*
@@ -180,6 +185,9 @@
                goto ok;
        }
        if ((off == 0 || offp) && M_LEADINGSPACE(n->m_next) >= hlen &&
+#ifndef __NO_STRICT_ALIGNMENT
+           ALIGNED_POINTER((n->m_next->m_data - hlen), uint32_t) &&
+#endif
            !sharedcluster && n->m_next->m_len >= tlen) {
                n->m_next->m_data -= hlen;
                n->m_next->m_len += hlen;



Home | Main Index | Thread Index | Old Index