From patchwork Thu Nov 14 17:32:13 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Florian Westphal X-Patchwork-Id: 1194984 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (no SPF record) smtp.mailfrom=lists.01.org (client-ip=2001:19d0:306:5::1; helo=ml01.01.org; envelope-from=mptcp-bounces@lists.01.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=strlen.de Received: from ml01.01.org (ml01.01.org [IPv6:2001:19d0:306:5::1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 47DSwL1nTbz9sP6 for ; Fri, 15 Nov 2019 04:22:26 +1100 (AEDT) Received: from new-ml01.vlan13.01.org (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id C4F29100DC3D2; Thu, 14 Nov 2019 09:23:53 -0800 (PST) Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=2a0a:51c0:0:12e:520::1; helo=chamillionaire.breakpoint.cc; envelope-from=fw@breakpoint.cc; receiver= Received: from Chamillionaire.breakpoint.cc (Chamillionaire.breakpoint.cc [IPv6:2a0a:51c0:0:12e:520::1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id 8C1AD100DC3D0 for ; Thu, 14 Nov 2019 09:23:51 -0800 (PST) Received: from fw by Chamillionaire.breakpoint.cc with local (Exim 4.92) (envelope-from ) id 1iVIp2-00061V-Uj; Thu, 14 Nov 2019 18:22:20 +0100 From: Florian Westphal To: Cc: Florian Westphal Date: Thu, 14 Nov 2019 18:32:13 +0100 Message-Id: <20191114173225.21199-3-fw@strlen.de> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20191114173225.21199-1-fw@strlen.de> References: <20191114173225.21199-1-fw@strlen.de> MIME-Version: 1.0 Message-ID-Hash: VBBOKSMGEFMTDPNA3MQFFD5POA7QHXQJ X-Message-ID-Hash: VBBOKSMGEFMTDPNA3MQFFD5POA7QHXQJ X-MailFrom: fw@breakpoint.cc X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; suspicious-header X-Mailman-Version: 3.1.1 Precedence: list Subject: [MPTCP] [RFC 02/14] selftests: make sockets non-blocking for default poll mode List-Id: Discussions regarding MPTCP upstreaming Archived-At: List-Archive: List-Help: List-Post: List-Subscribe: List-Unsubscribe: This change makes tests fail because mptcp_poll may signal POLLIN when no data is there and POLLOUT when it should not. Rest of series addresses this and makes selftest work again. Signed-off-by: Florian Westphal --- tools/testing/selftests/net/mptcp/mptcp_connect.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/tools/testing/selftests/net/mptcp/mptcp_connect.c b/tools/testing/selftests/net/mptcp/mptcp_connect.c index ea8e08b1f481..ab52468a4b51 100644 --- a/tools/testing/selftests/net/mptcp/mptcp_connect.c +++ b/tools/testing/selftests/net/mptcp/mptcp_connect.c @@ -279,6 +279,15 @@ static ssize_t do_rnd_read(const int fd, char *buf, const size_t len) return read(fd, buf, cap); } +static void set_nonblock(int fd) +{ + int flags = fcntl(fd, F_GETFL); + if (flags == -1) + return; + + fcntl(fd, F_SETFL, flags | O_NONBLOCK); +} + static int copyfd_io_poll(int infd, int peerfd, int outfd) { struct pollfd fds = { @@ -288,6 +297,8 @@ static int copyfd_io_poll(int infd, int peerfd, int outfd) unsigned int woff = 0, wlen = 0; char wbuf[8192]; + set_nonblock(peerfd); + for (;;) { char rbuf[8192]; ssize_t len;