From owner-freebsd-hackers@FreeBSD.ORG Mon Apr 1 09:56:46 2013 Return-Path: Delivered-To: freebsd-hackers@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by hub.freebsd.org (Postfix) with ESMTP id 5079C667 for ; Mon, 1 Apr 2013 09:56:46 +0000 (UTC) (envelope-from torek@torek.net) Received: from elf.torek.net (50-73-42-1-utah.hfc.comcastbusiness.net [50.73.42.1]) by mx1.freebsd.org (Postfix) with ESMTP id 2F97CFB9 for ; Mon, 1 Apr 2013 09:56:45 +0000 (UTC) Received: from elf.torek.net (localhost [127.0.0.1]) by elf.torek.net (8.14.5/8.14.5) with ESMTP id r319jJw7027369 for ; Mon, 1 Apr 2013 03:45:19 -0600 (MDT) (envelope-from torek@torek.net) Message-Id: <201304010945.r319jJw7027369@elf.torek.net> From: Chris Torek To: freebsd-hackers@freebsd.org Subject: boot time crash in if_detach_internal() Date: Mon, 01 Apr 2013 03:45:19 -0600 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.2.7 (elf.torek.net [127.0.0.1]); Mon, 01 Apr 2013 03:45:19 -0600 (MDT) X-Mailman-Approved-At: Mon, 01 Apr 2013 11:43:00 +0000 X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 01 Apr 2013 09:56:46 -0000 I have been poking about with the bhyve virtualization code in FreeBSD 10-current, and managed to crash FreeBSD during its bootstrap process due to the fact that if_detach is called from boot time configuration code, before the internal domain system initialization has happened. I added the following patch to work around the problem. As the large comment notes, it might not be quite correct but it does allow the boot to proceed (of course the "dead" network device is soon a problem anyway...). The fix mirrors (more or less) the code in if_attach_internal(). Feel free to accept, ignore, or modify the patch. :-) Chris diff --git a/sys/net/if.c b/sys/net/if.c --- a/sys/net/if.c +++ b/sys/net/if.c @@ -845,6 +845,15 @@ if_purgeaddrs(ifp); + /* + * torek: it's not entirely clear to me where and how this + * should go, but if domain_init_status < 2 then there should + * be no inet, inet6, etc items, and this is where the crash + * happens during boot, so let's try this: + */ + if (domain_init_status < 2) + return; + #ifdef INET in_ifdetach(ifp); #endif