diff options
author | Beniamino Galvani <bgalvani@redhat.com> | 2016-05-24 14:14:25 +0200 |
---|---|---|
committer | Beniamino Galvani <bgalvani@redhat.com> | 2016-05-24 14:26:24 +0200 |
commit | 40caeec712e8c42b742632a3dfae918e918810a9 (patch) | |
tree | bc29808fd08baedfce567dcb2fee92bb511f9b71 | |
parent | 0437abbef7b289901adc87c481dd6624ca7b16d1 (diff) | |
download | NetworkManager-bg/dnsmasq-cache-clear-rh1338731.tar.gz |
dns: clear dnsmasq cache after an updatebg/dnsmasq-cache-clear-rh1338731
When the list of DNS servers changes, old DNS entries cached by
dnsmasq must be invalidated as the answers returned by new servers may
be different (especially, old NXDOMAIN entries may now be valid). Call
the dnsmasq "ClearCache" D-Bus method to achieve this.
https://bugzilla.redhat.com/show_bug.cgi?id=1338731
-rw-r--r-- | src/dns-manager/nm-dns-dnsmasq.c | 31 |
1 files changed, 29 insertions, 2 deletions
diff --git a/src/dns-manager/nm-dns-dnsmasq.c b/src/dns-manager/nm-dns-dnsmasq.c index 45ec353171..ad8daf16e0 100644 --- a/src/dns-manager/nm-dns-dnsmasq.c +++ b/src/dns-manager/nm-dns-dnsmasq.c @@ -288,6 +288,25 @@ add_ip_config_data (NMDnsDnsmasq *self, GVariantBuilder *servers, const NMDnsIPC } static void +dnsmasq_clear_cache_done (GDBusProxy *proxy, GAsyncResult *res, gpointer user_data) +{ + NMDnsDnsmasq *self; + gs_free_error GError *error = NULL; + gs_unref_variant GVariant *response = NULL; + + response = g_dbus_proxy_call_finish (proxy, res, &error); + if (g_error_matches (error, G_IO_ERROR, G_IO_ERROR_CANCELLED)) + return; + + self = NM_DNS_DNSMASQ (user_data); + + if (!response) + _LOGW ("dnsmasq cache clear failed: %s", error->message); + else + _LOGD ("dnsmasq update successful, cache cleared"); +} + +static void dnsmasq_update_done (GDBusProxy *proxy, GAsyncResult *res, gpointer user_data) { NMDnsDnsmasq *self; @@ -304,8 +323,16 @@ dnsmasq_update_done (GDBusProxy *proxy, GAsyncResult *res, gpointer user_data) if (!response) _LOGW ("dnsmasq update failed: %s", error->message); - else - _LOGD ("dnsmasq update successful"); + else { + g_dbus_proxy_call (priv->dnsmasq, + "ClearCache", + NULL, + G_DBUS_CALL_FLAGS_NONE, + -1, + priv->update_cancellable, + (GAsyncReadyCallback) dnsmasq_clear_cache_done, + self); + } } static void |