From nobody Wed Aug 3 23:29:03 2022 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 4Lyp332nh0z4Y6qZ; Wed, 3 Aug 2022 23:29:03 +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 4Lyp332M6xz3gwf; Wed, 3 Aug 2022 23:29:03 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1659569343; 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=QiaO6UoMc5mOiVIesKqDheABDKa0i9e1LcjCtpjvzmY=; b=LLeVf2vI0ozM/IS1jbTB2JFUw0RIgJRtgxTJkijQYVFCySuLt32Zp4P4AjV4/MhkRMG/C6 oQHsy+81Dt+XbN2EWJ3Jc1A5URKG2MRbBwn1/YBrdiqJB+0+Z/sho/Q1QL/iH7Xgk29Idb sWU9WEBu2broIiuhyVSD24oyea5mw8nmoftZy9fkG1W19LPYU7I4QUXWJt0ARaQtEGIAiR XvHyBI/mOKAXyj2MTDrGpT8SZ3rXKYV7YO3pe9ULU3aZyamSsato0miGzK+VasEvH+Q4KP 4qkzSchovz+ax9ebSaVrAE6fjNXiRBikD1q976lK2ssv3CyUZjmqEeMj9vkFzQ== 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 4Lyp331Q6pz18Gy; Wed, 3 Aug 2022 23:29:03 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 273NT3ej075866; Wed, 3 Aug 2022 23:29:03 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 273NT3Be075865; Wed, 3 Aug 2022 23:29:03 GMT (envelope-from git) Date: Wed, 3 Aug 2022 23:29:03 GMT Message-Id: <202208032329.273NT3Be075865@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Gleb Smirnoff Subject: git: 99275445a424 - stable/13 - sockets: fix setsockopt(SO_RCVTIMEO) on a listening socket 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/stable/13 X-Git-Reftype: branch X-Git-Commit: 99275445a424f6ed2724ffefa8770d9faca1e71b Auto-Submitted: auto-generated ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1659569343; 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=QiaO6UoMc5mOiVIesKqDheABDKa0i9e1LcjCtpjvzmY=; b=xP37185Rk11cTIHLjjh0wozIR1lmt+3QXySOHbWRsHwzWWN3xyzIMbhm3qEilXZtKyFqgY I7IuxPXZPTt4ki2DrkJwrMkJmCALCw/32MnHoC0H5GHUlWekCCGWIGvnTxHzdcPaPMtELW gj0HXFfaag3/ywn5Su/pV0/tovGhWiu1q+QMsOV4xon2G6GsQQzDhXDvF6JqgMsyfRqRNX VkI98qTbBx5cfCHucP9ebv9ocKFDjk+bqZQlfAggOHutkUcW5F7dBSFWtx+dvEGdquWhkD 8yu0vLrPrE8rKdHKsuNyyqk3Avs5pEJ+PlK20qy3rFx/90OiuRjc3QPgXok1UA== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1659569343; a=rsa-sha256; cv=none; b=BdHCpNLv9Xl3c4CLGadF50nSRdHOShE1HSVQ/cMuL8HXaZCYb6bANGlkkOgOt8Q+JguZIa 7V62ED5JE46spzrd8M/glOmA1ommEjdn7KoQ9bmqVz5p9tDzR9Gt8VyHaB84q/NehuHSg1 1Q+fEJ+sKqcGkCjdOQ1bpogPWDqbzf0HPuvq9K+veRRgzvNYpxzZdk9GoInWPNw2QZdgPg PXqZIwPQOlLxNI48wULOIeVuPdRlvpemZ8ClbnpWKZn6yXy0k7KV5xGdHvF0qJeWVPLfvN 7pjGONTAws9XJTqLu4/wBzFTZXsNYo3w5jSawEn6ahd2ksk3q7fAZUvuEBDpzA== ARC-Authentication-Results: i=1; mx1.freebsd.org; none X-ThisMailContainsUnwantedMimeParts: N The branch stable/13 has been updated by glebius: URL: https://cgit.FreeBSD.org/src/commit/?id=99275445a424f6ed2724ffefa8770d9faca1e71b commit 99275445a424f6ed2724ffefa8770d9faca1e71b Author: Gleb Smirnoff AuthorDate: 2022-08-03 23:28:38 +0000 Commit: Gleb Smirnoff CommitDate: 2022-08-03 23:28:38 +0000 sockets: fix setsockopt(SO_RCVTIMEO) on a listening socket (cherry-picked from commit c261510ef5fce9eaf4c30685c317c1f8ec415eda) --- sys/kern/uipc_socket.c | 25 +++++++++++++++---------- 1 file changed, 15 insertions(+), 10 deletions(-) diff --git a/sys/kern/uipc_socket.c b/sys/kern/uipc_socket.c index 8f2122c98ef5..ce7279357fab 100644 --- a/sys/kern/uipc_socket.c +++ b/sys/kern/uipc_socket.c @@ -2996,7 +2996,7 @@ sosetopt(struct socket *so, struct sockopt *sopt) int error, optval; struct linger l; struct timeval tv; - sbintime_t val; + sbintime_t val, *valp; uint32_t val32; #ifdef MAC struct mac extmac; @@ -3135,14 +3135,14 @@ sosetopt(struct socket *so, struct sockopt *sopt) val = SBT_MAX; else val = tvtosbt(tv); - switch (sopt->sopt_name) { - case SO_SNDTIMEO: - so->so_snd.sb_timeo = val; - break; - case SO_RCVTIMEO: - so->so_rcv.sb_timeo = val; - break; - } + SOCK_LOCK(so); + valp = sopt->sopt_name == SO_SNDTIMEO ? + (SOLISTENING(so) ? &so->sol_sbsnd_timeo : + &so->so_snd.sb_timeo) : + (SOLISTENING(so) ? &so->sol_sbrcv_timeo : + &so->so_rcv.sb_timeo); + *valp = val; + SOCK_UNLOCK(so); break; case SO_LABEL: @@ -3324,8 +3324,13 @@ integer: case SO_SNDTIMEO: case SO_RCVTIMEO: + SOCK_LOCK(so); tv = sbttotv(sopt->sopt_name == SO_SNDTIMEO ? - so->so_snd.sb_timeo : so->so_rcv.sb_timeo); + (SOLISTENING(so) ? so->sol_sbsnd_timeo : + so->so_snd.sb_timeo) : + (SOLISTENING(so) ? so->sol_sbrcv_timeo : + so->so_rcv.sb_timeo)); + SOCK_UNLOCK(so); #ifdef COMPAT_FREEBSD32 if (SV_CURPROC_FLAG(SV_ILP32)) { struct timeval32 tv32;