Module Name: src Committed By: maxv Date: Mon Jan 22 07:22:52 UTC 2018
Modified Files: src/sys/kern: uipc_mbuf.c Log Message: Fix m_prepend(). If 'm' is not a pkthdr, it doesn't make sense to use MH_ALIGN, it should rather be M_ALIGN. I'm wondering whether there should not be a KASSERT to make sure 'm' is always a pkthdr. To generate a diff of this commit: cvs rdiff -u -r1.177 -r1.178 src/sys/kern/uipc_mbuf.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_mbuf.c diff -u src/sys/kern/uipc_mbuf.c:1.177 src/sys/kern/uipc_mbuf.c:1.178 --- src/sys/kern/uipc_mbuf.c:1.177 Sun Jan 14 16:59:37 2018 +++ src/sys/kern/uipc_mbuf.c Mon Jan 22 07:22:52 2018 @@ -1,4 +1,4 @@ -/* $NetBSD: uipc_mbuf.c,v 1.177 2018/01/14 16:59:37 maxv Exp $ */ +/* $NetBSD: uipc_mbuf.c,v 1.178 2018/01/22 07:22:52 maxv Exp $ */ /* * Copyright (c) 1999, 2001 The NetBSD Foundation, Inc. @@ -62,7 +62,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: uipc_mbuf.c,v 1.177 2018/01/14 16:59:37 maxv Exp $"); +__KERNEL_RCSID(0, "$NetBSD: uipc_mbuf.c,v 1.178 2018/01/22 07:22:52 maxv Exp $"); #ifdef _KERNEL_OPT #include "opt_mbuftrace.h" @@ -666,6 +666,7 @@ m_prepend(struct mbuf *m, int len, int h m_freem(m); return (NULL); } + if (m->m_flags & M_PKTHDR) { M_MOVE_PKTHDR(mn, m); } else { @@ -673,8 +674,15 @@ m_prepend(struct mbuf *m, int len, int h } mn->m_next = m; m = mn; - if (len < MHLEN) - MH_ALIGN(m, len); + + if (m->m_flags & M_PKTHDR) { + if (len < MHLEN) + MH_ALIGN(m, len); + } else { + if (len < MLEN) + M_ALIGN(m, len); + } + m->m_len = len; return (m); }