From owner-svn-src-all@FreeBSD.ORG Thu Dec 4 04:46:07 2014 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx2.freebsd.org (mx2.freebsd.org [IPv6:2001:1900:2254:206a::19:2]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 3CBD0116; Thu, 4 Dec 2014 04:46:07 +0000 (UTC) Received: from butcher-nb.yandex.net (hub.freebsd.org [IPv6:2001:1900:2254:206c::16:88]) by mx2.freebsd.org (Postfix) with ESMTP id 1318F1E39; Thu, 4 Dec 2014 04:46:05 +0000 (UTC) Message-ID: <547FE708.1000300@FreeBSD.org> Date: Thu, 04 Dec 2014 07:46:00 +0300 From: "Andrey V. Elsukov" User-Agent: Mozilla/5.0 (X11; FreeBSD amd64; rv:31.0) Gecko/20100101 Thunderbird/31.2.0 MIME-Version: 1.0 To: Gleb Smirnoff Subject: Re: svn commit: r275393 - head/sys/netipsec References: <201412020528.sB25SfxW096682@svn.freebsd.org> <20141203220322.GS47144@FreeBSD.org> In-Reply-To: <20141203220322.GS47144@FreeBSD.org> Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 7bit Cc: svn-src-head@freebsd.org, svn-src-all@freebsd.org, src-committers@freebsd.org X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 04 Dec 2014 04:46:07 -0000 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