From 599b84fbd18a0662661017f9f7e346567587ce31 Mon Sep 17 00:00:00 2001 From: "Jason A. Donenfeld" Date: Fri, 12 Oct 2018 16:40:29 +0200 Subject: wg: don't fail if a netlink interface dump is inconsistent 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 Signed-off-by: Jason A. Donenfeld --- contrib/embeddable-wg-library/wireguard.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) (limited to 'contrib') diff --git a/contrib/embeddable-wg-library/wireguard.c b/contrib/embeddable-wg-library/wireguard.c index a32fd50..b8368e9 100644 --- a/contrib/embeddable-wg-library/wireguard.c +++ b/contrib/embeddable-wg-library/wireguard.c @@ -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; -- cgit v1.2.3-59-g8ed1b