From nobody Sat Aug 19 18:56:16 2023 X-Original-To: dev-commits-src-main@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 4RSnyS5NzXz4mLRP; Sat, 19 Aug 2023 18:56:16 +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 4RSnyS4ftZz4b40; Sat, 19 Aug 2023 18:56:16 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1692471376; 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=lzO7z9e6RJT/9WmxvYzoRYPlnmLqj05RCmicIIPF9lg=; b=EMRxXhEb7E0pbtvh1gUgxqiohOoJBfBnBE5p1qoCm3sVeoKDM0k7KN8FEe7/mq28+caJVP 5cWE3FSbpRVfqO4pCpP4EAUOwYbrJUaOi2/CuO2Ncl0LEGqX8ftNBfxLyTqX6VS4ZGmK8u 7557X6fa7NMhhCL+fNZBOx4Nal7FFBFDaWA//F6SkT6ZhcQ69mSUFdLBpvZCjI9rmOdNlu WQNEfJuEzBa9BWXU3vYsE+SiCYPKey/QV+6Dai85hWvXj2Uk0UGEL4k1tGX1k7SuQHOL7D 0loLsdwX0kDzGEFnc+JbwJfKY/UpfF1al78lB2k7jU6DVxPbeotwEIKSn0IHcg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1692471376; 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=lzO7z9e6RJT/9WmxvYzoRYPlnmLqj05RCmicIIPF9lg=; b=S19MseV/XiOWU29+67AAM8z7hV2VPjUMRpcua4S5ItD7bnrsIdu4wlOHC2uldxfNJYEJAy Hgx2VYlrQUm9HtwaUV0obP6+XiW5kb/e2t1RgMAEPPRu/tby1b8VL7gwU4FHg5CZOEtkF5 jUaDLrOn9gleS8YWDyotHF3YDAjvtEBRI4SAoIet9bf0fU/lHxzcsfUJhtzM6W0rNaUHgP w3t/74faJ3te+A0edUxc9jFW3i5FCMOu09xunQpVEEfCc6+AFEWrfR/376TxI1kS2MVWoO sad8DcgG0CrpBp8YE7qC0lck2Gbmx3r7N9cw3oLmCle0N8eN5ZbC2pQEK90Ilw== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1692471376; a=rsa-sha256; cv=none; b=LP2eXWrFWyi6cm3El0WnPLe41PHLax2KLvvXgcuJmHi9LbdfMXqAbqfwshwB165JX37gYK g4ChhaCtJo1t2DD0omIgxaDd9zQOEZHKhPdjzQ6f9RxuiHHb2OpHY0OPwHHFVtScX9OHf6 PX0jRgC1C3whMMiq4dffprark6ub6hIFUdMLTdJzJVvNtLLTv59EZ8HTiih2O7dcsuaFJB aiR1np/ax6jVDSKc/3gp65U7yiU2PevTQih6v4zoIFcu2sAdCyvecf0gC23kPhe83hneXE DwCbQnOOxr+jtW9XXDit9GsPeuHSOkGftbgMTlEmVU4nF5VlBS3X6anYpvBY8g== ARC-Authentication-Results: i=1; mx1.freebsd.org; none 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 4RSnyS3jY1z17Xd; Sat, 19 Aug 2023 18:56:16 +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 37JIuGmL084177; Sat, 19 Aug 2023 18:56:16 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.17.1/8.17.1/Submit) id 37JIuGjm084174; Sat, 19 Aug 2023 18:56:16 GMT (envelope-from git) Date: Sat, 19 Aug 2023 18:56:16 GMT Message-Id: <202308191856.37JIuGjm084174@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Dmitry Chagin Subject: git: da5a6738d589 - main - linux(4): Allow in fd to be a socket in sendfile List-Id: Commit messages for the main branch of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-main List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-main@freebsd.org X-BeenThere: dev-commits-src-main@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: dchagin X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: da5a6738d589d748ddf93678767d1565558bddd9 Auto-Submitted: auto-generated The branch main has been updated by dchagin: URL: https://cgit.FreeBSD.org/src/commit/?id=da5a6738d589d748ddf93678767d1565558bddd9 commit da5a6738d589d748ddf93678767d1565558bddd9 Author: Dmitry Chagin AuthorDate: 2023-08-19 18:55:23 +0000 Commit: Dmitry Chagin CommitDate: 2023-08-19 18:55:23 +0000 linux(4): Allow in fd to be a socket in sendfile In this case sendfile fallback is used. MFC after: 1 month --- sys/compat/linux/linux_socket.c | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/sys/compat/linux/linux_socket.c b/sys/compat/linux/linux_socket.c index 6c7cf12cf42e..67736ecc69f6 100644 --- a/sys/compat/linux/linux_socket.c +++ b/sys/compat/linux/linux_socket.c @@ -2381,16 +2381,24 @@ out: * with FreeBSD sendfile. */ static bool -is_stream_socket(struct file *fp) +is_sendfile(struct file *fp, struct file *ofp) { struct socket *so; + /* + * FreeBSD sendfile() system call sends a regular file or + * shared memory object out a stream socket. + */ + if ((fp->f_type != DTYPE_SHM && fp->f_type != DTYPE_VNODE) || + (fp->f_type == DTYPE_VNODE && + (fp->f_vnode == NULL || fp->f_vnode->v_type != VREG))) + return (false); /* * The socket must be a stream socket and connected. */ - if (fp->f_type != DTYPE_SOCKET) + if (ofp->f_type != DTYPE_SOCKET) return (false); - so = fp->f_data; + so = ofp->f_data; if (so->so_type != SOCK_STREAM) return (false); /* @@ -2556,7 +2564,7 @@ linux_sendfile_common(struct thread *td, l_int out, l_int in, 0); } else { sbytes = 0; - if (is_stream_socket(ofp)) + if (is_sendfile(fp, ofp)) error = sendfile_sendfile(td, fp, out, offset, count, &sbytes); else