From owner-freebsd-current@FreeBSD.ORG Tue Jul 13 21:54:09 2004 Return-Path: Delivered-To: freebsd-current@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 1260F16A4CE for ; Tue, 13 Jul 2004 21:54:09 +0000 (GMT) Received: from mail-white.research.att.com (mail-red.research.att.com [192.20.225.110]) by mx1.FreeBSD.org (Postfix) with ESMTP id A19DD43D3F for ; Tue, 13 Jul 2004 21:54:08 +0000 (GMT) (envelope-from fenner@research.att.com) Received: from mail-blue.research.att.com (mail-blue.research.att.com [135.207.30.102]) by mail-white.research.att.com (Postfix) with ESMTP id 25304664059 for ; Tue, 13 Jul 2004 17:54:04 -0400 (EDT) Received: from windsor.research.att.com (windsor.research.att.com [135.207.26.46]) by mail-blue.research.att.com (Postfix) with ESMTP id 7A9F41974C3 for ; Tue, 13 Jul 2004 17:53:06 -0400 (EDT) Received: (from fenner@localhost) by windsor.research.att.com (8.11.6+Sun/8.8.5) id i6DLs3U27289; Tue, 13 Jul 2004 14:54:03 -0700 (PDT) Message-Id: <200407132154.i6DLs3U27289@windsor.research.att.com> MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII To: current@freebsd.org Date: Tue, 13 Jul 2004 14:54:02 -0700 From: Bill Fenner Versions: dmail (solaris) 2.6d/makemail 2.10 Subject: Sysctl object type unification X-BeenThere: freebsd-current@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: Discussions about the use of FreeBSD-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 13 Jul 2004 21:54:09 -0000 After discovering (years ago, now, I've finally caught up) that some of the networking sysctls show up as 0 on sparc64 because they are using the top 32 bits of a 64-bit value, I developed some CTASSERTs to audit sysctl type usage, e.g. #define SYSCTL_UINT(parent, nbr, name, access, ptr, val, descr) \ CTASSERT(__builtin_types_compatible_p(__typeof__(ptr), unsigned int *)); \ SYSCTL_OID(parent, nbr, name, CTLTYPE_UINT|(access), \ ptr, val, sysctl_handle_int, "IU", descr) I found quite a few. A patch to handle nearly all is at http://people.freebsd.org/~fenner/sysctl-types.diff . Note that in places outside of the networking stack, I was relatively conservative and didn't change variables that were used in a SYSCTL_UINT to unsigned, but instead changed to SYSCTL_INT. In addition, I mostly changed values to int instead of changing the SYSCTL to long, since they were mostly buffer sizes or timeouts. dummynet wants to expose a u_int64_t but there is no SYSCTL_QUAD, so it uses SYSCTL_INT which will be wrong on any big-endian platform. Some code wants to expose u_int32_t; I couldn't decide whether to think that we want a SYSCTL_UINT32 or to think that these values should simply be unsigned int. Luckily, there's no difference on our current platforms so I punted, but discussion is welcome. I'd like it if people could check through files that they're familiar with and see if they agree with my changes. I hope to commit these changes in a week or two. For convenience, here are the affected files: Index: contrib/ipfilter/netinet/ip_nat.c Index: contrib/ipfilter/netinet/ip_nat.h Index: contrib/ipfilter/netinet/ip_state.c Index: contrib/ipfilter/netinet/ip_state.h Index: contrib/ipfilter/netinet/mlfk_ipl.c Index: fs/devfs/devfs_devs.c Index: kern/kern_mib.c Index: kern/sched_4bsd.c Index: kern/sched_ule.c Index: kern/subr_kobj.c Index: kern/uipc_usrreq.c Index: kern/vfs_subr.c Index: netinet/ip_fw2.c Index: netinet/raw_ip.c Index: netinet/tcp_hostcache.c Index: netinet/tcp_subr.c Index: netinet/tcp_syncache.c Index: netinet/tcp_usrreq.c Index: netinet/tcp_var.h Index: netinet/udp_usrreq.c Index: netinet/udp_var.h Index: netinet6/raw_ip6.c Index: rpc/rpcclnt.h Index: security/mac_seeotheruids/mac_seeotheruids.c Thanks, Bill