summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas Haller <thaller@redhat.com>2017-06-14 00:44:03 +0200
committerThomas Haller <thaller@redhat.com>2017-06-19 15:15:49 +0200
commit4c81a447cc8af239773b878922af82f2f04b93a6 (patch)
tree8c4988053e69890d7e9b46027c962b00e2b565e6
parent6ac67655befb6611b052fedb31afe31af310a1d4 (diff)
downloadNetworkManager-4c81a447cc8af239773b878922af82f2f04b93a6.tar.gz
dns: fix negative ipv4.dns-priority for systemd-resolved
A negative ipv4.dns-priority and ipv6.dns-priority has the meaning to configure the DNS information of the connection exclusively. With systemd-resolved, that means we must explicitly unset the configuration from other interfaces. https://bugzilla.gnome.org/show_bug.cgi?id=783569 (cherry picked from commit 70792e51d94a5e7790b3e65b7d6cf591b251f4cd)
-rw-r--r--src/dns/nm-dns-dnsmasq.c12
-rw-r--r--src/dns/nm-dns-manager.c6
-rw-r--r--src/dns/nm-dns-plugin.c2
-rw-r--r--src/dns/nm-dns-systemd-resolved.c24
4 files changed, 30 insertions, 14 deletions
diff --git a/src/dns/nm-dns-dnsmasq.c b/src/dns/nm-dns-dnsmasq.c
index 33cda8371b..67aae6f431 100644
--- a/src/dns/nm-dns-dnsmasq.c
+++ b/src/dns/nm-dns-dnsmasq.c
@@ -561,6 +561,8 @@ update (NMDnsPlugin *plugin,
NMDnsDnsmasq *self = NM_DNS_DNSMASQ (plugin);
NMDnsDnsmasqPrivate *priv = NM_DNS_DNSMASQ_GET_PRIVATE (self);
GVariantBuilder servers;
+ guint i;
+ int prio, first_prio;
start_dnsmasq (self);
@@ -569,9 +571,13 @@ update (NMDnsPlugin *plugin,
if (global_config)
add_global_config (self, &servers, global_config);
else {
- while (*configs) {
- add_ip_config_data (self, &servers, *configs);
- configs++;
+ for (i = 0; configs[i]; i++) {
+ prio = nm_dns_ip_config_data_get_dns_priority (configs[i]);
+ if (i == 0)
+ first_prio = prio;
+ else if (first_prio < 0 && first_prio != prio)
+ break;
+ add_ip_config_data (self, &servers, configs[i]);
}
}
diff --git a/src/dns/nm-dns-manager.c b/src/dns/nm-dns-manager.c
index 6e567e5d4a..c99ed112d4 100644
--- a/src/dns/nm-dns-manager.c
+++ b/src/dns/nm-dns-manager.c
@@ -1041,10 +1041,10 @@ _collect_resolv_conf_data (NMDnsManager *self, /* only for logging context, no o
get_nameserver_list (current->config, &tmp_gstring));
}
- if (!skip) {
+ if (!skip)
merge_one_ip_config_data (&rc, current);
- plugin_confs[j++] = current;
- }
+
+ plugin_confs[j++] = current;
}
plugin_confs[j++] = NULL;
}
diff --git a/src/dns/nm-dns-plugin.c b/src/dns/nm-dns-plugin.c
index 460093440c..740ff26bab 100644
--- a/src/dns/nm-dns-plugin.c
+++ b/src/dns/nm-dns-plugin.c
@@ -84,7 +84,7 @@ nm_dns_plugin_update (NMDnsPlugin *self,
g_return_val_if_fail (NM_DNS_PLUGIN_GET_CLASS (self)->update != NULL, FALSE);
return NM_DNS_PLUGIN_GET_CLASS (self)->update (self,
- configs,
+ configs ?: NM_PTRARRAY_EMPTY (const NMDnsIPConfigData *),
global_config,
hostname);
}
diff --git a/src/dns/nm-dns-systemd-resolved.c b/src/dns/nm-dns-systemd-resolved.c
index a943e572d9..f49aed57da 100644
--- a/src/dns/nm-dns-systemd-resolved.c
+++ b/src/dns/nm-dns-systemd-resolved.c
@@ -102,7 +102,8 @@ call_done (GObject *source, GAsyncResult *r, gpointer user_data)
static void
add_interface_configuration (NMDnsSystemdResolved *self,
GArray *interfaces,
- const NMDnsIPConfigData *data)
+ const NMDnsIPConfigData *data,
+ gboolean skip)
{
int i;
InterfaceConfig *ic = NULL;
@@ -130,7 +131,8 @@ add_interface_configuration (NMDnsSystemdResolved *self,
ic->ifindex = ifindex;
}
- ic->configs = g_list_append (ic->configs, data->config);
+ if (!skip)
+ ic->configs = g_list_append (ic->configs, data->config);
}
static void
@@ -294,11 +296,19 @@ update (NMDnsPlugin *plugin,
{
NMDnsSystemdResolved *self = NM_DNS_SYSTEMD_RESOLVED (plugin);
GArray *interfaces = g_array_new (TRUE, TRUE, sizeof (InterfaceConfig));
- const NMDnsIPConfigData *const*c;
- int i;
-
- for (c = configs; *c != NULL; c++)
- add_interface_configuration (self, interfaces, *c);
+ guint i;
+ int prio, first_prio = 0;
+
+ for (i = 0; configs[i]; i++) {
+ gboolean skip = FALSE;
+
+ prio = nm_dns_ip_config_data_get_dns_priority (configs[i]);
+ if (i == 0)
+ first_prio = prio;
+ else if (first_prio < 0 && first_prio != prio)
+ skip = TRUE;
+ add_interface_configuration (self, interfaces, configs[i], skip);
+ }
free_pending_updates (self);