summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--sys/kern/subr_mbuf.c11
-rw-r--r--sys/sys/mbuf.h1
2 files changed, 9 insertions, 3 deletions
diff --git a/sys/kern/subr_mbuf.c b/sys/kern/subr_mbuf.c
index 02ad99a..21e1a40 100644
--- a/sys/kern/subr_mbuf.c
+++ b/sys/kern/subr_mbuf.c
@@ -1062,7 +1062,8 @@ mb_reclaim(void)
(((uintptr_t)(cl) - (uintptr_t)cl_refcntmap) >> MCLSHIFT)
#define _mext_dealloc_ref(m) \
- free((m)->m_ext.ref_cnt, M_MBUF)
+ if ((m)->m_ext.ext_type != EXT_EXTREF) \
+ free((m)->m_ext.ref_cnt, M_MBUF)
/******************************************************************************
* Internal routines.
@@ -1508,9 +1509,13 @@ void
m_extadd(struct mbuf *mb, caddr_t buf, u_int size,
void (*freef)(void *, void *), void *args, int flags, int type)
{
+ u_int *ref_cnt = NULL;
- _mext_init_ref(mb, ((type != EXT_CLUSTER) ?
- NULL : &cl_refcntmap[cl2ref(mb->m_ext.ext_buf)]));
+ if (type == EXT_CLUSTER)
+ ref_cnt = &cl_refcntmap[cl2ref(mb->m_ext.ext_buf)];
+ else if (type == EXT_EXTREF)
+ ref_cnt = mb->m_ext.ref_cnt;
+ _mext_init_ref(mb, ref_cnt);
if (mb->m_ext.ref_cnt != NULL) {
mb->m_flags |= (M_EXT | flags);
mb->m_ext.ext_buf = buf;
diff --git a/sys/sys/mbuf.h b/sys/sys/mbuf.h
index adc4832..0ad8664 100644
--- a/sys/sys/mbuf.h
+++ b/sys/sys/mbuf.h
@@ -173,6 +173,7 @@ struct mbuf {
#define EXT_NET_DRV 100 /* custom ext_buf provided by net driver(s) */
#define EXT_MOD_TYPE 200 /* custom module's ext_buf type */
#define EXT_DISPOSABLE 300 /* can throw this buffer away w/page flipping */
+#define EXT_EXTREF 400 /* has externally maintained ref_cnt ptr*/
/*
* Flags copied when copying m_pkthdr.
OpenPOWER on IntegriCloud