From nobody Thu Dec 18 13:01:10 2025 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id DEB8AC32789 for ; Tue, 23 Aug 2022 08:17:23 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S242463AbiHWIRV (ORCPT ); Tue, 23 Aug 2022 04:17:21 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60998 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S242474AbiHWILV (ORCPT ); Tue, 23 Aug 2022 04:11:21 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6D4E04DB23; Tue, 23 Aug 2022 01:08:35 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 83940B81BF8; Tue, 23 Aug 2022 08:08:33 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id BB61EC433C1; Tue, 23 Aug 2022 08:08:31 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1661242112; bh=/4kHocZ4fRwT5Rs9tihjUYOuPoQZ/ZAaNCXwJv/VS10=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=OCpeF4PUhlCq3a7yE3vlpxDH18MmlELAIcEyTwFRleXMHobSCzzcKDcGyM72GKn8H UFAE0ztud2a8uPR8y5HpvVWwWOERrO13o138nl44p2R4KF9Bvvpd7pcNJSPwvXAuma kDg014JzN0z+XAW+tSZru3uzeXPmz7WiL7hhk3KU= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Xiumei Mu , Mat Martineau , Florian Westphal , "David S. Miller" Subject: [PATCH 5.19 060/365] selftests: mptcp: make sendfile selftest work Date: Tue, 23 Aug 2022 09:59:21 +0200 Message-Id: <20220823080120.704317819@linuxfoundation.org> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20220823080118.128342613@linuxfoundation.org> References: <20220823080118.128342613@linuxfoundation.org> User-Agent: quilt/0.67 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" From: Florian Westphal commit df9e03aec3b14970df05b72d54f8ac9da3ab29e1 upstream. When the selftest got added, sendfile() on mptcp sockets returned -EOPNOTSUPP, so running 'mptcp_connect.sh -m sendfile' failed immediately. This is no longer the case, but the script fails anyway due to timeout. Let the receiver know once the sender has sent all data, just like with '-m mmap' mode. v2: need to respect cfg_wait too, as pm_userspace.sh relied on -m sendfile to keep the connection open (Mat Martineau) Fixes: 048d19d444be ("mptcp: add basic kselftest for mptcp") Reported-by: Xiumei Mu Reviewed-by: Mat Martineau Signed-off-by: Florian Westphal Signed-off-by: Mat Martineau Signed-off-by: David S. Miller Signed-off-by: Greg Kroah-Hartman --- tools/testing/selftests/net/mptcp/mptcp_connect.c | 26 ++++++++++++++---= ----- 1 file changed, 17 insertions(+), 9 deletions(-) --- a/tools/testing/selftests/net/mptcp/mptcp_connect.c +++ b/tools/testing/selftests/net/mptcp/mptcp_connect.c @@ -553,6 +553,18 @@ static void set_nonblock(int fd, bool no fcntl(fd, F_SETFL, flags & ~O_NONBLOCK); } =20 +static void shut_wr(int fd) +{ + /* Close our write side, ev. give some time + * for address notification and/or checking + * the current status + */ + if (cfg_wait) + usleep(cfg_wait); + + shutdown(fd, SHUT_WR); +} + static int copyfd_io_poll(int infd, int peerfd, int outfd, bool *in_closed= _after_out) { struct pollfd fds =3D { @@ -630,14 +642,7 @@ static int copyfd_io_poll(int infd, int /* ... and peer also closed already */ break; =20 - /* ... but we still receive. - * Close our write side, ev. give some time - * for address notification and/or checking - * the current status - */ - if (cfg_wait) - usleep(cfg_wait); - shutdown(peerfd, SHUT_WR); + shut_wr(peerfd); } else { if (errno =3D=3D EINTR) continue; @@ -767,7 +772,7 @@ static int copyfd_io_mmap(int infd, int if (err) return err; =20 - shutdown(peerfd, SHUT_WR); + shut_wr(peerfd); =20 err =3D do_recvfile(peerfd, outfd); *in_closed_after_out =3D true; @@ -791,6 +796,9 @@ static int copyfd_io_sendfile(int infd, err =3D do_sendfile(infd, peerfd, size); if (err) return err; + + shut_wr(peerfd); + err =3D do_recvfile(peerfd, outfd); *in_closed_after_out =3D true; }