From owner-svn-src-head@freebsd.org Fri Nov 18 00:01:03 2016 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 1915FC47BC1; Fri, 18 Nov 2016 00:01:03 +0000 (UTC) (envelope-from glebius@FreeBSD.org) Received: from cell.glebi.us (glebi.us [96.95.210.25]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "cell.glebi.us", Issuer "cell.glebi.us" (not verified)) by mx1.freebsd.org (Postfix) with ESMTPS id 022EA691; Fri, 18 Nov 2016 00:01:02 +0000 (UTC) (envelope-from glebius@FreeBSD.org) Received: from cell.glebi.us (localhost [127.0.0.1]) by cell.glebi.us (8.15.2/8.15.2) with ESMTPS id uAI0123u063984 (version=TLSv1.2 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Thu, 17 Nov 2016 16:01:02 -0800 (PST) (envelope-from glebius@FreeBSD.org) Received: (from glebius@localhost) by cell.glebi.us (8.15.2/8.15.2/Submit) id uAI012Nm063983; Thu, 17 Nov 2016 16:01:02 -0800 (PST) (envelope-from glebius@FreeBSD.org) X-Authentication-Warning: cell.glebi.us: glebius set sender to glebius@FreeBSD.org using -f Date: Thu, 17 Nov 2016 16:01:02 -0800 From: Gleb Smirnoff To: Sepherosa Ziehau Cc: svn-src-head@freebsd.org, svn-src-all@freebsd.org, "Bjoern A. Zeeb" , src-committers@freebsd.org Subject: Re: svn commit: r308748 - head/sys/netgraph Message-ID: <20161118000102.GW27748@FreeBSD.org> References: <201611171403.uAHE3i3N044462@repo.freebsd.org> <20161117235657.GV27748@FreeBSD.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20161117235657.GV27748@FreeBSD.org> User-Agent: Mutt/1.7.0 (2016-08-17) X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 18 Nov 2016 00:01:03 -0000 On Thu, Nov 17, 2016 at 03:56:57PM -0800, Gleb Smirnoff wrote: T> On Thu, Nov 17, 2016 at 10:44:12PM +0800, Sepherosa Ziehau wrote: T> S> On Thu, Nov 17, 2016 at 10:03 PM, Bjoern A. Zeeb wrote: T> S> > Author: bz T> S> > Date: Thu Nov 17 14:03:44 2016 T> S> > New Revision: 308748 T> S> > URL: https://svnweb.freebsd.org/changeset/base/308748 T> S> > T> S> > Log: T> S> > Writing out the L2TP control packet requires 12 bytes of T> S> > contiguous memory but in one path we did not always guarantee this, T> S> > thus do a m_pullup() there. T> S> > T> S> > PR: 214385 T> S> > Submitted by: Joe Jones (joeknockando googlemail.com) T> S> > MFC after: 3 days T> S> > T> S> > Modified: T> S> > head/sys/netgraph/ng_l2tp.c T> S> > T> S> > Modified: head/sys/netgraph/ng_l2tp.c T> S> > ============================================================================== T> S> > --- head/sys/netgraph/ng_l2tp.c Thu Nov 17 11:48:07 2016 (r308747) T> S> > +++ head/sys/netgraph/ng_l2tp.c Thu Nov 17 14:03:44 2016 (r308748) T> S> > @@ -1544,6 +1544,16 @@ ng_l2tp_xmit_ctrl(priv_p priv, struct mb T> S> > priv->stats.memoryFailures++; T> S> > return (ENOBUFS); T> S> > } T> S> > + T> S> > + /* T> S> > + * The below requires 12 contiguous bytes for the L2TP header T> S> > + * to be written into. T> S> > + */ T> S> > + m = m_pullup(m, 12); T> S> > + if (m == NULL) { T> S> > + priv->stats.memoryFailures++; T> S> > + return (ENOBUFS); T> S> > + } T> S> T> S> Would it be better that we do a (m->m_len < 12) test before doing the T> S> m_pullup()? T> T> Yes, and a line like: T> T> if (m->m_len < 12 && (m = m_pullup(m, 12)) == NULL) T> T> will also match the style of the rest of the code in the function. I think the whole block can be shortened to: - prepend 10 - pullup 12 - read session_id at offset 10 The first pullup can be removed. -- Totus tuus, Glebius.