diff --git a/sys/kern/uipc_mbuf.c b/sys/kern/uipc_mbuf.c --- a/sys/kern/uipc_mbuf.c +++ b/sys/kern/uipc_mbuf.c @@ -1899,8 +1899,12 @@ mb->m_len = length; progress += length; - if (flags & M_PKTHDR) + if (flags & M_PKTHDR) { m->m_pkthdr.len += length; + m->m_pkthdr.memlen += MSIZE; + if (mb->m_flags & M_EXT) + m->m_pkthdr.memlen += mb->m_ext.ext_size; + } } KASSERT(progress == total, ("%s: progress != total", __func__)); diff --git a/sys/kern/uipc_usrreq.c b/sys/kern/uipc_usrreq.c --- a/sys/kern/uipc_usrreq.c +++ b/sys/kern/uipc_usrreq.c @@ -1268,7 +1268,7 @@ if (cc <= sbspace(sb)) { STAILQ_INSERT_TAIL(&sb->uxdg_mb, f, m_stailqpkt); /* XXX: would be nice if m_uiotombuf() returns count. */ - for (; f != NULL ; f = f->m_next) { + for (; f != NULL; f = f->m_next) { if (f->m_type != MT_DATA) sb->sb_ctl += f->m_len; sb->sb_mbcnt += MSIZE; diff --git a/sys/sys/mbuf.h b/sys/sys/mbuf.h --- a/sys/sys/mbuf.h +++ b/sys/sys/mbuf.h @@ -207,13 +207,17 @@ /* Layer specific non-persistent local storage for reassembly, etc. */ union { - uint8_t eight[8]; - uint16_t sixteen[4]; - uint32_t thirtytwo[2]; - uint64_t sixtyfour[1]; - uintptr_t unintptr[1]; - void *ptr; - } PH_loc; + union { + uint8_t eight[8]; + uint16_t sixteen[4]; + uint32_t thirtytwo[2]; + uint64_t sixtyfour[1]; + uintptr_t unintptr[1]; + void *ptr; + } PH_loc; + /* Upon allocation: total packet memory consumption. */ + u_int memlen; + }; }; #define ether_vtag PH_per.sixteen[0] #define tcp_tun_port PH_per.sixteen[0] /* outbound */