From bcc955fcc9d7287d8ad35a10111614fc503e0485 Mon Sep 17 00:00:00 2001 From: Thomas Haller Date: Mon, 30 May 2016 13:59:30 +0200 Subject: [PATCH] dns: reload DNS plugin in SIGHUP Previously, on SIGHUP we would re-read the configuration and possibly reconfigure DNS. However, if the DNS plugin didn't change, we would not restart it. That is good, because restarting the DNS plugin shortly interrupts name resolution. dnsmasq might depend on additional configuration from /etc/NetworkManager/dnsmasq.d, thus, the user also needs a way to restart the plugin to pickup the configuration. For that, it could just kill the dnsmasq instance, but that means, ratelimiting will hit and restarting dnsmasq too often might bork the plugin for 5 minutes. Now, on SIGHUP, also restart the DNS plugin. The advantage is that one signal reloads everything, including the dnsmasq instance, without ratelimiting. The disadvantage is, that it shortly interrupts name resolution. (cherry picked from commit 9ae307347b8b49e7c7c5a09790362e271a30e817) --- src/dns-manager/nm-dns-manager.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/src/dns-manager/nm-dns-manager.c b/src/dns-manager/nm-dns-manager.c index 83c86e7429..6441fd8990 100644 --- a/src/dns-manager/nm-dns-manager.c +++ b/src/dns-manager/nm-dns-manager.c @@ -1520,7 +1520,7 @@ _get_resconf_immutable (void) NM_DEFINE_SINGLETON_GETTER (NMDnsManager, nm_dns_manager_get, NM_TYPE_DNS_MANAGER); static void -init_resolv_conf_mode (NMDnsManager *self) +init_resolv_conf_mode (NMDnsManager *self, gboolean force_reload_plugin) { NMDnsManagerPrivate *priv = NM_DNS_MANAGER_GET_PRIVATE (self); NMDnsManagerResolvConfManager rc_manager; @@ -1565,13 +1565,13 @@ again: } if (nm_streq0 (mode, "dnsmasq")) { - if (!NM_IS_DNS_DNSMASQ (priv->plugin)) { + if (force_reload_plugin || !NM_IS_DNS_DNSMASQ (priv->plugin)) { _clear_plugin (self); priv->plugin = nm_dns_dnsmasq_new (); plugin_changed = TRUE; } } else if (nm_streq0 (mode, "unbound")) { - if (!NM_IS_DNS_UNBOUND (priv->plugin)) { + if (force_reload_plugin || !NM_IS_DNS_UNBOUND (priv->plugin)) { _clear_plugin (self); priv->plugin = nm_dns_unbound_new (); plugin_changed = TRUE; @@ -1615,7 +1615,8 @@ config_changed_cb (NMConfig *config, * The reason is, that the configuration also depends on whether resolv.conf * is immutable, thus, without the configuration changing, we always want to * re-configure the mode. */ - init_resolv_conf_mode (self); + init_resolv_conf_mode (self, + NM_FLAGS_HAS (changes, NM_CONFIG_CHANGE_SIGHUP)); } if (NM_FLAGS_ANY (changes, NM_CONFIG_CHANGE_SIGHUP | @@ -1647,7 +1648,7 @@ nm_dns_manager_init (NMDnsManager *self) NM_CONFIG_SIGNAL_CONFIG_CHANGED, G_CALLBACK (config_changed_cb), self); - init_resolv_conf_mode (self); + init_resolv_conf_mode (self, TRUE); } static void