Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 17 Nov 2016 16:01:02 -0800
From:      Gleb Smirnoff <glebius@FreeBSD.org>
To:        Sepherosa Ziehau <sepherosa@gmail.com>
Cc:        svn-src-head@freebsd.org, svn-src-all@freebsd.org, "Bjoern A. Zeeb" <bz@freebsd.org>, src-committers@freebsd.org
Subject:   Re: svn commit: r308748 - head/sys/netgraph
Message-ID:  <20161118000102.GW27748@FreeBSD.org>
In-Reply-To: <20161117235657.GV27748@FreeBSD.org>
References:  <201611171403.uAHE3i3N044462@repo.freebsd.org> <CAMOc5czJePr9ObomdsSLKgHOov_iVUoN4KLzqGpdXZ%2B9JccA3w@mail.gmail.com> <20161117235657.GV27748@FreeBSD.org>

next in thread | previous in thread | raw e-mail | index | archive | help
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 <bz@freebsd.org> 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.



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20161118000102.GW27748>