Retire MT_HEADER mbuf type and change its users to use MT_DATA.
Having an additional MT_HEADER mbuf type is superfluous and redundant as nothing depends on it. It only adds a layer of confusion. The distinction between header mbuf's and data mbuf's is solely done through the m->m_flags M_PKTHDR flag. Non-native code is not changed in this commit. For compatibility MT_HEADER is mapped to MT_DATA. Sponsored by: TCP/IP Optimization Fundraise 2005
This commit is contained in:
parent
728b935c7f
commit
0df84f5a83
@ -717,7 +717,7 @@ ndis_ptom(m0, p)
|
||||
|
||||
for (buf = priv->npp_head; buf != NULL; buf = buf->mdl_next) {
|
||||
if (buf == priv->npp_head)
|
||||
MGETHDR(m, M_DONTWAIT, MT_HEADER);
|
||||
MGETHDR(m, M_DONTWAIT, MT_DATA);
|
||||
else
|
||||
MGET(m, M_DONTWAIT, MT_DATA);
|
||||
if (m == NULL) {
|
||||
|
@ -1076,8 +1076,7 @@ sbcompress(sb, m, n)
|
||||
(unsigned)m->m_len);
|
||||
n->m_len += m->m_len;
|
||||
sb->sb_cc += m->m_len;
|
||||
if (m->m_type != MT_DATA && m->m_type != MT_HEADER &&
|
||||
m->m_type != MT_OOBDATA)
|
||||
if (m->m_type != MT_DATA && m->m_type != MT_OOBDATA)
|
||||
/* XXX: Probably don't need.*/
|
||||
sb->sb_ctl += m->m_len;
|
||||
m = m_free(m);
|
||||
@ -1163,8 +1162,7 @@ sbdrop_locked(sb, len)
|
||||
m->m_len -= len;
|
||||
m->m_data += len;
|
||||
sb->sb_cc -= len;
|
||||
if (m->m_type != MT_DATA && m->m_type != MT_HEADER &&
|
||||
m->m_type != MT_OOBDATA)
|
||||
if (m->m_type != MT_DATA && m->m_type != MT_OOBDATA)
|
||||
sb->sb_ctl -= len;
|
||||
break;
|
||||
}
|
||||
|
@ -1216,7 +1216,7 @@ dontblock:
|
||||
} else if (type == MT_OOBDATA)
|
||||
break;
|
||||
else
|
||||
KASSERT(m->m_type == MT_DATA || m->m_type == MT_HEADER,
|
||||
KASSERT(m->m_type == MT_DATA,
|
||||
("m->m_type == %d", m->m_type));
|
||||
so->so_rcv.sb_state &= ~SBS_RCVATMARK;
|
||||
len = uio->uio_resid;
|
||||
|
@ -1076,8 +1076,7 @@ sbcompress(sb, m, n)
|
||||
(unsigned)m->m_len);
|
||||
n->m_len += m->m_len;
|
||||
sb->sb_cc += m->m_len;
|
||||
if (m->m_type != MT_DATA && m->m_type != MT_HEADER &&
|
||||
m->m_type != MT_OOBDATA)
|
||||
if (m->m_type != MT_DATA && m->m_type != MT_OOBDATA)
|
||||
/* XXX: Probably don't need.*/
|
||||
sb->sb_ctl += m->m_len;
|
||||
m = m_free(m);
|
||||
@ -1163,8 +1162,7 @@ sbdrop_locked(sb, len)
|
||||
m->m_len -= len;
|
||||
m->m_data += len;
|
||||
sb->sb_cc -= len;
|
||||
if (m->m_type != MT_DATA && m->m_type != MT_HEADER &&
|
||||
m->m_type != MT_OOBDATA)
|
||||
if (m->m_type != MT_DATA && m->m_type != MT_OOBDATA)
|
||||
sb->sb_ctl -= len;
|
||||
break;
|
||||
}
|
||||
|
@ -315,7 +315,7 @@ gre_output(struct ifnet *ifp, struct mbuf *m, struct sockaddr *dst,
|
||||
|
||||
if ((m->m_data - msiz) < m->m_pktdat) {
|
||||
/* need new mbuf */
|
||||
MGETHDR(m0, M_DONTWAIT, MT_HEADER);
|
||||
MGETHDR(m0, M_DONTWAIT, MT_DATA);
|
||||
if (m0 == NULL) {
|
||||
_IF_DROP(&ifp->if_snd);
|
||||
m_freem(m);
|
||||
|
@ -170,7 +170,7 @@ ieee80211_getmgtframe(u_int8_t **frm, u_int pktlen)
|
||||
len = roundup(sizeof(struct ieee80211_frame) + pktlen, 4);
|
||||
KASSERT(len <= MCLBYTES, ("802.11 mgt frame too large: %u", len));
|
||||
if (len < MINCLSIZE) {
|
||||
m = m_gethdr(M_NOWAIT, MT_HEADER);
|
||||
m = m_gethdr(M_NOWAIT, MT_DATA);
|
||||
/*
|
||||
* Align the data in case additional headers are added.
|
||||
* This should only happen when a WEP header is added
|
||||
@ -180,7 +180,7 @@ ieee80211_getmgtframe(u_int8_t **frm, u_int pktlen)
|
||||
if (m != NULL)
|
||||
MH_ALIGN(m, len);
|
||||
} else
|
||||
m = m_getcl(M_NOWAIT, MT_HEADER, M_PKTHDR);
|
||||
m = m_getcl(M_NOWAIT, MT_DATA, M_PKTHDR);
|
||||
if (m != NULL) {
|
||||
m->m_data += sizeof(struct ieee80211_frame);
|
||||
*frm = m->m_data;
|
||||
|
@ -212,7 +212,7 @@ ieee80211_send_nulldata(struct ieee80211_node *ni)
|
||||
struct mbuf *m;
|
||||
struct ieee80211_frame *wh;
|
||||
|
||||
MGETHDR(m, M_NOWAIT, MT_HEADER);
|
||||
MGETHDR(m, M_NOWAIT, MT_DATA);
|
||||
if (m == NULL) {
|
||||
/* XXX debug msg */
|
||||
ic->ic_stats.is_tx_nobuf++;
|
||||
|
@ -462,7 +462,7 @@ igmp_sendpkt(struct in_multi *inm, int type, unsigned long addr)
|
||||
|
||||
IN_MULTI_LOCK_ASSERT();
|
||||
|
||||
MGETHDR(m, M_DONTWAIT, MT_HEADER);
|
||||
MGETHDR(m, M_DONTWAIT, MT_DATA);
|
||||
if (m == NULL)
|
||||
return;
|
||||
|
||||
|
@ -1559,7 +1559,7 @@ send_pkt(struct ipfw_flow_id *id, u_int32_t seq, u_int32_t ack, int flags)
|
||||
struct ip *ip;
|
||||
struct tcphdr *tcp;
|
||||
|
||||
MGETHDR(m, M_DONTWAIT, MT_HEADER);
|
||||
MGETHDR(m, M_DONTWAIT, MT_DATA);
|
||||
if (m == 0)
|
||||
return (NULL);
|
||||
m->m_pkthdr.rcvif = (struct ifnet *)0;
|
||||
|
@ -183,7 +183,7 @@ icmp_error(n, type, code, dest, mtu)
|
||||
/*
|
||||
* First, formulate icmp message
|
||||
*/
|
||||
MGETHDR(m, M_DONTWAIT, MT_HEADER);
|
||||
MGETHDR(m, M_DONTWAIT, MT_DATA);
|
||||
if (m == NULL)
|
||||
goto freeit;
|
||||
#ifdef MAC
|
||||
@ -719,7 +719,7 @@ match:
|
||||
*/
|
||||
cp = (u_char *) (ip + 1);
|
||||
if ((opts = ip_srcroute(m)) == 0 &&
|
||||
(opts = m_gethdr(M_DONTWAIT, MT_HEADER))) {
|
||||
(opts = m_gethdr(M_DONTWAIT, MT_DATA))) {
|
||||
opts->m_len = sizeof(struct in_addr);
|
||||
mtod(opts, struct in_addr *)->s_addr = 0;
|
||||
}
|
||||
|
@ -1900,7 +1900,7 @@ encap_send(struct ip *ip, struct vif *vifp, struct mbuf *m)
|
||||
* new mbuf so we can modify it. Try to fill the new
|
||||
* mbuf since if we don't the ethernet driver will.
|
||||
*/
|
||||
MGETHDR(mb_copy, M_DONTWAIT, MT_HEADER);
|
||||
MGETHDR(mb_copy, M_DONTWAIT, MT_DATA);
|
||||
if (mb_copy == NULL)
|
||||
return;
|
||||
#ifdef MAC
|
||||
@ -2715,7 +2715,7 @@ bw_upcalls_send(void)
|
||||
* Allocate a new mbuf, initialize it with the header and
|
||||
* the payload for the pending calls.
|
||||
*/
|
||||
MGETHDR(m, M_DONTWAIT, MT_HEADER);
|
||||
MGETHDR(m, M_DONTWAIT, MT_DATA);
|
||||
if (m == NULL) {
|
||||
log(LOG_WARNING, "bw_upcalls_send: cannot allocate mbuf\n");
|
||||
return;
|
||||
@ -3055,7 +3055,7 @@ pim_register_send_upcall(struct ip *ip, struct vif *vifp,
|
||||
/*
|
||||
* Add a new mbuf with an upcall header
|
||||
*/
|
||||
MGETHDR(mb_first, M_DONTWAIT, MT_HEADER);
|
||||
MGETHDR(mb_first, M_DONTWAIT, MT_DATA);
|
||||
if (mb_first == NULL) {
|
||||
m_freem(mb_copy);
|
||||
return ENOBUFS;
|
||||
@ -3115,7 +3115,7 @@ pim_register_send_rp(struct ip *ip, struct vif *vifp,
|
||||
/*
|
||||
* Add a new mbuf with the encapsulating header
|
||||
*/
|
||||
MGETHDR(mb_first, M_DONTWAIT, MT_HEADER);
|
||||
MGETHDR(mb_first, M_DONTWAIT, MT_DATA);
|
||||
if (mb_first == NULL) {
|
||||
m_freem(mb_copy);
|
||||
return ENOBUFS;
|
||||
|
@ -941,7 +941,7 @@ smart_frag_failure:
|
||||
struct mbuf *m;
|
||||
int mhlen = sizeof (struct ip);
|
||||
|
||||
MGETHDR(m, M_DONTWAIT, MT_HEADER);
|
||||
MGETHDR(m, M_DONTWAIT, MT_DATA);
|
||||
if (m == NULL) {
|
||||
error = ENOBUFS;
|
||||
ipstat.ips_odropped++;
|
||||
@ -1067,7 +1067,7 @@ ip_insertoptions(m, opt, phlen)
|
||||
if (p->ipopt_dst.s_addr)
|
||||
ip->ip_dst = p->ipopt_dst;
|
||||
if (m->m_flags & M_EXT || m->m_data - optlen < m->m_pktdat) {
|
||||
MGETHDR(n, M_DONTWAIT, MT_HEADER);
|
||||
MGETHDR(n, M_DONTWAIT, MT_DATA);
|
||||
if (n == NULL) {
|
||||
*phlen = 0;
|
||||
return (m);
|
||||
|
@ -747,7 +747,7 @@ send:
|
||||
m->m_len += hdrlen;
|
||||
m->m_data -= hdrlen;
|
||||
#else
|
||||
MGETHDR(m, M_DONTWAIT, MT_HEADER);
|
||||
MGETHDR(m, M_DONTWAIT, MT_DATA);
|
||||
if (m == NULL) {
|
||||
SOCKBUF_UNLOCK(&so->so_snd);
|
||||
error = ENOBUFS;
|
||||
@ -800,7 +800,7 @@ send:
|
||||
else
|
||||
tcpstat.tcps_sndwinup++;
|
||||
|
||||
MGETHDR(m, M_DONTWAIT, MT_HEADER);
|
||||
MGETHDR(m, M_DONTWAIT, MT_DATA);
|
||||
if (m == NULL) {
|
||||
error = ENOBUFS;
|
||||
goto out;
|
||||
|
@ -446,7 +446,7 @@ tcp_respond(tp, ipgen, th, m, ack, seq, flags)
|
||||
}
|
||||
}
|
||||
if (m == NULL) {
|
||||
m = m_gethdr(M_DONTWAIT, MT_HEADER);
|
||||
m = m_gethdr(M_DONTWAIT, MT_DATA);
|
||||
if (m == NULL)
|
||||
return;
|
||||
tlen = 0;
|
||||
@ -1794,7 +1794,7 @@ tcp_twrespond(struct tcptw *tw, int flags)
|
||||
|
||||
INP_LOCK_ASSERT(inp);
|
||||
|
||||
m = m_gethdr(M_DONTWAIT, MT_HEADER);
|
||||
m = m_gethdr(M_DONTWAIT, MT_DATA);
|
||||
if (m == NULL)
|
||||
return (ENOBUFS);
|
||||
m->m_data += max_linkhdr;
|
||||
|
@ -1072,7 +1072,7 @@ syncache_respond(sc, m)
|
||||
if (m)
|
||||
m_freem(m);
|
||||
|
||||
m = m_gethdr(M_DONTWAIT, MT_HEADER);
|
||||
m = m_gethdr(M_DONTWAIT, MT_DATA);
|
||||
if (m == NULL)
|
||||
return (ENOBUFS);
|
||||
m->m_data += max_linkhdr;
|
||||
|
@ -446,7 +446,7 @@ tcp_respond(tp, ipgen, th, m, ack, seq, flags)
|
||||
}
|
||||
}
|
||||
if (m == NULL) {
|
||||
m = m_gethdr(M_DONTWAIT, MT_HEADER);
|
||||
m = m_gethdr(M_DONTWAIT, MT_DATA);
|
||||
if (m == NULL)
|
||||
return;
|
||||
tlen = 0;
|
||||
@ -1794,7 +1794,7 @@ tcp_twrespond(struct tcptw *tw, int flags)
|
||||
|
||||
INP_LOCK_ASSERT(inp);
|
||||
|
||||
m = m_gethdr(M_DONTWAIT, MT_HEADER);
|
||||
m = m_gethdr(M_DONTWAIT, MT_DATA);
|
||||
if (m == NULL)
|
||||
return (ENOBUFS);
|
||||
m->m_data += max_linkhdr;
|
||||
|
@ -500,7 +500,7 @@ ipsec6_splithdr(struct mbuf *m)
|
||||
ip6 = mtod(m, struct ip6_hdr *);
|
||||
hlen = sizeof(struct ip6_hdr);
|
||||
if (m->m_len > hlen) {
|
||||
MGETHDR(mh, M_DONTWAIT, MT_HEADER);
|
||||
MGETHDR(mh, M_DONTWAIT, MT_DATA);
|
||||
if (!mh) {
|
||||
m_freem(m);
|
||||
return NULL;
|
||||
|
@ -260,7 +260,7 @@ ipxipoutput(ifp, m, dst, rt)
|
||||
/* following clause not necessary on vax */
|
||||
if (3 & (intptr_t)m->m_data) {
|
||||
/* force longword alignment of ip hdr */
|
||||
struct mbuf *m0 = m_gethdr(MT_HEADER, M_DONTWAIT);
|
||||
struct mbuf *m0 = m_gethdr(MT_DATA, M_DONTWAIT);
|
||||
if (m0 == NULL) {
|
||||
m_freem(m);
|
||||
return (ENOBUFS);
|
||||
|
@ -813,7 +813,7 @@ spx_output(cb, m0)
|
||||
m->m_next = m1;
|
||||
}
|
||||
}
|
||||
m = m_gethdr(M_DONTWAIT, MT_HEADER);
|
||||
m = m_gethdr(M_DONTWAIT, MT_DATA);
|
||||
if (m == NULL) {
|
||||
m_freem(m0);
|
||||
return (ENOBUFS);
|
||||
@ -1026,7 +1026,7 @@ send:
|
||||
spxstat.spxs_sndprobe++;
|
||||
if (cb->s_flags & SF_ACKNOW)
|
||||
spxstat.spxs_sndacks++;
|
||||
m = m_gethdr(M_DONTWAIT, MT_HEADER);
|
||||
m = m_gethdr(M_DONTWAIT, MT_DATA);
|
||||
if (m == NULL)
|
||||
return (ENOBUFS);
|
||||
/*
|
||||
@ -1373,7 +1373,7 @@ spx_attach(so, proto, td)
|
||||
}
|
||||
sb = &so->so_snd;
|
||||
|
||||
mm = m_getclr(M_DONTWAIT, MT_HEADER);
|
||||
mm = m_getclr(M_DONTWAIT, MT_DATA);
|
||||
if (mm == NULL) {
|
||||
FREE(cb, M_PCB);
|
||||
error = ENOBUFS;
|
||||
|
@ -221,7 +221,7 @@ struct mbuf {
|
||||
*/
|
||||
#define MT_NOTMBUF 0 /* USED INTERNALLY ONLY! Object is not mbuf */
|
||||
#define MT_DATA 1 /* dynamic (data) allocation */
|
||||
#define MT_HEADER 2 /* packet header */
|
||||
#define MT_HEADER MT_DATA /* packet header, use M_PKTHDR instead */
|
||||
#if 0
|
||||
#define MT_SOCKET 3 /* socket structure */
|
||||
#define MT_PCB 4 /* protocol control block */
|
||||
|
@ -297,8 +297,7 @@ struct xsocket {
|
||||
/* adjust counters in sb reflecting allocation of m */
|
||||
#define sballoc(sb, m) { \
|
||||
(sb)->sb_cc += (m)->m_len; \
|
||||
if ((m)->m_type != MT_DATA && (m)->m_type != MT_HEADER && \
|
||||
(m)->m_type != MT_OOBDATA) \
|
||||
if ((m)->m_type != MT_DATA && (m)->m_type != MT_OOBDATA) \
|
||||
(sb)->sb_ctl += (m)->m_len; \
|
||||
(sb)->sb_mbcnt += MSIZE; \
|
||||
if ((m)->m_flags & M_EXT) \
|
||||
@ -308,8 +307,7 @@ struct xsocket {
|
||||
/* adjust counters in sb reflecting freeing of m */
|
||||
#define sbfree(sb, m) { \
|
||||
(sb)->sb_cc -= (m)->m_len; \
|
||||
if ((m)->m_type != MT_DATA && (m)->m_type != MT_HEADER && \
|
||||
(m)->m_type != MT_OOBDATA) \
|
||||
if ((m)->m_type != MT_DATA && (m)->m_type != MT_OOBDATA) \
|
||||
(sb)->sb_ctl -= (m)->m_len; \
|
||||
(sb)->sb_mbcnt -= MSIZE; \
|
||||
if ((m)->m_flags & M_EXT) \
|
||||
|
Loading…
x
Reference in New Issue
Block a user