From owner-freebsd-net@FreeBSD.ORG Wed May 29 18:16:46 2013 Return-Path: Delivered-To: freebsd-net@freebsd.org Received: from mx1.freebsd.org (mx1.FreeBSD.org [8.8.178.115]) by hub.freebsd.org (Postfix) with ESMTP id CC04CAB6; Wed, 29 May 2013 18:16:46 +0000 (UTC) (envelope-from jhb@freebsd.org) Received: from bigwig.baldwin.cx (bigwig.baldwin.cx [IPv6:2001:470:1f11:75::1]) by mx1.freebsd.org (Postfix) with ESMTP id A96C8E5C; Wed, 29 May 2013 18:16:46 +0000 (UTC) Received: from jhbbsd.localnet (unknown [209.249.190.124]) by bigwig.baldwin.cx (Postfix) with ESMTPSA id 298E4B993; Wed, 29 May 2013 14:16:46 -0400 (EDT) From: John Baldwin To: freebsd-net@freebsd.org Subject: Re: RFC: removing redundant checks in ether_input_internal() Date: Wed, 29 May 2013 13:16:39 -0400 User-Agent: KMail/1.13.5 (FreeBSD/8.2-CBSD-20110714-p25; KDE/4.5.5; amd64; ; ) References: <20130522125828.GA93728@onelab2.iet.unipi.it> <519CDBE9.304@freebsd.org> In-Reply-To: <519CDBE9.304@freebsd.org> MIME-Version: 1.0 Content-Type: Text/Plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit Message-Id: <201305291316.39654.jhb@freebsd.org> X-Greylist: Sender succeeded SMTP AUTH, not delayed by milter-greylist-4.2.7 (bigwig.baldwin.cx); Wed, 29 May 2013 14:16:46 -0400 (EDT) Cc: Luigi Rizzo , Andre Oppermann , net@freebsd.org X-BeenThere: freebsd-net@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: Networking and TCP/IP with FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 29 May 2013 18:16:46 -0000 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