From nobody Tue Jan 16 18:31:32 2024 X-Original-To: dev-commits-src-all@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4TDyJj2SL2z57mdw; Tue, 16 Jan 2024 18:31:33 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4TDyJj1bGwz4wGB; Tue, 16 Jan 2024 18:31:33 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1705429893; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=AlqRP5sw3uuG3i4PaNYBxd1/K/A3KoykEu2Dym/3XOo=; b=mOqhjYqRCtR5shDaDlMkYaVQRdDhc1qwmuPLRPgV9YogAfHPKjLohHtv55p+WdD4aLCJ2A 4KfysejezWF3xkoqftnYI9Wzd+7yX4VAIUvnpJKTafETa0NkMwlhg097z0sDVd72eRQx5K Tugb+5JAb2SNd6Wq/7ZuheuYPrRTHh7NkYUl38775ozNK/CQK7RUo3NgC2+jUua153LC0N 4WEVo/xiJg2Yx+tpdoM5tgsbbte2ujgeDnAWGxv4R2+IXvc5bbp8Ybp4NdOkyY9VnbJQ9a iw6ImGOOB+sV4+MPws0qXG8apiBCwnK4tY4j/ulR2xLMPGU8sN4H52Wal4Ym/Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1705429893; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=AlqRP5sw3uuG3i4PaNYBxd1/K/A3KoykEu2Dym/3XOo=; b=BaNKTHpg3fboR9FOZqCiTdc1OR9/FNlXuryyX20K52PGYsK38MV8sydWCYdXd8xmEn8Ok8 QnsblZHEyXQbgJmmNg27qDS9mnhdN/kuFA1rMGOsR4Q2x75OFB1j16yhaNEycvkeOZTCM2 LeRLJ3xvGVz85hS64akweuhsqfFjdeQ1ZdLcH8Qao7lETCzqfd2Dwyi8ku9FIu1tkEHycL 4lApwZDrKZWnLXzT9LftEV4GNTZe3GZQXAhMPlXQXOJPWHdKytUw1+hc/hoYOyS8F2H1u1 ZW/CGCq6w9FxGIBGeB5m4tC9rndaTEIKS5y5en+syTgibMs2w/Vx+9scEMGbxw== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1705429893; a=rsa-sha256; cv=none; b=oAKJ0am1N6+1L4/C3pVekWdZQEyIWPS1/Tuw5FJhAkjBKt7agNM00F5S0jJNuupPYyskoc pX89rTVIewnUcWnjf0Q25p7shXxBsg7S5aQY0YijXePtmEPLj928U4E10uZibMJnQqq/9w rqWzn7bfWCmTq85EFBwlTP9RyB2a9eNJrSyCqHUtHTLuEjmRmss51CsJaE7pIRqfH4jNsU rPkaNBiMm7afwQYakDhZxjIptVH5Exa/Maph75VDveSeYdqGtv2m5LRV6pmGtq1USkpz9U dhKZ/ofMHIqQ24zeWzby2E5DMCRyetA4cmP92L101aRdi00wppFrJjZDCTT49Q== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 4TDyJj0KtPzrCP; Tue, 16 Jan 2024 18:31:33 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.17.1/8.17.1) with ESMTP id 40GIVWbc055866; Tue, 16 Jan 2024 18:31:32 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.17.1/8.17.1/Submit) id 40GIVWbs055863; Tue, 16 Jan 2024 18:31:32 GMT (envelope-from git) Date: Tue, 16 Jan 2024 18:31:32 GMT Message-Id: <202401161831.40GIVWbs055863@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Gleb Smirnoff Subject: git: c3276e02beab - main - sockets: make shutdown(2) how argument a enum List-Id: Commit messages for all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-all@freebsd.org X-BeenThere: dev-commits-src-all@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: glebius X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: c3276e02beab825824e3147b31af33af66298430 Auto-Submitted: auto-generated The branch main has been updated by glebius: URL: https://cgit.FreeBSD.org/src/commit/?id=c3276e02beab825824e3147b31af33af66298430 commit c3276e02beab825824e3147b31af33af66298430 Author: Gleb Smirnoff AuthorDate: 2024-01-16 18:26:10 +0000 Commit: Gleb Smirnoff CommitDate: 2024-01-16 18:26:27 +0000 sockets: make shutdown(2) how argument a enum Reviwed by: tuexen Differential Revision: https://reviews.freebsd.org/D43412 --- sys/kern/uipc_socket.c | 5 +---- sys/kern/uipc_syscalls.c | 3 +++ sys/sys/socket.h | 8 +++++--- sys/sys/socketvar.h | 3 ++- 4 files changed, 11 insertions(+), 8 deletions(-) diff --git a/sys/kern/uipc_socket.c b/sys/kern/uipc_socket.c index 3409a7085df6..919879e86e21 100644 --- a/sys/kern/uipc_socket.c +++ b/sys/kern/uipc_socket.c @@ -2964,14 +2964,11 @@ soreceive(struct socket *so, struct sockaddr **psa, struct uio *uio, } int -soshutdown(struct socket *so, int how) +soshutdown(struct socket *so, enum shutdown_how how) { struct protosw *pr; int error, soerror_enotconn; - if (!(how == SHUT_RD || how == SHUT_WR || how == SHUT_RDWR)) - return (EINVAL); - soerror_enotconn = 0; SOCK_LOCK(so); if ((so->so_state & diff --git a/sys/kern/uipc_syscalls.c b/sys/kern/uipc_syscalls.c index e46fdef84fc9..366698054bce 100644 --- a/sys/kern/uipc_syscalls.c +++ b/sys/kern/uipc_syscalls.c @@ -1172,6 +1172,9 @@ kern_shutdown(struct thread *td, int s, int how) struct file *fp; int error; + if (__predict_false(how < SHUT_RD || how > SHUT_RDWR)) + return (EINVAL); + AUDIT_ARG_FD(s); error = getsock(td, s, &cap_shutdown_rights, &fp); if (error == 0) { diff --git a/sys/sys/socket.h b/sys/sys/socket.h index 23762ec3b78f..9e78281e5dd2 100644 --- a/sys/sys/socket.h +++ b/sys/sys/socket.h @@ -627,9 +627,11 @@ struct omsghdr { /* * howto arguments for shutdown(2), specified by Posix.1g. */ -#define SHUT_RD 0 /* shut down the reading side */ -#define SHUT_WR 1 /* shut down the writing side */ -#define SHUT_RDWR 2 /* shut down both sides */ +enum shutdown_how { + SHUT_RD = 0, /* shut down the reading side */ + SHUT_WR, /* shut down the writing side */ + SHUT_RDWR /* shut down both sides */ +}; #if __BSD_VISIBLE /* for SCTP */ diff --git a/sys/sys/socketvar.h b/sys/sys/socketvar.h index ae7baa87d202..19ca52177d17 100644 --- a/sys/sys/socketvar.h +++ b/sys/sys/socketvar.h @@ -434,6 +434,7 @@ struct mbuf; struct sockaddr; struct ucred; struct uio; +enum shutdown_how; /* Return values for socket upcalls. */ #define SU_OK 0 @@ -512,7 +513,7 @@ int sosend_dgram(struct socket *so, struct sockaddr *addr, int sosend_generic(struct socket *so, struct sockaddr *addr, struct uio *uio, struct mbuf *top, struct mbuf *control, int flags, struct thread *td); -int soshutdown(struct socket *so, int how); +int soshutdown(struct socket *so, enum shutdown_how); void soupcall_clear(struct socket *, sb_which); void soupcall_set(struct socket *, sb_which, so_upcall_t, void *); void solisten_upcall_set(struct socket *, so_upcall_t, void *);