Source-Changes-HG archive

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

[src/trunk]: src/sys Implement M_COPY_PKTHDR as a function, like...



details:   https://anonhg.NetBSD.org/src/rev/ce18d10135d6
branches:  trunk
changeset: 318498:ce18d10135d6
user:      maxv <maxv%NetBSD.org@localhost>
date:      Fri Apr 27 07:20:33 2018 +0000
description:
Implement M_COPY_PKTHDR as a function, like m_move_pkthdr.

diffstat:

 sys/kern/uipc_mbuf.c |  16 ++++++++++++++--
 sys/sys/mbuf.h       |  22 +++-------------------
 2 files changed, 17 insertions(+), 21 deletions(-)

diffs (80 lines):

diff -r e0b96c49c0e0 -r ce18d10135d6 sys/kern/uipc_mbuf.c
--- a/sys/kern/uipc_mbuf.c      Fri Apr 27 06:56:21 2018 +0000
+++ b/sys/kern/uipc_mbuf.c      Fri Apr 27 07:20:33 2018 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: uipc_mbuf.c,v 1.201 2018/04/27 06:56:21 maxv Exp $     */
+/*     $NetBSD: uipc_mbuf.c,v 1.202 2018/04/27 07:20:33 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.201 2018/04/27 06:56:21 maxv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: uipc_mbuf.c,v 1.202 2018/04/27 07:20:33 maxv Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_mbuftrace.h"
@@ -1528,6 +1528,18 @@
 }
 
 void
+m_copy_pkthdr(struct mbuf *to, struct mbuf *from)
+{
+       KASSERT((from->m_flags & M_PKTHDR) != 0);
+
+       to->m_pkthdr = from->m_pkthdr;
+       to->m_flags = from->m_flags & M_COPYFLAGS;
+       SLIST_INIT(&to->m_pkthdr.tags);
+       m_tag_copy_chain(to, from);
+       to->m_data = to->m_pktdat;
+}
+
+void
 m_move_pkthdr(struct mbuf *to, struct mbuf *from)
 {
 
diff -r e0b96c49c0e0 -r ce18d10135d6 sys/sys/mbuf.h
--- a/sys/sys/mbuf.h    Fri Apr 27 06:56:21 2018 +0000
+++ b/sys/sys/mbuf.h    Fri Apr 27 07:20:33 2018 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: mbuf.h,v 1.191 2018/04/27 06:56:21 maxv Exp $  */
+/*     $NetBSD: mbuf.h,v 1.192 2018/04/27 07:20:33 maxv Exp $  */
 
 /*
  * Copyright (c) 1996, 1997, 1999, 2001, 2007 The NetBSD Foundation, Inc.
@@ -575,24 +575,7 @@
                (m)->m_data = (m)->m_dat;                               \
 } while (/* CONSTCOND */ 0)
 
-/*
- * Copy mbuf pkthdr from `from' to `to'.
- * `from' must have M_PKTHDR set, and `to' must be empty.
- */
-#define        M_COPY_PKTHDR(to, from)                                         \
-do {                                                                   \
-       KASSERT(((from)->m_flags & M_PKTHDR) != 0);                     \
-       (to)->m_pkthdr = (from)->m_pkthdr;                              \
-       (to)->m_flags = (from)->m_flags & M_COPYFLAGS;                  \
-       SLIST_INIT(&(to)->m_pkthdr.tags);                               \
-       m_tag_copy_chain((to), (from));                                 \
-       (to)->m_data = (to)->m_pktdat;                                  \
-} while (/* CONSTCOND */ 0)
-
-/*
- * Move mbuf pkthdr from `from' to `to'.
- * `from' must have M_PKTHDR set, and `to' must be empty.
- */
+#define        M_COPY_PKTHDR(to, from) m_copy_pkthdr(to, from)
 #define        M_MOVE_PKTHDR(to, from) m_move_pkthdr(to, from)
 
 /*
@@ -871,6 +854,7 @@
 void   m_freem(struct mbuf *);
 void   m_reclaim(void *, int);
 void   mbinit(void);
+void   m_copy_pkthdr(struct mbuf *, struct mbuf *);
 void   m_move_pkthdr(struct mbuf *, struct mbuf *);
 
 bool   m_ensure_contig(struct mbuf **, int);



Home | Main Index | Thread Index | Old Index