[ovs-dev,v2] netdev: Retry getting interfaces on inconsistent dumps from kernel

Message ID 20180809085014.23474-1-dalvarez@redhat.com
State Superseded
Headers show
  • [ovs-dev,v2] netdev: Retry getting interfaces on inconsistent dumps from kernel
Related show

Commit Message

Daniel Alvarez Aug. 9, 2018, 8:50 a.m.
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

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 <dalvarez@redhat.com>
Co-authored-by: Jiri Benc <jbenc@redhat.com>
 lib/netdev.c | 16 ++++++++++++++++
 1 file changed, 16 insertions(+)

Signed-off-by: Daniel Alvarez <dalvarez@redhat.com>
 lib/netdev.c | 17 +++++++++++++++++
 1 file changed, 17 insertions(+)


0-day Robot Aug. 9, 2018, 8:56 a.m. | #1
Bleep bloop.  Greetings Daniel Alvarez, I am a robot and I have tried out your patch.
Thanks for your contribution.

I encountered some error that I wasn't expecting.  See the details below.

ERROR: Too many signoffs; are you missing Co-authored-by lines?
ERROR: Co-authored-by/Signed-off-by corruption
Lines checked: 74, Warnings: 0, Errors: 2

Please check this out.  If you feel there has been an error, please email aconole@bytheb.org

0-day Robot


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;
     if (!if_addr_list) {
         int err;
         err = getifaddrs(&if_addr_list);
         if (err) {
             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;