summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorbluhm <bluhm@openbsd.org>2015-10-30 19:47:40 +0000
committerbluhm <bluhm@openbsd.org>2015-10-30 19:47:40 +0000
commit4d4cc9a33b84be3fa508e2d45b2dfc2d2ef36994 (patch)
tree501a5c4bf1831e2639c84ed18c288c069cf0cbf4
parentRedo 1.69, but correctly, so that this really works for yp setups. (diff)
downloadwireguard-openbsd-4d4cc9a33b84be3fa508e2d45b2dfc2d2ef36994.tar.xz
wireguard-openbsd-4d4cc9a33b84be3fa508e2d45b2dfc2d2ef36994.zip
Let m_resethdr() clear the whole mbuf packet header, not only the
pf part. This allows to reuse this function in socket splicing. Reset the mbuf flags that are related to the packet header, but preserve the data flags. pair(4) tested by reyk@; sosplice(9) tested by bluhm@; OK mikeb@ reyk@
-rw-r--r--sys/kern/uipc_mbuf.c17
-rw-r--r--sys/kern/uipc_socket.c6
2 files changed, 13 insertions, 10 deletions
diff --git a/sys/kern/uipc_mbuf.c b/sys/kern/uipc_mbuf.c
index 2c8f87a90da..06fe2bc3d0f 100644
--- a/sys/kern/uipc_mbuf.c
+++ b/sys/kern/uipc_mbuf.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: uipc_mbuf.c,v 1.209 2015/10/30 12:54:36 reyk Exp $ */
+/* $OpenBSD: uipc_mbuf.c,v 1.210 2015/10/30 19:47:40 bluhm Exp $ */
/* $NetBSD: uipc_mbuf.c,v 1.15.4.1 1996/06/13 17:11:44 cgd Exp $ */
/*
@@ -253,13 +253,18 @@ m_inithdr(struct mbuf *m)
void
m_resethdr(struct mbuf *m)
{
- /* like the previous, but keep any associated data and mbufs */
- m->m_flags = M_PKTHDR;
- memset(&m->m_pkthdr.pf, 0, sizeof(m->m_pkthdr.pf));
- m->m_pkthdr.pf.prio = IFQ_DEFPRIO;
+ int len = m->m_pkthdr.len;
+
+ KASSERT(m->m_flags & M_PKTHDR);
+ m->m_flags &= (M_EXT|M_PKTHDR|M_EOR|M_EXTWR|M_ZEROIZE);
- /* also delete all mbuf tags to reset the state */
+ /* delete all mbuf tags to reset the state */
m_tag_delete_chain(m);
+
+ /* like m_inithdr(), but keep any associated data and mbufs */
+ memset(&m->m_pkthdr, 0, sizeof(m->m_pkthdr));
+ m->m_pkthdr.pf.prio = IFQ_DEFPRIO;
+ m->m_pkthdr.len = len;
}
struct mbuf *
diff --git a/sys/kern/uipc_socket.c b/sys/kern/uipc_socket.c
index 379020389cb..6df9c63fde0 100644
--- a/sys/kern/uipc_socket.c
+++ b/sys/kern/uipc_socket.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: uipc_socket.c,v 1.142 2015/08/24 14:28:25 bluhm Exp $ */
+/* $OpenBSD: uipc_socket.c,v 1.143 2015/10/30 19:47:40 bluhm Exp $ */
/* $NetBSD: uipc_socket.c,v 1.21 1996/02/04 02:17:52 christos Exp $ */
/*
@@ -1325,10 +1325,8 @@ somove(struct socket *so, int wait)
goto release;
m->m_nextpkt = NULL;
if (m->m_flags & M_PKTHDR) {
- m_tag_delete_chain(m);
- memset(&m->m_pkthdr, 0, sizeof(m->m_pkthdr));
+ m_resethdr(m);
m->m_pkthdr.len = len;
- m->m_pkthdr.pf.prio = IFQ_DEFPRIO;
}
/* Send window update to source peer as receive buffer has changed. */