diff options
author | Alexander Bluhm <bluhm@cvs.openbsd.org> | 2015-10-30 19:47:41 +0000 |
---|---|---|
committer | Alexander Bluhm <bluhm@cvs.openbsd.org> | 2015-10-30 19:47:41 +0000 |
commit | ec90619bffd0167dbac76f114dcc0b2d211cb5de (patch) | |
tree | bafa76cb3ff689453aca466807fe0ab6008daffb /sys/kern | |
parent | 82e74f32dcdb3301a64ac3b08b2cad571bbc6d60 (diff) |
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@
Diffstat (limited to 'sys/kern')
-rw-r--r-- | sys/kern/uipc_mbuf.c | 17 | ||||
-rw-r--r-- | sys/kern/uipc_socket.c | 6 |
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. */ |