136 lines
4.9 KiB
Diff
136 lines
4.9 KiB
Diff
From 2171b984e3c9a17c032ac80054db79523d97d9dd Mon Sep 17 00:00:00 2001
|
|
From: Dan Williams <dcbw@redhat.com>
|
|
Date: Wed, 14 Jan 2015 17:03:22 -0600
|
|
Subject: [PATCH 2/4] dns: refactor building IP config lists for plugins (bgo
|
|
#728342)
|
|
|
|
Don't bother building the lists if no DNS plugins are enabled.
|
|
|
|
https://bugzilla.gnome.org/show_bug.cgi?id=728342
|
|
(cherry picked from commit cc8d9f778c2237b3e9e6815a2e0cc5635328edab)
|
|
---
|
|
src/dns-manager/nm-dns-manager.c | 70 ++++++++++++++++++++++++----------------
|
|
1 file changed, 43 insertions(+), 27 deletions(-)
|
|
|
|
diff --git a/src/dns-manager/nm-dns-manager.c b/src/dns-manager/nm-dns-manager.c
|
|
index ddf31af..e6984e3 100644
|
|
--- a/src/dns-manager/nm-dns-manager.c
|
|
+++ b/src/dns-manager/nm-dns-manager.c
|
|
@@ -561,6 +561,42 @@ compute_hash (NMDnsManager *self, guint8 buffer[HASH_LEN])
|
|
g_checksum_free (sum);
|
|
}
|
|
|
|
+static void
|
|
+build_plugin_config_lists (NMDnsManager *self,
|
|
+ GSList **out_vpn_configs,
|
|
+ GSList **out_dev_configs,
|
|
+ GSList **out_other_configs)
|
|
+{
|
|
+ NMDnsManagerPrivate *priv = NM_DNS_MANAGER_GET_PRIVATE (self);
|
|
+ GSList *iter;
|
|
+
|
|
+ g_return_if_fail (out_vpn_configs && !*out_vpn_configs);
|
|
+ g_return_if_fail (out_dev_configs && !*out_dev_configs);
|
|
+ g_return_if_fail (out_other_configs && !*out_other_configs);
|
|
+
|
|
+ /* Build up config lists for plugins; we use the raw configs here, not the
|
|
+ * merged information that we write to resolv.conf so that the plugins can
|
|
+ * still use the domain information in each config to provide split DNS if
|
|
+ * they want to.
|
|
+ */
|
|
+ if (priv->ip4_vpn_config)
|
|
+ *out_vpn_configs = g_slist_append (*out_vpn_configs, priv->ip4_vpn_config);
|
|
+ if (priv->ip6_vpn_config)
|
|
+ *out_vpn_configs = g_slist_append (*out_vpn_configs, priv->ip6_vpn_config);
|
|
+ if (priv->ip4_device_config)
|
|
+ *out_dev_configs = g_slist_append (*out_dev_configs, priv->ip4_device_config);
|
|
+ if (priv->ip6_device_config)
|
|
+ *out_dev_configs = g_slist_append (*out_dev_configs, priv->ip6_device_config);
|
|
+
|
|
+ for (iter = priv->configs; iter; iter = g_slist_next (iter)) {
|
|
+ if ( (iter->data != priv->ip4_vpn_config)
|
|
+ && (iter->data != priv->ip4_device_config)
|
|
+ && (iter->data != priv->ip6_vpn_config)
|
|
+ && (iter->data != priv->ip6_device_config))
|
|
+ *out_other_configs = g_slist_append (*out_other_configs, iter->data);
|
|
+ }
|
|
+}
|
|
+
|
|
static gboolean
|
|
update_dns (NMDnsManager *self,
|
|
gboolean no_caching,
|
|
@@ -568,7 +604,7 @@ update_dns (NMDnsManager *self,
|
|
{
|
|
NMDnsManagerPrivate *priv;
|
|
NMResolvConfData rc;
|
|
- GSList *iter, *vpn_configs = NULL, *dev_configs = NULL, *other_configs = NULL;
|
|
+ GSList *iter;
|
|
const char *nis_domain = NULL;
|
|
char **searches = NULL;
|
|
char **nameservers = NULL;
|
|
@@ -674,32 +710,11 @@ update_dns (NMDnsManager *self,
|
|
|
|
nis_domain = rc.nis_domain;
|
|
|
|
- /* Build up config lists for plugins; we use the raw configs here, not the
|
|
- * merged information that we write to resolv.conf so that the plugins can
|
|
- * still use the domain information in each config to provide split DNS if
|
|
- * they want to.
|
|
- */
|
|
- if (priv->ip4_vpn_config)
|
|
- vpn_configs = g_slist_append (vpn_configs, priv->ip4_vpn_config);
|
|
- if (priv->ip6_vpn_config)
|
|
- vpn_configs = g_slist_append (vpn_configs, priv->ip6_vpn_config);
|
|
- if (priv->ip4_device_config)
|
|
- dev_configs = g_slist_append (dev_configs, priv->ip4_device_config);
|
|
- if (priv->ip6_device_config)
|
|
- dev_configs = g_slist_append (dev_configs, priv->ip6_device_config);
|
|
-
|
|
- for (iter = priv->configs; iter; iter = g_slist_next (iter)) {
|
|
- if ( (iter->data != priv->ip4_vpn_config)
|
|
- && (iter->data != priv->ip4_device_config)
|
|
- && (iter->data != priv->ip6_vpn_config)
|
|
- && (iter->data != priv->ip6_device_config))
|
|
- other_configs = g_slist_append (other_configs, iter->data);
|
|
- }
|
|
-
|
|
/* Let any plugins do their thing first */
|
|
if (priv->plugin) {
|
|
NMDnsPlugin *plugin = priv->plugin;
|
|
const char *plugin_name = nm_dns_plugin_get_name (plugin);
|
|
+ GSList *vpn_configs = NULL, *dev_configs = NULL, *other_configs = NULL;
|
|
|
|
if (nm_dns_plugin_is_caching (plugin)) {
|
|
if (no_caching) {
|
|
@@ -710,6 +725,8 @@ update_dns (NMDnsManager *self,
|
|
caching = TRUE;
|
|
}
|
|
|
|
+ build_plugin_config_lists (self, &vpn_configs, &dev_configs, &other_configs);
|
|
+
|
|
nm_log_dbg (LOGD_DNS, "DNS: updating plugin %s", plugin_name);
|
|
if (!nm_dns_plugin_update (plugin,
|
|
vpn_configs,
|
|
@@ -723,15 +740,14 @@ update_dns (NMDnsManager *self,
|
|
*/
|
|
caching = FALSE;
|
|
}
|
|
+ g_slist_free (vpn_configs);
|
|
+ g_slist_free (dev_configs);
|
|
+ g_slist_free (other_configs);
|
|
|
|
skip:
|
|
;
|
|
}
|
|
|
|
- g_slist_free (vpn_configs);
|
|
- g_slist_free (dev_configs);
|
|
- g_slist_free (other_configs);
|
|
-
|
|
/* If caching was successful, we only send 127.0.0.1 to /etc/resolv.conf
|
|
* to ensure that the glibc resolver doesn't try to round-robin nameservers,
|
|
* but only uses the local caching nameserver.
|
|
--
|
|
2.4.0
|
|
|