I tested this with 'sysctl net' before and after and compared the outputs (using GENERIC.MP).
OK? >From c9e0001650e156434f63ba69f4f266115fcf4a35 Mon Sep 17 00:00:00 2001 From: Greg Steuck <g...@nest.cx> Date: Thu, 12 Nov 2020 19:47:46 -0800 Subject: [PATCH] Replace sysctl_rdint with sysctl_bounded_args entries in net.inet* --- sys/netinet/ip_input.c | 10 +++++++--- sys/netinet/tcp_usrreq.c | 5 ++--- sys/netinet6/ip6_input.c | 13 ++++++++----- 3 files changed, 17 insertions(+), 11 deletions(-) diff --git sys/netinet/ip_input.c sys/netinet/ip_input.c index 130f7a48a09..1378ef0c052 100644 --- sys/netinet/ip_input.c +++ sys/netinet/ip_input.c @@ -107,7 +107,14 @@ LIST_HEAD(, ipq) ipq; int ip_maxqueue = 300; int ip_frags = 0; +#ifdef MROUTING +extern int ip_mrtproto; +#endif + const struct sysctl_bounded_args ipctl_vars[] = { +#ifdef MROUTING + { IPCTL_MRTPROTO, &ip_mrtproto, 1, 0 }, +#endif { IPCTL_FORWARDING, &ipforwarding, 0, 1 }, { IPCTL_SENDREDIRECTS, &ipsendredirects, 0, 1 }, { IPCTL_DEFTTL, &ip_defttl, 0, 255 }, @@ -1562,7 +1569,6 @@ ip_sysctl(int *name, u_int namelen, void *oldp, size_t *oldlenp, void *newp, { int error; #ifdef MROUTING - extern int ip_mrtproto; extern struct mrtstat mrtstat; #endif @@ -1636,8 +1642,6 @@ ip_sysctl(int *name, u_int namelen, void *oldp, size_t *oldlenp, void *newp, case IPCTL_MRTSTATS: return (sysctl_rdstruct(oldp, oldlenp, newp, &mrtstat, sizeof(mrtstat))); - case IPCTL_MRTPROTO: - return (sysctl_rdint(oldp, oldlenp, newp, ip_mrtproto)); case IPCTL_MRTMFC: if (newp) return (EPERM); diff --git sys/netinet/tcp_usrreq.c sys/netinet/tcp_usrreq.c index 5057a6af44e..f36570b3bcc 100644 --- sys/netinet/tcp_usrreq.c +++ sys/netinet/tcp_usrreq.c @@ -110,7 +110,9 @@ u_int tcp_sendspace = TCP_SENDSPACE; u_int tcp_recvspace = TCP_RECVSPACE; u_int tcp_autorcvbuf_inc = 16 * 1024; +static int pr_slowhz = PR_SLOWHZ; const struct sysctl_bounded_args tcpctl_vars[] = { + { TCPCTL_SLOWHZ, &pr_slowhz, 1, 0 }, { TCPCTL_RFC1323, &tcp_do_rfc1323, 0, 1 }, { TCPCTL_KEEPINITTIME, &tcptv_keep_init, 1, 3 * TCPTV_KEEP_INIT }, { TCPCTL_KEEPIDLE, &tcp_keepidle, 1, 5 * TCPTV_KEEP_IDLE }, @@ -997,9 +999,6 @@ tcp_sysctl(int *name, u_int namelen, void *oldp, size_t *oldlenp, void *newp, return (ENOTDIR); switch (name[0]) { - case TCPCTL_SLOWHZ: - return (sysctl_rdint(oldp, oldlenp, newp, PR_SLOWHZ)); - case TCPCTL_BADDYNAMIC: NET_LOCK(); error = sysctl_struct(oldp, oldlenp, newp, newlen, diff --git sys/netinet6/ip6_input.c sys/netinet6/ip6_input.c index 1421a433a16..a05475680dd 100644 --- sys/netinet6/ip6_input.c +++ sys/netinet6/ip6_input.c @@ -1334,7 +1334,15 @@ const u_char inet6ctlerrmap[PRC_NCMDS] = { ENOPROTOOPT }; +#ifdef MROUTING +extern int ip6_mrtproto; +#endif + const struct sysctl_bounded_args ipv6ctl_vars[] = { + { IPV6CTL_DAD_PENDING, &ip6_dad_pending, 1, 0 }, +#ifdef MROUTING + { IPV6CTL_MRTPROTO, &ip6_mrtproto, 1, 0 }, +#endif { IPV6CTL_FORWARDING, &ip6_forwarding, 0, 1 }, { IPV6CTL_SENDREDIRECTS, &ip6_sendredirects, 0, 1 }, { IPV6CTL_DEFHLIM, &ip6_defhlim, 0, 255 }, @@ -1393,7 +1401,6 @@ ip6_sysctl(int *name, u_int namelen, void *oldp, size_t *oldlenp, void *newp, size_t newlen) { #ifdef MROUTING - extern int ip6_mrtproto; extern struct mrt6stat mrt6stat; #endif int error; @@ -1403,8 +1410,6 @@ ip6_sysctl(int *name, u_int namelen, void *oldp, size_t *oldlenp, return (ENOTDIR); switch (name[0]) { - case IPV6CTL_DAD_PENDING: - return sysctl_rdint(oldp, oldlenp, newp, ip6_dad_pending); case IPV6CTL_STATS: return (ip6_sysctl_ip6stat(oldp, oldlenp, newp)); #ifdef MROUTING @@ -1416,8 +1421,6 @@ ip6_sysctl(int *name, u_int namelen, void *oldp, size_t *oldlenp, &mrt6stat, sizeof(mrt6stat)); NET_UNLOCK(); return (error); - case IPV6CTL_MRTPROTO: - return sysctl_rdint(oldp, oldlenp, newp, ip6_mrtproto); case IPV6CTL_MRTMIF: if (newp) return (EPERM); -- 2.29.2