From nobody Fri Jul 08 18:34:18 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 A1F8B17F9C11; Fri, 8 Jul 2022 18:34:18 +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 4Lfhky4Chcz3KLY; Fri, 8 Jul 2022 18:34:18 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1657305258; 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=t7M2ADuBNTXxdVNflF3ujbREdswiK63jUWGlYHbNBEE=; b=q/TZ6noR+gHXWxVBKdgxHOlQ2qxOtlmXZlGFcW3/Vw/dQBbxTU1dm0xyRsgZrvNFD+4wHs EksMYTxBrpaPBsgrHwntA2IFipV3g+j4gHNhjYVT5E8O0lOsWx9H2PgYRtRa7eMFhVvk00 Z/28vOiGSZ+wsxk/EG1lLokAcwwyC8rTvfZfA9zAJA4v1J3MeFUL2ock+SrkBh4a/LB9NB 3zcGIYDAxW5JNCT6umF9+31q+xMLAfGAkmgqJ62ZEkWAJFSbXr3BZ2bYiEuw+ZCvgcskYH dxBX9+pOoVmkHyPU4x/SFchaBTpuxHmlcvPRe9YxEg+AH8VlgxN2sTzHqgmOEw== 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 4Lfhky3FmszH5t; Fri, 8 Jul 2022 18:34:18 +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 268IYIfM033043; Fri, 8 Jul 2022 18:34:18 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 268IYI0R033042; Fri, 8 Jul 2022 18:34:18 GMT (envelope-from git) Date: Fri, 8 Jul 2022 18:34:18 GMT Message-Id: <202207081834.268IYI0R033042@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: c261510ef5fc - main - 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/main X-Git-Reftype: branch X-Git-Commit: c261510ef5fce9eaf4c30685c317c1f8ec415eda Auto-Submitted: auto-generated ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1657305258; 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=t7M2ADuBNTXxdVNflF3ujbREdswiK63jUWGlYHbNBEE=; b=Ybe3JnllYOprLbEKl//4s7tkRh/zSvcQaqAmvfbbiECLTkz1xnUcCnpjtuwQCm27ctfd/q vwzmn9ClNMlOwaVFldY1DkfGgdJBPBMFBtlsRJc6IcoPQdTnP0M+tsJoKUHQ5R7AamWBEV xnocKMvDv1kU9cptj87iu+PfGi84Kgx8WJabvVLuKJsvZ6FIWKirZ9KLxvz6WHQKgoBGaz JgaOBKO0lPcwNgq6p17sfmJqWO07FeBD+67B7z32dsCt0aVBnAb6gq1J/OUDONoXv/tHNC jRCz1RxVfET3UlEGnCZbXxUH/E+D755pOqPcQoTaymCpcgwIwHLSQZoH4Bqh3w== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1657305258; a=rsa-sha256; cv=none; b=ixlx98ppK1GKR7OBrpzl5GGeTTNLQd49d4O2xbexEHG+HSCOKPmW0AAJtiFhwvEAxBC0TD msdx2xXlju3mJWBFpgNNzCilzgIgNz0SK6kRGqhCAmRNeRRn4A/62nvHQLdMS91sjOaWz9 Z+ckncXn+ymIVC9ey2jmJuEkg4Flnk2DUD++xAPlsVyj0XkT4fRTsNpRuuiCNfchncYwmF x/Dgn+QMtzRmwvN6jj8lG0adU7PN6JS8K2cz/X+Q6SqH888VFG2XYMGkpGrUalLGWlJl9N hcHmbywqSIoC+A9CfUeNL+DP/uJY26MeXqFV8v48ipzIMDGNc7L8+7Y+cOglig== ARC-Authentication-Results: i=1; mx1.freebsd.org; none X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by glebius: URL: https://cgit.FreeBSD.org/src/commit/?id=c261510ef5fce9eaf4c30685c317c1f8ec415eda commit c261510ef5fce9eaf4c30685c317c1f8ec415eda Author: Gleb Smirnoff AuthorDate: 2022-07-08 18:22:53 +0000 Commit: Gleb Smirnoff CommitDate: 2022-07-08 18:33:24 +0000 sockets: fix setsockopt(SO_RCVTIMEO) on a listening socket MFC after: 3 weeks --- 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 f25db7be1fd8..dac1373773fb 100644 --- a/sys/kern/uipc_socket.c +++ b/sys/kern/uipc_socket.c @@ -2967,7 +2967,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; @@ -3106,14 +3106,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: @@ -3295,8 +3295,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;