Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/sys Setting a socket buffer size stops autoscaling. Add ...
details: https://anonhg.NetBSD.org/src/rev/4cb240363fba
branches: trunk
changeset: 1015188:4cb240363fba
user: mlelstv <mlelstv%NetBSD.org@localhost>
date: Sat Oct 17 09:06:15 2020 +0000
description:
Setting a socket buffer size stops autoscaling. Add a sysctl to
prevent this behaviour. The default is not changed.
diffstat:
share/man/man7/sysctl.7 | 5 ++++-
sys/kern/uipc_socket.c | 22 ++++++++++++++++++----
sys/sys/sysctl.h | 3 ++-
3 files changed, 24 insertions(+), 6 deletions(-)
diffs (107 lines):
diff -r fce3574bff56 -r 4cb240363fba share/man/man7/sysctl.7
--- a/share/man/man7/sysctl.7 Sat Oct 17 09:04:59 2020 +0000
+++ b/share/man/man7/sysctl.7 Sat Oct 17 09:06:15 2020 +0000
@@ -1,4 +1,4 @@
-.\" $NetBSD: sysctl.7,v 1.149 2020/09/11 15:16:48 roy Exp $
+.\" $NetBSD: sysctl.7,v 1.150 2020/10/17 09:06:15 mlelstv Exp $
.\"
.\" Copyright (c) 1993
.\" The Regents of the University of California. All rights reserved.
@@ -359,6 +359,7 @@
.It kern.sbmax integer yes
.It kern.sched node not applicable
.It kern.securelevel integer raise only
+.It kern.sofixedbuf boolean yes
.It kern.somaxkva integer yes
.It kern.sooptions integer yes
.It kern.synchronized_io integer no
@@ -1206,6 +1207,8 @@
See
.Xr sched 3 .
.El
+.It Li kern.sofixedbuf ( Dv KERN_SOFIXEDBUF )
+Prevent socket buffer autoscaling when a size is set with SO_SNDBUF or SO_RCVBUF.
.It Li kern.somaxkva ( Dv KERN_SOMAXKVA )
Maximum amount of kernel memory to be used for socket buffers in bytes.
.It Li kern.sooptions
diff -r fce3574bff56 -r 4cb240363fba sys/kern/uipc_socket.c
--- a/sys/kern/uipc_socket.c Sat Oct 17 09:04:59 2020 +0000
+++ b/sys/kern/uipc_socket.c Sat Oct 17 09:06:15 2020 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: uipc_socket.c,v 1.291 2020/08/26 22:54:30 christos Exp $ */
+/* $NetBSD: uipc_socket.c,v 1.292 2020/10/17 09:06:15 mlelstv Exp $ */
/*
* Copyright (c) 2002, 2007, 2008, 2009 The NetBSD Foundation, Inc.
@@ -71,7 +71,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: uipc_socket.c,v 1.291 2020/08/26 22:54:30 christos Exp $");
+__KERNEL_RCSID(0, "$NetBSD: uipc_socket.c,v 1.292 2020/10/17 09:06:15 mlelstv Exp $");
#ifdef _KERNEL_OPT
#include "opt_compat_netbsd.h"
@@ -166,6 +166,11 @@
static int socurkva;
static kcondvar_t socurkva_cv;
+#ifndef SOFIXEDBUF
+#define SOFIXEDBUF true
+#endif
+bool sofixedbuf = SOFIXEDBUF;
+
static kauth_listener_t socket_listener;
#define SOCK_LOAN_CHUNK 65536
@@ -1798,7 +1803,8 @@
error = ENOBUFS;
break;
}
- so->so_snd.sb_flags &= ~SB_AUTOSIZE;
+ if (sofixedbuf)
+ so->so_snd.sb_flags &= ~SB_AUTOSIZE;
break;
case SO_RCVBUF:
@@ -1806,7 +1812,8 @@
error = ENOBUFS;
break;
}
- so->so_rcv.sb_flags &= ~SB_AUTOSIZE;
+ if (sofixedbuf)
+ so->so_rcv.sb_flags &= ~SB_AUTOSIZE;
break;
/*
@@ -2540,6 +2547,13 @@
sysctl_createv(&socket_sysctllog, 0, NULL, NULL,
CTLFLAG_PERMANENT|CTLFLAG_READWRITE,
+ CTLTYPE_BOOL, "sofixedbuf",
+ SYSCTL_DESCR("Prevent scaling of fixed socket buffers"),
+ NULL, 0, &sofixedbuf, 0,
+ CTL_KERN, KERN_SOFIXEDBUF, CTL_EOL);
+
+ sysctl_createv(&socket_sysctllog, 0, NULL, NULL,
+ CTLFLAG_PERMANENT|CTLFLAG_READWRITE,
CTLTYPE_INT, "sbmax",
SYSCTL_DESCR("Maximum socket buffer size"),
sysctl_kern_sbmax, 0, NULL, 0,
diff -r fce3574bff56 -r 4cb240363fba sys/sys/sysctl.h
--- a/sys/sys/sysctl.h Sat Oct 17 09:04:59 2020 +0000
+++ b/sys/sys/sysctl.h Sat Oct 17 09:06:15 2020 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: sysctl.h,v 1.230 2019/05/31 23:01:39 kamil Exp $ */
+/* $NetBSD: sysctl.h,v 1.231 2020/10/17 09:06:15 mlelstv Exp $ */
/*
* Copyright (c) 1989, 1993
@@ -274,6 +274,7 @@
#define KERN_SYSVIPC 82 /* node: SysV IPC parameters */
#define KERN_BOOTTIME 83 /* struct: time kernel was booted */
#define KERN_EVCNT 84 /* struct: evcnts */
+#define KERN_SOFIXEDBUF 85 /* bool: fixed socket buffer sizes */
/*
* KERN_CLOCKRATE structure
Home |
Main Index |
Thread Index |
Old Index