From patchwork Thu Jul 12 06:18:43 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Alvarez Sanchez X-Patchwork-Id: 942816 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=openvswitch.org (client-ip=140.211.169.12; helo=mail.linuxfoundation.org; envelope-from=ovs-dev-bounces@openvswitch.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=redhat.com Received: from mail.linuxfoundation.org (mail.linuxfoundation.org [140.211.169.12]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 41R5P25d40z9ryt for ; Thu, 12 Jul 2018 16:19:02 +1000 (AEST) Received: from mail.linux-foundation.org (localhost [127.0.0.1]) by mail.linuxfoundation.org (Postfix) with ESMTP id 172CCC8A; Thu, 12 Jul 2018 06:18:59 +0000 (UTC) X-Original-To: dev@openvswitch.org Delivered-To: ovs-dev@mail.linuxfoundation.org Received: from smtp1.linuxfoundation.org (smtp1.linux-foundation.org [172.17.192.35]) by mail.linuxfoundation.org (Postfix) with ESMTPS id E0AE241C for ; Thu, 12 Jul 2018 06:18:57 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from mx1.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by smtp1.linuxfoundation.org (Postfix) with ESMTPS id 7CE0E25A for ; Thu, 12 Jul 2018 06:18:57 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 698B0859AF for ; Thu, 12 Jul 2018 06:18:56 +0000 (UTC) Received: from MacBook-Pro-de-Daniel.local.net (ovpn-116-139.ams2.redhat.com [10.36.116.139]) by smtp.corp.redhat.com (Postfix) with ESMTP id 9F32E2026D6B; Thu, 12 Jul 2018 06:18:55 +0000 (UTC) From: Daniel Alvarez To: dev@openvswitch.org Date: Thu, 12 Jul 2018 08:18:43 +0200 Message-Id: <20180712061843.46010-1-dalvarez@redhat.com> X-Scanned-By: MIMEDefang 2.78 on 10.11.54.4 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.2]); Thu, 12 Jul 2018 06:18:56 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.2]); Thu, 12 Jul 2018 06:18:56 +0000 (UTC) for IP:'10.11.54.4' DOMAIN:'int-mx04.intmail.prod.int.rdu2.redhat.com' HELO:'smtp.corp.redhat.com' FROM:'dalvarez@redhat.com' RCPT:'' X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on smtp1.linux-foundation.org Cc: Jiri Benc Subject: [ovs-dev] [PATCH] netdev: Retry getting interfaces on inconsistent dumps from kernel X-BeenThere: ovs-dev@openvswitch.org X-Mailman-Version: 2.1.12 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: ovs-dev-bounces@openvswitch.org Errors-To: ovs-dev-bounces@openvswitch.org This patch in glibc [0] is fixing a bug where we may be getting inconsistent dumps from the kernel when listing interfaces due to a race condition. This could happen if we try to retrieve them while interfaces are being added/removed from the system at the same time. For systems running against old glibc versions, this patch is retrying the operation up to 3 times and then proceeding by logging a warning. Note that 3 times should be enough to not delay the operation much and since it's unlikely that we hit the race condition 3 times in a row. Still, if this happened, this patch is not changing the current behavior. [0] https://sourceware.org/git/gitweb.cgi?p=glibc.git;h=c1f86a33ca32e26a9d6e29fc961e5ecb5e2e5eb4 Signed-off-by: Daniel Alvarez Signed-off-by: Jiri Benc --- lib/netdev.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/lib/netdev.c b/lib/netdev.c index 82ffeb901..448d6e661 100644 --- a/lib/netdev.c +++ b/lib/netdev.c @@ -2039,19 +2039,35 @@ netdev_get_addrs(const char dev[], struct in6_addr **paddr, struct in6_addr *addr_array, *mask_array; const struct ifaddrs *ifa; int cnt = 0, i = 0; + int retries = 3; ovs_mutex_lock(&if_addr_list_lock); if (!if_addr_list) { int err; +retry: err = getifaddrs(&if_addr_list); if (err) { ovs_mutex_unlock(&if_addr_list_lock); return -err; } + retries--; } for (ifa = if_addr_list; ifa; ifa = ifa->ifa_next) { + if (!ifa->ifa_name) { + if (retries) { + /* Older versions of glibc have a bug on race condition with + * address addition which may cause one of the returned ifa_name + * values to be NULL. In such case, we know that we've got an + * inconsistent dump. Retry but beware of an endless loop. */ + freeifaddrs(if_addr_list); + goto retry; + } else { + VLOG_WARN("Proceeding with an inconsistent dump of " + "interfaces from the kernel. Some may be missing"); + } + } if (ifa->ifa_addr && ifa->ifa_name && ifa->ifa_netmask) { int family;