summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHenning Brauer <henning@cvs.openbsd.org>2007-09-26 13:05:53 +0000
committerHenning Brauer <henning@cvs.openbsd.org>2007-09-26 13:05:53 +0000
commit840875529f90055d075f45cd3b26a4ec8ad20d44 (patch)
tree8e500d02eed906b5308f5b97cf1263bf483dfada
parent7c7b7adabcdab5abf6ac15d613f20c313ec47ec1 (diff)
provide m_inithdr(), which takes an mbuf and gives an initialized M_PKTHDR
mbuf back. for fixing PR5563 in a few, tested janjaap@stack.nl, ok claudio
-rw-r--r--sys/kern/uipc_mbuf.c25
-rw-r--r--sys/sys/mbuf.h3
2 files changed, 26 insertions, 2 deletions
diff --git a/sys/kern/uipc_mbuf.c b/sys/kern/uipc_mbuf.c
index 5bec7746a28..c95648a262a 100644
--- a/sys/kern/uipc_mbuf.c
+++ b/sys/kern/uipc_mbuf.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: uipc_mbuf.c,v 1.85 2007/07/20 09:59:19 claudio Exp $ */
+/* $OpenBSD: uipc_mbuf.c,v 1.86 2007/09/26 13:05:52 henning Exp $ */
/* $NetBSD: uipc_mbuf.c,v 1.15.4.1 1996/06/13 17:11:44 cgd Exp $ */
/*
@@ -186,6 +186,8 @@ m_gethdr(int nowait, int type)
if (m) {
m->m_type = type;
mbstat.m_mtypes[type]++;
+
+ /* keep in sync with m_inithdr */
m->m_next = (struct mbuf *)NULL;
m->m_nextpkt = (struct mbuf *)NULL;
m->m_data = m->m_pktdat;
@@ -205,6 +207,27 @@ m_gethdr(int nowait, int type)
}
struct mbuf *
+m_inithdr(struct mbuf *m)
+{
+ /* keep in sync with m_gethdr */
+ m->m_next = (struct mbuf *)NULL;
+ m->m_nextpkt = (struct mbuf *)NULL;
+ m->m_data = m->m_pktdat;
+ m->m_flags = M_PKTHDR;
+ m->m_pkthdr.rcvif = NULL;
+ SLIST_INIT(&m->m_pkthdr.tags);
+ m->m_pkthdr.csum_flags = 0;
+ m->m_pkthdr.pf.hdr = NULL;
+ m->m_pkthdr.pf.rtableid = 0;
+ m->m_pkthdr.pf.qid = 0;
+ m->m_pkthdr.pf.tag = 0;
+ m->m_pkthdr.pf.flags = 0;
+ m->m_pkthdr.pf.routed = 0;
+
+ return (m);
+}
+
+struct mbuf *
m_getclr(int nowait, int type)
{
struct mbuf *m;
diff --git a/sys/sys/mbuf.h b/sys/sys/mbuf.h
index b44618dc075..dc531b8d371 100644
--- a/sys/sys/mbuf.h
+++ b/sys/sys/mbuf.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: mbuf.h,v 1.93 2007/09/19 18:19:10 blambert Exp $ */
+/* $OpenBSD: mbuf.h,v 1.94 2007/09/26 13:05:52 henning Exp $ */
/* $NetBSD: mbuf.h,v 1.19 1996/02/09 18:25:14 christos Exp $ */
/*
@@ -471,6 +471,7 @@ struct mbuf *m_free(struct mbuf *);
struct mbuf *m_get(int, int);
struct mbuf *m_getclr(int, int);
struct mbuf *m_gethdr(int, int);
+struct mbuf *m_inithdr(struct mbuf *);
struct mbuf *m_prepend(struct mbuf *, int, int);
struct mbuf *m_pulldown(struct mbuf *, int, int, int *);
struct mbuf *m_pullup(struct mbuf *, int);