Source-Changes-HG archive

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

[src/trunk]: src/sys/kern Fix m_prepend(). If 'm' is not a pkthdr, it doesn't...



details:   https://anonhg.NetBSD.org/src/rev/ee019d156a05
branches:  trunk
changeset: 829206:ee019d156a05
user:      maxv <maxv%NetBSD.org@localhost>
date:      Mon Jan 22 07:22:52 2018 +0000

description:
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.

diffstat:

 sys/kern/uipc_mbuf.c |  16 ++++++++++++----
 1 files changed, 12 insertions(+), 4 deletions(-)

diffs (44 lines):

diff -r 93d96958a99d -r ee019d156a05 sys/kern/uipc_mbuf.c
--- a/sys/kern/uipc_mbuf.c      Mon Jan 22 07:11:45 2018 +0000
+++ b/sys/kern/uipc_mbuf.c      Mon Jan 22 07:22:52 2018 +0000
@@ -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_freem(m);
                return (NULL);
        }
+
        if (m->m_flags & M_PKTHDR) {
                M_MOVE_PKTHDR(mn, m);
        } else {
@@ -673,8 +674,15 @@
        }
        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);
 }



Home | Main Index | Thread Index | Old Index