From owner-cvs-all@FreeBSD.ORG Wed Sep 21 19:52:49 2005 Return-Path: X-Original-To: cvs-all@freebsd.org Delivered-To: cvs-all@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 7D78516A41F; Wed, 21 Sep 2005 19:52:49 +0000 (GMT) (envelope-from imp@bsdimp.com) Received: from harmony.bsdimp.com (vc4-2-0-87.dsl.netrack.net [199.45.160.85]) by mx1.FreeBSD.org (Postfix) with ESMTP id 1169943D46; Wed, 21 Sep 2005 19:52:48 +0000 (GMT) (envelope-from imp@bsdimp.com) Received: from localhost (localhost.village.org [127.0.0.1] (may be forged)) by harmony.bsdimp.com (8.13.3/8.13.3) with ESMTP id j8LJnVWg056438; Wed, 21 Sep 2005 13:49:31 -0600 (MDT) (envelope-from imp@bsdimp.com) Date: Wed, 21 Sep 2005 13:49:50 -0600 (MDT) Message-Id: <20050921.134950.132929273.imp@bsdimp.com> To: ru@freebsd.org From: "M. Warner Losh" In-Reply-To: <20050921193410.GC24516@ip.net.ua> References: <20050921191906.GA24516@ip.net.ua> <20050921.132322.116350250.imp@bsdimp.com> <20050921193410.GC24516@ip.net.ua> X-Mailer: Mew version 3.3 on Emacs 21.3 / Mule 5.0 (SAKAKI) Mime-Version: 1.0 Content-Type: Text/Plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-2.0 (harmony.bsdimp.com [127.0.0.1]); Wed, 21 Sep 2005 13:49:32 -0600 (MDT) Cc: cvs-src@freebsd.org, src-committers@freebsd.org, rwatson@freebsd.org, cvs-all@freebsd.org, jhb@freebsd.org Subject: Re: cvs commit: src/sys/dev/an if_an.c src/sys/dev/arl if_arl_isa.c src/sys/dev/awi if_awi_pccard.c src/sys/dev/cm if_cm_isa.c src/sys/dev/cnw if_cnw.c src/sys/dev/cp if_cp.c src/sys/dev/cs if_cs.c src/sys/dev/ed if_ed.c src/sys/dev/em if_em.c ... X-BeenThere: cvs-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: CVS commit messages for the entire tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 21 Sep 2005 19:52:49 -0000 In message: <20050921193410.GC24516@ip.net.ua> Ruslan Ermilov writes: : On Wed, Sep 21, 2005 at 01:23:22PM -0600, M. Warner Losh wrote: : > In message: <20050921191906.GA24516@ip.net.ua> : > Ruslan Ermilov writes: : > : On Wed, Sep 21, 2005 at 01:02:41PM -0600, M. Warner Losh wrote: : > : > In message: <200509211455.59154.jhb@FreeBSD.org> : > : > John Baldwin writes: : > : > : > 5. Fix all drivers to set some flag in foo_detach() and foo_shutdown() : > : > : > and refuse to work in foo_ioctl() if it's set. This should fix : > : > : > panics when BPF listener is attached while interface goes away or : > : > : > module is unloaded. : > : > : > : > : I'd rather 5) be simpler in : > : > : that it only check in the flags case to not force the driver lock to be : > : > : acquired for all the ioctls that the driver doesn't actually handle. : > : > : Actually, I think I'd really prefer that we think about how to fix the BPF : > : > : issue in BPF itself if possible. It may be that we don't need to set the : > : > : flags (i.e. skip the actual ioctl) if the interface is in the process of : > : > : detaching and we can make that change centrally without having to scatter : > : > : gone flags in all the drivers. : > : > : > : > This would solve the race at hand. However, it wouldn't solve the : > : > problems with driver shutdown racing with other things in the system : > : > (like ifconfig during detach). : > : > : > : > I've knocked around the idea of creating a if_dead() function that one : > : > would call before foo_stop(). if_dead would just return (possibly an : > : > error) for all the entry points before the device is actually : > : > detached. This would mean that we don't need to add flags to all the : > : > drivers, but we do need to change all the detach routine. This would : > : > avoid the LOCK operations that you are worried about... : > : > : > : I'm afraid you cannot safely change the ifnet method pointers, if : > : you mean that foo_detach() should set ifp->if_start etc. to point : > : to if_dead(). : > : > Why not? What's the problem? : > : The time you change say ifp->if_start in foo_detach(), stack may call : it and get a half-changed pointer. Unless we invent locking shared : between stack and the drivers. pointers can be changed atomically on all our platforms. The only race is that there's a number of pointers that you need to change and you can't change all of them at the same time. ifp->if_start will either point to the old driver start routine, or it will point to the new routine. It won't be 1/2 and 1/2. Warner