diff --git a/sys/kern/uipc_mbuf.c b/sys/kern/uipc_mbuf.c index 02a9a120b970..17fa670c9406 100644 --- a/sys/kern/uipc_mbuf.c +++ b/sys/kern/uipc_mbuf.c @@ -1899,8 +1899,12 @@ m_uiotombuf(struct uio *uio, int how, int len, int align, int flags) 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 index 553d0293770c..d1c87865c632 100644 --- a/sys/kern/uipc_usrreq.c +++ b/sys/kern/uipc_usrreq.c @@ -1268,7 +1268,7 @@ uipc_sosend_dgram(struct socket *so, struct sockaddr *addr, struct uio *uio, 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 index 8f377d580aa4..48ed63ef67b8 100644 --- a/sys/sys/mbuf.h +++ b/sys/sys/mbuf.h @@ -207,13 +207,17 @@ struct pkthdr { /* 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 */