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 <[email protected]> Co-authored-by: Jiri Benc <[email protected]> --- lib/netdev.c | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/lib/netdev.c b/lib/netdev.c index 82ffeb901..690d28409 100644 --- a/lib/netdev.c +++ b/lib/netdev.c @@ -2039,19 +2039,36 @@ 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; -- 2.15.2 (Apple Git-101.1) _______________________________________________ dev mailing list [email protected] https://mail.openvswitch.org/mailman/listinfo/ovs-dev
