Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 30 Nov 2004 17:53:56 +0100
From:      Max Laier <max@love2party.net>
To:        Max Laier <mlaier@FreeBSD.org>
Cc:        freebsd-bugs@FreeBSD.org
Subject:   Re: kern/73321: Reproducible Panic (LOR: I4B / INET6)
Message-ID:  <20041130165356.GA98091@router.laiers.local>
In-Reply-To: <200411301653.iAUGr6t2082800@freefall.freebsd.org>
References:  <200411301653.iAUGr6t2082800@freefall.freebsd.org>

next in thread | previous in thread | raw e-mail | index | archive | help

--9amGYk9869ThD9tj
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline

Here is the Patch:

-- 
/"\  Best regards,                      | mlaier@freebsd.org
\ /  Max Laier                          | ICQ #67774661
 X   http://pf4freebsd.love2party.net/  | mlaier@EFnet
/ \  ASCII Ribbon Campaign              | Against HTML Mail and News
--9amGYk9869ThD9tj
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment; filename="dom_init.diff"

Index: kern/uipc_domain.c
===================================================================
RCS file: /usr/store/mlaier/fcvs/src/sys/kern/uipc_domain.c,v
retrieving revision 1.40
diff -u -r1.40 uipc_domain.c
--- kern/uipc_domain.c	11 Nov 2004 19:19:54 -0000	1.40
+++ kern/uipc_domain.c	30 Nov 2004 00:55:14 -0000
@@ -59,6 +59,10 @@
 static void domaininit(void *);
 SYSINIT(domain, SI_SUB_PROTO_DOMAIN, SI_ORDER_FIRST, domaininit, NULL)
 
+static void domainfinalize(void *);
+SYSINIT(domainfin, SI_SUB_PROTO_IFATTACHDOMAIN, SI_ORDER_FIRST, domainfinalize,
+    NULL)
+
 static struct callout pffast_callout;
 static struct callout pfslow_callout;
 
@@ -66,6 +70,7 @@
 static void	pfslowtimo(void *);
 
 struct domain *domains;		/* registered protocol domains */
+int domain_init_status = 0;
 struct mtx dom_mtx;		/* domain list lock */
 MTX_SYSINIT(domain, &dom_mtx, "domain list", MTX_DEF);
 
@@ -160,6 +165,21 @@
 	mtx_lock(&dom_mtx);
 	dp->dom_next = domains;
 	domains = dp;
+
+	KASSERT(domain_init_status >= 1,
+	    ("attempt to net_add_domain(%s) before domaininit()",
+	    dp->dom_name));
+	KASSERT(domain_init_status < 2,
+	    ("attempt to net_add_domain(%s) after domainfinalize()",
+	    dp->dom_name));
+#ifndef INVARIANTS
+	if (domain_init_status == 0)
+		printf("WARNING: attempt to net_add_domain(%s) before "
+		    "domaininit()\n", dp->dom_name);
+	if (domain_init_status != 0)
+		printf("WARNING: attempt to net_add_domain(%s) after "
+		    "domainfinalize()\n", dp->dom_name);
+#endif
 	mtx_unlock(&dom_mtx);
 	net_init_domain(dp);
 }
@@ -188,10 +208,24 @@
 		callout_init(&pfslow_callout, 0);
 	}
 
+	mtx_lock(&dom_mtx);
+	KASSERT(domain_init_status == 0, ("domaininit called too late!"));
+	domain_init_status = 1;
+	mtx_unlock(&dom_mtx);
+
 	callout_reset(&pffast_callout, 1, pffasttimo, NULL);
 	callout_reset(&pfslow_callout, 1, pfslowtimo, NULL);
 }
 
+/* ARGSUSED*/
+static void
+domainfinalize(void *dummy)
+{
+	mtx_lock(&dom_mtx);
+	KASSERT(domain_init_status == 1, ("domainfinalize called too late!"));
+	domain_init_status = 2;
+	mtx_unlock(&dom_mtx);	
+}
 
 struct protosw *
 pffindtype(family, type)
Index: net/if.c
===================================================================
RCS file: /usr/store/mlaier/fcvs/src/sys/net/if.c,v
retrieving revision 1.212
diff -u -r1.212 if.c
--- net/if.c	23 Nov 2004 23:31:33 -0000	1.212
+++ net/if.c	30 Nov 2004 00:23:46 -0000
@@ -451,7 +451,7 @@
 	ifp->if_snd.altq_tbr  = NULL;
 	ifp->if_snd.altq_ifp  = ifp;
 
-	if (domains)
+	if (domain_init_status >= 2)
 		if_attachdomain1(ifp);
 
 	EVENTHANDLER_INVOKE(ifnet_arrival_event, ifp);
@@ -471,7 +471,7 @@
 		if_attachdomain1(ifp);
 	splx(s);
 }
-SYSINIT(domainifattach, SI_SUB_PROTO_IFATTACHDOMAIN, SI_ORDER_FIRST,
+SYSINIT(domainifattach, SI_SUB_PROTO_IFATTACHDOMAIN, SI_ORDER_SECOND,
     if_attachdomain, NULL);
 
 static void
@@ -490,14 +490,14 @@
 		splx(s);
 		return;
 	}
-	if (ifp->if_afdata_initialized) {
+	if (ifp->if_afdata_initialized >= domain_init_status) {
 		IF_AFDATA_UNLOCK(ifp);
 		splx(s);
 		printf("if_attachdomain called more than once on %s\n",
 		    ifp->if_xname);
 		return;
 	}
-	ifp->if_afdata_initialized = 1;
+	ifp->if_afdata_initialized = domain_init_status;
 	IF_AFDATA_UNLOCK(ifp);
 
 	/* address family dependent data region */
Index: sys/domain.h
===================================================================
RCS file: /usr/store/mlaier/fcvs/src/sys/sys/domain.h,v
retrieving revision 1.19
diff -u -r1.19 domain.h
--- sys/domain.h	7 Apr 2004 04:19:49 -0000	1.19
+++ sys/domain.h	29 Nov 2004 20:00:32 -0000
@@ -64,6 +64,7 @@
 };
 
 #ifdef _KERNEL
+extern int	domain_init_status;
 extern struct	domain *domains;
 extern struct	domain localdomain;
 extern void	net_add_domain(void *);

--9amGYk9869ThD9tj--



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20041130165356.GA98091>