Changeset View
Changeset View
Standalone View
Standalone View
head/sys/kern/kern_mbuf.c
Show First 20 Lines • Show All 1,417 Lines • ▼ Show 20 Lines | m_getm2(struct mbuf *m, int len, int how, short type, int flags) | ||||
flags &= (M_PKTHDR | M_EOR); | flags &= (M_PKTHDR | M_EOR); | ||||
/* Packet header mbuf must be first in chain. */ | /* Packet header mbuf must be first in chain. */ | ||||
if ((flags & M_PKTHDR) && m != NULL) | if ((flags & M_PKTHDR) && m != NULL) | ||||
flags &= ~M_PKTHDR; | flags &= ~M_PKTHDR; | ||||
/* Loop and append maximum sized mbufs to the chain tail. */ | /* Loop and append maximum sized mbufs to the chain tail. */ | ||||
while (len > 0) { | while (len > 0) { | ||||
if (len > MCLBYTES) | mb = NULL; | ||||
mb = m_getjcl(how, type, (flags & M_PKTHDR), | if (len > MCLBYTES) { | ||||
mb = m_getjcl(M_NOWAIT, type, (flags & M_PKTHDR), | |||||
MJUMPAGESIZE); | MJUMPAGESIZE); | ||||
else if (len >= MINCLSIZE) | |||||
} | |||||
if (mb == NULL) { | |||||
if (len >= MINCLSIZE) | |||||
mb = m_getcl(how, type, (flags & M_PKTHDR)); | mb = m_getcl(how, type, (flags & M_PKTHDR)); | ||||
else if (flags & M_PKTHDR) | else if (flags & M_PKTHDR) | ||||
mb = m_gethdr(how, type); | mb = m_gethdr(how, type); | ||||
else | else | ||||
mb = m_get(how, type); | mb = m_get(how, type); | ||||
/* Fail the whole operation if one mbuf can't be allocated. */ | /* | ||||
* Fail the whole operation if one mbuf can't be | |||||
* allocated. | |||||
*/ | |||||
if (mb == NULL) { | if (mb == NULL) { | ||||
if (nm != NULL) | |||||
m_freem(nm); | m_freem(nm); | ||||
return (NULL); | return (NULL); | ||||
} | |||||
} | } | ||||
/* Book keeping. */ | /* Book keeping. */ | ||||
len -= M_SIZE(mb); | len -= M_SIZE(mb); | ||||
if (mtail != NULL) | if (mtail != NULL) | ||||
mtail->m_next = mb; | mtail->m_next = mb; | ||||
else | else | ||||
nm = mb; | nm = mb; | ||||
▲ Show 20 Lines • Show All 194 Lines • Show Last 20 Lines |