From kabaev@mail.ru  Sat Jul 21 20:34:31 2001
Return-Path: <kabaev@mail.ru>
Received: from smtp3.port.ru (mx3.port.ru [194.67.23.37])
	by hub.freebsd.org (Postfix) with ESMTP id 9757D37B401
	for <FreeBSD-gnats-submit@freebsd.org>; Sat, 21 Jul 2001 20:34:30 -0700 (PDT)
	(envelope-from kabaev@mail.ru)
Received: from adsl-141-154-21-78.bostma.adsl.bellatlantic.net ([141.154.21.78] helo=kan.dnsalias.net)
	by smtp3.port.ru with esmtp (Exim 3.14 #1)
	id 15OA0i-000L4p-00
	for FreeBSD-gnats-submit@freebsd.org; Sun, 22 Jul 2001 07:34:29 +0400
Received: (from kan@localhost)
	by kan.dnsalias.net (8.11.4/8.11.4) id f6M3YRe01219;
	Sat, 21 Jul 2001 23:34:27 -0400 (EDT)
	(envelope-from kan)
Message-Id: <200107220334.f6M3YRe01219@kan.dnsalias.net>
Date: Sat, 21 Jul 2001 23:34:27 -0400 (EDT)
From: "Alexander N. Kabaev" <kabaev@mail.ru>
Reply-To: "Alexander N. Kabaev" <ak03@gte.com>
To: FreeBSD-gnats-submit@freebsd.org
Cc:
Subject: Current hungs in sysctl -a while booting + patch
X-Send-Pr-Version: 3.113
X-GNATS-Notify:

>Number:         29131
>Category:       kern
>Synopsis:       Current hungs in sysctl -a while booting + patch
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    roam
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Sat Jul 21 20:40:09 PDT 2001
>Closed-Date:    Mon Jul 22 12:17:44 PDT 2002
>Last-Modified:  Mon Jul 22 12:17:44 PDT 2002
>Originator:     Alexander N. Kabaev
>Release:        FreeBSD 5.0-CURRENT i386
>Organization:
Verizon
>Environment:
System: FreeBSD kan.dnsalias.net 5.0-CURRENT FreeBSD 5.0-CURRENT #1: Sat Jul 21 23:05:49 EDT 2001 root@kan.dnsalias.net:/usr/src/sys/i386/compile/KAN i386

>Description:
	-CURRENT appears to hung while booting because sysctl -a never
	finishes. ^C can be used to interrupt the sysctl execution and
	to continue booting. 
	
	It appears, that a sysctl oid_number collision is happening. Namely,
	sysctl_register_oid allocates new numbers for OID_AUTO sysctl nodes
	starting from the number 100, while at the same time kernel registers
	predefined sysctls with ids as high as 255 (see SYSCTL_NODE for
	net.inet.raw). If I raise the starting number for dynamic sysctls
	to be 255, the problem disappears.

>How-To-Repeat:
	N/A
>Fix:

Index: kern_sysctl.c
===================================================================
RCS file: /home/ncvs/src/sys/kern/kern_sysctl.c,v
retrieving revision 1.110
diff -u -u -r1.110 kern_sysctl.c
--- kern_sysctl.c	2001/06/22 19:54:38	1.110
+++ kern_sysctl.c	2001/07/22 03:04:45
@@ -113,7 +113,7 @@
 	 * 100 to leave space for pre-assigned oid numbers.
 	 */
 	if (oidp->oid_number == OID_AUTO) {
-		static int newoid = 100;
+		static int newoid = 0x100;
 
 		oidp->oid_number = newoid++;
 		if (newoid == 0x7fffffff)
>Release-Note:
>Audit-Trail:
State-Changed-From-To: open->analyzed 
State-Changed-By: roam 
State-Changed-When: Sun Jul 22 11:17:17 PDT 2001 
State-Changed-Why:  
I have a patch in the works, and there is ongoing discussion 
on the -arch mailing list. 


Responsible-Changed-From-To: freebsd-bugs->roam 
Responsible-Changed-By: roam 
Responsible-Changed-When: Sun Jul 22 11:17:17 PDT 2001 
Responsible-Changed-Why:  
I'll take a look at this. 

http://www.FreeBSD.org/cgi/query-pr.cgi?pr=29131 

From: Peter Pentchev <roam@orbitel.bg>
To: freebsd-gnats-submit@FreeBSD.org
Cc: arch@FreeBSD.org
Subject: Re: kern/29131: Current hungs in sysctl -a while booting + patch
Date: Sun, 22 Jul 2001 23:59:34 +0300

 --Nq2Wo0NMKNjxTN9z
 Content-Type: text/plain; charset=us-ascii
 Content-Disposition: inline
 
 On Sun, Jul 22, 2001 at 03:42:33AM -0500, Alfred Perlstein wrote:
 > * Peter Pentchev <roam@orbitel.bg> [010722 03:02] wrote:
 > > Hi,
 > > 
 > > Can anyone envision any side effects from committing the patch
 > > in this PR?  Seems like a trivial fix for a typo to me..
 > 
 > Shouldn't "magic" constants be put into the sysctl.h header?
 
 Good call!
 
 Attached are two patches: one to make sys/kern/kern_sysctl.c a bit
 more style(9)-compliant (what made me do it was the failed search
 for /^sysctl_register_oid/ when I saw it referenced), and one to put
 a magic constant into sysctl.h and make kern_sysctl.c use it and
 complain (albeit a bit harshly ;) about misbehaving static sysctl's.
 
 Comments?
 
 G'luck,
 Peter
 
 -- 
 If I were you, who would be reading this sentence?
 
 --Nq2Wo0NMKNjxTN9z
 Content-Type: text/plain; charset=us-ascii
 Content-Disposition: attachment; filename="kern_sysctl.c-style.patch"
 
 Index: src/sys/kern/kern_sysctl.c
 ===================================================================
 RCS file: /home/ncvs/src/sys/kern/kern_sysctl.c,v
 retrieving revision 1.110
 diff -u -r1.110 kern_sysctl.c
 --- src/sys/kern/kern_sysctl.c	2001/06/22 19:54:38	1.110
 +++ src/sys/kern/kern_sysctl.c	2001/07/22 20:38:15
 @@ -87,7 +87,8 @@
   * Order by number in each list.
   */
  
 -void sysctl_register_oid(struct sysctl_oid *oidp)
 +void
 +sysctl_register_oid(struct sysctl_oid *oidp)
  {
  	struct sysctl_oid_list *parent = oidp->oid_parent;
  	struct sysctl_oid *p;
 @@ -135,7 +136,8 @@
  		SLIST_INSERT_HEAD(parent, oidp, oid_link);
  }
  
 -void sysctl_unregister_oid(struct sysctl_oid *oidp)
 +void
 +sysctl_unregister_oid(struct sysctl_oid *oidp)
  {
  	SLIST_REMOVE(oidp->oid_parent, oidp, sysctl_oid, oid_link);
  }
 @@ -371,7 +373,8 @@
   */
  SET_DECLARE(sysctl_set, struct sysctl_oid);
  
 -static void sysctl_register_all(void *arg)
 +static void
 +sysctl_register_all(void *arg)
  {
  	struct sysctl_oid **oidp;
  
 @@ -1084,7 +1087,8 @@
   * must be in kernel space.
   */
  int
 -userland_sysctl(struct proc *p, int *name, u_int namelen, void *old, size_t *oldlenp, int inkernel, void *new, size_t newlen, size_t *retval)
 +userland_sysctl(struct proc *p, int *name, u_int namelen, void *old,
 +    size_t *oldlenp, int inkernel, void *new, size_t newlen, size_t *retval)
  {
  	int error = 0;
  	struct sysctl_req req, req2;
 
 --Nq2Wo0NMKNjxTN9z
 Content-Type: text/plain; charset=us-ascii
 Content-Disposition: attachment; filename="sysctl-auto-start.patch"
 
 Index: src/sys/kern/kern_sysctl.c
 ===================================================================
 RCS file: /home/ncvs/src/sys/kern/kern_sysctl.c,v
 retrieving revision 1.110
 diff -u -r1.110 kern_sysctl.c
 --- src/sys/kern/kern_sysctl.c	2001/06/22 19:54:38	1.110
 +++ src/sys/kern/kern_sysctl.c	2001/07/22 20:46:50
 @@ -113,11 +113,13 @@
  	 * 100 to leave space for pre-assigned oid numbers.
  	 */
  	if (oidp->oid_number == OID_AUTO) {
 -		static int newoid = 100;
 +		static int newoid = CTL_AUTO_START;
  
  		oidp->oid_number = newoid++;
  		if (newoid == 0x7fffffff)
  			panic("out of oids");
 +	} else if (oidp->oid_number >= CTL_AUTO_START) {
 +		panic("static sysctl oid too high: %d", oidp->oid_number);
  	}
  
  	/*
 Index: src/sys/sys/sysctl.h
 ===================================================================
 RCS file: /home/ncvs/src/sys/sys/sysctl.h,v
 retrieving revision 1.97
 diff -u -r1.97 sysctl.h
 --- src/sys/sys/sysctl.h	2001/06/22 06:35:19	1.97
 +++ src/sys/sys/sysctl.h	2001/07/22 20:46:55
 @@ -95,6 +95,12 @@
   */ 
  #define OID_AUTO	(-1)
  
 +/*
 + * The starting number for dynamically-assigned entries.  WARNING!
 + * ALL static sysctl entries should have numbers LESS than this!
 + */
 +#define CTL_AUTO_START	0x100
 +
  #ifdef _KERNEL
  #define SYSCTL_HANDLER_ARGS struct sysctl_oid *oidp, void *arg1, int arg2, \
  	struct sysctl_req *req
 
 --Nq2Wo0NMKNjxTN9z--

From: "Alexander N. Kabaev" <ak03@gte.com>
To: freebsd-gnats-submit@FreeBSD.org
Cc:  
Subject: Re: kern/29131: Current hungs in sysctl -a while booting + patch
Date: Mon, 29 Oct 2001 11:40:40 -0500

 This PR can be closed.
 

From: "Alexander N. Kabaev" <ak03@gte.com>
To: freebsd-gnats-submit@FreeBSD.org
Cc:  
Subject: Re: kern/29131: Current hungs in sysctl -a while booting + patch
Date: Thu, 18 Apr 2002 13:42:00 -0400

 Please close this PR.  The problem has been fixed a long time ago and 
 yet PR is
 still lingers in analyzed state.
 
 This is a second attempt to get this PR closed.
 
State-Changed-From-To: analyzed->closed 
State-Changed-By: kan 
State-Changed-When: Mon Jul 22 12:16:44 PDT 2002 
State-Changed-Why:  
The problem has been resolved. Closed at the originator request. 

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