Date: Wed, 29 May 2013 13:16:39 -0400 From: John Baldwin <jhb@freebsd.org> To: freebsd-net@freebsd.org Cc: Luigi Rizzo <rizzo@iet.unipi.it>, Andre Oppermann <andre@freebsd.org>, net@freebsd.org Subject: Re: RFC: removing redundant checks in ether_input_internal() Message-ID: <201305291316.39654.jhb@freebsd.org> In-Reply-To: <519CDBE9.304@freebsd.org> References: <20130522125828.GA93728@onelab2.iet.unipi.it> <519CDBE9.304@freebsd.org>
next in thread | previous in thread | raw e-mail | index | archive | help
On Wednesday, May 22, 2013 10:53:29 am Andre Oppermann wrote:
> On 22.05.2013 14:58, Luigi Rizzo wrote:
> > if_ethersubr.c :: ether_input_internal() is only called as follows:
> >
> > static void
> > ether_nh_input(struct mbuf *m)
> > {
> >
> > ether_input_internal(m->m_pkthdr.rcvif, m);
> > }
> >
> > hence the following checks in the body are unnecessary:
> >
> > if (m->m_pkthdr.rcvif == NULL) {
> > if_printf(ifp, "discard frame w/o interface pointer\n");
> > ifp->if_ierrors++;
> > m_freem(m);
> > return;
> > }
> > #ifdef DIAGNOSTIC
> > if (m->m_pkthdr.rcvif != ifp) {
> > if_printf(ifp, "Warning, frame marked as received on
%s\n",
> > m->m_pkthdr.rcvif->if_xname);
> > }
> > #endif
> >
> > Any objection if i remove them ?
>
> No, but they should remain as KASSERTs. None of these should trigger in
> production and all of them are an indication that something is very wrong
> with the packet or the caller.
Eh, but if the only caller is ether_nh_input() then by definition you know
that m->m_pkthdr.rcvif == ifp.
--
John Baldwin
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201305291316.39654.jhb>
