From nobody@FreeBSD.org  Tue Aug 16 00:45:52 2011
Return-Path: <nobody@FreeBSD.org>
Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34])
	by hub.freebsd.org (Postfix) with ESMTP id E5B9F1065674
	for <freebsd-gnats-submit@FreeBSD.org>; Tue, 16 Aug 2011 00:45:52 +0000 (UTC)
	(envelope-from nobody@FreeBSD.org)
Received: from red.freebsd.org (red.freebsd.org [IPv6:2001:4f8:fff6::22])
	by mx1.freebsd.org (Postfix) with ESMTP id BB1598FC14
	for <freebsd-gnats-submit@FreeBSD.org>; Tue, 16 Aug 2011 00:45:52 +0000 (UTC)
Received: from red.freebsd.org (localhost [127.0.0.1])
	by red.freebsd.org (8.14.4/8.14.4) with ESMTP id p7G0jqRD042482
	for <freebsd-gnats-submit@FreeBSD.org>; Tue, 16 Aug 2011 00:45:52 GMT
	(envelope-from nobody@red.freebsd.org)
Received: (from nobody@localhost)
	by red.freebsd.org (8.14.4/8.14.4/Submit) id p7G0jqb0042474;
	Tue, 16 Aug 2011 00:45:52 GMT
	(envelope-from nobody)
Message-Id: <201108160045.p7G0jqb0042474@red.freebsd.org>
Date: Tue, 16 Aug 2011 00:45:52 GMT
From: John Hickey <jjh@deterlab.net>
To: freebsd-gnats-submit@FreeBSD.org
Cc: hrs@FreeBSD.org
Subject: RC file for mrouted causes kernel panic by running before devd is up.
X-Send-Pr-Version: www-3.1
X-GNATS-Notify:

>Number:         159807
>Category:       ports
>Synopsis:       RC file for net/mrouted causes kernel panic by running before devd is up.
>Confidential:   no
>Severity:       serious
>Priority:       high
>Responsible:    hrs
>State:          feedback
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Tue Aug 16 00:50:09 UTC 2011
>Closed-Date:    
>Last-Modified:  Fri Jan 04 20:37:26 UTC 2013
>Originator:     John Hickey
>Release:        8.2-STABLE
>Organization:
ISI - USC
>Environment:
FreeBSD router 8.2-STABLE FreeBSD 8.2-STABLE #1: Fri Jul 29 18:42:53 UTC 2011     root@router:/usr/obj/usr/src/sys/ROUTER  i386

>Description:
mrouted gets started before devd.  This results in a kernel panic:

....

<118>em3: flags=8843<UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST> metric 0 mtu 1500
<118>	options=9b<RXCSUM,TXCSUM,VLAN_MTU,VLAN_HWTAGGING,VLAN_HWCSUM>
<118>	ether 00:0c:29:88:f7:ce
<118>	inet 192.168.254.254 netmask 0xffffff00 broadcast 192.168.254.255
<118>	media: Ethernet autoselect (1000baseT <full-duplex>)
<118>	status: active
<118>Additional routing options:
<118> IP gateway=YES
<118>.
<118>Starting mrouted.
<118>Starting devd.


Fatal trap 12: page fault while in kernel mode
cpuid = 0; apic id = 00
fault virtual address	= 0x0
fault code		= supervisor read, page not present
instruction pointer	= 0x20:0xc095c1f8
stack pointer	        = 0x28:0xe6c3eb30
frame pointer	        = 0x28:0xe6c3eb30
code segment		= base 0x0, limit 0xfffff, type 0x1b
			= DPL 0, pres 1, def32 1, gran 1
processor eflags	= interrupt enabled, resume, IOPL = 0
current process		= 543 (devd)
trap number		= 12
panic: page fault
cpuid = 0
KDB: stack backtrace:
#0 0xc08ec597 at kdb_backtrace+0x47
#1 0xc08bcbf7 at panic+0x117
#2 0xc0bfc043 at trap_fatal+0x323
#3 0xc0bfc2a0 at trap_pfault+0x250
#4 0xc0bfc7c3 at trap+0x443
#5 0xc0be364c at calltrap+0x6
#6 0xc08e6ae3 at devread+0x193
#7 0xc087836c at giant_read+0x8c
#8 0xc083c5ae at devfs_read_f+0x7e
#9 0xc08fca96 at dofileread+0x96
#10 0xc08fce18 at kern_readv+0x58
#11 0xc08fcf0f at read+0x4f
#12 0xc08f8b79 at syscallenter+0x329
#13 0xc0bfc2f4 at syscall+0x34
#14 0xc0be36b1 at Xint0x80_syscall+0x21
Uptime: 11s
Physical memory: 1007 MB
Dumping 59 MB: 44 28 12

#0  doadump () at pcpu.h:231
231	pcpu.h: No such file or directory.
	in pcpu.h

(kgdb) 
>How-To-Repeat:
Enable mrouted in rc.conf.  Reboot system.  Panic ensues.
>Fix:
We need to make sure that the rc script for mrouted depends on devd.

diff -u mrouted.in.orig mrouted.in
--- mrouted.in.orig     2011-08-15 17:39:01.000000000 -0700
+++ mrouted.in  2011-08-15 17:39:07.000000000 -0700
@@ -5,7 +5,7 @@
 #
 
 # PROVIDE: mrouted
-# REQUIRE: netif routing cleanvar
+# REQUIRE: netif routing cleanvar devd
 # KEYWORD: nojail
 
 . /etc/rc.subr


>Release-Note:
>Audit-Trail:

From: John Hickey <jjh@deterlab.net>
To: bug-followup@FreeBSD.org
Cc:  
Subject: Re: ports/159807: RC file for mrouted causes kernel panic by running before devd is up.
Date: Mon, 15 Aug 2011 18:08:51 -0700

 Upon further investigation, I am not sure why starting mrouted after =
 devd should matter.  I removed the REQUIRES for devd and inserted a =
 sleep 10 before launching mrouted to see if it is a timing issue, but I =
 still get a panic.=
Responsible-Changed-From-To: freebsd-ports-bugs->johans 
Responsible-Changed-By: linimon 
Responsible-Changed-When: Tue Aug 16 03:51:22 UTC 2011 
Responsible-Changed-Why:  
Fix synopsis and assign. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=159807 
Responsible-Changed-From-To: johans->hrs 
Responsible-Changed-By: johans 
Responsible-Changed-When: Mon Dec 31 13:39:02 UTC 2012 
Responsible-Changed-Why:  
I couldn't reproduce this in the past. Can you confirm if the problem 
still occurs with the current version of mrouted? 

I am now handing this PR over to the new maintainer. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=159807 
State-Changed-From-To: open->feedback 
State-Changed-By: hrs 
State-Changed-When: Fri Jan 4 20:35:38 UTC 2013 
State-Changed-Why:  
Please let us know if this problem still occurs with the latest version of 
mrouted and 8.3-RELEASE. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=159807 
>Unformatted:
