]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
IPv6 route check: list devices only once
authorCédric Bosdonnat <cbosdonnat@suse.com>
Wed, 26 Apr 2017 09:45:42 +0000 (11:45 +0200)
committerCédric Bosdonnat <cbosdonnat@suse.com>
Wed, 26 Apr 2017 16:59:24 +0000 (18:59 +0200)
If several RA routes are found for the same device, only list that
device once in the error message.

src/util/virnetdevip.c

index 09925e1d74a60e89dd29bb720953bd919c1da344..bf98ed8a59e0e332d6456e1fbe6695994d145d7f 100644 (file)
@@ -551,6 +551,8 @@ virNetDevIPCheckIPv6ForwardingCallback(const struct nlmsghdr *resp,
     int ret = 0;
     int len = RTM_PAYLOAD(resp);
     int oif = -1;
+    size_t i;
+    bool hasDevice;
 
     /* Ignore messages other than route ones */
     if (resp->nlmsg_type != RTM_NEWROUTE)
@@ -587,7 +589,13 @@ virNetDevIPCheckIPv6ForwardingCallback(const struct nlmsghdr *resp,
     accept_ra = virNetDevIPGetAcceptRA(ifname);
     VIR_DEBUG("Checking route for device %s, accept_ra: %d", ifname, accept_ra);
 
-    if (accept_ra != 2 && VIR_APPEND_ELEMENT(data->devices, data->ndevices, ifname) < 0)
+    hasDevice = false;
+    for (i = 0; i < data->ndevices && !hasDevice; i++) {
+        if (STREQ(data->devices[i], ifname))
+            hasDevice = true;
+    }
+    if (accept_ra != 2 && !hasDevice &&
+        VIR_APPEND_ELEMENT(data->devices, data->ndevices, ifname) < 0)
         goto error;
 
  cleanup: