From owner-svn-src-head@FreeBSD.ORG Wed Apr 15 13:26:02 2015 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 214CD37C; Wed, 15 Apr 2015 13:26:02 +0000 (UTC) Received: from venus.codepro.be (venus.codepro.be [IPv6:2a01:4f8:162:1127::2]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "*.codepro.be", Issuer "Gandi Standard SSL CA" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id D4829E34; Wed, 15 Apr 2015 13:26:01 +0000 (UTC) Received: from vega.codepro.be (unknown [172.16.1.3]) by venus.codepro.be (Postfix) with ESMTP id 423BA10DB5; Wed, 15 Apr 2015 15:25:56 +0200 (CEST) Received: by vega.codepro.be (Postfix, from userid 1001) id 35C3F8C4B9; Wed, 15 Apr 2015 15:25:56 +0200 (CEST) Date: Wed, 15 Apr 2015 15:25:56 +0200 From: Kristof Provost To: Gleb Smirnoff Cc: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: Re: svn commit: r281536 - head/sys/netpfil/pf Message-ID: <20150415132556.GB2058@vega.codepro.be> References: <201504141907.t3EJ7bZp044696@svn.freebsd.org> <20150415125302.GB883@FreeBSD.org> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <20150415125302.GB883@FreeBSD.org> X-Checked-By-NSA: Probably User-Agent: Mutt/1.5.23 (2014-03-12) X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.20 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: Wed, 15 Apr 2015 13:26:02 -0000 On 2015-04-15 15:53:02 (+0300), Gleb Smirnoff wrote: > On Tue, Apr 14, 2015 at 07:07:37PM +0000, Kristof Provost wrote: > K> Author: kp > K> Date: Tue Apr 14 19:07:37 2015 > K> New Revision: 281536 > K> URL: https://svnweb.freebsd.org/changeset/base/281536 > K> > K> Log: > K> pf: Fix forwarding detection > K> > K> If the direction is not PF_OUT we can never be forwarding. Some input packets > K> have rcvif != ifp (looped back packets), which lead us to ip6_forward() inbound > K> packets, causing panics. > K> > K> Equally, we need to ensure that packets were really received and not locally > K> generated before trying to ip6_forward() them. > K> > K> Differential Revision: https://reviews.freebsd.org/D2286 > K> Approved by: gnn(mentor) > K> > K> Modified: > K> head/sys/netpfil/pf/pf.c > K> > K> Modified: head/sys/netpfil/pf/pf.c > K> ============================================================================== > K> --- head/sys/netpfil/pf/pf.c Tue Apr 14 18:57:50 2015 (r281535) > K> +++ head/sys/netpfil/pf/pf.c Tue Apr 14 19:07:37 2015 (r281536) > K> @@ -6070,7 +6070,7 @@ pf_test6(int dir, struct ifnet *ifp, str > K> > K> M_ASSERTPKTHDR(m); > K> > K> - if (ifp != m->m_pkthdr.rcvif) > K> + if (dir == PF_OUT && m->m_pkthdr.rcvif && ifp != m->m_pkthdr.rcvif) > K> fwdir = PF_FWD; > > The ifp argument to pf_test6() is always not NULL, so the (m->m_pkthdr.rcvif) > conjunct is extraneous. > m->pkthdr.rcvif can be NULL though (e.g. when this is a locally generated packet). In that case we don't want to forward, which we'd end up doing because, as you say, ifp won't be NULL. (In other words: If m->pkthdr.rcvif is NULL we don't forward, even if ifp != m->pkthdr.rcvif.) Regards, Kristof