Module Name:    src
Committed By:   maxv
Date:           Fri Apr 27 07:20:33 UTC 2018

Modified Files:
        src/sys/kern: uipc_mbuf.c
        src/sys/sys: mbuf.h

Log Message:
Implement M_COPY_PKTHDR as a function, like m_move_pkthdr.


To generate a diff of this commit:
cvs rdiff -u -r1.201 -r1.202 src/sys/kern/uipc_mbuf.c
cvs rdiff -u -r1.191 -r1.192 src/sys/sys/mbuf.h

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.201 src/sys/kern/uipc_mbuf.c:1.202
--- src/sys/kern/uipc_mbuf.c:1.201	Fri Apr 27 06:56:21 2018
+++ src/sys/kern/uipc_mbuf.c	Fri Apr 27 07:20:33 2018
@@ -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 @@ enobufs:
 }
 
 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)
 {
 

Index: src/sys/sys/mbuf.h
diff -u src/sys/sys/mbuf.h:1.191 src/sys/sys/mbuf.h:1.192
--- src/sys/sys/mbuf.h:1.191	Fri Apr 27 06:56:21 2018
+++ src/sys/sys/mbuf.h	Fri Apr 27 07:20:33 2018
@@ -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 @@ do {									\
 		(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 @@ struct	mbuf *m_free(struct mbuf *);
 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);

Reply via email to