-.\" $OpenBSD: mbuf.9,v 1.107 2017/05/19 05:59:27 jmc Exp $
+.\" $OpenBSD: mbuf.9,v 1.108 2017/06/19 17:58:49 bluhm Exp $
.\"
.\" Copyright (c) 2001 Jean-Jacques Bernard-Gundol <jjbg@openbsd.org>
.\" All rights reserved.
.\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
.\" THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
.\"
-.Dd $Mdocdate: May 19 2017 $
+.Dd $Mdocdate: June 19 2017 $
.Dt MGET 9
.Os
.Sh NAME
.Nm m_copyback ,
.Nm m_defrag ,
.Nm m_freem ,
+.Nm m_freemp ,
.Nm m_purge ,
.Nm m_reclaim ,
.Nm m_copydata ,
.Fn m_defrag "struct mbuf *m" "int wait"
.Ft struct mbuf *
.Fn m_freem "struct mbuf *m"
+.Ft struct mbuf *
+.Fn m_freem "struct mbuf **mp"
.Ft void
.Fn m_purge "struct mbuf *m"
.Ft void
pointer, no action occurs and
.Dv NULL
is returned.
+.It Fn m_freemp "struct mbuf **mp"
+Set the input mbuf pointer to
+.Dv NULL
+and call
+.Fn m_freem .
.It Fn m_purge "struct mbuf *m"
Free the list of mbufs linked by m_nextpkt that is pointed to by
.Fa m .
-/* $OpenBSD: bsd-comp.c,v 1.13 2015/11/24 13:37:16 mpi Exp $ */
+/* $OpenBSD: bsd-comp.c,v 1.14 2017/06/19 17:58:49 bluhm Exp $ */
/* $NetBSD: bsd-comp.c,v 1.6 1996/10/13 02:10:58 christos Exp $ */
/* Because this code is derived from the 4.3BSD compress source:
++db->uncomp_count;
if (olen + PPP_HDRLEN + BSD_OVHD > maxolen) {
/* throw away the compressed stuff if it is longer than uncompressed */
- m_freem(*mret);
- *mret = NULL;
+ m_freemp(mret);
++db->incomp_count;
db->incomp_bytes += ilen;
-/* $OpenBSD: if_gif.c,v 1.96 2017/05/18 10:56:45 bluhm Exp $ */
+/* $OpenBSD: if_gif.c,v 1.97 2017/06/19 17:58:49 bluhm Exp $ */
/* $KAME: if_gif.c,v 1.43 2001/02/20 08:51:07 itojun Exp $ */
/*
break;
#endif
default:
- m_freem(*mp);
+ m_freemp(mp);
error = EAFNOSUPPORT;
break;
}
-/* $OpenBSD: pf_norm.c,v 1.205 2017/06/05 22:18:28 sashan Exp $ */
+/* $OpenBSD: pf_norm.c,v 1.206 2017/06/19 17:58:49 bluhm Exp $ */
/*
* Copyright 2001 Niels Provos <provos@citi.umich.edu>
(*m0)->m_nextpkt = NULL;
if (error == 0) {
/* The first mbuf contains the unfragmented packet */
- m_freem(*m0);
- *m0 = NULL;
+ m_freemp(m0);
action = PF_PASS;
} else {
/* Drop expects an mbuf to free */
-/* $OpenBSD: ppp-deflate.c,v 1.12 2015/07/15 22:16:42 deraadt Exp $ */
+/* $OpenBSD: ppp-deflate.c,v 1.13 2017/06/19 17:58:49 bluhm Exp $ */
/* $NetBSD: ppp-deflate.c,v 1.1 1996/03/15 02:28:09 paulus Exp $ */
/*
state->stats.comp_bytes += olen;
state->stats.comp_packets++;
} else {
- m_freem(*mret);
- *mret = NULL;
+ m_freemp(mret);
state->stats.inc_bytes += orig_len;
state->stats.inc_packets++;
-/* $OpenBSD: igmp.c,v 1.68 2017/05/16 12:24:01 mpi Exp $ */
+/* $OpenBSD: igmp.c,v 1.69 2017/06/19 17:58:49 bluhm Exp $ */
/* $NetBSD: igmp.c,v 1.15 1996/02/13 23:41:25 christos Exp $ */
/*
ifp = if_get((*mp)->m_pkthdr.ph_ifidx);
if (ifp == NULL) {
- m_freem(*mp);
+ m_freemp(mp);
return IPPROTO_DONE;
}
-/* $OpenBSD: ip_carp.c,v 1.312 2017/05/30 12:09:27 friehm Exp $ */
+/* $OpenBSD: ip_carp.c,v 1.313 2017/06/19 17:58:49 bluhm Exp $ */
/*
* Copyright (c) 2002 Michael Shalayeff. All rights reserved.
ifp = if_get((*mp)->m_pkthdr.ph_ifidx);
if (ifp == NULL) {
- m_freem(*mp);
+ m_freemp(mp);
return IPPROTO_DONE;
}
ifp = if_get((*mp)->m_pkthdr.ph_ifidx);
if (ifp == NULL) {
- m_freem(*mp);
+ m_freemp(mp);
return IPPROTO_DONE;
}
-/* $OpenBSD: ip_ether.c,v 1.85 2017/04/14 20:46:31 bluhm Exp $ */
+/* $OpenBSD: ip_ether.c,v 1.86 2017/06/19 17:58:49 bluhm Exp $ */
/*
* The author of this code is Angelos D. Keromytis (kermit@adk.gr)
*
if (!etherip_allow && ((*mp)->m_flags & (M_AUTH|M_CONF)) == 0) {
DPRINTF(("etherip_input(): dropped due to policy\n"));
etheripstat.etherips_pdrops++;
- m_freem(*mp);
+ m_freemp(mp);
return IPPROTO_DONE;
}
etherip_decap(*mp, *offp);
default:
DPRINTF(("etherip_input(): dropped, unhandled protocol\n"));
etheripstat.etherips_pdrops++;
- m_freem(*mp);
+ m_freemp(mp);
return IPPROTO_DONE;
}
}
-/* $OpenBSD: ip_icmp.c,v 1.169 2017/05/30 12:09:27 friehm Exp $ */
+/* $OpenBSD: ip_icmp.c,v 1.170 2017/06/19 17:58:49 bluhm Exp $ */
/* $NetBSD: ip_icmp.c,v 1.19 1996/02/13 23:42:22 christos Exp $ */
/*
ifp = if_get((*mp)->m_pkthdr.ph_ifidx);
if (ifp == NULL) {
- m_freem(*mp);
+ m_freemp(mp);
return IPPROTO_DONE;
}
-/* $OpenBSD: ip_input.c,v 1.311 2017/06/19 17:00:16 bluhm Exp $ */
+/* $OpenBSD: ip_input.c,v 1.312 2017/06/19 17:58:49 bluhm Exp $ */
/* $NetBSD: ip_input.c,v 1.30 1996/03/16 23:53:58 christos Exp $ */
/*
#ifdef IPSEC
bad:
#endif
- m_freem(*mp);
+ m_freemp(mp);
}
int
-/* $OpenBSD: ip_ipip.c,v 1.83 2017/06/11 19:59:57 bluhm Exp $ */
+/* $OpenBSD: ip_ipip.c,v 1.84 2017/06/19 17:58:49 bluhm Exp $ */
/*
* The authors of this code are John Ioannidis (ji@tla.org),
* Angelos D. Keromytis (kermit@csd.uch.gr) and
if (!ipip_allow && ((*mp)->m_flags & (M_AUTH|M_CONF)) == 0) {
DPRINTF(("%s: dropped due to policy\n", __func__));
ipipstat_inc(ipips_pdrops);
- m_freem(*mp);
+ m_freemp(mp);
return IPPROTO_DONE;
}
#endif
}
bad:
- m_freem(*mp);
- *mp = NULL;
+ m_freemp(mp);
return IPPROTO_DONE;
}
-/* $OpenBSD: ipsec_input.c,v 1.154 2017/05/28 09:25:51 bluhm Exp $ */
+/* $OpenBSD: ipsec_input.c,v 1.155 2017/06/19 17:58:49 bluhm Exp $ */
/*
* The authors of this code are John Ioannidis (ji@tla.org),
* Angelos D. Keromytis (kermit@csd.uch.gr) and
if (*offp < sizeof(struct ip6_hdr)) {
DPRINTF(("ah6_input(): bad offset\n"));
ahstat.ahs_hdrops++;
- m_freem(*mp);
- *mp = NULL;
+ m_freemp(mp);
return IPPROTO_DONE;
} else if (*offp == sizeof(struct ip6_hdr)) {
protoff = offsetof(struct ip6_hdr, ip6_nxt);
if (protoff + l != *offp) {
DPRINTF(("ah6_input(): bad packet header chain\n"));
ahstat.ahs_hdrops++;
- m_freem(*mp);
- *mp = NULL;
+ m_freemp(mp);
return IPPROTO_DONE;
}
protoff += offsetof(struct ip6_ext, ip6e_nxt);
if (*offp < sizeof(struct ip6_hdr)) {
DPRINTF(("esp6_input(): bad offset\n"));
espstat.esps_hdrops++;
- m_freem(*mp);
- *mp = NULL;
+ m_freemp(mp);
return IPPROTO_DONE;
} else if (*offp == sizeof(struct ip6_hdr)) {
protoff = offsetof(struct ip6_hdr, ip6_nxt);
if (protoff + l != *offp) {
DPRINTF(("esp6_input(): bad packet header chain\n"));
espstat.esps_hdrops++;
- m_freem(*mp);
- *mp = NULL;
+ m_freemp(mp);
return IPPROTO_DONE;
}
protoff += offsetof(struct ip6_ext, ip6e_nxt);
if (*offp < sizeof(struct ip6_hdr)) {
DPRINTF(("ipcomp6_input(): bad offset\n"));
ipcompstat.ipcomps_hdrops++;
- m_freem(*mp);
- *mp = NULL;
+ m_freemp(mp);
return IPPROTO_DONE;
} else if (*offp == sizeof(struct ip6_hdr)) {
protoff = offsetof(struct ip6_hdr, ip6_nxt);
if (protoff + l != *offp) {
DPRINTF(("ipcomp6_input(): bad packet header chain\n"));
ipcompstat.ipcomps_hdrops++;
- m_freem(*mp);
- *mp = NULL;
+ m_freemp(mp);
return IPPROTO_DONE;
}
-/* $OpenBSD: ip6_input.c,v 1.195 2017/06/19 17:00:16 bluhm Exp $ */
+/* $OpenBSD: ip6_input.c,v 1.196 2017/06/19 17:58:49 bluhm Exp $ */
/* $KAME: ip6_input.c,v 1.188 2001/03/29 05:34:31 itojun Exp $ */
/*
}
return;
bad:
- m_freem(*mp);
+ m_freemp(mp);
}
int
-/* $OpenBSD: nfs_socket.c,v 1.116 2017/05/17 08:59:05 mpi Exp $ */
+/* $OpenBSD: nfs_socket.c,v 1.117 2017/06/19 17:58:49 bluhm Exp $ */
/* $NetBSD: nfs_socket.c,v 1.27 1996/04/15 20:20:00 thorpej Exp $ */
/*
}
errout:
if (error && error != EINTR && error != ERESTART) {
- m_freem(*mp);
- *mp = NULL;
+ m_freemp(mp);
if (error != EPIPE)
log(LOG_INFO,
"receive error %d from nfs server %s\n",
} while (error == EWOULDBLOCK);
len -= auio.uio_resid;
}
- if (error) {
- m_freem(*mp);
- *mp = NULL;
- }
+ if (error)
+ m_freemp(mp);
/*
* Search for any mbufs that are not a multiple of 4 bytes long
* or with m_data not longword aligned.
off += m->m_len;
m = m->m_next;
}
- m_freem(*pm);
+ m_freemp(pm);
*pm = n;
}
}
-/* $OpenBSD: mbuf.h,v 1.229 2017/05/30 12:09:27 friehm Exp $ */
+/* $OpenBSD: mbuf.h,v 1.230 2017/06/19 17:58:49 bluhm Exp $ */
/* $NetBSD: mbuf.h,v 1.19 1996/02/09 18:25:14 christos Exp $ */
/*
struct mbuf *m_dup_pkt(struct mbuf *, unsigned int, int);
int m_dup_pkthdr(struct mbuf *, struct mbuf *, int);
+static inline struct mbuf *
+m_freemp(struct mbuf **mp)
+{
+ struct mbuf *m = *mp;
+
+ *mp = NULL;
+ return m_freem(m);
+}
+
/* Packet tag routines */
struct m_tag *m_tag_get(int, int, int);
void m_tag_prepend(struct mbuf *, struct m_tag *);