Date: Thu, 04 Dec 2014 07:46:00 +0300 From: "Andrey V. Elsukov" <ae@FreeBSD.org> To: Gleb Smirnoff <glebius@FreeBSD.org> Cc: svn-src-head@freebsd.org, svn-src-all@freebsd.org, src-committers@freebsd.org Subject: Re: svn commit: r275393 - head/sys/netipsec Message-ID: <547FE708.1000300@FreeBSD.org> In-Reply-To: <20141203220322.GS47144@FreeBSD.org> References: <201412020528.sB25SfxW096682@svn.freebsd.org> <20141203220322.GS47144@FreeBSD.org>
next in thread | previous in thread | raw e-mail | index | archive | help
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
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?547FE708.1000300>