From nobody Tue Jan 16 20:03:35 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 4TF0Lw1gn2z57wjW; Tue, 16 Jan 2024 20:03:36 +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 4TF0Lw0fLqz43gg; Tue, 16 Jan 2024 20:03:36 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1705435416; 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=IWktRBCFpMI/5RcFmMX3qPn+j2KuAOoJfpfQoRS31RI=; b=RepS5ih3n+g98MisJDyBvq0/dZLMMPnmGJ9ubzL5UhJt0yNPeck3obguj23kh8hjegXD6d 3H7mtO72tEVeGE1G1DWkw6ze4QQRvM+OYtfv6WN/08h202Zrbac+KGgbX8IG//uk3hqYPZ 2C7uA2jJLzKjIKgbYWWG18i1Ut0tDrAOMqHkt0C3/BHNwALQU1qsMospHtsbS1DwNKutQt GIpSpgNk9Dv84T0V1rZLHYaDGfHsn/TYe6TOZwkQ42mSCRjgP5jkN4jD6RyLf9IYwSAcUL MH0h1cvVzhg0wLkdPwZgBjl5BVjRgtYvHkJ+ytd/HuTd19t5PDR9ejSd3AtshQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1705435416; 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=IWktRBCFpMI/5RcFmMX3qPn+j2KuAOoJfpfQoRS31RI=; b=JZnl40SDCTed9MjHBZJv18s023Vkdk8t8OLPE3/kkkXuT+JuSZQkAEvr5mWG+BGS7PO4Xi cCtfcUej67XoAXzl+DrOZNRMKsGvprPP7aKJk6UPak27pIEw8wU2bTaEFv+5bkXOc3OzNC 2ONIf1ygCQms5DzE2M1Y7URvptjBXxm6O3sl8h//G0py8DGLkcV6+5FYhP+bzWnbR0srb9 tFNK39DfOyGvG8LgN0qvM6NHF54EDpBv2pH6eJ6NdvzS353W7IrnCzY7KDUwwrsmbbaAkk 9mpTe4eMG10DMHxpTLZJcy/H3kg74365XB5UwbsMTmZp6fxdLOZI9ws8UnnHlA== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1705435416; a=rsa-sha256; cv=none; b=JFUCCH9//GSd5u6J9WM3OtF+TzZDUfd/OUv5BV6P3G1fBwc0wcNFE3lQg0W6FxDmiXz07D ffp2Gd1l+4RZwoHtlyOXwPIQ8OGbUMIUQ4jJPGAPW6cmMIZTNaKUitsgwyle0fdC+qUY74 pKO+9J32AuGd4o37b/ZTEbDutF8ozl4z9eTdvDHlgQ43x7M5Aguuulkgi7L3fAGY6gKHkz NZe/n0oEUlapwvVpzr0jEhVtx10Sk7i6eJfRu0zeh1NJgT4gYPXAUzAvL6lnr6Lup8pmGm feTJMYskBmR7X+CE/gHD7Z0tRjZAZolFnP40GkRf1x6287XpBs+HZsRxhgOhlQ== 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 4TF0Lv6qnSztlG; Tue, 16 Jan 2024 20:03:35 +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 40GK3Zb9010782; Tue, 16 Jan 2024 20:03:35 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.17.1/8.17.1/Submit) id 40GK3ZRi010779; Tue, 16 Jan 2024 20:03:35 GMT (envelope-from git) Date: Tue, 16 Jan 2024 20:03:35 GMT Message-Id: <202401162003.40GK3ZRi010779@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: 296a4cb5c5b1 - main - sockets: provide correct pr_shutdown for keysock and SDP 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: 296a4cb5c5b18f82da7a365d9f209cb9fc09003b Auto-Submitted: auto-generated The branch main has been updated by glebius: URL: https://cgit.FreeBSD.org/src/commit/?id=296a4cb5c5b18f82da7a365d9f209cb9fc09003b commit 296a4cb5c5b18f82da7a365d9f209cb9fc09003b Author: Gleb Smirnoff AuthorDate: 2024-01-16 20:00:36 +0000 Commit: Gleb Smirnoff CommitDate: 2024-01-16 20:02:59 +0000 sockets: provide correct pr_shutdown for keysock and SDP My failure to run all kinds of kernel builds lead to missing the keysock and incorrectly assuming SDP as not having a shutdown method. Fixes: 5bba2728079ed4da33f727dbc2b6ae1de02ba897 --- sys/netipsec/keysock.c | 19 +++++++++- sys/ofed/drivers/infiniband/ulp/sdp/sdp_main.c | 52 +++++++++++++++++++------- 2 files changed, 56 insertions(+), 15 deletions(-) diff --git a/sys/netipsec/keysock.c b/sys/netipsec/keysock.c index 18bbdae316f0..d9297d44c18a 100644 --- a/sys/netipsec/keysock.c +++ b/sys/netipsec/keysock.c @@ -310,9 +310,24 @@ key_detach(struct socket *so) } static int -key_shutdown(struct socket *so) +key_shutdown(struct socket *so, enum shutdown_how how) { - socantsendmore(so); + /* + * Note: key socket marks itself as connected through its lifetime. + */ + switch (how) { + case SHUT_RD: + socantrcvmore(so); + sbrelease(so, SO_RCV); + break; + case SHUT_RDWR: + socantrcvmore(so); + sbrelease(so, SO_RCV); + /* FALLTHROUGH */ + case SHUT_WR: + socantsendmore(so); + } + return (0); } diff --git a/sys/ofed/drivers/infiniband/ulp/sdp/sdp_main.c b/sys/ofed/drivers/infiniband/ulp/sdp/sdp_main.c index 95048a1dc186..cfc2390db02e 100644 --- a/sys/ofed/drivers/infiniband/ulp/sdp/sdp_main.c +++ b/sys/ofed/drivers/infiniband/ulp/sdp/sdp_main.c @@ -787,24 +787,50 @@ sdp_accept(struct socket *so, struct sockaddr *sa) * Mark the connection as being incapable of further output. */ static int -sdp_shutdown(struct socket *so) +sdp_shutdown(struct socket *so, enum shutdown_how how) { + struct sdp_sock *ssk = sdp_sk(so); int error = 0; - struct sdp_sock *ssk; - ssk = sdp_sk(so); - SDP_WLOCK(ssk); - if (ssk->flags & (SDP_TIMEWAIT | SDP_DROPPED)) { - error = ECONNRESET; - goto out; + SOCK_LOCK(so); + if ((so->so_state & + (SS_ISCONNECTED | SS_ISCONNECTING | SS_ISDISCONNECTING)) == 0) { + SOCK_UNLOCK(so); + return (ENOTCONN); } - socantsendmore(so); - sdp_usrclosed(ssk); - if (!(ssk->flags & SDP_DROPPED)) - sdp_output_disconnect(ssk); + if (SOLISTENING(so)) { + if (how != SHUT_WR) { + so->so_error = ECONNABORTED; + solisten_wakeup(so); /* unlocks so */ + } else + SOCK_UNLOCK(so); + return (0); + } + SOCK_UNLOCK(so); -out: - SDP_WUNLOCK(ssk); + switch (how) { + case SHUT_RD: + socantrcvmore(so); + sbrelease(so, SO_RCV); + break; + case SHUT_RDWR: + socantrcvmore(so); + sbrelease(so, SO_RCV); + /* FALLTHROUGH */ + case SHUT_WR: + SDP_WLOCK(ssk); + if (ssk->flags & (SDP_TIMEWAIT | SDP_DROPPED)) { + SDP_WUNLOCK(ssk); + error = ECONNRESET; + break; + } + socantsendmore(so); + sdp_usrclosed(ssk); + if (!(ssk->flags & SDP_DROPPED)) + sdp_output_disconnect(ssk); + SDP_WUNLOCK(ssk); + } + wakeup(&so->so_timeo); return (error); }