Author: rwatson
Date: Tue Jan  6 12:59:37 2015
New Revision: 276750
URL: https://svnweb.freebsd.org/changeset/base/276750

Log:
  In order to reduce use of M_EXT outside of the mbuf allocator and
  socket-buffer implementations, introduce a return value for MCLGET()
  (and m_cljget() that underlies it) to allow the caller to avoid testing
  M_EXT itself.  Update all callers to use the return value.
  
  With this change, very few network device drivers remain aware of
  M_EXT; the primary exceptions lie in mbuf-chain pretty printers for
  debugging, and in a few cases, custom mbuf and cluster allocation
  implementations.
  
  NB: This is a difficult-to-test change as it touches many drivers for
  which I don't have physical devices.  Instead we've gone for intensive
  review, but further post-commit review would definitely be appreciated
  to spot errors where changes could not easily be made mechanically,
  but were largely mechanical in nature.
  
  Differential Revision:        https://reviews.freebsd.org/D1440
  Reviewed by:  adrian, bz, gnn
  Sponsored by: EMC / Isilon Storage Division

Modified:
  head/share/man/man9/mbuf.9
  head/sys/contrib/ipfilter/netinet/ip_fil_freebsd.c
  head/sys/dev/an/if_an.c
  head/sys/dev/bge/if_bge.c
  head/sys/dev/ce/if_ce.c
  head/sys/dev/cm/smc90cx6.c
  head/sys/dev/cp/if_cp.c
  head/sys/dev/cs/if_cs.c
  head/sys/dev/ctau/if_ct.c
  head/sys/dev/ed/if_ed.c
  head/sys/dev/ex/if_ex.c
  head/sys/dev/fe/if_fe.c
  head/sys/dev/hifn/hifn7751.c
  head/sys/dev/ie/if_ie.c
  head/sys/dev/le/lance.c
  head/sys/dev/lmc/if_lmc.c
  head/sys/dev/mn/if_mn.c
  head/sys/dev/my/if_my.c
  head/sys/dev/pcn/if_pcn.c
  head/sys/dev/pdq/pdq_freebsd.h
  head/sys/dev/pdq/pdq_ifsubr.c
  head/sys/dev/pdq/pdqvar.h
  head/sys/dev/safe/safe.c
  head/sys/dev/sbni/if_sbni.c
  head/sys/dev/smc/if_smc.c
  head/sys/dev/sn/if_sn.c
  head/sys/dev/snc/dp83932.c
  head/sys/dev/ti/if_ti.c
  head/sys/dev/tl/if_tl.c
  head/sys/dev/usb/misc/udbp.c
  head/sys/dev/vx/if_vx.c
  head/sys/dev/wb/if_wb.c
  head/sys/dev/xe/if_xe.c
  head/sys/dev/xen/netfront/netfront.c
  head/sys/mips/adm5120/if_admsw.c
  head/sys/netgraph/atm/ngatmbase.c
  head/sys/netgraph/atm/sscop/ng_sscop_cust.h
  head/sys/netgraph/bluetooth/drivers/bt3c/ng_bt3c_pccard.c
  head/sys/netgraph/bluetooth/drivers/ubt/ng_ubt.c
  head/sys/netgraph/ng_vjc.c
  head/sys/netipsec/key.c
  head/sys/netipsec/keysock.c
  head/sys/sys/mbuf.h

Modified: head/share/man/man9/mbuf.9
==============================================================================
--- head/share/man/man9/mbuf.9  Tue Jan  6 10:02:14 2015        (r276749)
+++ head/share/man/man9/mbuf.9  Tue Jan  6 12:59:37 2015        (r276750)
@@ -24,7 +24,7 @@
 .\"
 .\" $FreeBSD$
 .\"
-.Dd October 21, 2014
+.Dd January 5, 2015
 .Dt MBUF 9
 .Os
 .\"
@@ -40,6 +40,7 @@
 .Ss Mbuf allocation macros
 .Fn MGET "struct mbuf *mbuf" "int how" "short type"
 .Fn MGETHDR "struct mbuf *mbuf" "int how" "short type"
+.Ft int
 .Fn MCLGET "struct mbuf *mbuf" "int how"
 .Fo MEXTADD
 .Fa "struct mbuf *mbuf"
@@ -436,10 +437,12 @@ Allocate and attach an
 .Vt mbuf cluster
 to
 .Fa mbuf .
-If the macro fails, the
+On success, a non-zero value returned; otherwise, 0.
+Historically, consumers would check for success by testing the
 .Dv M_EXT
-flag will not be set in
-.Fa mbuf .
+flag on the mbuf, but this is now discouraged to avoid unnecessary awareness
+of the implementation of external storage in protocol stacks and device
+drivers.
 .It Fn M_ALIGN mbuf len
 Set the pointer
 .Fa mbuf->m_data

Modified: head/sys/contrib/ipfilter/netinet/ip_fil_freebsd.c
==============================================================================
--- head/sys/contrib/ipfilter/netinet/ip_fil_freebsd.c  Tue Jan  6 10:02:14 
2015        (r276749)
+++ head/sys/contrib/ipfilter/netinet/ip_fil_freebsd.c  Tue Jan  6 12:59:37 
2015        (r276750)
@@ -386,8 +386,7 @@ ipf_send_reset(fin)
        if (m == NULL)
                return -1;
        if (sizeof(*tcp2) + hlen > MLEN) {
-               MCLGET(m, M_NOWAIT);
-               if ((m->m_flags & M_EXT) == 0) {
+               if (!(MCLGET(m, M_NOWAIT))) {
                        FREE_MB_T(m);
                        return -1;
                }
@@ -610,8 +609,7 @@ ipf_send_icmp_err(type, fin, dst)
                        code = icmptoicmp6unreach[code];
 
                if (iclen + max_linkhdr + fin->fin_plen > avail) {
-                       MCLGET(m, M_NOWAIT);
-                       if ((m->m_flags & M_EXT) == 0) {
+                       if (!(MCLGET(m, M_NOWAIT))) {
                                FREE_MB_T(m);
                                return -1;
                        }

Modified: head/sys/dev/an/if_an.c
==============================================================================
--- head/sys/dev/an/if_an.c     Tue Jan  6 10:02:14 2015        (r276749)
+++ head/sys/dev/an/if_an.c     Tue Jan  6 12:59:37 2015        (r276750)
@@ -943,8 +943,7 @@ an_rxeof(struct an_softc *sc)
                                if_inc_counter(ifp, IFCOUNTER_IERRORS, 1);
                                return;
                        }
-                       MCLGET(m, M_NOWAIT);
-                       if (!(m->m_flags & M_EXT)) {
+                       if (!(MCLGET(m, M_NOWAIT))) {
                                m_freem(m);
                                if_inc_counter(ifp, IFCOUNTER_IERRORS, 1);
                                return;
@@ -1034,8 +1033,7 @@ an_rxeof(struct an_softc *sc)
                                        if_inc_counter(ifp, IFCOUNTER_IERRORS, 
1);
                                        return;
                                }
-                               MCLGET(m, M_NOWAIT);
-                               if (!(m->m_flags & M_EXT)) {
+                               if (!(MCLGET(m, M_NOWAIT))) {
                                        m_freem(m);
                                        if_inc_counter(ifp, IFCOUNTER_IERRORS, 
1);
                                        return;

Modified: head/sys/dev/bge/if_bge.c
==============================================================================
--- head/sys/dev/bge/if_bge.c   Tue Jan  6 10:02:14 2015        (r276749)
+++ head/sys/dev/bge/if_bge.c   Tue Jan  6 12:59:37 2015        (r276750)
@@ -1383,8 +1383,7 @@ bge_newbuf_jumbo(struct bge_softc *sc, i
        if (m == NULL)
                return (ENOBUFS);
 
-       m_cljget(m, M_NOWAIT, MJUM9BYTES);
-       if (!(m->m_flags & M_EXT)) {
+       if (m_cljget(m, M_NOWAIT, MJUM9BYTES) == NULL) {
                m_freem(m);
                return (ENOBUFS);
        }

Modified: head/sys/dev/ce/if_ce.c
==============================================================================
--- head/sys/dev/ce/if_ce.c     Tue Jan  6 10:02:14 2015        (r276749)
+++ head/sys/dev/ce/if_ce.c     Tue Jan  6 12:59:37 2015        (r276750)
@@ -307,8 +307,7 @@ static struct mbuf *makembuf (void *buf,
        MGETHDR (m, M_NOWAIT, MT_DATA);
        if (! m)
                return 0;
-       MCLGET (m, M_NOWAIT);
-       if (! (m->m_flags & M_EXT)) {
+       if (!(MCLGET(m, M_NOWAIT))) {
                m_freem (m);
                return 0;
        }

Modified: head/sys/dev/cm/smc90cx6.c
==============================================================================
--- head/sys/dev/cm/smc90cx6.c  Tue Jan  6 10:02:14 2015        (r276749)
+++ head/sys/dev/cm/smc90cx6.c  Tue Jan  6 12:59:37 2015        (r276750)
@@ -540,10 +540,7 @@ cm_srint_locked(vsc)
         */
        if ((len + 2 + 2) > MHLEN) {
                /* attach an mbuf cluster */
-               MCLGET(m, M_NOWAIT);
-
-               /* Insist on getting a cluster */
-               if ((m->m_flags & M_EXT) == 0) {
+               if (!(MCLGET(m, M_NOWAIT))) {
                        if_inc_counter(ifp, IFCOUNTER_IERRORS, 1);
                        goto cleanup;
                }

Modified: head/sys/dev/cp/if_cp.c
==============================================================================
--- head/sys/dev/cp/if_cp.c     Tue Jan  6 10:02:14 2015        (r276749)
+++ head/sys/dev/cp/if_cp.c     Tue Jan  6 12:59:37 2015        (r276750)
@@ -191,8 +191,7 @@ static struct mbuf *makembuf (void *buf,
        MGETHDR (m, M_NOWAIT, MT_DATA);
        if (! m)
                return 0;
-       MCLGET (m, M_NOWAIT);
-       if (! (m->m_flags & M_EXT)) {
+       if (!(MCLGET (m, M_NOWAIT))) {
                m_freem (m);
                return 0;
        }

Modified: head/sys/dev/cs/if_cs.c
==============================================================================
--- head/sys/dev/cs/if_cs.c     Tue Jan  6 10:02:14 2015        (r276749)
+++ head/sys/dev/cs/if_cs.c     Tue Jan  6 12:59:37 2015        (r276750)
@@ -716,8 +716,7 @@ cs_get_packet(struct cs_softc *sc)
                return (-1);
 
        if (length > MHLEN) {
-               MCLGET(m, M_NOWAIT);
-               if (!(m->m_flags & M_EXT)) {
+               if (!(MCLGET(m, M_NOWAIT))) {
                        m_freem(m);
                        return (-1);
                }

Modified: head/sys/dev/ctau/if_ct.c
==============================================================================
--- head/sys/dev/ctau/if_ct.c   Tue Jan  6 10:02:14 2015        (r276749)
+++ head/sys/dev/ctau/if_ct.c   Tue Jan  6 12:59:37 2015        (r276750)
@@ -194,8 +194,7 @@ static struct mbuf *makembuf (void *buf,
        MGETHDR (m, M_NOWAIT, MT_DATA);
        if (! m)
                return 0;
-       MCLGET (m, M_NOWAIT);
-       if (! (m->m_flags & M_EXT)) {
+       if (!(MCLGET(m, M_NOWAIT))) {
                m_freem (m);
                return 0;
        }

Modified: head/sys/dev/ed/if_ed.c
==============================================================================
--- head/sys/dev/ed/if_ed.c     Tue Jan  6 10:02:14 2015        (r276749)
+++ head/sys/dev/ed/if_ed.c     Tue Jan  6 12:59:37 2015        (r276750)
@@ -1323,10 +1323,7 @@ ed_get_packet(struct ed_softc *sc, bus_s
         */
        if ((len + 2) > MHLEN) {
                /* Attach an mbuf cluster */
-               MCLGET(m, M_NOWAIT);
-
-               /* Insist on getting a cluster */
-               if ((m->m_flags & M_EXT) == 0) {
+               if (!(MCLGET(m, M_NOWAIT))) {
                        m_freem(m);
                        return;
                }

Modified: head/sys/dev/ex/if_ex.c
==============================================================================
--- head/sys/dev/ex/if_ex.c     Tue Jan  6 10:02:14 2015        (r276749)
+++ head/sys/dev/ex/if_ex.c     Tue Jan  6 12:59:37 2015        (r276750)
@@ -745,8 +745,7 @@ ex_rx_intr(struct ex_softc *sc)
 
                                while (pkt_len > 0) {
                                        if (pkt_len >= MINCLSIZE) {
-                                               MCLGET(m, M_NOWAIT);
-                                               if (m->m_flags & M_EXT) {
+                                               if (MCLGET(m, M_NOWAIT)) {
                                                        m->m_len = MCLBYTES;
                                                } else {
                                                        m_freem(ipkt);

Modified: head/sys/dev/fe/if_fe.c
==============================================================================
--- head/sys/dev/fe/if_fe.c     Tue Jan  6 10:02:14 2015        (r276749)
+++ head/sys/dev/fe/if_fe.c     Tue Jan  6 12:59:37 2015        (r276750)
@@ -1880,8 +1880,7 @@ fe_get_packet (struct fe_softc * sc, u_s
 
        /* Attach a cluster if this packet doesn't fit in a normal mbuf.  */
        if (len > MHLEN - NFS_MAGIC_OFFSET) {
-               MCLGET(m, M_NOWAIT);
-               if (!(m->m_flags & M_EXT)) {
+               if (!(MCLGET(m, M_NOWAIT))) {
                        m_freem(m);
                        return -1;
                }

Modified: head/sys/dev/hifn/hifn7751.c
==============================================================================
--- head/sys/dev/hifn/hifn7751.c        Tue Jan  6 10:02:14 2015        
(r276749)
+++ head/sys/dev/hifn/hifn7751.c        Tue Jan  6 12:59:37 2015        
(r276750)
@@ -1890,8 +1890,7 @@ hifn_crypto(
                                goto err_srcmap;
                        }
                        if (totlen >= MINCLSIZE) {
-                               MCLGET(m0, M_NOWAIT);
-                               if ((m0->m_flags & M_EXT) == 0) {
+                               if (!(MCLGET(m0, M_NOWAIT))) {
                                        hifnstats.hst_nomem_mcl++;
                                        err = sc->sc_cmdu ? ERESTART : ENOMEM;
                                        m_freem(m0);
@@ -1913,8 +1912,7 @@ hifn_crypto(
                                }
                                len = MLEN;
                                if (totlen >= MINCLSIZE) {
-                                       MCLGET(m, M_NOWAIT);
-                                       if ((m->m_flags & M_EXT) == 0) {
+                                       if (!(MCLGET(m, M_NOWAIT))) {
                                                hifnstats.hst_nomem_mcl++;
                                                err = sc->sc_cmdu ? ERESTART : 
ENOMEM;
                                                mlast->m_next = m;

Modified: head/sys/dev/ie/if_ie.c
==============================================================================
--- head/sys/dev/ie/if_ie.c     Tue Jan  6 10:02:14 2015        (r276749)
+++ head/sys/dev/ie/if_ie.c     Tue Jan  6 12:59:37 2015        (r276750)
@@ -728,8 +728,7 @@ ieget(struct ie_softc *sc, struct mbuf *
                        m->m_len = MLEN;
                }
                if (resid >= MINCLSIZE) {
-                       MCLGET(m, M_NOWAIT);
-                       if (m->m_flags & M_EXT)
+                       if (MCLGET(m, M_NOWAIT))
                                m->m_len = min(resid, MCLBYTES);
                } else {
                        if (resid < m->m_len) {

Modified: head/sys/dev/le/lance.c
==============================================================================
--- head/sys/dev/le/lance.c     Tue Jan  6 10:02:14 2015        (r276749)
+++ head/sys/dev/le/lance.c     Tue Jan  6 12:59:37 2015        (r276750)
@@ -398,8 +398,7 @@ lance_get(struct lance_softc *sc, int bo
 
        while (totlen > 0) {
                if (totlen >= MINCLSIZE) {
-                       MCLGET(m, M_NOWAIT);
-                       if ((m->m_flags & M_EXT) == 0)
+                       if (!(MCLGET(m, M_NOWAIT)))
                                goto bad;
                        len = MCLBYTES;
                }

Modified: head/sys/dev/lmc/if_lmc.c
==============================================================================
--- head/sys/dev/lmc/if_lmc.c   Tue Jan  6 10:02:14 2015        (r276749)
+++ head/sys/dev/lmc/if_lmc.c   Tue Jan  6 12:59:37 2015        (r276750)
@@ -2689,8 +2689,7 @@ rxintr_setup(softc_t *sc)
       printf("%s: rxintr_setup: MGETHDR() failed\n", NAME_UNIT);
     return 0;
     }
-  MCLGET(m, M_NOWAIT);
-  if ((m->m_flags & M_EXT) == 0)
+  if (!(MCLGET(m, M_NOWAIT)))
     {
     m_freem(m);
     sc->status.cntrs.rxdma++;

Modified: head/sys/dev/mn/if_mn.c
==============================================================================
--- head/sys/dev/mn/if_mn.c     Tue Jan  6 10:02:14 2015        (r276749)
+++ head/sys/dev/mn/if_mn.c     Tue Jan  6 12:59:37 2015        (r276750)
@@ -1165,8 +1165,7 @@ mn_rx_intr(struct mn_softc *sc, u_int32_
                                mn_free_desc(dp);
                                return; /* ENOBUFS */
                        }
-                       MCLGET(m, M_NOWAIT);
-                       if((m->m_flags & M_EXT) == 0) {
+                       if (!(MCLGET(m, M_NOWAIT))) {
                                mn_free_desc(dp);
                                m_freem(m);
                                return; /* ENOBUFS */

Modified: head/sys/dev/my/if_my.c
==============================================================================
--- head/sys/dev/my/if_my.c     Tue Jan  6 10:02:14 2015        (r276749)
+++ head/sys/dev/my/if_my.c     Tue Jan  6 12:59:37 2015        (r276750)
@@ -1085,8 +1085,7 @@ my_newbuf(struct my_softc * sc, struct m
                    "no memory for rx list -- packet dropped!\n");
                return (ENOBUFS);
        }
-       MCLGET(m_new, M_NOWAIT);
-       if (!(m_new->m_flags & M_EXT)) {
+       if (!(MCLGET(m_new, M_NOWAIT))) {
                device_printf(sc->my_dev,
                    "no memory for rx list -- packet dropped!\n");
                m_freem(m_new);
@@ -1352,8 +1351,7 @@ my_encap(struct my_softc * sc, struct my
                return (1);
        }
        if (m_head->m_pkthdr.len > MHLEN) {
-               MCLGET(m_new, M_NOWAIT);
-               if (!(m_new->m_flags & M_EXT)) {
+               if (!(MCLGET(m_new, M_NOWAIT))) {
                        m_freem(m_new);
                        device_printf(sc->my_dev, "no memory for tx list");
                        return (1);

Modified: head/sys/dev/pcn/if_pcn.c
==============================================================================
--- head/sys/dev/pcn/if_pcn.c   Tue Jan  6 10:02:14 2015        (r276749)
+++ head/sys/dev/pcn/if_pcn.c   Tue Jan  6 12:59:37 2015        (r276750)
@@ -803,8 +803,7 @@ pcn_newbuf(sc, idx, m)
                if (m_new == NULL)
                        return(ENOBUFS);
 
-               MCLGET(m_new, M_NOWAIT);
-               if (!(m_new->m_flags & M_EXT)) {
+               if (!(MCLGET(m_new, M_NOWAIT))) {
                        m_freem(m_new);
                        return(ENOBUFS);
                }

Modified: head/sys/dev/pdq/pdq_freebsd.h
==============================================================================
--- head/sys/dev/pdq/pdq_freebsd.h      Tue Jan  6 10:02:14 2015        
(r276749)
+++ head/sys/dev/pdq/pdq_freebsd.h      Tue Jan  6 12:59:37 2015        
(r276750)
@@ -190,8 +190,7 @@ typedef struct _pdq_os_ctx_t {
     PDQ_OS_DATABUF_T *x_m0; \
     MGETHDR(x_m0, M_NOWAIT, MT_DATA); \
     if (x_m0 != NULL) { \
-       MCLGET(x_m0, M_NOWAIT); \
-       if ((x_m0->m_flags & M_EXT) == 0) { \
+       if (!(MCLGET(x_m0, M_NOWAIT))) { \
            m_free(x_m0); \
            (b) = NULL; \
        } else { \

Modified: head/sys/dev/pdq/pdq_ifsubr.c
==============================================================================
--- head/sys/dev/pdq/pdq_ifsubr.c       Tue Jan  6 10:02:14 2015        
(r276749)
+++ head/sys/dev/pdq/pdq_ifsubr.c       Tue Jan  6 12:59:37 2015        
(r276750)
@@ -748,8 +748,7 @@ pdq_os_databuf_alloc(
        printf("%s: can't alloc small buf\n", sc->sc_dev.dv_xname);
        return NULL;
     }
-    MCLGET(m, M_NOWAIT);
-    if ((m->m_flags & M_EXT) == 0) {
+    if (!(MCLGET(m, M_NOWAIT))) {
        printf("%s: can't alloc cluster\n", sc->sc_dev.dv_xname);
         m_free(m);
        return NULL;

Modified: head/sys/dev/pdq/pdqvar.h
==============================================================================
--- head/sys/dev/pdq/pdqvar.h   Tue Jan  6 10:02:14 2015        (r276749)
+++ head/sys/dev/pdq/pdqvar.h   Tue Jan  6 12:59:37 2015        (r276750)
@@ -216,8 +216,7 @@ typedef struct mbuf PDQ_OS_DATABUF_T;
     PDQ_OS_DATABUF_T *x_m0; \
     MGETHDR(x_m0, M_NOWAIT, MT_DATA); \
     if (x_m0 != NULL) { \
-       MCLGET(x_m0, M_NOWAIT); \
-       if ((x_m0->m_flags & M_EXT) == 0) { \
+       if (!(MCLGET(x_m0, M_NOWAIT))) { \
            m_free(x_m0); \
            (b) = NULL; \
        } else { \

Modified: head/sys/dev/safe/safe.c
==============================================================================
--- head/sys/dev/safe/safe.c    Tue Jan  6 10:02:14 2015        (r276749)
+++ head/sys/dev/safe/safe.c    Tue Jan  6 12:59:37 2015        (r276750)
@@ -1328,8 +1328,7 @@ safe_process(device_t dev, struct crypto
                                        goto errout;
                                }
                                if (totlen >= MINCLSIZE) {
-                                       MCLGET(m, M_NOWAIT);
-                                       if ((m->m_flags & M_EXT) == 0) {
+                                       if (!(MCLGET(m, M_NOWAIT))) {
                                                m_free(m);
                                                safestats.st_nomcl++;
                                                err = sc->sc_nqchip ?
@@ -1355,8 +1354,7 @@ safe_process(device_t dev, struct crypto
                                                len = MLEN;
                                        }
                                        if (top && totlen >= MINCLSIZE) {
-                                               MCLGET(m, M_NOWAIT);
-                                               if ((m->m_flags & M_EXT) == 0) {
+                                               if (!(MCLGET(m, M_NOWAIT))) {
                                                        *mp = m;
                                                        m_freem(top);
                                                        safestats.st_nomcl++;

Modified: head/sys/dev/sbni/if_sbni.c
==============================================================================
--- head/sys/dev/sbni/if_sbni.c Tue Jan  6 10:02:14 2015        (r276749)
+++ head/sys/dev/sbni/if_sbni.c Tue Jan  6 12:59:37 2015        (r276750)
@@ -878,8 +878,7 @@ get_rx_buf(struct sbni_softc *sc)
         */
        if (ETHER_MAX_LEN + 2 > MHLEN) {
                /* Attach an mbuf cluster */
-               MCLGET(m, M_NOWAIT);
-               if ((m->m_flags & M_EXT) == 0) {
+               if (!(MCLGET(m, M_NOWAIT))) {
                        m_freem(m);
                        return (0);
                }

Modified: head/sys/dev/smc/if_smc.c
==============================================================================
--- head/sys/dev/smc/if_smc.c   Tue Jan  6 10:02:14 2015        (r276749)
+++ head/sys/dev/smc/if_smc.c   Tue Jan  6 12:59:37 2015        (r276750)
@@ -693,8 +693,7 @@ smc_task_rx(void *context, int pending)
                if (m == NULL) {
                        break;
                }
-               MCLGET(m, M_NOWAIT);
-               if ((m->m_flags & M_EXT) == 0) {
+               if (!(MCLGET(m, M_NOWAIT))) {
                        m_freem(m);
                        break;
                }

Modified: head/sys/dev/sn/if_sn.c
==============================================================================
--- head/sys/dev/sn/if_sn.c     Tue Jan  6 10:02:14 2015        (r276749)
+++ head/sys/dev/sn/if_sn.c     Tue Jan  6 12:59:37 2015        (r276750)
@@ -1065,14 +1065,9 @@ read_another:
        m->m_pkthdr.len = m->m_len = packet_length;
 
        /*
-        * Attach an mbuf cluster
+        * Attach an mbuf cluster.
         */
-       MCLGET(m, M_NOWAIT);
-
-       /*
-        * Insist on getting a cluster
-        */
-       if ((m->m_flags & M_EXT) == 0) {
+       if (!(MCLGET(m, M_NOWAIT))) {
                m_freem(m);
                if_inc_counter(ifp, IFCOUNTER_IERRORS, 1);
                printf("sn: snread() kernel memory allocation problem\n");

Modified: head/sys/dev/snc/dp83932.c
==============================================================================
--- head/sys/dev/snc/dp83932.c  Tue Jan  6 10:02:14 2015        (r276749)
+++ head/sys/dev/snc/dp83932.c  Tue Jan  6 12:59:37 2015        (r276750)
@@ -1129,8 +1129,7 @@ sonic_get(struct snc_softc *sc, u_int32_
                        len = MLEN;
                }
                if (datalen >= MINCLSIZE) {
-                       MCLGET(m, M_NOWAIT);
-                       if ((m->m_flags & M_EXT) == 0) {
+                       if (!(MCLGET(m, M_NOWAIT))) {
                                if (top) m_freem(top);
                                return (0);
                        }

Modified: head/sys/dev/ti/if_ti.c
==============================================================================
--- head/sys/dev/ti/if_ti.c     Tue Jan  6 10:02:14 2015        (r276749)
+++ head/sys/dev/ti/if_ti.c     Tue Jan  6 12:59:37 2015        (r276750)
@@ -1596,8 +1596,7 @@ ti_newbuf_jumbo(struct ti_softc *sc, int
                            "failed -- packet dropped!\n");
                        goto nobufs;
                }
-               MCLGET(m[NPAYLOAD], M_NOWAIT);
-               if ((m[NPAYLOAD]->m_flags & M_EXT) == 0) {
+               if (!(MCLGET(m[NPAYLOAD], M_NOWAIT))) {
                        device_printf(sc->ti_dev, "mbuf allocation failed "
                            "-- packet dropped!\n");
                        goto nobufs;

Modified: head/sys/dev/tl/if_tl.c
==============================================================================
--- head/sys/dev/tl/if_tl.c     Tue Jan  6 10:02:14 2015        (r276749)
+++ head/sys/dev/tl/if_tl.c     Tue Jan  6 12:59:37 2015        (r276750)
@@ -1813,8 +1813,7 @@ tl_encap(sc, c, m_head)
                        return(1);
                }
                if (m_head->m_pkthdr.len > MHLEN) {
-                       MCLGET(m_new, M_NOWAIT);
-                       if (!(m_new->m_flags & M_EXT)) {
+                       if (!(MCLGET(m_new, M_NOWAIT))) {
                                m_freem(m_new);
                                if_printf(ifp, "no memory for tx list\n");
                                return(1);

Modified: head/sys/dev/usb/misc/udbp.c
==============================================================================
--- head/sys/dev/usb/misc/udbp.c        Tue Jan  6 10:02:14 2015        
(r276749)
+++ head/sys/dev/usb/misc/udbp.c        Tue Jan  6 12:59:37 2015        
(r276750)
@@ -417,9 +417,8 @@ udbp_bulk_read_callback(struct usb_xfer 
                if (m == NULL) {
                        goto tr_setup;
                }
-               MCLGET(m, M_NOWAIT);
 
-               if (!(m->m_flags & M_EXT)) {
+               if (!(MCLGET(m, M_NOWAIT))) {
                        m_freem(m);
                        goto tr_setup;
                }

Modified: head/sys/dev/vx/if_vx.c
==============================================================================
--- head/sys/dev/vx/if_vx.c     Tue Jan  6 10:02:14 2015        (r276749)
+++ head/sys/dev/vx/if_vx.c     Tue Jan  6 12:59:37 2015        (r276750)
@@ -865,8 +865,7 @@ vx_get(struct vx_softc *sc, u_int totlen
                        len = MLEN;
                }
                if (totlen >= MINCLSIZE) {
-                       MCLGET(m, M_NOWAIT);
-                       if (m->m_flags & M_EXT)
+                       if (MCLGET(m, M_NOWAIT))
                                len = MCLBYTES;
                }
                len = min(totlen, len);

Modified: head/sys/dev/wb/if_wb.c
==============================================================================
--- head/sys/dev/wb/if_wb.c     Tue Jan  6 10:02:14 2015        (r276749)
+++ head/sys/dev/wb/if_wb.c     Tue Jan  6 12:59:37 2015        (r276750)
@@ -1194,8 +1194,7 @@ wb_encap(sc, c, m_head)
                if (m_new == NULL)
                        return(1);
                if (m_head->m_pkthdr.len > MHLEN) {
-                       MCLGET(m_new, M_NOWAIT);
-                       if (!(m_new->m_flags & M_EXT)) {
+                       if (!(MCLGET(m_new, M_NOWAIT))) {
                                m_freem(m_new);
                                return(1);
                        }

Modified: head/sys/dev/xe/if_xe.c
==============================================================================
--- head/sys/dev/xe/if_xe.c     Tue Jan  6 10:02:14 2015        (r276749)
+++ head/sys/dev/xe/if_xe.c     Tue Jan  6 12:59:37 2015        (r276750)
@@ -765,8 +765,7 @@ xe_rxintr(struct xe_softc *scp, uint8_t 
                        }
 
                        if (len + 3 > MHLEN) {
-                               MCLGET(mbp, M_NOWAIT);
-                               if ((mbp->m_flags & M_EXT) == 0) {
+                               if (!(MCLGET(mbp, M_NOWAIT))) {
                                        m_freem(mbp);
                                        if_inc_counter(ifp, IFCOUNTER_IQDROPS, 
1);
                                        continue;

Modified: head/sys/dev/xen/netfront/netfront.c
==============================================================================
--- head/sys/dev/xen/netfront/netfront.c        Tue Jan  6 10:02:14 2015        
(r276749)
+++ head/sys/dev/xen/netfront/netfront.c        Tue Jan  6 12:59:37 2015        
(r276750)
@@ -822,8 +822,7 @@ network_alloc_rx_buffers(struct netfront
                        goto no_mbuf;
                }
 
-               m_cljget(m_new, M_NOWAIT, MJUMPAGESIZE);
-               if ((m_new->m_flags & M_EXT) == 0) {
+               if (m_cljget(m_new, M_NOWAIT, MJUMPAGESIZE) == NULL) {
                        printf("%s: m_cljget failed\n", __func__);
                        m_freem(m_new);
 

Modified: head/sys/mips/adm5120/if_admsw.c
==============================================================================
--- head/sys/mips/adm5120/if_admsw.c    Tue Jan  6 10:02:14 2015        
(r276749)
+++ head/sys/mips/adm5120/if_admsw.c    Tue Jan  6 12:59:37 2015        
(r276750)
@@ -655,8 +655,7 @@ admsw_start(struct ifnet *ifp)
                                break;
                        }
                        if (m0->m_pkthdr.len > MHLEN) {
-                               MCLGET(m, M_NOWAIT);
-                               if ((m->m_flags & M_EXT) == 0) {
+                               if (!(MCLGET(m, M_NOWAIT))) {
                                        device_printf(sc->sc_dev, 
                                            "unable to allocate Tx cluster\n");
                                        m_freem(m);
@@ -1227,8 +1226,7 @@ admsw_add_rxbuf(struct admsw_softc *sc, 
        if (m == NULL)
                return (ENOBUFS);
 
-       MCLGET(m, M_NOWAIT);
-       if ((m->m_flags & M_EXT) == 0) {
+       if (!(MCLGET(m, M_NOWAIT))) {
                m_freem(m);
                return (ENOBUFS);
        }

Modified: head/sys/netgraph/atm/ngatmbase.c
==============================================================================
--- head/sys/netgraph/atm/ngatmbase.c   Tue Jan  6 10:02:14 2015        
(r276749)
+++ head/sys/netgraph/atm/ngatmbase.c   Tue Jan  6 12:59:37 2015        
(r276750)
@@ -151,8 +151,7 @@ uni_msg_pack_mbuf(struct uni_msg *msg, v
 
        } else {
                if ((n = uni_msg_len(msg)) > MHLEN) {
-                       MCLGET(m0, M_NOWAIT);
-                       if (!(m0->m_flags & M_EXT))
+                       if (!(MCLGET(m0, M_NOWAIT)))
                                goto drop;
                        if (n > MCLBYTES)
                                n = MCLBYTES;
@@ -173,8 +172,7 @@ uni_msg_pack_mbuf(struct uni_msg *msg, v
                last = m;
 
                if (n > MLEN) {
-                       MCLGET(m, M_NOWAIT);
-                       if (!(m->m_flags & M_EXT))
+                       if (!(MCLGET(m, M_NOWAIT)))
                                goto drop;
                        if (n > MCLBYTES)
                                n = MCLBYTES;

Modified: head/sys/netgraph/atm/sscop/ng_sscop_cust.h
==============================================================================
--- head/sys/netgraph/atm/sscop/ng_sscop_cust.h Tue Jan  6 10:02:14 2015        
(r276749)
+++ head/sys/netgraph/atm/sscop/ng_sscop_cust.h Tue Jan  6 12:59:37 2015        
(r276750)
@@ -327,8 +327,7 @@ ng_sscop_mbuf_alloc(size_t n)                               
                \
                m->m_len = 0;                                           \
                m->m_pkthdr.len = 0;                                    \
                if (n > MHLEN) {                                        \
-                       MCLGET(m, M_NOWAIT);                            \
-                       if (!(m->m_flags & M_EXT)){                     \
+                       if (!(MCLGET(m, M_NOWAIT))){                    \
                                m_free(m);                              \
                                m = NULL;                               \
                        }                                               \

Modified: head/sys/netgraph/bluetooth/drivers/bt3c/ng_bt3c_pccard.c
==============================================================================
--- head/sys/netgraph/bluetooth/drivers/bt3c/ng_bt3c_pccard.c   Tue Jan  6 
10:02:14 2015        (r276749)
+++ head/sys/netgraph/bluetooth/drivers/bt3c/ng_bt3c_pccard.c   Tue Jan  6 
12:59:37 2015        (r276750)
@@ -814,8 +814,7 @@ bt3c_receive(bt3c_softc_p sc)
                                break; /* XXX lost of sync */
                        }
 
-                       MCLGET(sc->m, M_NOWAIT);
-                       if (!(sc->m->m_flags & M_EXT)) {
+                       if (!(MCLGET(sc->m, M_NOWAIT))) {
                                NG_FREE_M(sc->m);
 
                                NG_BT3C_ERR(sc->dev, "Could not get cluster\n");

Modified: head/sys/netgraph/bluetooth/drivers/ubt/ng_ubt.c
==============================================================================
--- head/sys/netgraph/bluetooth/drivers/ubt/ng_ubt.c    Tue Jan  6 10:02:14 
2015        (r276749)
+++ head/sys/netgraph/bluetooth/drivers/ubt/ng_ubt.c    Tue Jan  6 12:59:37 
2015        (r276750)
@@ -816,8 +816,7 @@ ubt_intr_read_callback(struct usb_xfer *
                        goto submit_next;
                }
 
-               MCLGET(m, M_NOWAIT);
-               if (!(m->m_flags & M_EXT)) {
+               if (!(MCLGET(m, M_NOWAIT))) {
                        UBT_STAT_IERROR(sc);
                        goto submit_next;
                }
@@ -916,8 +915,7 @@ ubt_bulk_read_callback(struct usb_xfer *
                        goto submit_next;
                }
 
-               MCLGET(m, M_NOWAIT);
-               if (!(m->m_flags & M_EXT)) {
+               if (!(MCLGET(m, M_NOWAIT))) {
                        UBT_STAT_IERROR(sc);
                        goto submit_next;
                }
@@ -1126,8 +1124,7 @@ ubt_isoc_read_one_frame(struct usb_xfer 
                                return (-1);    /* XXX out of sync! */
                        }
 
-                       MCLGET(m, M_NOWAIT);
-                       if (!(m->m_flags & M_EXT)) {
+                       if (!(MCLGET(m, M_NOWAIT))) {
                                UBT_STAT_IERROR(sc);
                                NG_FREE_M(m);
                                return (-1);    /* XXX out of sync! */

Modified: head/sys/netgraph/ng_vjc.c
==============================================================================
--- head/sys/netgraph/ng_vjc.c  Tue Jan  6 10:02:14 2015        (r276749)
+++ head/sys/netgraph/ng_vjc.c  Tue Jan  6 12:59:37 2015        (r276750)
@@ -484,8 +484,7 @@ ng_vjc_rcvdata(hook_p hook, item_p item)
                hm->m_len = 0;
                hm->m_pkthdr.rcvif = NULL;
                if (hlen > MHLEN) {             /* unlikely, but can happen */
-                       MCLGET(hm, M_NOWAIT);
-                       if ((hm->m_flags & M_EXT) == 0) {
+                       if (!(MCLGET(hm, M_NOWAIT))) {
                                m_freem(hm);
                                priv->slc.sls_errorin++;
                                NG_FREE_M(m);

Modified: head/sys/netipsec/key.c
==============================================================================
--- head/sys/netipsec/key.c     Tue Jan  6 10:02:14 2015        (r276749)
+++ head/sys/netipsec/key.c     Tue Jan  6 12:59:37 2015        (r276750)
@@ -2153,8 +2153,7 @@ key_spddelete2(struct socket *so, struct
 
        MGETHDR(n, M_NOWAIT, MT_DATA);
        if (n && len > MHLEN) {
-               MCLGET(n, M_NOWAIT);
-               if ((n->m_flags & M_EXT) == 0) {
+               if (!(MCLGET(n, M_NOWAIT))) {
                        m_freem(n);
                        n = NULL;
                }
@@ -3496,8 +3495,7 @@ key_setsadbmsg(u_int8_t type, u_int16_t 
                return NULL;
        MGETHDR(m, M_NOWAIT, MT_DATA);
        if (m && len > MHLEN) {
-               MCLGET(m, M_NOWAIT);
-               if ((m->m_flags & M_EXT) == 0) {
+               if (!(MCLGET(m, M_NOWAIT))) {
                        m_freem(m);
                        m = NULL;
                }
@@ -4694,8 +4692,7 @@ key_getspi(struct socket *so, struct mbu
 
        MGETHDR(n, M_NOWAIT, MT_DATA);
        if (len > MHLEN) {
-               MCLGET(n, M_NOWAIT);
-               if ((n->m_flags & M_EXT) == 0) {
+               if (!(MCLGET(n, M_NOWAIT))) {
                        m_freem(n);
                        n = NULL;
                }
@@ -6628,8 +6625,7 @@ key_register(struct socket *so, struct m
 
        MGETHDR(n, M_NOWAIT, MT_DATA);
        if (len > MHLEN) {
-               MCLGET(n, M_NOWAIT);
-               if ((n->m_flags & M_EXT) == 0) {
+               if (!(MCLGET(n, M_NOWAIT))) {
                        m_freem(n);
                        n = NULL;
                }
@@ -7187,8 +7183,7 @@ key_parse(struct mbuf *m, struct socket 
 
                MGETHDR(n, M_NOWAIT, MT_DATA);
                if (n && m->m_pkthdr.len > MHLEN) {
-                       MCLGET(n, M_NOWAIT);
-                       if ((n->m_flags & M_EXT) == 0) {
+                       if (!(MCLGET(n, M_NOWAIT))) {
                                m_free(n);
                                n = NULL;
                        }

Modified: head/sys/netipsec/keysock.c
==============================================================================
--- head/sys/netipsec/keysock.c Tue Jan  6 10:02:14 2015        (r276749)
+++ head/sys/netipsec/keysock.c Tue Jan  6 12:59:37 2015        (r276750)
@@ -223,8 +223,7 @@ key_sendup(struct socket *so, struct sad
                        n->m_len = MLEN;
                }
                if (tlen >= MCLBYTES) { /*XXX better threshold? */
-                       MCLGET(n, M_NOWAIT);
-                       if ((n->m_flags & M_EXT) == 0) {
+                       if (!(MCLGET(n, M_NOWAIT))) {
                                m_free(n);
                                m_freem(m);
                                PFKEYSTAT_INC(in_nomem);

Modified: head/sys/sys/mbuf.h
==============================================================================
--- head/sys/sys/mbuf.h Tue Jan  6 10:02:14 2015        (r276749)
+++ head/sys/sys/mbuf.h Tue Jan  6 12:59:37 2015        (r276750)
@@ -667,7 +667,7 @@ m_getcl(int how, short type, int flags)
        return (uma_zalloc_arg(zone_pack, &args, how));
 }
 
-static __inline void
+static __inline int
 m_clget(struct mbuf *m, int how)
 {
 
@@ -683,6 +683,7 @@ m_clget(struct mbuf *m, int how)
                zone_drain(zone_pack);
                uma_zalloc_arg(zone_clust, m, how);
        }
+       return (m->m_flags & M_EXT);
 }
 
 /*
_______________________________________________
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"

Reply via email to