git: c441592a0e15 - main - Allow kern.ipc.maxsockets to be set to current value without error

From: Allan Jude <allanjude_at_FreeBSD.org>
Date: Thu, 04 Nov 2021 12:56:38 UTC
The branch main has been updated by allanjude:

URL: https://cgit.FreeBSD.org/src/commit/?id=c441592a0e1591591665cd037a8a5e9b54675f99

commit c441592a0e1591591665cd037a8a5e9b54675f99
Author:     Allan Jude <allanjude@FreeBSD.org>
AuthorDate: 2021-11-04 12:55:33 +0000
Commit:     Allan Jude <allanjude@FreeBSD.org>
CommitDate: 2021-11-04 12:56:09 +0000

    Allow kern.ipc.maxsockets to be set to current value without error
    
    Normally setting kern.ipc.maxsockets returns EINVAL if the new value
    is not greater than the previous value. This can cause spurious
    error messages when sysctl.conf is processed multiple times, or when
    automation systems try to ensure the sysctl is set to the correct
    value. If the value is unchanged, then just do nothing.
    
    PR:     243532
    Reviewed by:    markj
    MFC after:      3 days
    Sponsored by:   Modirum MDPay
    Sponsored by:   Klara Inc.
    Differential Revision:  https://reviews.freebsd.org/D32775
---
 sys/kern/uipc_socket.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/sys/kern/uipc_socket.c b/sys/kern/uipc_socket.c
index 267a33feac3b..e033b2d77f1d 100644
--- a/sys/kern/uipc_socket.c
+++ b/sys/kern/uipc_socket.c
@@ -364,7 +364,7 @@ sysctl_maxsockets(SYSCTL_HANDLER_ARGS)
 
 	newmaxsockets = maxsockets;
 	error = sysctl_handle_int(oidp, &newmaxsockets, 0, req);
-	if (error == 0 && req->newptr) {
+	if (error == 0 && req->newptr && newmaxsockets != maxsockets) {
 		if (newmaxsockets > maxsockets &&
 		    newmaxsockets <= maxfiles) {
 			maxsockets = newmaxsockets;