summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTheo de Raadt <deraadt@cvs.openbsd.org>2009-08-09 11:40:59 +0000
committerTheo de Raadt <deraadt@cvs.openbsd.org>2009-08-09 11:40:59 +0000
commit238ecfedf5eb81ff8e786e9cec23c9f422951a3a (patch)
treed8372c1a05c03969508d1bff93a0058199babb9b
parent4a5b03862209236ce66103e379544f2e1e0f8853 (diff)
MCLGETI() will now allocate a mbuf header if it is not provided, thus
reducing the amount of splnet/splx dancing required.. especially in the worst case (of m_cldrop) ok dlg kettenis damien
-rw-r--r--share/man/man9/mbuf.95
-rw-r--r--sys/arch/socppc/dev/if_tsec.c12
-rw-r--r--sys/arch/sparc64/dev/vnet.c12
-rw-r--r--sys/dev/ic/gem.c12
-rw-r--r--sys/dev/ic/hme.c12
-rw-r--r--sys/dev/ic/re.c12
-rw-r--r--sys/dev/pci/if_bge.c22
-rw-r--r--sys/dev/pci/if_bnx.c13
-rw-r--r--sys/dev/pci/if_em.c12
-rw-r--r--sys/dev/pci/if_iwn.c24
-rw-r--r--sys/dev/pci/if_ix.c12
-rw-r--r--sys/dev/pci/if_msk.c12
-rw-r--r--sys/dev/pci/if_sis.c12
-rw-r--r--sys/dev/pci/if_vic.c12
-rw-r--r--sys/dev/pci/if_vr.c12
-rw-r--r--sys/dev/pci/if_wpi.c24
-rw-r--r--sys/kern/uipc_mbuf.c22
-rw-r--r--sys/sys/mbuf.h4
18 files changed, 76 insertions, 170 deletions
diff --git a/share/man/man9/mbuf.9 b/share/man/man9/mbuf.9
index 8b24883cd1f..ca2c7b6e682 100644
--- a/share/man/man9/mbuf.9
+++ b/share/man/man9/mbuf.9
@@ -1,4 +1,4 @@
-.\" $OpenBSD: mbuf.9,v 1.43 2009/03/02 23:37:08 blambert Exp $
+.\" $OpenBSD: mbuf.9,v 1.44 2009/08/09 11:40:58 deraadt Exp $
.\"
.\" Copyright (c) 2001 Jean-Jacques Bernard-Gundol <jjbg@openbsd.org>
.\" All rights reserved.
@@ -25,7 +25,7 @@
.\" (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: March 2 2009 $
+.Dd $Mdocdate: August 9 2009 $
.Dt MBUF 9
.Os
.Sh NAME
@@ -84,6 +84,7 @@
.Fn m_apply "struct mbuf *m" "int off" "int len" \
"int (*func)(caddr_t, caddr_t, unsigned int)" "caddr_t fstate"
.Fn MCLGET "struct mbuf *m" "int how"
+.Ft struct mbuf *
.Fn MCLGETI "struct mbuf *m" "int how" "struct ifnet *ifp" "int len"
.Fn MEXTADD "struct mbuf *m" "caddr_t buf" "u_int size" "int type" \
"void (*free)(caddr_t, u_int, void *)" "void *arg"
diff --git a/sys/arch/socppc/dev/if_tsec.c b/sys/arch/socppc/dev/if_tsec.c
index bca792b7a21..ca377948d2d 100644
--- a/sys/arch/socppc/dev/if_tsec.c
+++ b/sys/arch/socppc/dev/if_tsec.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: if_tsec.c,v 1.22 2009/02/22 20:03:19 kettenis Exp $ */
+/* $OpenBSD: if_tsec.c,v 1.23 2009/08/09 11:40:58 deraadt Exp $ */
/*
* Copyright (c) 2008 Mark Kettenis
@@ -1196,15 +1196,9 @@ tsec_alloc_mbuf(struct tsec_softc *sc, bus_dmamap_t map)
{
struct mbuf *m = NULL;
- MGETHDR(m, M_DONTWAIT, MT_DATA);
- if (m == NULL)
+ m = MCLGETI(NULL, M_DONTWAIT, &sc->sc_ac.ac_if, MCLBYTES);
+ if (!m)
return (NULL);
-
- MCLGETI(m, M_DONTWAIT, &sc->sc_ac.ac_if, MCLBYTES);
- if ((m->m_flags & M_EXT) == 0) {
- m_freem(m);
- return (NULL);
- }
m->m_len = m->m_pkthdr.len = MCLBYTES;
if (bus_dmamap_load_mbuf(sc->sc_dmat, map, m, BUS_DMA_NOWAIT) != 0) {
diff --git a/sys/arch/sparc64/dev/vnet.c b/sys/arch/sparc64/dev/vnet.c
index 0364bddfa7f..c7cac05fbf9 100644
--- a/sys/arch/sparc64/dev/vnet.c
+++ b/sys/arch/sparc64/dev/vnet.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: vnet.c,v 1.16 2009/05/12 21:33:38 kettenis Exp $ */
+/* $OpenBSD: vnet.c,v 1.17 2009/08/09 11:40:58 deraadt Exp $ */
/*
* Copyright (c) 2009 Mark Kettenis
*
@@ -681,14 +681,10 @@ vnet_rx_vio_dring_data(struct vnet_softc *sc, struct vio_msg_tag *tag)
if (desc.hdr.dstate != VIO_DESC_READY)
break;
- MGETHDR(m, M_DONTWAIT, MT_DATA);
- if(m == NULL)
+ m = MCLGETI(NULL, M_DONTWAIT, &sc->sc_ac.ac_if,
+ MCLBYTES);
+ if (!m)
break;
- MCLGETI(m, M_DONTWAIT, &sc->sc_ac.ac_if, MCLBYTES);
- if ((m->m_flags & M_EXT) == 0) {
- m_freem(m);
- break;
- }
ifp->if_ipackets++;
m->m_pkthdr.rcvif = ifp;
m->m_len = m->m_pkthdr.len = desc.nbytes;
diff --git a/sys/dev/ic/gem.c b/sys/dev/ic/gem.c
index 851010ab767..9a02283a960 100644
--- a/sys/dev/ic/gem.c
+++ b/sys/dev/ic/gem.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: gem.c,v 1.93 2009/08/03 11:09:10 sthen Exp $ */
+/* $OpenBSD: gem.c,v 1.94 2009/08/09 11:40:58 deraadt Exp $ */
/* $NetBSD: gem.c,v 1.1 2001/09/16 00:11:43 eeh Exp $ */
/*
@@ -1006,15 +1006,9 @@ gem_add_rxbuf(struct gem_softc *sc, int idx)
struct mbuf *m;
int error;
- MGETHDR(m, M_DONTWAIT, MT_DATA);
- if (m == NULL)
+ m = MCLGETI(NULL, M_DONTWAIT, &sc->sc_arpcom.ac_if, MCLBYTES);
+ if (!m)
return (ENOBUFS);
-
- MCLGETI(m, M_DONTWAIT, &sc->sc_arpcom.ac_if, MCLBYTES);
- if ((m->m_flags & M_EXT) == 0) {
- m_freem(m);
- return (ENOBUFS);
- }
m->m_len = m->m_pkthdr.len = MCLBYTES;
#ifdef GEM_DEBUG
diff --git a/sys/dev/ic/hme.c b/sys/dev/ic/hme.c
index e5fa4e266ad..3c5a9413a59 100644
--- a/sys/dev/ic/hme.c
+++ b/sys/dev/ic/hme.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: hme.c,v 1.58 2009/06/22 14:31:04 sthen Exp $ */
+/* $OpenBSD: hme.c,v 1.59 2009/08/09 11:40:58 deraadt Exp $ */
/* $NetBSD: hme.c,v 1.21 2001/07/07 15:59:37 thorpej Exp $ */
/*-
@@ -1415,17 +1415,11 @@ hme_newbuf(sc, d)
* until we're sure everything is a success.
*/
- MGETHDR(m, M_DONTWAIT, MT_DATA);
- if (m == NULL)
+ m = MCLGETI(NULL, M_DONTWAIT, &sc->sc_arpcom.ac_if, MCLBYTES);
+ if (!m)
return (ENOBUFS);
m->m_pkthdr.rcvif = &sc->sc_arpcom.ac_if;
- MCLGETI(m, M_DONTWAIT, &sc->sc_arpcom.ac_if, MCLBYTES);
- if ((m->m_flags & M_EXT) == 0) {
- m_freem(m);
- return (ENOBUFS);
- }
-
if (bus_dmamap_load(sc->sc_dmatag, sc->sc_rxmap_spare,
mtod(m, caddr_t), MCLBYTES - HME_RX_OFFSET, NULL,
BUS_DMA_NOWAIT) != 0) {
diff --git a/sys/dev/ic/re.c b/sys/dev/ic/re.c
index e3caa4bae14..e6cbd4bf963 100644
--- a/sys/dev/ic/re.c
+++ b/sys/dev/ic/re.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: re.c,v 1.113 2009/07/23 20:15:32 kettenis Exp $ */
+/* $OpenBSD: re.c,v 1.114 2009/08/09 11:40:58 deraadt Exp $ */
/* $FreeBSD: if_re.c,v 1.31 2004/09/04 07:54:05 ru Exp $ */
/*
* Copyright (c) 1997, 1998-2003
@@ -1213,16 +1213,10 @@ re_newbuf(struct rl_softc *sc)
u_int32_t cmdstat;
int error, idx;
- MGETHDR(m, M_DONTWAIT, MT_DATA);
- if (m == NULL)
+ m = MCLGETI(NULL, M_DONTWAIT, &sc->sc_arpcom.ac_if, MCLBYTES);
+ if (!m)
return (ENOBUFS);
- MCLGETI(m, M_DONTWAIT, &sc->sc_arpcom.ac_if, MCLBYTES);
- if ((m->m_flags & M_EXT) == 0) {
- m_freem(m);
- return (ENOBUFS);
- }
-
/*
* Initialize mbuf length fields and fixup
* alignment so that the frame payload is
diff --git a/sys/dev/pci/if_bge.c b/sys/dev/pci/if_bge.c
index f03f1415002..8f8986974f1 100644
--- a/sys/dev/pci/if_bge.c
+++ b/sys/dev/pci/if_bge.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: if_bge.c,v 1.279 2009/08/08 15:58:14 naddy Exp $ */
+/* $OpenBSD: if_bge.c,v 1.280 2009/08/09 11:40:56 deraadt Exp $ */
/*
* Copyright (c) 2001 Wind River Systems
@@ -719,15 +719,9 @@ bge_newbuf(struct bge_softc *sc, int i)
struct mbuf *m;
int error;
- MGETHDR(m, M_DONTWAIT, MT_DATA);
- if (m == NULL)
+ m = MCLGETI(NULL, M_DONTWAIT, &sc->arpcom.ac_if, MCLBYTES);
+ if (!m)
return (ENOBUFS);
-
- MCLGETI(m, M_DONTWAIT, &sc->arpcom.ac_if, MCLBYTES);
- if (!(m->m_flags & M_EXT)) {
- m_freem(m);
- return (ENOBUFS);
- }
m->m_len = m->m_pkthdr.len = MCLBYTES;
if (!(sc->bge_flags & BGE_RX_ALIGNBUG))
m_adj(m, ETHER_ALIGN);
@@ -776,15 +770,9 @@ bge_newbuf_jumbo(struct bge_softc *sc, int i)
struct mbuf *m;
int error;
- MGETHDR(m, M_DONTWAIT, MT_DATA);
- if (m == NULL)
+ m = MCLGETI(NULL, M_DONTWAIT, &sc->arpcom.ac_if, BGE_JLEN);
+ if (!m)
return (ENOBUFS);
-
- MCLGETI(m, M_DONTWAIT, &sc->arpcom.ac_if, BGE_JLEN);
- if (!(m->m_flags & M_EXT)) {
- m_freem(m);
- return (ENOBUFS);
- }
m->m_len = m->m_pkthdr.len = BGE_JUMBO_FRAMELEN;
if (!(sc->bge_flags & BGE_RX_ALIGNBUG))
m_adj(m, ETHER_ALIGN);
diff --git a/sys/dev/pci/if_bnx.c b/sys/dev/pci/if_bnx.c
index e0f0de5c17a..3bf0151bdf1 100644
--- a/sys/dev/pci/if_bnx.c
+++ b/sys/dev/pci/if_bnx.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: if_bnx.c,v 1.82 2009/08/06 19:53:13 sthen Exp $ */
+/* $OpenBSD: if_bnx.c,v 1.83 2009/08/09 11:40:56 deraadt Exp $ */
/*-
* Copyright (c) 2006 Broadcom Corporation
@@ -3591,16 +3591,9 @@ bnx_get_buf(struct bnx_softc *sc, u_int16_t *prod,
*prod_bseq);
/* This is a new mbuf allocation. */
- MGETHDR(m, M_DONTWAIT, MT_DATA);
- if (m == NULL)
+ m = MCLGETI(NULL, M_DONTWAIT, &sc->arpcom.ac_if, MCLBYTES);
+ if (!m)
return (ENOBUFS);
-
- /* Attach a cluster to the mbuf. */
- MCLGETI(m, M_DONTWAIT, &sc->arpcom.ac_if, MCLBYTES);
- if (!(m->m_flags & M_EXT)) {
- m_freem(m);
- return (ENOBUFS);
- }
m->m_len = m->m_pkthdr.len = MCLBYTES;
/* the chip aligns the ip header for us, no need to m_adj */
diff --git a/sys/dev/pci/if_em.c b/sys/dev/pci/if_em.c
index 7dbec34a729..9a7155f2ab6 100644
--- a/sys/dev/pci/if_em.c
+++ b/sys/dev/pci/if_em.c
@@ -31,7 +31,7 @@ POSSIBILITY OF SUCH DAMAGE.
***************************************************************************/
-/* $OpenBSD: if_em.c,v 1.215 2009/07/27 16:37:52 claudio Exp $ */
+/* $OpenBSD: if_em.c,v 1.216 2009/08/09 11:40:56 deraadt Exp $ */
/* $FreeBSD: if_em.c,v 1.46 2004/09/29 18:28:28 mlaier Exp $ */
#include <dev/pci/if_em.h>
@@ -2307,14 +2307,8 @@ em_get_buf(struct em_softc *sc, int i)
return (ENOBUFS);
}
- MGETHDR(m, M_DONTWAIT, MT_DATA);
- if (m == NULL) {
- sc->mbuf_alloc_failed++;
- return (ENOBUFS);
- }
- MCLGETI(m, M_DONTWAIT, &sc->interface_data.ac_if, MCLBYTES);
- if ((m->m_flags & M_EXT) == 0) {
- m_freem(m);
+ m = MCLGETI(NULL, M_DONTWAIT, &sc->interface_data.ac_if, MCLBYTES);
+ if (!m) {
sc->mbuf_cluster_failed++;
return (ENOBUFS);
}
diff --git a/sys/dev/pci/if_iwn.c b/sys/dev/pci/if_iwn.c
index bc6c2d431ee..76883231278 100644
--- a/sys/dev/pci/if_iwn.c
+++ b/sys/dev/pci/if_iwn.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: if_iwn.c,v 1.60 2009/07/10 07:44:04 blambert Exp $ */
+/* $OpenBSD: if_iwn.c,v 1.61 2009/08/09 11:40:56 deraadt Exp $ */
/*-
* Copyright (c) 2007-2009 Damien Bergamini <damien.bergamini@free.fr>
@@ -1010,15 +1010,8 @@ iwn_alloc_rx_ring(struct iwn_softc *sc, struct iwn_rx_ring *ring)
goto fail;
}
- MGETHDR(data->m, M_DONTWAIT, MT_DATA);
- if (data->m == NULL) {
- printf("%s: could not allocate RX mbuf\n",
- sc->sc_dev.dv_xname);
- error = ENOMEM;
- goto fail;
- }
- MCLGETI(data->m, M_DONTWAIT, NULL, IWN_RBUF_SIZE);
- if (!(data->m->m_flags & M_EXT)) {
+ data->m = MCLGETI(NULL, M_DONTWAIT, NULL, IWN_RBUF_SIZE);
+ if (!data->m) {
printf("%s: could not allocate RX mbuf cluster\n",
sc->sc_dev.dv_xname);
error = ENOBUFS;
@@ -1704,15 +1697,8 @@ iwn_rx_done(struct iwn_softc *sc, struct iwn_rx_desc *desc,
return;
}
- MGETHDR(m1, M_DONTWAIT, MT_DATA);
- if (m1 == NULL) {
- ic->ic_stats.is_rx_nombuf++;
- ifp->if_ierrors++;
- return;
- }
- MCLGETI(m1, M_DONTWAIT, NULL, IWN_RBUF_SIZE);
- if (!(m1->m_flags & M_EXT)) {
- m_freem(m1);
+ m1 = MCLGETI(NULL, M_DONTWAIT, NULL, IWN_RBUF_SIZE);
+ if (!m1) {
ic->ic_stats.is_rx_nombuf++;
ifp->if_ierrors++;
return;
diff --git a/sys/dev/pci/if_ix.c b/sys/dev/pci/if_ix.c
index e4a03ef8e93..067efcc2b69 100644
--- a/sys/dev/pci/if_ix.c
+++ b/sys/dev/pci/if_ix.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: if_ix.c,v 1.24 2009/07/10 12:00:52 dlg Exp $ */
+/* $OpenBSD: if_ix.c,v 1.25 2009/08/09 11:40:56 deraadt Exp $ */
/******************************************************************************
@@ -2217,14 +2217,8 @@ ixgbe_get_buf(struct rx_ring *rxr, int i)
return (ENOBUFS);
}
- MGETHDR(m, M_DONTWAIT, MT_DATA);
- if (m == NULL) {
- sc->mbuf_alloc_failed++;
- return (ENOBUFS);
- }
- MCLGETI(m, M_DONTWAIT, &sc->arpcom.ac_if, size);
- if ((m->m_flags & M_EXT) == 0) {
- m_freem(m);
+ m = MCLGETI(NULL, M_DONTWAIT, &sc->arpcom.ac_if, size);
+ if (!m) {
sc->mbuf_cluster_failed++;
return (ENOBUFS);
}
diff --git a/sys/dev/pci/if_msk.c b/sys/dev/pci/if_msk.c
index 9cc0ef3dad6..387837302e0 100644
--- a/sys/dev/pci/if_msk.c
+++ b/sys/dev/pci/if_msk.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: if_msk.c,v 1.75 2009/03/29 14:36:34 jsg Exp $ */
+/* $OpenBSD: if_msk.c,v 1.76 2009/08/09 11:40:56 deraadt Exp $ */
/*
* Copyright (c) 1997, 1998, 1999, 2000
@@ -503,15 +503,9 @@ msk_newbuf(struct sk_if_softc *sc_if)
int error;
int opcode, i;
- MGETHDR(m, M_DONTWAIT, MT_DATA);
- if (m == NULL)
+ m = MCLGETI(NULL, M_DONTWAIT, &sc_if->arpcom.ac_if, sc_if->sk_pktlen);
+ if (!m)
return (ENOBUFS);
-
- MCLGETI(m, M_DONTWAIT, &sc_if->arpcom.ac_if, sc_if->sk_pktlen);
- if ((m->m_flags & M_EXT) == 0) {
- m_freem(m);
- return (ENOBUFS);
- }
m->m_len = m->m_pkthdr.len = sc_if->sk_pktlen;
m_adj(m, ETHER_ALIGN);
diff --git a/sys/dev/pci/if_sis.c b/sys/dev/pci/if_sis.c
index bc8a6d9cfa6..3fb8be5af3b 100644
--- a/sys/dev/pci/if_sis.c
+++ b/sys/dev/pci/if_sis.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: if_sis.c,v 1.94 2009/07/22 21:32:50 miod Exp $ */
+/* $OpenBSD: if_sis.c,v 1.95 2009/08/09 11:40:56 deraadt Exp $ */
/*
* Copyright (c) 1997, 1998, 1999
* Bill Paul <wpaul@ctr.columbia.edu>. All rights reserved.
@@ -1232,16 +1232,10 @@ sis_newbuf(struct sis_softc *sc, struct sis_desc *c)
if (c == NULL)
return (EINVAL);
- MGETHDR(m_new, M_DONTWAIT, MT_DATA);
- if (m_new == NULL)
+ m_new = MCLGETI(NULL, M_DONTWAIT, &sc->arpcom.ac_if, MCLBYTES);
+ if (!m_new)
return (ENOBUFS);
- MCLGETI(m_new, M_DONTWAIT, &sc->arpcom.ac_if, MCLBYTES);
- if (!(m_new->m_flags & M_EXT)) {
- m_free(m_new);
- return (ENOBUFS);
- }
-
m_new->m_len = m_new->m_pkthdr.len = MCLBYTES;
if (bus_dmamap_load_mbuf(sc->sc_dmat, c->map, m_new,
diff --git a/sys/dev/pci/if_vic.c b/sys/dev/pci/if_vic.c
index cbe5345796f..3a5e9c1f0de 100644
--- a/sys/dev/pci/if_vic.c
+++ b/sys/dev/pci/if_vic.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: if_vic.c,v 1.71 2009/06/02 12:32:06 deraadt Exp $ */
+/* $OpenBSD: if_vic.c,v 1.72 2009/08/09 11:40:56 deraadt Exp $ */
/*
* Copyright (c) 2006 Reyk Floeter <reyk@openbsd.org>
@@ -1340,15 +1340,9 @@ vic_alloc_mbuf(struct vic_softc *sc, bus_dmamap_t map, u_int pktlen)
{
struct mbuf *m = NULL;
- MGETHDR(m, M_DONTWAIT, MT_DATA);
- if (m == NULL)
+ m = MCLGETI(NULL, M_DONTWAIT, &sc->sc_ac.ac_if, pktlen);
+ if (!m)
return (NULL);
-
- MCLGETI(m, M_DONTWAIT, &sc->sc_ac.ac_if, pktlen);
- if ((m->m_flags & M_EXT) == 0) {
- m_freem(m);
- return (NULL);
- }
m->m_data += ETHER_ALIGN;
m->m_len = m->m_pkthdr.len = pktlen - ETHER_ALIGN;
diff --git a/sys/dev/pci/if_vr.c b/sys/dev/pci/if_vr.c
index 1dbe51a569e..4c961ebe1c2 100644
--- a/sys/dev/pci/if_vr.c
+++ b/sys/dev/pci/if_vr.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: if_vr.c,v 1.97 2009/06/18 18:53:02 claudio Exp $ */
+/* $OpenBSD: if_vr.c,v 1.98 2009/08/09 11:40:56 deraadt Exp $ */
/*
* Copyright (c) 1997, 1998
@@ -1568,16 +1568,10 @@ vr_alloc_mbuf(struct vr_softc *sc, struct vr_chain_onefrag *r)
if (r == NULL)
return (EINVAL);
- MGETHDR(m, M_DONTWAIT, MT_DATA);
- if (m == NULL)
+ m = MCLGETI(NULL, M_DONTWAIT, &sc->arpcom.ac_if, MCLBYTES);
+ if (!m)
return (ENOBUFS);
- MCLGETI(m, M_DONTWAIT, &sc->arpcom.ac_if, MCLBYTES);
- if (!(m->m_flags & M_EXT)) {
- m_free(m);
- return (ENOBUFS);
- }
-
m->m_len = m->m_pkthdr.len = MCLBYTES;
m_adj(m, sizeof(u_int64_t));
diff --git a/sys/dev/pci/if_wpi.c b/sys/dev/pci/if_wpi.c
index d52562647fe..ccd1cd72728 100644
--- a/sys/dev/pci/if_wpi.c
+++ b/sys/dev/pci/if_wpi.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: if_wpi.c,v 1.89 2009/07/11 13:28:36 blambert Exp $ */
+/* $OpenBSD: if_wpi.c,v 1.90 2009/08/09 11:40:56 deraadt Exp $ */
/*-
* Copyright (c) 2006-2008
@@ -641,15 +641,8 @@ wpi_alloc_rx_ring(struct wpi_softc *sc, struct wpi_rx_ring *ring)
goto fail;
}
- MGETHDR(data->m, M_DONTWAIT, MT_DATA);
- if (data->m == NULL) {
- printf("%s: could not allocate RX mbuf\n",
- sc->sc_dev.dv_xname);
- error = ENOBUFS;
- goto fail;
- }
- MCLGETI(data->m, M_DONTWAIT, NULL, WPI_RBUF_SIZE);
- if (!(data->m->m_flags & M_EXT)) {
+ data->m = MCLGETI(NULL, M_DONTWAIT, NULL, WPI_RBUF_SIZE);
+ if (!data->m) {
printf("%s: could not allocate RX mbuf cluster\n",
sc->sc_dev.dv_xname);
error = ENOBUFS;
@@ -1192,15 +1185,8 @@ wpi_rx_done(struct wpi_softc *sc, struct wpi_rx_desc *desc,
return;
}
- MGETHDR(m1, M_DONTWAIT, MT_DATA);
- if (m1 == NULL) {
- ic->ic_stats.is_rx_nombuf++;
- ifp->if_ierrors++;
- return;
- }
- MCLGETI(m1, M_DONTWAIT, NULL, WPI_RBUF_SIZE);
- if (!(m1->m_flags & M_EXT)) {
- m_freem(m1);
+ m1 = MCLGETI(NULL, M_DONTWAIT, NULL, WPI_RBUF_SIZE);
+ if (!m1) {
ic->ic_stats.is_rx_nombuf++;
ifp->if_ierrors++;
return;
diff --git a/sys/kern/uipc_mbuf.c b/sys/kern/uipc_mbuf.c
index 02d221f0bc5..4d005f58054 100644
--- a/sys/kern/uipc_mbuf.c
+++ b/sys/kern/uipc_mbuf.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: uipc_mbuf.c,v 1.122 2009/06/22 10:51:06 thib Exp $ */
+/* $OpenBSD: uipc_mbuf.c,v 1.123 2009/08/09 11:40:58 deraadt Exp $ */
/* $NetBSD: uipc_mbuf.c,v 1.15.4.1 1996/06/13 17:11:44 cgd Exp $ */
/*
@@ -386,9 +386,10 @@ m_cluncount(struct mbuf *m, int all)
} while (all && (m = m->m_next));
}
-void
+struct mbuf *
m_clget(struct mbuf *m, int how, struct ifnet *ifp, u_int pktlen)
{
+ struct mbuf *m0 = NULL;
int pi;
int s;
@@ -399,11 +400,25 @@ m_clget(struct mbuf *m, int how, struct ifnet *ifp, u_int pktlen)
#endif
if (ifp != NULL && m_cldrop(ifp, pi))
- return;
+ return (NULL);
s = splnet();
+ if (m == NULL) {
+ MGETHDR(m0, M_DONTWAIT, MT_DATA);
+ if (m0 == NULL) {
+ splx(s);
+ return (NULL);
+ }
+ m = m0;
+ }
m->m_ext.ext_buf = pool_get(&mclpools[pi],
how == M_WAIT ? PR_WAITOK : 0);
+ if (!m->m_ext.ext_buf) {
+ if (m0)
+ m_freem(m0);
+ splx(s);
+ return (NULL);
+ }
splx(s);
if (m->m_ext.ext_buf != NULL) {
m->m_data = m->m_ext.ext_buf;
@@ -419,6 +434,7 @@ m_clget(struct mbuf *m, int how, struct ifnet *ifp, u_int pktlen)
MCLINITREFERENCE(m);
}
+ return (m);
}
struct mbuf *
diff --git a/sys/sys/mbuf.h b/sys/sys/mbuf.h
index 68871411ce6..7ac36d34010 100644
--- a/sys/sys/mbuf.h
+++ b/sys/sys/mbuf.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: mbuf.h,v 1.123 2009/06/05 00:05:22 claudio Exp $ */
+/* $OpenBSD: mbuf.h,v 1.124 2009/08/09 11:40:58 deraadt Exp $ */
/* $NetBSD: mbuf.h,v 1.19 1996/02/09 18:25:14 christos Exp $ */
/*
@@ -421,7 +421,7 @@ struct mbuf *m_inject(struct mbuf *, int, int, int);
struct mbuf *m_getptr(struct mbuf *, int, int *);
int m_leadingspace(struct mbuf *);
int m_trailingspace(struct mbuf *);
-void m_clget(struct mbuf *, int, struct ifnet *, u_int);
+struct mbuf *m_clget(struct mbuf *, int, struct ifnet *, u_int);
void m_clsetwms(struct ifnet *, u_int, u_int, u_int);
int m_cldrop(struct ifnet *, int);
void m_clcount(struct ifnet *, int);