On 04.12.2014 01:03, Gleb Smirnoff wrote: > On Tue, Dec 02, 2014 at 05:28:41AM +0000, Andrey V. Elsukov wrote: > A> Author: ae > A> Date: Tue Dec 2 05:28:40 2014 > A> New Revision: 275393 > A> URL: https://svnweb.freebsd.org/changeset/base/275393 > A> > A> Log: > A> Remove unneded check. No need to do m_pullup to the size that we > prepended. > A> > A> Sponsored by: Yandex LLC > A> > A> Modified: > A> head/sys/netipsec/keysock.c > A> > A> Modified: head/sys/netipsec/keysock.c > A> > ============================================================================== > A> --- head/sys/netipsec/keysock.c Tue Dec 2 04:20:50 2014 > (r275392) > A> +++ head/sys/netipsec/keysock.c Tue Dec 2 05:28:40 2014 > (r275393) > A> @@ -148,8 +148,6 @@ key_sendup0(rp, m, promisc) > A> struct sadb_msg *pmsg; > A> > A> M_PREPEND(m, sizeof(struct sadb_msg), M_NOWAIT); > A> - if (m && m->m_len < sizeof(struct sadb_msg)) > A> - m = m_pullup(m, sizeof(struct sadb_msg)); > A> if (!m) { > A> PFKEYSTAT_INC(in_nomem); > A> m_freem(m); > A> > > - Substitute M_PREPEND with m_prepend()
m_prepend() will always allocate new mbuf, but M_PREPEND can use unused space without allocation. I didn't checked how it behaves here, but very often first mbuf in the chain that contains packet header is aligned to the end of mbuf's data (it has unused space from start of the mbuf's data), so M_PREPEND is preferable. > - style: if (m == NULL) > - Don't call m_freem(NULL) -- WBR, Andrey V. Elsukov _______________________________________________ svn-src-head@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/svn-src-head To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"