Module Name: src
Committed By: pgoyette
Date: Tue Apr 25 22:07:10 UTC 2017
Modified Files:
src/sys/kern: kern_sysctl.c
Log Message:
Add a check to ensure that a new sysctl node was attached in the tree
at the place we expected it to be attached!
As mentioned several times (on tech-kern@ mailing list) over the past
18 months or so, I've seen a few instances where this will trigger,
although I've been unable to reproduce them. Hopefully some wider
exposure will reveal the under-lying cause of this rare phenomenon.
Commit was proposed on tech-kern list, and no objections raised.
To generate a diff of this commit:
cvs rdiff -u -r1.258 -r1.259 src/sys/kern/kern_sysctl.c
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
Modified files:
Index: src/sys/kern/kern_sysctl.c
diff -u src/sys/kern/kern_sysctl.c:1.258 src/sys/kern/kern_sysctl.c:1.259
--- src/sys/kern/kern_sysctl.c:1.258 Fri Oct 23 01:58:43 2015
+++ src/sys/kern/kern_sysctl.c Tue Apr 25 22:07:10 2017
@@ -1,4 +1,4 @@
-/* $NetBSD: kern_sysctl.c,v 1.258 2015/10/23 01:58:43 pgoyette Exp $ */
+/* $NetBSD: kern_sysctl.c,v 1.259 2017/04/25 22:07:10 pgoyette Exp $ */
/*-
* Copyright (c) 2003, 2007, 2008 The NetBSD Foundation, Inc.
@@ -68,7 +68,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: kern_sysctl.c,v 1.258 2015/10/23 01:58:43 pgoyette Exp $");
+__KERNEL_RCSID(0, "$NetBSD: kern_sysctl.c,v 1.259 2017/04/25 22:07:10 pgoyette Exp $");
#ifdef _KERNEL_OPT
#include "opt_defcorename.h"
@@ -1955,6 +1955,7 @@ sysctl_createv(struct sysctllog **log, i
const struct sysctlnode *root, *pnode;
struct sysctlnode nnode, onode, *dnode;
size_t sz;
+ const struct sysctlnode *snode __diagused;
/*
* where are we putting this?
@@ -2111,6 +2112,7 @@ sysctl_createv(struct sysctllog **log, i
*/
pnode = root;
error = sysctl_locate(NULL, &name[0], namelen - 1, &pnode, &ni);
+ snode = pnode;
/*
* manual scan of last layer so that aliased nodes
@@ -2131,6 +2133,8 @@ sysctl_createv(struct sysctllog **log, i
* not expecting an error here, but...
*/
if (error == 0) {
+ KASSERTMSG(pnode->sysctl_parent == snode,
+ "sysctl parent mis-match");
if (log != NULL)
sysctl_log_add(log, pnode);
if (cnode != NULL)