Changeset View
Changeset View
Standalone View
Standalone View
sys/kern/kern_mbuf.c
Show First 20 Lines • Show All 841 Lines • ▼ Show 20 Lines | mb_free_ext(struct mbuf *m) | ||||
* important that we can't touch any of the mbuf fields | * important that we can't touch any of the mbuf fields | ||||
* after we have freed the external storage, since mbuf | * after we have freed the external storage, since mbuf | ||||
* could have been embedded in it. For now, the mbufs | * could have been embedded in it. For now, the mbufs | ||||
* embedded into the cluster are always of type EXT_EXTREF, | * embedded into the cluster are always of type EXT_EXTREF, | ||||
* and for this type we won't free the mref. | * and for this type we won't free the mref. | ||||
*/ | */ | ||||
if (m->m_flags & M_NOFREE) { | if (m->m_flags & M_NOFREE) { | ||||
freembuf = 0; | freembuf = 0; | ||||
KASSERT(m->m_ext.ext_type == EXT_EXTREF, | KASSERT(m->m_ext.ext_type == EXT_EXTREF || | ||||
m->m_ext.ext_type == EXT_RXRING, | |||||
("%s: no-free mbuf %p has wrong type", __func__, m)); | ("%s: no-free mbuf %p has wrong type", __func__, m)); | ||||
} else | } else | ||||
freembuf = 1; | freembuf = 1; | ||||
/* Free attached storage if this mbuf is the only reference to it. */ | /* Free attached storage if this mbuf is the only reference to it. */ | ||||
if (*refcnt == 1 || atomic_fetchadd_int(refcnt, -1) == 1) { | if (*refcnt == 1 || atomic_fetchadd_int(refcnt, -1) == 1) { | ||||
switch (m->m_ext.ext_type) { | switch (m->m_ext.ext_type) { | ||||
case EXT_PACKET: | case EXT_PACKET: | ||||
Show All 26 Lines | case EXT_DISPOSABLE: | ||||
("%s: ext_free not set", __func__)); | ("%s: ext_free not set", __func__)); | ||||
mref->m_ext.ext_free(mref); | mref->m_ext.ext_free(mref); | ||||
uma_zfree(zone_mbuf, mref); | uma_zfree(zone_mbuf, mref); | ||||
break; | break; | ||||
case EXT_EXTREF: | case EXT_EXTREF: | ||||
KASSERT(m->m_ext.ext_free != NULL, | KASSERT(m->m_ext.ext_free != NULL, | ||||
("%s: ext_free not set", __func__)); | ("%s: ext_free not set", __func__)); | ||||
m->m_ext.ext_free(m); | m->m_ext.ext_free(m); | ||||
break; | |||||
case EXT_RXRING: | |||||
KASSERT(m->m_ext.ext_free == NULL, | |||||
("%s: ext_free is set", __func__)); | |||||
break; | break; | ||||
default: | default: | ||||
KASSERT(m->m_ext.ext_type == 0, | KASSERT(m->m_ext.ext_type == 0, | ||||
("%s: unknown ext_type", __func__)); | ("%s: unknown ext_type", __func__)); | ||||
} | } | ||||
} | } | ||||
if (freembuf && m != mref) | if (freembuf && m != mref) | ||||
▲ Show 20 Lines • Show All 247 Lines • Show Last 20 Lines |