Module Name: src Committed By: msaitoh Date: Thu Aug 2 04:28:56 UTC 2018
Modified Files: src/sys/kern: uipc_mbuf2.c Log Message: 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. To generate a diff of this commit: cvs rdiff -u -r1.32 -r1.33 src/sys/kern/uipc_mbuf2.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Modified files: Index: src/sys/kern/uipc_mbuf2.c diff -u src/sys/kern/uipc_mbuf2.c:1.32 src/sys/kern/uipc_mbuf2.c:1.33 --- src/sys/kern/uipc_mbuf2.c:1.32 Sun Apr 29 07:13:10 2018 +++ src/sys/kern/uipc_mbuf2.c Thu Aug 2 04:28:56 2018 @@ -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 @@ m_pulldown(struct mbuf *m, int off, int * 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 @@ m_pulldown(struct mbuf *m, int off, int 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;