Sysctl object type unification

From: Bill Fenner <fenner_at_research.att.com>
Date: Tue, 13 Jul 2004 14:54:02 -0700
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
Received on Tue Jul 13 2004 - 19:54:09 UTC

This archive was generated by hypermail 2.4.0 : Wed May 19 2021 - 11:38:01 UTC