From owner-freebsd-net Fri Mar 14 1:51: 7 2003 Delivered-To: freebsd-net@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 0F46A37B401 for ; Fri, 14 Mar 2003 01:51:06 -0800 (PST) Received: from mailhub.fokus.fraunhofer.de (mailhub.fokus.fraunhofer.de [193.174.154.14]) by mx1.FreeBSD.org (Postfix) with ESMTP id BAA1E43F75 for ; Fri, 14 Mar 2003 01:51:04 -0800 (PST) (envelope-from brandt@fokus.fraunhofer.de) Received: from beagle (beagle [193.175.132.100]) by mailhub.fokus.fraunhofer.de (8.11.6/8.11.6) with ESMTP id h2E9p3M29604 for ; Fri, 14 Mar 2003 10:51:03 +0100 (MET) Date: Fri, 14 Mar 2003 10:51:01 +0100 (CET) From: Harti Brandt To: net@freebsd.org Subject: locking in network if attach again Message-ID: <20030314104019.T65266@beagle.fokus.fraunhofer.de> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Sender: owner-freebsd-net@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.org Hi all, the following problem occured just to me. Suppose the last lines in my attach() function look something like: if_attach(...) bus_setup_intr(...) Last time we had the locking discussion it was more or less the concensus, that no locking is needed in attach() and that the last thing I do is setting up the interrupt. It seems to me, however, that the following may happen here: 1. After if_attach but before setup_intr() a process on another processor calls if_ioctl to make the interface UP and if_start() to start output. 2. while the attach routine is blocked (perhaps while an interrupt is serverd) if_start initiates output. 3. The device tries to interrupt but cannot do that (setup_intr() has not been called yet). 4. The device gets stuck, because the interrupt is lost. 5. setup_intr() is called but that does not help. Is this a possible scenario? I must admit, that such a scenarion has a rather low probability, but according to Murphy's Law, it will happen. Maybe if_attach and bus_setup_intr can be reversed. In this case the interrupt routine must be careful to not call into the network system, because the network system doesn't know anything about the interface until if_attach(). Another solution would be to lock softc before if_attach, but this would probably provoke an LOR (as I remember). Regards, harti -- harti brandt, http://www.fokus.fraunhofer.de/research/cc/cats/employees/hartmut.brandt/private brandt@fokus.fraunhofer.de, harti@freebsd.org To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-net" in the body of the message