summaryrefslogtreecommitdiff
path: root/src/dns/nm-dns-systemd-resolved.c
diff options
context:
space:
mode:
authorIsmo Puustinen <ismo.puustinen@intel.com>2017-11-10 14:49:47 +0200
committerThomas Haller <thaller@redhat.com>2018-01-09 14:24:53 +0100
commit25906eda9e669c53d1e5c450fe423cc4360d25e3 (patch)
treed31c6d81efadf46908f9eb65a465faa0625e5be6 /src/dns/nm-dns-systemd-resolved.c
parent2e2ff6f27aa1bfa7a27d49980b319873240ec84b (diff)
downloadNetworkManager-25906eda9e669c53d1e5c450fe423cc4360d25e3.tar.gz
dns: add mechanism for propagating mDNS setting.
Update nm-policy.c and nm-dns-manager.c so that the connection-specific settings get propagated to DNS manger. Currently the only such value is the mDNS status. Add update_mdns() function to DNS plugin interface. If a DNS plugin supports mDNS, it can set an interface with a given index to support mDNS resolving or also register the current hostname. The mDNS support is currently added only to systemd-resolved DNS plugin.
Diffstat (limited to 'src/dns/nm-dns-systemd-resolved.c')
-rw-r--r--src/dns/nm-dns-systemd-resolved.c43
1 files changed, 43 insertions, 0 deletions
diff --git a/src/dns/nm-dns-systemd-resolved.c b/src/dns/nm-dns-systemd-resolved.c
index 71424d182d..8dd395d291 100644
--- a/src/dns/nm-dns-systemd-resolved.c
+++ b/src/dns/nm-dns-systemd-resolved.c
@@ -38,6 +38,7 @@
#include "nm-ip6-config.h"
#include "nm-bus-manager.h"
#include "nm-manager.h"
+#include "nm-setting-connection.h"
#include "devices/nm-device.h"
#include "NetworkManagerUtils.h"
@@ -57,6 +58,7 @@ typedef struct {
GDBusProxy *resolve;
GCancellable *init_cancellable;
GCancellable *update_cancellable;
+ GCancellable *mdns_cancellable;
GQueue dns_updates;
GQueue domain_updates;
} NMDnsSystemdResolvedPrivate;
@@ -314,6 +316,45 @@ update (NMDnsPlugin *plugin,
return TRUE;
}
+static gboolean
+update_mdns (NMDnsPlugin *plugin, int ifindex, NMSettingConnectionMdns mdns)
+{
+ NMDnsSystemdResolved *self = NM_DNS_SYSTEMD_RESOLVED (plugin);
+ NMDnsSystemdResolvedPrivate *priv = NM_DNS_SYSTEMD_RESOLVED_GET_PRIVATE (self);
+ char *value;
+
+ _LOGI ("update_mdns: %i/%d", ifindex, mdns);
+
+ nm_clear_g_cancellable (&priv->mdns_cancellable);
+
+ if (!priv->resolve)
+ return FALSE;
+
+ priv->mdns_cancellable = g_cancellable_new ();
+
+ switch (mdns) {
+ case NM_SETTING_CONNECTION_MDNS_YES:
+ value = "yes";
+ break;
+ case NM_SETTING_CONNECTION_MDNS_NO:
+ value = "no";
+ break;
+ case NM_SETTING_CONNECTION_MDNS_RESOLVE:
+ value = "resolve";
+ break;
+ default:
+ /* reset to system default */
+ value = "";
+ }
+
+ g_dbus_proxy_call (priv->resolve, "SetLinkMulticastDNS",
+ g_variant_new ("(is)", ifindex, value),
+ G_DBUS_CALL_FLAGS_NONE,
+ -1, priv->mdns_cancellable, call_done, self);
+
+ return TRUE;
+}
+
/*****************************************************************************/
static gboolean
@@ -402,6 +443,7 @@ dispose (GObject *object)
g_clear_object (&priv->resolve);
nm_clear_g_cancellable (&priv->init_cancellable);
nm_clear_g_cancellable (&priv->update_cancellable);
+ nm_clear_g_cancellable (&priv->mdns_cancellable);
G_OBJECT_CLASS (nm_dns_systemd_resolved_parent_class)->dispose (object);
}
@@ -416,5 +458,6 @@ nm_dns_systemd_resolved_class_init (NMDnsSystemdResolvedClass *dns_class)
plugin_class->is_caching = is_caching;
plugin_class->update = update;
+ plugin_class->update_mdns = update_mdns;
plugin_class->get_name = get_name;
}