From owner-freebsd-net@freebsd.org Thu Apr 20 13:28:38 2017 Return-Path: Delivered-To: freebsd-net@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 53483D480EE for ; Thu, 20 Apr 2017 13:28:38 +0000 (UTC) (envelope-from zec@fer.hr) Received: from mail.fer.hr (mail.fer.hr [161.53.72.233]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-SHA384 (256/256 bits)) (Client CN "mail.fer.hr", Issuer "TERENA SSL CA 3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id D2138A5F for ; Thu, 20 Apr 2017 13:28:36 +0000 (UTC) (envelope-from zec@fer.hr) Received: from x23 (161.53.63.210) by MAIL.fer.hr (161.53.72.233) with Microsoft SMTP Server (TLS) id 14.3.319.2; Thu, 20 Apr 2017 15:28:33 +0200 Date: Thu, 20 Apr 2017 15:28:53 +0200 From: Marko Zec To: Kristof Provost CC: , Subject: Re: MFC VIMAGE fixes to 11-stable Message-ID: <20170420152853.019e5480@x23> In-Reply-To: <60C3FBF7-7CF3-49AF-9DDF-0589AE9D9146@sigsegv.be> References: <8E6FC1CD-24D5-46D5-A6A1-760DD612F92D@bsd4all.org> <20170420124256.1190665d@x23> <60C3FBF7-7CF3-49AF-9DDF-0589AE9D9146@sigsegv.be> X-Mailer: Claws Mail 3.14.1 (GTK+ 2.24.29; amd64-portbld-freebsd11.0) MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Originating-IP: [161.53.63.210] X-BeenThere: freebsd-net@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Networking and TCP/IP with FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 20 Apr 2017 13:28:38 -0000 On Thu, 20 Apr 2017 15:13:42 +0200 Kristof Provost wrote: > On 20 Apr 2017, at 12:42, Marko Zec wrote: > > The real culprit lies somewhere in PF code which operates on a wrong > > vnet. Without a backtrace it's difficult to guess, but a quick read > > reveals that > > > > pfi_initialize() > > > > is called from the default vnet context, and subsequently registers > > interface eventhandlers so that all interface attach, change and=20 > > detach > > events will be always executed in the default vnet, regardless of > > the real vnet where the interfaces bound to the events actually > > reside. In > > other words, > > > > pfi_attach_group_event() > > pfi_change_group_event() > > pfi_detach_group_event() > > > > will operate fine only in the default vnet, but will wreak havoc > > otherwise. Hence, those handlers should be fixed first. > > =20 > I don=E2=80=99t think that=E2=80=99s right. >=20 > The event handler doesn=E2=80=99t carry vnet information. It=E2=80=99s j= ust called=20 > in whatever vnet is active when it=E2=80=99s invoked. > There's no CURVNET_SET() in the EVENTHANDLER_INVOKE() macro. >=20 > That means that we end up in pf_attach_group_event() with CURVNET set > to the relevant vnet, not to the default vnet. Right. But pfi_attach_group_event() and the other handlers cited above _do_ in fact invoke CURVNET_SET(vnet0) on entry, overriding the proper vnet choice from the caller. Therefore the proper fix should be as simple as removing CURVNET_SET() / CURVNET_RESTORE() macro pairs from the cited handlers. Marko >=20 > There are certainly still issues with pf and vnets, but I don't think=20 > this is > one. >=20 > Regards, > Kristof