Page MenuHomeFreeBSD

D1454.id3037.diff
No OneTemporary

D1454.id3037.diff

Index: sys/arm/allwinner/if_emac.c
===================================================================
--- sys/arm/allwinner/if_emac.c
+++ sys/arm/allwinner/if_emac.c
@@ -375,12 +375,12 @@
* the new mbuf. The new mbuf is prepended into the
* existing mbuf chain.
*/
- if (m->m_len <= (MHLEN - ETHER_HDR_LEN)) {
+ if (m->m_len <= (M_SIZE(m) - ETHER_HDR_LEN)) {
bcopy(m->m_data, m->m_data + ETHER_HDR_LEN,
m->m_len);
m->m_data += ETHER_HDR_LEN;
} else if (m->m_len <= (MCLBYTES - ETHER_HDR_LEN) &&
- m->m_len > (MHLEN - ETHER_HDR_LEN)) {
+ m->m_len > (M_SIZE(m) - ETHER_HDR_LEN)) {
MGETHDR(m0, M_NOWAIT, MT_DATA);
if (m0 != NULL) {
len = ETHER_HDR_LEN +
Index: sys/dev/age/if_age.c
===================================================================
--- sys/dev/age/if_age.c
+++ sys/dev/age/if_age.c
@@ -3095,7 +3095,7 @@
m = m_getcl(M_NOWAIT, MT_DATA, M_PKTHDR);
if (m == NULL)
return (ENOBUFS);
- m->m_len = m->m_pkthdr.len = MCLBYTES;
+ m->m_len = m->m_pkthdr.len = M_SIZE(m);
#ifndef __NO_STRICT_ALIGNMENT
m_adj(m, AGE_RX_BUF_ALIGN);
#endif
Index: sys/dev/altera/atse/if_atse.c
===================================================================
--- sys/dev/altera/atse/if_atse.c
+++ sys/dev/altera/atse/if_atse.c
@@ -1244,7 +1244,7 @@
m = m_getcl(M_NOWAIT, MT_DATA, M_PKTHDR);
if (m == NULL)
return (rx_npkts);
- m->m_len = m->m_pkthdr.len = MCLBYTES;
+ m->m_len = m->m_pkthdr.len = M_SIZE(m);
/* Make sure upper layers will be aligned. */
m_adj(m, ETHER_ALIGN);
sc->atse_rx_m = m;
Index: sys/dev/bce/if_bce.c
===================================================================
--- sys/dev/bce/if_bce.c
+++ sys/dev/bce/if_bce.c
@@ -5526,7 +5526,7 @@
DBRUN(sc->debug_pg_mbuf_alloc++);
- m_new->m_len = MCLBYTES;
+ m_new->m_len = M_SIZE(m_new);
/* ToDo: Consider calling m_fragment() to test error handling. */
Index: sys/dev/bfe/if_bfe.c
===================================================================
--- sys/dev/bfe/if_bfe.c
+++ sys/dev/bfe/if_bfe.c
@@ -793,7 +793,9 @@
int nsegs;
m = m_getcl(M_NOWAIT, MT_DATA, M_PKTHDR);
- m->m_len = m->m_pkthdr.len = MCLBYTES;
+ if (m == NULL)
+ return (ENOBUFS);
+ m->m_len = m->m_pkthdr.len = M_SIZE(m);
if (bus_dmamap_load_mbuf_sg(sc->bfe_rxmbuf_tag, sc->bfe_rx_sparemap,
m, segs, &nsegs, 0) != 0) {
Index: sys/dev/bge/if_bge.c
===================================================================
--- sys/dev/bge/if_bge.c
+++ sys/dev/bge/if_bge.c
@@ -1326,13 +1326,12 @@
m = m_getjcl(M_NOWAIT, MT_DATA, M_PKTHDR, MJUM9BYTES);
if (m == NULL)
return (ENOBUFS);
- m->m_len = m->m_pkthdr.len = MJUM9BYTES;
} else {
m = m_getcl(M_NOWAIT, MT_DATA, M_PKTHDR);
if (m == NULL)
return (ENOBUFS);
- m->m_len = m->m_pkthdr.len = MCLBYTES;
}
+ m->m_len = m->m_pkthdr.len = M_SIZE(m);
if ((sc->bge_flags & BGE_FLAG_RX_ALIGNBUG) == 0)
m_adj(m, ETHER_ALIGN);
Index: sys/dev/bwi/if_bwi.c
===================================================================
--- sys/dev/bwi/if_bwi.c
+++ sys/dev/bwi/if_bwi.c
@@ -2549,7 +2549,7 @@
else
goto back;
}
- m->m_len = m->m_pkthdr.len = MCLBYTES;
+ m->m_len = m->m_pkthdr.len = M_SIZE(m);
/*
* Try to load RX buf into temporary DMA map
Index: sys/dev/bwn/if_bwn.c
===================================================================
--- sys/dev/bwn/if_bwn.c
+++ sys/dev/bwn/if_bwn.c
@@ -9197,7 +9197,7 @@
else
goto back;
}
- m->m_len = m->m_pkthdr.len = MCLBYTES;
+ m->m_len = m->m_pkthdr.len = M_SIZE(m);
bwn_dma_set_redzone(dr, m);
Index: sys/dev/cadence/if_cgem.c
===================================================================
--- sys/dev/cadence/if_cgem.c
+++ sys/dev/cadence/if_cgem.c
@@ -481,8 +481,7 @@
if (m == NULL)
break;
- m->m_len = MCLBYTES;
- m->m_pkthdr.len = MCLBYTES;
+ m->m_len = m->m_pkthdr.len = M_SIZE(m);
m->m_pkthdr.rcvif = sc->ifp;
/* Load map and plug in physical address. */
Index: sys/dev/cm/smc90cx6.c
===================================================================
--- sys/dev/cm/smc90cx6.c
+++ sys/dev/cm/smc90cx6.c
@@ -538,7 +538,7 @@
* first +2 bytes for align fixup below
* second +2 bytes are for src/dst addresses
*/
- if ((len + 2 + 2) > MHLEN) {
+ if ((len + 2 + 2) > M_SIZE(m)) {
/* attach an mbuf cluster */
if (!(MCLGET(m, M_NOWAIT))) {
if_inc_counter(ifp, IFCOUNTER_IERRORS, 1);
Index: sys/dev/cs/if_cs.c
===================================================================
--- sys/dev/cs/if_cs.c
+++ sys/dev/cs/if_cs.c
@@ -715,7 +715,7 @@
if (m==NULL)
return (-1);
- if (length > MHLEN) {
+ if (length > M_SIZE(m)) {
if (!(MCLGET(m, M_NOWAIT))) {
m_freem(m);
return (-1);
Index: sys/dev/dc/if_dc.c
===================================================================
--- sys/dev/dc/if_dc.c
+++ sys/dev/dc/if_dc.c
@@ -2654,7 +2654,7 @@
m = m_getcl(M_NOWAIT, MT_DATA, M_PKTHDR);
if (m == NULL)
return (ENOBUFS);
- m->m_len = m->m_pkthdr.len = MCLBYTES;
+ m->m_len = m->m_pkthdr.len = M_SIZE(m);
m_adj(m, sizeof(u_int64_t));
/*
Index: sys/dev/e1000/if_igb.c
===================================================================
--- sys/dev/e1000/if_igb.c
+++ sys/dev/e1000/if_igb.c
@@ -4209,8 +4209,7 @@
} else
mh = rxbuf->m_head;
- mh->m_pkthdr.len = mh->m_len = MHLEN;
- mh->m_len = MHLEN;
+ mh->m_pkthdr.len = mh->m_len = M_SIZE(mh);
mh->m_flags |= M_PKTHDR;
/* Get the memory mapping */
error = bus_dmamap_load_mbuf_sg(rxr->htag,
@@ -4450,7 +4449,7 @@
}
m_adj(rxbuf->m_head, ETHER_ALIGN);
mh = rxbuf->m_head;
- mh->m_len = mh->m_pkthdr.len = MHLEN;
+ mh->m_len = mh->m_pkthdr.len = M_SIZE(mh);
mh->m_flags |= M_PKTHDR;
/* Get the memory mapping */
error = bus_dmamap_load_mbuf_sg(rxr->htag,
Index: sys/dev/e1000/if_lem.c
===================================================================
--- sys/dev/e1000/if_lem.c
+++ sys/dev/e1000/if_lem.c
@@ -3228,9 +3228,9 @@
adapter->mbuf_cluster_failed++;
return (ENOBUFS);
}
- m->m_len = m->m_pkthdr.len = MCLBYTES;
+ m->m_len = m->m_pkthdr.len = M_SIZE(m);
- if (adapter->max_frame_size <= (MCLBYTES - ETHER_ALIGN))
+ if (adapter->max_frame_size <= (M_SIZE(m) - ETHER_ALIGN))
m_adj(m, ETHER_ALIGN);
/*
Index: sys/dev/ed/if_ed.c
===================================================================
--- sys/dev/ed/if_ed.c
+++ sys/dev/ed/if_ed.c
@@ -1321,7 +1321,7 @@
* to the header. The +2 is to compensate for the alignment
* fixup below.
*/
- if ((len + 2) > MHLEN) {
+ if ((len + 2) > M_SIZE(m)) {
/* Attach an mbuf cluster */
if (!(MCLGET(m, M_NOWAIT))) {
m_freem(m);
Index: sys/dev/en/midway.c
===================================================================
--- sys/dev/en/midway.c
+++ sys/dev/en/midway.c
@@ -840,16 +840,13 @@
{
struct mbuf *new;
+ /* XXXRW: Why not use m_copym() or similar? */
MGET(new, M_WAITOK, MT_DATA);
- if (m->m_flags & M_PKTHDR) {
+ if (m->m_flags & M_PKTHDR)
M_MOVE_PKTHDR(new, m);
- if (m->m_len > MHLEN)
- MCLGET(new, M_WAITOK);
- } else {
- if (m->m_len > MLEN)
- MCLGET(new, M_WAITOK);
- }
+ if (m->m_len > M_SIZE(new))
+ MCLGET(new, M_WAITOK);
bcopy(m->m_data, new->m_data, m->m_len);
new->m_len = m->m_len;
Index: sys/dev/et/if_et.c
===================================================================
--- sys/dev/et/if_et.c
+++ sys/dev/et/if_et.c
@@ -2338,7 +2338,7 @@
m = m_getcl(M_NOWAIT, MT_DATA, M_PKTHDR);
if (m == NULL)
return (ENOBUFS);
- m->m_len = m->m_pkthdr.len = MCLBYTES;
+ m->m_len = m->m_pkthdr.len = M_SIZE(m);
m_adj(m, ETHER_ALIGN);
sc = rbd->rbd_softc;
@@ -2397,7 +2397,7 @@
MGETHDR(m, M_NOWAIT, MT_DATA);
if (m == NULL)
return (ENOBUFS);
- m->m_len = m->m_pkthdr.len = MHLEN;
+ m->m_len = m->m_pkthdr.len = M_SIZE(m);
m_adj(m, ETHER_ALIGN);
sc = rbd->rbd_softc;
Index: sys/dev/ex/if_ex.c
===================================================================
--- sys/dev/ex/if_ex.c
+++ sys/dev/ex/if_ex.c
@@ -741,12 +741,12 @@
} else {
ipkt->m_pkthdr.rcvif = ifp;
ipkt->m_pkthdr.len = pkt_len;
- ipkt->m_len = MHLEN;
+ ipkt->m_len = M_SIZE(ipkt);
while (pkt_len > 0) {
if (pkt_len >= MINCLSIZE) {
if (MCLGET(m, M_NOWAIT)) {
- m->m_len = MCLBYTES;
+ m->m_len = M_SIZE(m);
} else {
m_freem(ipkt);
if_inc_counter(ifp, IFCOUNTER_IQDROPS, 1);
@@ -776,7 +776,7 @@
goto rx_another;
}
m = m->m_next;
- m->m_len = MLEN;
+ m->m_len = M_SIZE(m);
}
}
eh = mtod(ipkt, struct ether_header *);
Index: sys/dev/fatm/if_fatm.c
===================================================================
--- sys/dev/fatm/if_fatm.c
+++ sys/dev/fatm/if_fatm.c
@@ -1773,14 +1773,11 @@
if (new == NULL)
return (NULL);
- if (m->m_flags & M_PKTHDR) {
+ /* XXXRW: Why not use m_copym() or similar? */
+ if (m->m_flags & M_PKTHDR)
M_MOVE_PKTHDR(new, m);
- if (m->m_len > MHLEN)
- MCLGET(new, M_WAITOK);
- } else {
- if (m->m_len > MLEN)
- MCLGET(new, M_WAITOK);
- }
+ if (m->m_len > M_SIZE(new))
+ MCLGET(new, M_WAITOK);
bcopy(m->m_data, new->m_data, m->m_len);
new->m_len = m->m_len;
Index: sys/dev/fe/if_fe.c
===================================================================
--- sys/dev/fe/if_fe.c
+++ sys/dev/fe/if_fe.c
@@ -1879,7 +1879,7 @@
return -1;
/* Attach a cluster if this packet doesn't fit in a normal mbuf. */
- if (len > MHLEN - NFS_MAGIC_OFFSET) {
+ if (len > M_SIZE(m) - NFS_MAGIC_OFFSET) {
if (!(MCLGET(m, M_NOWAIT))) {
m_freem(m);
return -1;
Index: sys/dev/fxp/if_fxp.c
===================================================================
--- sys/dev/fxp/if_fxp.c
+++ sys/dev/fxp/if_fxp.c
@@ -2662,7 +2662,7 @@
rfa->rfa_status = 0;
rfa->rfa_control = htole16(FXP_RFA_CONTROL_EL);
rfa->actual_size = 0;
- m->m_len = m->m_pkthdr.len = MCLBYTES - RFA_ALIGNMENT_FUDGE -
+ m->m_len = m->m_pkthdr.len = M_SIZE(m) - RFA_ALIGNMENT_FUDGE -
sc->rfa_size;
/*
Index: sys/dev/hifn/hifn7751.c
===================================================================
--- sys/dev/hifn/hifn7751.c
+++ sys/dev/hifn/hifn7751.c
@@ -1874,7 +1874,6 @@
*/
totlen = cmd->src_mapsize;
if (cmd->src_m->m_flags & M_PKTHDR) {
- len = MHLEN;
MGETHDR(m0, M_NOWAIT, MT_DATA);
if (m0 && !m_dup_pkthdr(m0, cmd->src_m, M_NOWAIT)) {
m_free(m0);
@@ -1881,7 +1880,6 @@
m0 = NULL;
}
} else {
- len = MLEN;
MGET(m0, M_NOWAIT, MT_DATA);
}
if (m0 == NULL) {
@@ -1889,6 +1887,7 @@
err = sc->sc_cmdu ? ERESTART : ENOMEM;
goto err_srcmap;
}
+ len = M_SIZE(m0);
if (totlen >= MINCLSIZE) {
if (!(MCLGET(m0, M_NOWAIT))) {
hifnstats.hst_nomem_mcl++;
@@ -1910,7 +1909,6 @@
m_freem(m0);
goto err_srcmap;
}
- len = MLEN;
if (totlen >= MINCLSIZE) {
if (!(MCLGET(m, M_NOWAIT))) {
hifnstats.hst_nomem_mcl++;
@@ -1919,8 +1917,8 @@
m_freem(m0);
goto err_srcmap;
}
- len = MCLBYTES;
}
+ len = M_SIZE(m);
m->m_len = len;
m0->m_pkthdr.len += len;
Index: sys/dev/ie/if_ie.c
===================================================================
--- sys/dev/ie/if_ie.c
+++ sys/dev/ie/if_ie.c
@@ -699,7 +699,7 @@
*mp = m;
m->m_pkthdr.rcvif = sc->ifp;
- m->m_len = MHLEN;
+ m->m_len = M_SIZE(m);
resid = m->m_pkthdr.len = totlen;
top = 0;
@@ -725,7 +725,7 @@
ie_drop_packet_buffer(sc);
return (-1);
}
- m->m_len = MLEN;
+ m->m_len = M_SIZE(m);
}
if (resid >= MINCLSIZE) {
if (MCLGET(m, M_NOWAIT))
Index: sys/dev/iscsi_initiator/isc_soc.c
===================================================================
--- sys/dev/iscsi_initiator/isc_soc.c
+++ sys/dev/iscsi_initiator/isc_soc.c
@@ -109,7 +109,7 @@
/*
| Add any AHS to the iSCSI hdr mbuf
*/
- if((mh->m_len + pp->ahs_len) < MHLEN) {
+ if((mh->m_len + pp->ahs_len) < M_SIZE(mh)) {
M_ALIGN(mh, mh->m_len + pp->ahs_len);
bcopy(&pp->ipdu, mh->m_data, mh->m_len);
bcopy(pp->ahs_addr, mh->m_data + mh->m_len, pp->ahs_len);
Index: sys/dev/ixgb/if_ixgb.c
===================================================================
--- sys/dev/ixgb/if_ixgb.c
+++ sys/dev/ixgb/if_ixgb.c
@@ -1792,12 +1792,11 @@
adapter->mbuf_alloc_failed++;
return (ENOBUFS);
}
- mp->m_len = mp->m_pkthdr.len = MCLBYTES;
} else {
- mp->m_len = mp->m_pkthdr.len = MCLBYTES;
mp->m_data = mp->m_ext.ext_buf;
mp->m_next = NULL;
}
+ mp->m_len = mp->m_pkthdr.len = M_SIZE(mp);
if (ifp->if_mtu <= ETHERMTU) {
m_adj(mp, ETHER_ALIGN);
Index: sys/dev/ixgbe/ixv.c
===================================================================
--- sys/dev/ixgbe/ixv.c
+++ sys/dev/ixgbe/ixv.c
@@ -2715,9 +2715,8 @@
mh = m_gethdr(M_NOWAIT, MT_DATA);
if (mh == NULL)
goto update;
- mh->m_pkthdr.len = mh->m_len = MHLEN;
- mh->m_len = MHLEN;
- mh->m_flags |= M_PKTHDR;
+ mh->m_flags |= M_PKTHDR; /* XXXRW: Redundant? */
+ mh->m_pkthdr.len = mh->m_len = M_SIZE(mh);
m_adj(mh, ETHER_ALIGN);
/* Get the memory mapping */
error = bus_dmamap_load_mbuf_sg(rxr->htag,
@@ -2937,8 +2936,8 @@
}
m_adj(rxbuf->m_head, ETHER_ALIGN);
mh = rxbuf->m_head;
- mh->m_len = mh->m_pkthdr.len = MHLEN;
- mh->m_flags |= M_PKTHDR;
+ mh->m_flags |= M_PKTHDR; /* XXXRW: Redundant? */
+ mh->m_len = mh->m_pkthdr.len = M_SIZE(mh);
/* Get the memory mapping */
error = bus_dmamap_load_mbuf_sg(rxr->htag,
rxbuf->hmap, rxbuf->m_head, hseg,
Index: sys/dev/ixl/ixl_txrx.c
===================================================================
--- sys/dev/ixl/ixl_txrx.c
+++ sys/dev/ixl/ixl_txrx.c
@@ -941,9 +941,8 @@
} else
mh = buf->m_head;
- mh->m_pkthdr.len = mh->m_len = MHLEN;
- mh->m_len = MHLEN;
- mh->m_flags |= M_PKTHDR;
+ mh->m_flags |= M_PKTHDR; /* XXXRW: Redundant? */
+ mh->m_pkthdr.len = mh->m_len = M_SIZE(mh);
/* Get the memory mapping */
error = bus_dmamap_load_mbuf_sg(rxr->htag,
buf->hmap, mh, hseg, &nsegs, BUS_DMA_NOWAIT);
@@ -1147,8 +1146,8 @@
}
m_adj(buf->m_head, ETHER_ALIGN);
mh = buf->m_head;
- mh->m_len = mh->m_pkthdr.len = MHLEN;
- mh->m_flags |= M_PKTHDR;
+ mh->m_flags |= M_PKTHDR; /* XXXRW: Redundant? */
+ mh->m_len = mh->m_pkthdr.len = M_SIZE(mh);
/* Get the memory mapping */
error = bus_dmamap_load_mbuf_sg(rxr->htag,
buf->hmap, buf->m_head, hseg,
Index: sys/dev/jme/if_jme.c
===================================================================
--- sys/dev/jme/if_jme.c
+++ sys/dev/jme/if_jme.c
@@ -3189,7 +3189,7 @@
* in order not to copy entire frame to align IP header on
* 32bit boundary.
*/
- m->m_len = m->m_pkthdr.len = MCLBYTES;
+ m->m_len = m->m_pkthdr.len = M_SIZE(m);
if (bus_dmamap_load_mbuf_sg(sc->jme_cdata.jme_rx_tag,
sc->jme_cdata.jme_rx_sparemap, m, segs, &nsegs, 0) != 0) {
Index: sys/dev/le/lance.c
===================================================================
--- sys/dev/le/lance.c
+++ sys/dev/le/lance.c
@@ -393,7 +393,7 @@
return (NULL);
m0->m_pkthdr.rcvif = ifp;
m0->m_pkthdr.len = totlen;
- len = MHLEN;
+ len = M_SIZE(m0);
m = m0;
while (totlen > 0) {
@@ -400,7 +400,7 @@
if (totlen >= MINCLSIZE) {
if (!(MCLGET(m, M_NOWAIT)))
goto bad;
- len = MCLBYTES;
+ len = M_SIZE(m);
}
if (m == m0) {
Index: sys/dev/msk/if_msk.c
===================================================================
--- sys/dev/msk/if_msk.c
+++ sys/dev/msk/if_msk.c
@@ -905,7 +905,7 @@
if (m == NULL)
return (ENOBUFS);
- m->m_len = m->m_pkthdr.len = MCLBYTES;
+ m->m_len = m->m_pkthdr.len = M_SIZE(m);
if ((sc_if->msk_flags & MSK_FLAG_RAMBUF) == 0)
m_adj(m, ETHER_ALIGN);
#ifndef __NO_STRICT_ALIGNMENT
Index: sys/dev/mxge/if_mxge.c
===================================================================
--- sys/dev/mxge/if_mxge.c
+++ sys/dev/mxge/if_mxge.c
@@ -2426,7 +2426,7 @@
err = ENOBUFS;
goto done;
}
- m->m_len = MHLEN;
+ m->m_len = M_SIZE(m);
err = bus_dmamap_load_mbuf_sg(rx->dmat, map, m,
&seg, &cnt, BUS_DMA_NOWAIT);
if (err != 0) {
Index: sys/dev/my/if_my.c
===================================================================
--- sys/dev/my/if_my.c
+++ sys/dev/my/if_my.c
@@ -1350,7 +1350,7 @@
device_printf(sc->my_dev, "no memory for tx list");
return (1);
}
- if (m_head->m_pkthdr.len > MHLEN) {
+ if (m_head->m_pkthdr.len > M_SIZE(m_new)) {
if (!(MCLGET(m_new, M_NOWAIT))) {
m_freem(m_new);
device_printf(sc->my_dev, "no memory for tx list");
Index: sys/dev/netfpga10g/nf10bmac/if_nf10bmac.c
===================================================================
--- sys/dev/netfpga10g/nf10bmac/if_nf10bmac.c
+++ sys/dev/netfpga10g/nf10bmac/if_nf10bmac.c
@@ -386,14 +386,14 @@
m = m_getcl(M_NOWAIT, MT_DATA, M_PKTHDR);
if (m == NULL)
return (0);
- m->m_len = m->m_pkthdr.len = MCLBYTES;
} else {
/* Hey this still fits into the mbuf+pkthdr. */
m = m_gethdr(M_NOWAIT, MT_DATA);
if (m == NULL)
return (0);
- m->m_len = m->m_pkthdr.len = MHLEN;
}
+ m->m_len = m->m_pkthdr.len = M_SIZE(m);
+
/* Make sure upper layers will be aligned. */
m_adj(m, ETHER_ALIGN);
Index: sys/dev/nfe/if_nfe.c
===================================================================
--- sys/dev/nfe/if_nfe.c
+++ sys/dev/nfe/if_nfe.c
@@ -2008,7 +2008,7 @@
if (m == NULL)
return (ENOBUFS);
- m->m_len = m->m_pkthdr.len = MCLBYTES;
+ m->m_len = m->m_pkthdr.len = M_SIZE(m);
m_adj(m, ETHER_ALIGN);
if (bus_dmamap_load_mbuf_sg(sc->rxq.rx_data_tag, sc->rxq.rx_spare_map,
Index: sys/dev/nge/if_nge.c
===================================================================
--- sys/dev/nge/if_nge.c
+++ sys/dev/nge/if_nge.c
@@ -1383,7 +1383,7 @@
m = m_getcl(M_NOWAIT, MT_DATA, M_PKTHDR);
if (m == NULL)
return (ENOBUFS);
- m->m_len = m->m_pkthdr.len = MCLBYTES;
+ m->m_len = m->m_pkthdr.len = M_SIZE(m);
m_adj(m, sizeof(uint64_t));
if (bus_dmamap_load_mbuf_sg(sc->nge_cdata.nge_rx_tag,
Index: sys/dev/oce/oce_if.c
===================================================================
--- sys/dev/oce/oce_if.c
+++ sys/dev/oce/oce_if.c
@@ -1571,7 +1571,7 @@
if (pd->mbuf == NULL)
break;
- pd->mbuf->m_len = pd->mbuf->m_pkthdr.len = MCLBYTES;
+ pd->mbuf->m_len = pd->mbuf->m_pkthdr.len = M_SIZE(pd->mbuf);
rc = bus_dmamap_load_mbuf_sg(rq->tag,
pd->map,
pd->mbuf,
Index: sys/dev/pcn/if_pcn.c
===================================================================
--- sys/dev/pcn/if_pcn.c
+++ sys/dev/pcn/if_pcn.c
@@ -807,12 +807,11 @@
m_freem(m_new);
return(ENOBUFS);
}
- m_new->m_len = m_new->m_pkthdr.len = MCLBYTES;
} else {
m_new = m;
- m_new->m_len = m_new->m_pkthdr.len = MCLBYTES;
m_new->m_data = m_new->m_ext.ext_buf;
}
+ m_new->m_len = m_new->m_pkthdr.len = M_SIZE(m_new);
m_adj(m_new, ETHER_ALIGN);
Index: sys/dev/qlxgb/qla_os.c
===================================================================
--- sys/dev/qlxgb/qla_os.c
+++ sys/dev/qlxgb/qla_os.c
@@ -1422,7 +1422,6 @@
"%s: m_getcl failed\n", __func__);
goto exit_qla_get_mbuf;
}
- mp->m_len = mp->m_pkthdr.len = MCLBYTES;
} else {
mp = m_getjcl(M_NOWAIT, MT_DATA, M_PKTHDR,
MJUM9BYTES);
@@ -1433,19 +1432,13 @@
"%s: m_getjcl failed\n", __func__);
goto exit_qla_get_mbuf;
}
- mp->m_len = mp->m_pkthdr.len = MJUM9BYTES;
}
} else {
- if (!jumbo)
- mp->m_len = mp->m_pkthdr.len = MCLBYTES;
- else
- mp->m_len = mp->m_pkthdr.len = MJUM9BYTES;
-
mp->m_data = mp->m_ext.ext_buf;
mp->m_next = NULL;
}
+ mp->m_len = mp->m_pkthdr.len = M_SIZE(mp);
-
offset = (uint32_t)((unsigned long long)mp->m_data & 0x7ULL);
if (offset) {
offset = 8 - offset;
Index: sys/dev/qlxgbe/ql_os.c
===================================================================
--- sys/dev/qlxgbe/ql_os.c
+++ sys/dev/qlxgbe/ql_os.c
@@ -1527,12 +1527,11 @@
"%s: m_getcl failed\n", __func__);
goto exit_ql_get_mbuf;
}
- mp->m_len = mp->m_pkthdr.len = MCLBYTES;
} else {
- mp->m_len = mp->m_pkthdr.len = MCLBYTES;
mp->m_data = mp->m_ext.ext_buf;
mp->m_next = NULL;
}
+ mp->m_len = mp->m_pkthdr.len = M_SIZE(mp);
offset = (uint32_t)((unsigned long long)mp->m_data & 0x7ULL);
if (offset) {
Index: sys/dev/re/if_re.c
===================================================================
--- sys/dev/re/if_re.c
+++ sys/dev/re/if_re.c
@@ -1934,7 +1934,7 @@
if (m == NULL)
return (ENOBUFS);
- m->m_len = m->m_pkthdr.len = MCLBYTES;
+ m->m_len = m->m_pkthdr.len = M_SIZE(m);
#ifdef RE_FIXUP_RX
/*
* This is part of an evil trick to deal with non-x86 platforms.
Index: sys/dev/safe/safe.c
===================================================================
--- sys/dev/safe/safe.c
+++ sys/dev/safe/safe.c
@@ -1311,7 +1311,6 @@
safestats.st_notuniform++;
totlen = re->re_src_mapsize;
if (re->re_src_m->m_flags & M_PKTHDR) {
- len = MHLEN;
MGETHDR(m, M_NOWAIT, MT_DATA);
if (m && !m_dup_pkthdr(m, re->re_src_m,
M_NOWAIT)) {
@@ -1319,7 +1318,6 @@
m = NULL;
}
} else {
- len = MLEN;
MGET(m, M_NOWAIT, MT_DATA);
}
if (m == NULL) {
@@ -1327,6 +1325,7 @@
err = sc->sc_nqchip ? ERESTART : ENOMEM;
goto errout;
}
+ len = M_SIZE(m);
if (totlen >= MINCLSIZE) {
if (!(MCLGET(m, M_NOWAIT))) {
m_free(m);
@@ -1335,7 +1334,7 @@
ERESTART : ENOMEM;
goto errout;
}
- len = MCLBYTES;
+ len = M_SIZE(m);
}
m->m_len = len;
top = NULL;
@@ -1362,7 +1361,7 @@
ERESTART : ENOMEM;
goto errout;
}
- len = MCLBYTES;
+ len = M_SIZE(m);
}
m->m_len = len = min(totlen, len);
totlen -= len;
Index: sys/dev/sbni/if_sbni.c
===================================================================
--- sys/dev/sbni/if_sbni.c
+++ sys/dev/sbni/if_sbni.c
@@ -876,7 +876,7 @@
* to the header. The +2 is to compensate for the alignment
* fixup below.
*/
- if (ETHER_MAX_LEN + 2 > MHLEN) {
+ if (ETHER_MAX_LEN + 2 > M_SIZE(m)) {
/* Attach an mbuf cluster */
if (!(MCLGET(m, M_NOWAIT))) {
m_freem(m);
Index: sys/dev/sf/if_sf.c
===================================================================
--- sys/dev/sf/if_sf.c
+++ sys/dev/sf/if_sf.c
@@ -1455,7 +1455,7 @@
m = m_getcl(M_NOWAIT, MT_DATA, M_PKTHDR);
if (m == NULL)
return (ENOBUFS);
- m->m_len = m->m_pkthdr.len = MCLBYTES;
+ m->m_len = m->m_pkthdr.len = M_SIZE(m);
m_adj(m, sizeof(uint32_t));
if (bus_dmamap_load_mbuf_sg(sc->sf_cdata.sf_rx_tag,
Index: sys/dev/sge/if_sge.c
===================================================================
--- sys/dev/sge/if_sge.c
+++ sys/dev/sge/if_sge.c
@@ -1087,7 +1087,7 @@
m = m_getcl(M_NOWAIT, MT_DATA, M_PKTHDR);
if (m == NULL)
return (ENOBUFS);
- m->m_len = m->m_pkthdr.len = MCLBYTES;
+ m->m_len = m->m_pkthdr.len = M_SIZE(m);
m_adj(m, SGE_RX_BUF_ALIGN);
error = bus_dmamap_load_mbuf_sg(cd->sge_rxmbuf_tag,
cd->sge_rx_spare_map, m, segs, &nsegs, 0);
Index: sys/dev/sk/if_sk.c
===================================================================
--- sys/dev/sk/if_sk.c
+++ sys/dev/sk/if_sk.c
@@ -967,7 +967,7 @@
m = m_getcl(M_NOWAIT, MT_DATA, M_PKTHDR);
if (m == NULL)
return (ENOBUFS);
- m->m_len = m->m_pkthdr.len = MCLBYTES;
+ m->m_len = m->m_pkthdr.len = M_SIZE(m);
m_adj(m, ETHER_ALIGN);
if (bus_dmamap_load_mbuf_sg(sc_if->sk_cdata.sk_rx_tag,
Index: sys/dev/snc/dp83932.c
===================================================================
--- sys/dev/snc/dp83932.c
+++ sys/dev/snc/dp83932.c
@@ -1115,7 +1115,7 @@
return (0);
m->m_pkthdr.rcvif = sc->sc_ifp;
m->m_pkthdr.len = datalen;
- len = MHLEN;
+ len = M_SIZE(m);
top = 0;
mp = &top;
@@ -1126,7 +1126,7 @@
m_freem(top);
return (0);
}
- len = MLEN;
+ len = M_SIZE(m);
}
if (datalen >= MINCLSIZE) {
if (!(MCLGET(m, M_NOWAIT))) {
@@ -1133,7 +1133,7 @@
if (top) m_freem(top);
return (0);
}
- len = MCLBYTES;
+ len = M_SIZE(m);
}
#if 0
/* XXX: Require? */
Index: sys/dev/ste/if_ste.c
===================================================================
--- sys/dev/ste/if_ste.c
+++ sys/dev/ste/if_ste.c
@@ -1387,7 +1387,7 @@
m = m_getcl(M_NOWAIT, MT_DATA, M_PKTHDR);
if (m == NULL)
return (ENOBUFS);
- m->m_len = m->m_pkthdr.len = MCLBYTES;
+ m->m_len = m->m_pkthdr.len = M_SIZE(m);
m_adj(m, ETHER_ALIGN);
if ((error = bus_dmamap_load_mbuf_sg(sc->ste_cdata.ste_rx_tag,
Index: sys/dev/stge/if_stge.c
===================================================================
--- sys/dev/stge/if_stge.c
+++ sys/dev/stge/if_stge.c
@@ -1603,7 +1603,7 @@
struct mbuf *n;
n = NULL;
- if (m->m_len <= (MCLBYTES - ETHER_HDR_LEN)) {
+ if (m->m_len <= (M_SIZE(m) - ETHER_HDR_LEN)) {
bcopy(m->m_data, m->m_data + ETHER_HDR_LEN, m->m_len);
m->m_data += ETHER_HDR_LEN;
n = m;
@@ -2441,12 +2441,12 @@
m = m_getcl(M_NOWAIT, MT_DATA, M_PKTHDR);
if (m == NULL)
return (ENOBUFS);
- m->m_len = m->m_pkthdr.len = MCLBYTES;
+ m->m_len = m->m_pkthdr.len = M_SIZE(m);
/*
* The hardware requires 4bytes aligned DMA address when JUMBO
* frame is used.
*/
- if (sc->sc_if_framesize <= (MCLBYTES - ETHER_ALIGN))
+ if (sc->sc_if_framesize <= (M_SIZE(m) - ETHER_ALIGN))
m_adj(m, ETHER_ALIGN);
if (bus_dmamap_load_mbuf_sg(sc->sc_cdata.stge_rx_tag,
Index: sys/dev/ti/if_ti.c
===================================================================
--- sys/dev/ti/if_ti.c
+++ sys/dev/ti/if_ti.c
@@ -1391,7 +1391,7 @@
m = m_getcl(M_NOWAIT, MT_DATA, M_PKTHDR);
if (m == NULL)
return (ENOBUFS);
- m->m_len = m->m_pkthdr.len = MCLBYTES;
+ m->m_len = m->m_pkthdr.len = M_SIZE(m);
m_adj(m, ETHER_ALIGN);
error = bus_dmamap_load_mbuf_sg(sc->ti_cdata.ti_rx_std_tag,
@@ -1446,7 +1446,7 @@
MGETHDR(m, M_NOWAIT, MT_DATA);
if (m == NULL)
return (ENOBUFS);
- m->m_len = m->m_pkthdr.len = MHLEN;
+ m->m_len = m->m_pkthdr.len = M_SIZE(m);
m_adj(m, ETHER_ALIGN);
error = bus_dmamap_load_mbuf_sg(sc->ti_cdata.ti_rx_mini_tag,
@@ -1601,7 +1601,7 @@
"-- packet dropped!\n");
goto nobufs;
}
- m[NPAYLOAD]->m_len = MCLBYTES;
+ m[NPAYLOAD]->m_len = M_SIZE(m[NPAYLOAD]);
for (i = 0; i < NPAYLOAD; i++){
MGET(m[i], M_NOWAIT, MT_DATA);
@@ -1642,7 +1642,7 @@
m_new->m_next = m[0];
m_new->m_data += ETHER_ALIGN;
if (sc->ti_hdrsplit)
- m_new->m_len = MHLEN - ETHER_ALIGN;
+ m_new->m_len = M_SIZE(m_new) - ETHER_ALIGN;
else
m_new->m_len = HDR_LEN;
m_new->m_pkthdr.len = NPAYLOAD * PAGE_SIZE + m_new->m_len;
Index: sys/dev/tx/if_tx.c
===================================================================
--- sys/dev/tx/if_tx.c
+++ sys/dev/tx/if_tx.c
@@ -766,7 +766,7 @@
if_inc_counter(ifp, IFCOUNTER_IERRORS, 1);
continue;
}
- buf->mbuf->m_len = buf->mbuf->m_pkthdr.len = MCLBYTES;
+ buf->mbuf->m_len = buf->mbuf->m_pkthdr.len = M_SIZE(buf->mbuf);
m_adj(buf->mbuf, ETHER_ALIGN);
/* Point to new mbuf, and give descriptor to chip. */
@@ -1496,7 +1496,7 @@
return (ENOBUFS);
/* Prepare mbuf. */
- m0->m_len = min(MHLEN, ETHER_MIN_LEN - ETHER_CRC_LEN);
+ m0->m_len = min(M_SIZE(m0), ETHER_MIN_LEN - ETHER_CRC_LEN);
m0->m_pkthdr.len = m0->m_len;
m0->m_pkthdr.rcvif = sc->ifp;
bzero(mtod(m0, caddr_t), m0->m_len);
@@ -1645,7 +1645,7 @@
epic_free_rings(sc);
return (ENOBUFS);
}
- buf->mbuf->m_len = buf->mbuf->m_pkthdr.len = MCLBYTES;
+ buf->mbuf->m_len = buf->mbuf->m_pkthdr.len = M_SIZE(buf->mbuf);
m_adj(buf->mbuf, ETHER_ALIGN);
error = bus_dmamap_create(sc->mtag, 0, &buf->map);
Index: sys/dev/txp/if_txp.c
===================================================================
--- sys/dev/txp/if_txp.c
+++ sys/dev/txp/if_txp.c
@@ -1021,7 +1021,8 @@
sd->sd_mbuf = m_getcl(M_NOWAIT, MT_DATA, M_PKTHDR);
if (sd->sd_mbuf == NULL)
break;
- sd->sd_mbuf->m_pkthdr.len = sd->sd_mbuf->m_len = MCLBYTES;
+ sd->sd_mbuf->m_pkthdr.len = sd->sd_mbuf->m_len =
+ M_SIZE(sd->sd_mbuf);
#ifndef __NO_STRICT_ALIGNMENT
m_adj(sd->sd_mbuf, TXP_RXBUF_ALIGN);
#endif
@@ -1808,7 +1809,8 @@
sd->sd_mbuf = m_getcl(M_NOWAIT, MT_DATA, M_PKTHDR);
if (sd->sd_mbuf == NULL)
return (ENOMEM);
- sd->sd_mbuf->m_pkthdr.len = sd->sd_mbuf->m_len = MCLBYTES;
+ sd->sd_mbuf->m_pkthdr.len = sd->sd_mbuf->m_len =
+ M_SIZE(sd->sd_mbuf);
#ifndef __NO_STRICT_ALIGNMENT
m_adj(sd->sd_mbuf, TXP_RXBUF_ALIGN);
#endif
Index: sys/dev/ubsec/ubsec.c
===================================================================
--- sys/dev/ubsec/ubsec.c
+++ sys/dev/ubsec/ubsec.c
@@ -1364,13 +1364,10 @@
if (totlen >= MINCLSIZE) {
m = m_getcl(M_NOWAIT, MT_DATA,
q->q_src_m->m_flags & M_PKTHDR);
- len = MCLBYTES;
} else if (q->q_src_m->m_flags & M_PKTHDR) {
m = m_gethdr(M_NOWAIT, MT_DATA);
- len = MHLEN;
} else {
m = m_get(M_NOWAIT, MT_DATA);
- len = MLEN;
}
if (m && q->q_src_m->m_flags & M_PKTHDR &&
!m_dup_pkthdr(m, q->q_src_m, M_NOWAIT)) {
@@ -1382,6 +1379,7 @@
err = sc->sc_nqueue ? ERESTART : ENOMEM;
goto errout;
}
+ len = M_SIZE(m);
m->m_len = len = min(totlen, len);
totlen -= len;
top = m;
@@ -1391,10 +1389,8 @@
if (totlen >= MINCLSIZE) {
m = m_getcl(M_NOWAIT,
MT_DATA, 0);
- len = MCLBYTES;
} else {
m = m_get(M_NOWAIT, MT_DATA);
- len = MLEN;
}
if (m == NULL) {
m_freem(top);
@@ -1402,6 +1398,7 @@
err = sc->sc_nqueue ? ERESTART : ENOMEM;
goto errout;
}
+ len = M_SIZE(m);
m->m_len = len = min(totlen, len);
totlen -= len;
*mp = m;
Index: sys/dev/usb/net/if_axe.c
===================================================================
--- sys/dev/usb/net/if_axe.c
+++ sys/dev/usb/net/if_axe.c
@@ -1118,7 +1118,7 @@
if_inc_counter(ifp, IFCOUNTER_IQDROPS, 1);
return (ENOMEM);
}
- m->m_len = m->m_pkthdr.len = MCLBYTES;
+ m->m_len = m->m_pkthdr.len = M_SIZE(m);
m_adj(m, ETHER_ALIGN);
usbd_copy_out(pc, offset, mtod(m, uint8_t *), len);
Index: sys/dev/usb/net/usb_ethernet.c
===================================================================
--- sys/dev/usb/net/usb_ethernet.c
+++ sys/dev/usb/net/usb_ethernet.c
@@ -565,7 +565,7 @@
m_new = m_getcl(M_NOWAIT, MT_DATA, M_PKTHDR);
if (m_new == NULL)
return (NULL);
- m_new->m_len = m_new->m_pkthdr.len = MCLBYTES;
+ m_new->m_len = m_new->m_pkthdr.len = M_SIZE(m_new);
m_adj(m_new, ETHER_ALIGN);
return (m_new);
Index: sys/dev/vge/if_vge.c
===================================================================
--- sys/dev/vge/if_vge.c
+++ sys/dev/vge/if_vge.c
@@ -1251,7 +1251,7 @@
* This is slightly more efficient than allocating a new buffer,
* copying the contents, and discarding the old buffer.
*/
- m->m_len = m->m_pkthdr.len = MCLBYTES;
+ m->m_len = m->m_pkthdr.len = M_SIZE(m);
m_adj(m, VGE_RX_BUF_ALIGN);
if (bus_dmamap_load_mbuf_sg(sc->vge_cdata.vge_rx_tag,
@@ -1472,7 +1472,7 @@
vge_discard_rxbuf(sc, prod);
continue;
}
- m->m_len = MCLBYTES - VGE_RX_BUF_ALIGN;
+ m->m_len = M_SIZE(m) - VGE_RX_BUF_ALIGN;
if (sc->vge_cdata.vge_head == NULL) {
sc->vge_cdata.vge_head = m;
sc->vge_cdata.vge_tail = m;
@@ -1517,7 +1517,7 @@
/* Chain received mbufs. */
if (sc->vge_cdata.vge_head != NULL) {
- m->m_len = total_len % (MCLBYTES - VGE_RX_BUF_ALIGN);
+ m->m_len = total_len % (M_SIZE(m) - VGE_RX_BUF_ALIGN);
/*
* Special case: if there's 4 bytes or less
* in this buffer, the mbuf can be discarded:
Index: sys/dev/vr/if_vr.c
===================================================================
--- sys/dev/vr/if_vr.c
+++ sys/dev/vr/if_vr.c
@@ -1226,7 +1226,7 @@
m = m_getcl(M_NOWAIT, MT_DATA, M_PKTHDR);
if (m == NULL)
return (ENOBUFS);
- m->m_len = m->m_pkthdr.len = MCLBYTES;
+ m->m_len = m->m_pkthdr.len = M_SIZE(m);
m_adj(m, sizeof(uint64_t));
if (bus_dmamap_load_mbuf_sg(sc->vr_cdata.vr_rx_tag,
Index: sys/dev/vte/if_vte.c
===================================================================
--- sys/dev/vte/if_vte.c
+++ sys/dev/vte/if_vte.c
@@ -1442,7 +1442,7 @@
m = m_getcl(M_NOWAIT, MT_DATA, M_PKTHDR);
if (m == NULL)
return (ENOBUFS);
- m->m_len = m->m_pkthdr.len = MCLBYTES;
+ m->m_len = m->m_pkthdr.len = M_SIZE(m);
m_adj(m, sizeof(uint32_t));
if (bus_dmamap_load_mbuf_sg(sc->vte_cdata.vte_rx_tag,
@@ -1891,8 +1891,9 @@
MT_DATA, M_PKTHDR);
if (sc->vte_cdata.vte_txmbufs[i] == NULL)
return (ENOBUFS);
- sc->vte_cdata.vte_txmbufs[i]->m_pkthdr.len = MCLBYTES;
- sc->vte_cdata.vte_txmbufs[i]->m_len = MCLBYTES;
+ sc->vte_cdata.vte_txmbufs[i]->m_pkthdr.len =
+ sc->vte_cdata.vte_txmbufs[i]->m_len =
+ M_SIZE(sc->vte_cdata.vte_txmbufs[i]);
}
}
desc = sc->vte_cdata.vte_tx_ring;
Index: sys/dev/vx/if_vx.c
===================================================================
--- sys/dev/vx/if_vx.c
+++ sys/dev/vx/if_vx.c
@@ -825,6 +825,8 @@
}
/* Convert one of our saved mbuf's. */
sc->vx_next_mb = (sc->vx_next_mb + 1) % MAX_MBS;
+
+ /* XXXRW: need to properly initialise with m_pkthdr_init(). */
m->m_data = m->m_pktdat;
m->m_flags = M_PKTHDR;
bzero(&m->m_pkthdr, sizeof(m->m_pkthdr));
@@ -831,7 +833,7 @@
}
m->m_pkthdr.rcvif = ifp;
m->m_pkthdr.len = totlen;
- len = MHLEN;
+ len = M_SIZE(m);
top = NULL;
mp = &top;
@@ -862,13 +864,11 @@
} else {
sc->vx_next_mb = (sc->vx_next_mb + 1) % MAX_MBS;
}
- len = MLEN;
}
if (totlen >= MINCLSIZE) {
- if (MCLGET(m, M_NOWAIT))
- len = MCLBYTES;
+ (void)MCLGET(m, M_NOWAIT);
}
- len = min(totlen, len);
+ len = min(totlen, M_SIZE(m));
if (len > 3)
bus_space_read_multi_4(sc->vx_bst, sc->vx_bsh,
VX_W1_RX_PIO_RD_1, mtod(m, u_int32_t *), len / 4);
Index: sys/dev/wb/if_wb.c
===================================================================
--- sys/dev/wb/if_wb.c
+++ sys/dev/wb/if_wb.c
@@ -1193,7 +1193,7 @@
MGETHDR(m_new, M_NOWAIT, MT_DATA);
if (m_new == NULL)
return(1);
- if (m_head->m_pkthdr.len > MHLEN) {
+ if (m_head->m_pkthdr.len > M_SIZE(m_new)) {
if (!(MCLGET(m_new, M_NOWAIT))) {
m_freem(m_new);
return(1);
Index: sys/dev/wl/if_wl.c
===================================================================
--- sys/dev/wl/if_wl.c
+++ sys/dev/wl/if_wl.c
@@ -1099,7 +1099,7 @@
}
return 0;
}
- m->m_pkthdr.len = m->m_len = MCLBYTES;
+ m->m_pkthdr.len = m->m_len = M_SIZE(m);
m_adj(m, ETHER_ALIGN); /* align IP header */
/*
Index: sys/dev/xe/if_xe.c
===================================================================
--- sys/dev/xe/if_xe.c
+++ sys/dev/xe/if_xe.c
@@ -764,7 +764,7 @@
continue;
}
- if (len + 3 > MHLEN) {
+ if (len + 3 > M_SIZE(mbp)) {
if (!(MCLGET(mbp, M_NOWAIT))) {
m_freem(mbp);
if_inc_counter(ifp, IFCOUNTER_IQDROPS, 1);
Index: sys/dev/xl/if_xl.c
===================================================================
--- sys/dev/xl/if_xl.c
+++ sys/dev/xl/if_xl.c
@@ -1767,7 +1767,7 @@
if (m_new == NULL)
return (ENOBUFS);
- m_new->m_len = m_new->m_pkthdr.len = MCLBYTES;
+ m_new->m_len = m_new->m_pkthdr.len = M_SIZE(m_new);
/* Force longword alignment for packet payload. */
m_adj(m_new, ETHER_ALIGN);
Index: sys/mips/adm5120/if_admsw.c
===================================================================
--- sys/mips/adm5120/if_admsw.c
+++ sys/mips/adm5120/if_admsw.c
@@ -654,7 +654,7 @@
"unable to allocate Tx mbuf\n");
break;
}
- if (m0->m_pkthdr.len > MHLEN) {
+ if (m0->m_pkthdr.len > M_SIZE(m)) {
if (!(MCLGET(m, M_NOWAIT))) {
device_printf(sc->sc_dev,
"unable to allocate Tx cluster\n");
Index: sys/net/if_spppsubr.c
===================================================================
--- sys/net/if_spppsubr.c
+++ sys/net/if_spppsubr.c
@@ -4717,7 +4717,7 @@
while ((mlen = (unsigned int)va_arg(ap, size_t)) != 0) {
msg = va_arg(ap, const char *);
len += mlen;
- if (len > MHLEN - PPP_HEADER_LEN - LCP_HEADER_LEN) {
+ if (len > M_SIZE(m) - PPP_HEADER_LEN - LCP_HEADER_LEN) {
va_end(ap);
m_freem(m);
return;
Index: sys/net80211/ieee80211_output.c
===================================================================
--- sys/net80211/ieee80211_output.c
+++ sys/net80211/ieee80211_output.c
@@ -1083,8 +1083,9 @@
m_freem(m);
return NULL;
}
- KASSERT(needed_space <= MHLEN,
- ("not enough room, need %u got %d\n", needed_space, MHLEN));
+ KASSERT(needed_space <= M_SIZE(n),
+ ("not enough room, need %u got %d\n", needed_space,
+ M_SIZE(n)));
/*
* Setup new mbuf to have leading space to prepend the
* 802.11 header and any crypto header bits that are
Index: sys/netgraph/atm/ccatm/ng_ccatm.c
===================================================================
--- sys/netgraph/atm/ccatm/ng_ccatm.c
+++ sys/netgraph/atm/ccatm/ng_ccatm.c
@@ -962,7 +962,7 @@
if (m0 == NULL)
return NULL;
- KASSERT(hlen <= MHLEN, ("hlen > MHLEN"));
+ KASSERT(hlen <= M_SIZE(m0), ("hlen > M_SIZE(m0)"));
bcopy(h, m0->m_data, hlen);
m0->m_len = hlen;
Index: sys/netgraph/atm/sscop/ng_sscop_cust.h
===================================================================
--- sys/netgraph/atm/sscop/ng_sscop_cust.h
+++ sys/netgraph/atm/sscop/ng_sscop_cust.h
@@ -326,7 +326,7 @@
if (m != NULL) { \
m->m_len = 0; \
m->m_pkthdr.len = 0; \
- if (n > MHLEN) { \
+ if (n > M_SIZE(m)) { \
if (!(MCLGET(m, M_NOWAIT))){ \
m_free(m); \
m = NULL; \
Index: sys/netgraph/bluetooth/drivers/h4/ng_h4.c
===================================================================
--- sys/netgraph/bluetooth/drivers/h4/ng_h4.c
+++ sys/netgraph/bluetooth/drivers/h4/ng_h4.c
@@ -530,7 +530,7 @@
m->m_pkthdr.len = 0;
/* XXX m_copyback() is stupid */
- m->m_len = min(MHLEN, sc->got);
+ m->m_len = min(M_SIZE(m), sc->got);
m_copyback(m, 0, sc->got, sc->ibuf);
NG_SEND_DATA_ONLY(c, sc->hook, m);
Index: sys/netgraph/bluetooth/socket/ng_btsocket_rfcomm.c
===================================================================
--- sys/netgraph/bluetooth/socket/ng_btsocket_rfcomm.c
+++ sys/netgraph/bluetooth/socket/ng_btsocket_rfcomm.c
@@ -1851,7 +1851,7 @@
mtx_assert(&s->session_mtx, MA_OWNED);
/* Pullup as much as we can into first mbuf (for direct access) */
- length = min(m0->m_pkthdr.len, MHLEN);
+ length = min(m0->m_pkthdr.len, M_SIZE(m0));
if (m0->m_len < length) {
if ((m0 = m_pullup(m0, length)) == NULL) {
NG_BTSOCKET_RFCOMM_ALERT(
@@ -3528,7 +3528,7 @@
top->m_pkthdr.len = length;
top->m_len = 0;
- mlen = MHLEN;
+ mlen = M_SIZE(top);
m = top;
n = sb->sb_mb;
Index: sys/netgraph/netflow/ng_netflow.c
===================================================================
--- sys/netgraph/netflow/ng_netflow.c
+++ sys/netgraph/netflow/ng_netflow.c
@@ -675,7 +675,7 @@
#define M_CHECK(length) do { \
pullup_len += length; \
if (((m)->m_pkthdr.len < (pullup_len)) || \
- ((pullup_len) > MHLEN)) { \
+ ((pullup_len) > M_SIZE(m))) { \
error = EINVAL; \
goto bypass; \
} \
Index: sys/netgraph/ng_bpf.c
===================================================================
--- sys/netgraph/ng_bpf.c
+++ sys/netgraph/ng_bpf.c
@@ -443,7 +443,7 @@
#endif
/* Need to put packet in contiguous memory for bpf */
- if (m->m_next != NULL && totlen > MHLEN) {
+ if (m->m_next != NULL && totlen > M_SIZE(m)) {
if (usejit) {
data = malloc(totlen, M_NETGRAPH_BPF, M_NOWAIT);
if (data == NULL) {
Index: sys/netgraph/ng_lmi.c
===================================================================
--- sys/netgraph/ng_lmi.c
+++ sys/netgraph/ng_lmi.c
@@ -567,7 +567,7 @@
packetlen = m->m_len;
/* XXX what if it's more than 1 mbuf? */
- if ((packetlen > MHLEN) && !(m->m_flags & M_EXT)) {
+ if (packetlen > M_SIZE(m)) {
log(LOG_WARNING, "nglmi: packetlen (%d) too big\n", packetlen);
goto drop;
}
Index: sys/netgraph/ng_pppoe.c
===================================================================
--- sys/netgraph/ng_pppoe.c
+++ sys/netgraph/ng_pppoe.c
@@ -1320,7 +1320,7 @@
* of a buffer and make a mess.
* (Linux wouldn't have this problem).
*/
- if (m->m_pkthdr.len <= MHLEN) {
+ if (m->m_pkthdr.len <= M_SIZE(m)) {
if( m->m_len < m->m_pkthdr.len) {
m = m_pullup(m, m->m_pkthdr.len);
if (m == NULL) {
Index: sys/netgraph/ng_vjc.c
===================================================================
--- sys/netgraph/ng_vjc.c
+++ sys/netgraph/ng_vjc.c
@@ -483,7 +483,7 @@
}
hm->m_len = 0;
hm->m_pkthdr.rcvif = NULL;
- if (hlen > MHLEN) { /* unlikely, but can happen */
+ if (hlen > M_SIZE(hm)) { /* unlikely, but can happen */
if (!(MCLGET(hm, M_NOWAIT))) {
m_freem(hm);
priv->slc.sls_errorin++;
Index: sys/netinet/tcp_output.c
===================================================================
--- sys/netinet/tcp_output.c
+++ sys/netinet/tcp_output.c
@@ -963,7 +963,7 @@
*/
mb = sbsndptr(&so->so_snd, off, len, &moff);
- if (len <= MHLEN - hdrlen - max_linkhdr) {
+ if (len <= M_SIZE(m) - hdrlen - max_linkhdr) {
m_copydata(mb, moff, (int)len,
mtod(m, caddr_t) + hdrlen);
m->m_len += len;
@@ -1005,8 +1005,8 @@
goto out;
}
#ifdef INET6
- if (isipv6 && (MHLEN < hdrlen + max_linkhdr) &&
- MHLEN >= hdrlen) {
+ if (isipv6 && (M_SIZE(m) < hdrlen + max_linkhdr) &&
+ M_SIZE(m) >= hdrlen) {
M_ALIGN(m, hdrlen);
} else
#endif
Index: sys/netinet/tcp_timewait.c
===================================================================
--- sys/netinet/tcp_timewait.c
+++ sys/netinet/tcp_timewait.c
@@ -569,7 +569,8 @@
m->m_len = hdrlen + optlen;
m->m_pkthdr.len = m->m_len;
- KASSERT(max_linkhdr + m->m_len <= MHLEN, ("tcptw: mbuf too small"));
+ KASSERT(max_linkhdr + m->m_len <= M_SIZE(m),
+ ("tcptw: mbuf too small"));
th->th_seq = htonl(tw->snd_nxt);
th->th_ack = htonl(tw->rcv_nxt);
Index: sys/netinet6/ip6_mroute.c
===================================================================
--- sys/netinet6/ip6_mroute.c
+++ sys/netinet6/ip6_mroute.c
@@ -1637,7 +1637,7 @@
m_freem(mm);
return (ENOBUFS);
}
- i = MHLEN - M_LEADINGSPACE(mm);
+ i = M_SIZE(mm) - M_LEADINGSPACE(mm);
if (i > len)
i = len;
mm = m_pullup(mm, i);
Index: sys/netipsec/ipsec_mbuf.c
===================================================================
--- sys/netipsec/ipsec_mbuf.c
+++ sys/netipsec/ipsec_mbuf.c
@@ -83,16 +83,15 @@
while (todo > 0) {
if (todo > MHLEN) {
n = m_getcl(M_NOWAIT, m->m_type, 0);
- len = MCLBYTES;
}
else {
n = m_get(M_NOWAIT, m->m_type);
- len = MHLEN;
}
if (n == NULL) {
m_freem(n0);
return NULL;
}
+ len = M_SIZE(n);
*np = n;
np = &n->m_next;
alloc++;
Index: sys/netipsec/key.c
===================================================================
--- sys/netipsec/key.c
+++ sys/netipsec/key.c
@@ -2152,7 +2152,7 @@
len = PFKEY_ALIGN8(sizeof(struct sadb_msg));
MGETHDR(n, M_NOWAIT, MT_DATA);
- if (n && len > MHLEN) {
+ if (n && len > M_SIZE(n)) {
if (!(MCLGET(n, M_NOWAIT))) {
m_freem(n);
n = NULL;
@@ -3494,7 +3494,7 @@
if (len > MCLBYTES)
return NULL;
MGETHDR(m, M_NOWAIT, MT_DATA);
- if (m && len > MHLEN) {
+ if (m && len > M_SIZE(m)) {
if (!(MCLGET(m, M_NOWAIT))) {
m_freem(m);
m = NULL;
@@ -4691,7 +4691,7 @@
PFKEY_ALIGN8(sizeof(struct sadb_sa));
MGETHDR(n, M_NOWAIT, MT_DATA);
- if (len > MHLEN) {
+ if (len > M_SIZE(n)) {
if (!(MCLGET(n, M_NOWAIT))) {
m_freem(n);
n = NULL;
@@ -6624,7 +6624,7 @@
return key_senderror(so, m, ENOBUFS);
MGETHDR(n, M_NOWAIT, MT_DATA);
- if (len > MHLEN) {
+ if (len > M_SIZE(n)) {
if (!(MCLGET(n, M_NOWAIT))) {
m_freem(n);
n = NULL;
@@ -7182,7 +7182,7 @@
struct mbuf *n;
MGETHDR(n, M_NOWAIT, MT_DATA);
- if (n && m->m_pkthdr.len > MHLEN) {
+ if (n && m->m_pkthdr.len > M_SIZE(n)) {
if (!(MCLGET(n, M_NOWAIT))) {
m_free(n);
n = NULL;
Index: sys/netipsec/keysock.c
===================================================================
--- sys/netipsec/keysock.c
+++ sys/netipsec/keysock.c
@@ -213,7 +213,6 @@
PFKEYSTAT_INC(in_nomem);
return ENOBUFS;
}
- n->m_len = MHLEN;
} else {
MGET(n, M_NOWAIT, MT_DATA);
if (n == NULL) {
@@ -220,7 +219,6 @@
PFKEYSTAT_INC(in_nomem);
return ENOBUFS;
}
- n->m_len = MLEN;
}
if (tlen >= MCLBYTES) { /*XXX better threshold? */
if (!(MCLGET(n, M_NOWAIT))) {
@@ -229,8 +227,8 @@
PFKEYSTAT_INC(in_nomem);
return ENOBUFS;
}
- n->m_len = MCLBYTES;
}
+ n->m_len = M_SIZE(n);
if (tlen < n->m_len)
n->m_len = tlen;
Index: sys/rpc/clnt_bck.c
===================================================================
--- sys/rpc/clnt_bck.c
+++ sys/rpc/clnt_bck.c
@@ -250,7 +250,7 @@
*/
mreq = m_gethdr(M_WAITOK, MT_DATA);
mreq->m_data += sizeof(uint32_t);
- KASSERT(ct->ct_mpos + sizeof(uint32_t) <= MHLEN,
+ KASSERT(ct->ct_mpos + sizeof(uint32_t) <= M_SIZE(mreq),
("RPC header too big"));
bcopy(ct->ct_mcallc, mreq->m_data, ct->ct_mpos);
mreq->m_len = ct->ct_mpos;
Index: sys/rpc/clnt_dg.c
===================================================================
--- sys/rpc/clnt_dg.c
+++ sys/rpc/clnt_dg.c
@@ -429,7 +429,7 @@
mtx_unlock(&cs->cs_lock);
mreq = m_gethdr(M_WAITOK, MT_DATA);
- KASSERT(cu->cu_mcalllen <= MHLEN, ("RPC header too big"));
+ KASSERT(cu->cu_mcalllen <= M_SIZE(mreq), ("RPC header too big"));
bcopy(cu->cu_mcallc, mreq->m_data, cu->cu_mcalllen);
mreq->m_len = cu->cu_mcalllen;
Index: sys/rpc/clnt_vc.c
===================================================================
--- sys/rpc/clnt_vc.c
+++ sys/rpc/clnt_vc.c
@@ -343,7 +343,7 @@
*/
mreq = m_gethdr(M_WAITOK, MT_DATA);
mreq->m_data += sizeof(uint32_t);
- KASSERT(ct->ct_mpos + sizeof(uint32_t) <= MHLEN,
+ KASSERT(ct->ct_mpos + sizeof(uint32_t) <= M_SIZE(mreq),
("RPC header too big"));
bcopy(ct->ct_mcallc, mreq->m_data, ct->ct_mpos);
mreq->m_len = ct->ct_mpos;

File Metadata

Mime Type
text/plain
Expires
Sat, Nov 16, 11:09 PM (20 h, 46 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
14667110
Default Alt Text
D1454.id3037.diff (45 KB)

Event Timeline