]> git.ipfire.org Git - thirdparty/wireguard-tools.git/commitdiff
wg: don't fail if a netlink interface dump is inconsistent
authorJason A. Donenfeld <Jason@zx2c4.com>
Fri, 12 Oct 2018 14:40:29 +0000 (16:40 +0200)
committerJason A. Donenfeld <Jason@zx2c4.com>
Fri, 12 Oct 2018 23:55:31 +0000 (01:55 +0200)
Netlink returns NLM_F_DUMP_INTR if the set of all tunnels changed
during the dump. That's unfortunate, but is pretty common on busy
systems that are adding and removing tunnels all the time. Rather
than retrying, potentially indefinitely, we just work with the
partial results.

Reported-by: Robert Gerus <ar@is-a.cat>
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
contrib/embeddable-wg-library/wireguard.c
src/ipc.c

index a32fd50a2fa6a353fe8a02cdbeb878dbcc74d734..b8368e9f211688d1f8b2d39ef2e56042f12ead1f 100644 (file)
@@ -998,8 +998,15 @@ another:
                goto cleanup;
        }
        if ((len = mnl_cb_run(rtnl_buffer, len, seq, portid, read_devices_cb, buffer)) < 0) {
-               ret = -errno;
-               goto cleanup;
+               /* Netlink returns NLM_F_DUMP_INTR if the set of all tunnels changed
+                * during the dump. That's unfortunate, but is pretty common on busy
+                * systems that are adding and removing tunnels all the time. Rather
+                * than retrying, potentially indefinitely, we just work with the
+                * partial results. */
+               if (errno != EINTR) {
+                       ret = -errno;
+                       goto cleanup;
+               }
        }
        if (len == MNL_CB_OK + 1)
                goto another;
index c64e3324206a67ad911229800b89caa15e9c5714..587910938c771835e189fd9261e875f77d1e2ab9 100644 (file)
--- a/src/ipc.c
+++ b/src/ipc.c
@@ -530,8 +530,15 @@ another:
                goto cleanup;
        }
        if ((len = mnl_cb_run(rtnl_buffer, len, seq, portid, read_devices_cb, buffer)) < 0) {
-               ret = -errno;
-               goto cleanup;
+               /* Netlink returns NLM_F_DUMP_INTR if the set of all tunnels changed
+                * during the dump. That's unfortunate, but is pretty common on busy
+                * systems that are adding and removing tunnels all the time. Rather
+                * than retrying, potentially indefinitely, we just work with the
+                * partial results. */
+               if (errno != EINTR) {
+                       ret = -errno;
+                       goto cleanup;
+               }
        }
        if (len == MNL_CB_OK + 1)
                goto another;