From patchwork Tue May 28 08:02:45 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Beniamino Galvani X-Patchwork-Id: 10964067 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 9C94492A for ; Tue, 28 May 2019 08:04:01 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 8F0D0201B0 for ; Tue, 28 May 2019 08:04:01 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 7FB6C2863F; Tue, 28 May 2019 08:04:01 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from bastion.fedoraproject.org (bastion01.fedoraproject.org [209.132.181.2]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 0BFBB201B0 for ; Tue, 28 May 2019 08:04:00 +0000 (UTC) Received: from mailman01.phx2.fedoraproject.org (mailman01.phx2.fedoraproject.org [10.5.126.36]) by bastion01.phx2.fedoraproject.org (Postfix) with ESMTP id 3F49D6075B53; Tue, 28 May 2019 08:04:00 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 bastion01.phx2.fedoraproject.org 3F49D6075B53 Received: from mailman01.phx2.fedoraproject.org (localhost [IPv6:::1]) by mailman01.phx2.fedoraproject.org (Postfix) with ESMTP id 3685957B2D06C; Tue, 28 May 2019 08:04:00 +0000 (UTC) Received: by mailman01.phx2.fedoraproject.org (Postfix, from userid 991) id DBEFD57B2D069; Tue, 28 May 2019 08:03:53 +0000 (UTC) Received: from smtp-mm-osuosl01.fedoraproject.org (smtp-mm-osuosl01.vpn.fedoraproject.org [192.168.1.23]) by mailman01.phx2.fedoraproject.org (Postfix) with ESMTP id 5D24D57B26B63 for ; Tue, 28 May 2019 08:03:53 +0000 (UTC) Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by smtp-mm-osuosl01.fedoraproject.org (Postfix) with ESMTPS id 156E598079 for ; Tue, 28 May 2019 08:03:53 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id CEAB35F79B; Tue, 28 May 2019 08:03:49 +0000 (UTC) Received: from localhost.localdomain (ovpn-116-234.ams2.redhat.com [10.36.116.234]) by smtp.corp.redhat.com (Postfix) with ESMTP id 7276B5C8B4; Tue, 28 May 2019 08:03:46 +0000 (UTC) From: Beniamino Galvani To: libteam@lists.fedorahosted.org Subject: [PATCH] libteam: set netlink event socket as non-blocking Date: Tue, 28 May 2019 10:02:45 +0200 Message-Id: <20190528080245.29690-1-bgalvani@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.39]); Tue, 28 May 2019 08:03:52 +0000 (UTC) Message-ID-Hash: FQYIMFLCS2ARNTVSBRX7X7V3T3LBN6PW X-Message-ID-Hash: FQYIMFLCS2ARNTVSBRX7X7V3T3LBN6PW X-MailFrom: bgalvani@redhat.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; header-match-config-1; header-match-config-2; header-match-config-3; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; suspicious-header CC: jiri@resnulli.us, Beniamino Galvani X-Mailman-Version: 3.1.1 Precedence: list List-Id: Archived-At: List-Archive: List-Help: List-Post: List-Subscribe: List-Unsubscribe: X-Virus-Scanned: ClamAV using ClamSMTP In some situations it was observed that recvmsg() blocks even if epoll_wait() reports the netlink socket as ready: select(15, [3 9 10 14], [], [], NULL) = 1 (in [9]) epoll_wait(9, [{EPOLLIN, {u32=8, u64=8}}], 2, -1) = 1 recvmsg(8, ### blocked (9 is the epoll fd, 8 the nl_cli event socket). Probably this is caused by a bug in kernel, however it seems more robust anyway to set the socket as non-blocking to avoid problems like this. Signed-off-by: Beniamino Galvani --- libteam/libteam.c | 1 + 1 file changed, 1 insertion(+) diff --git a/libteam/libteam.c b/libteam/libteam.c index 0065a7f..9c9c93a 100644 --- a/libteam/libteam.c +++ b/libteam/libteam.c @@ -638,6 +638,7 @@ int team_init(struct team_handle *th, uint32_t ifindex) nl_socket_modify_cb(th->nl_cli.sock_event, NL_CB_VALID, NL_CB_CUSTOM, cli_event_handler, th); nl_cli_connect(th->nl_cli.sock_event, NETLINK_ROUTE); + nl_socket_set_nonblocking(th->nl_cli.sock_event); env = getenv("TEAM_EVENT_BUFSIZE"); if (env) {