diff options
author | roam <roam@FreeBSD.org> | 2001-07-25 17:21:18 +0000 |
---|---|---|
committer | roam <roam@FreeBSD.org> | 2001-07-25 17:21:18 +0000 |
commit | a100af4fa8fb439e081a08bd1feaeee8228d209e (patch) | |
tree | 666eb8e043452947c205df448c6ea858d43f5c61 | |
parent | 3e1e624da70d565919479419c126fc463ee9f0d0 (diff) | |
download | FreeBSD-src-a100af4fa8fb439e081a08bd1feaeee8228d209e.zip FreeBSD-src-a100af4fa8fb439e081a08bd1feaeee8228d209e.tar.gz |
Make dynamic sysctl entries start at 0x100, not decimal 100 - there are
static entries with oid's over 100, and defining enough dynamic entries
causes an overlap.
Move the "magic" value 0x100 into <sys/sysctl.h> where it belongs.
PR: 29131
Submitted by: "Alexander N. Kabaev" <kabaev@mail.ru>
Reviewed by: -arch, -audit
MFC after: 2 weeks
-rw-r--r-- | sys/kern/kern_sysctl.c | 10 | ||||
-rw-r--r-- | sys/sys/sysctl.h | 6 |
2 files changed, 13 insertions, 3 deletions
diff --git a/sys/kern/kern_sysctl.c b/sys/kern/kern_sysctl.c index 0b4c3d4..c165bb3 100644 --- a/sys/kern/kern_sysctl.c +++ b/sys/kern/kern_sysctl.c @@ -110,15 +110,19 @@ sysctl_register_oid(struct sysctl_oid *oidp) } /* * If this oid has a number OID_AUTO, give it a number which - * is greater than any current oid. Make sure it is at least - * 100 to leave space for pre-assigned oid numbers. + * is greater than any current oid. + * NOTE: DO NOT change the starting value here, change it in + * <sys/sysctl.h>, and make sure it is at least 256 to + * accomodate e.g. net.inet.raw as a static sysctl node. */ 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); } /* diff --git a/sys/sys/sysctl.h b/sys/sys/sysctl.h index cb19d94..e83d626 100644 --- a/sys/sys/sysctl.h +++ b/sys/sys/sysctl.h @@ -95,6 +95,12 @@ struct ctlname { */ #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 |