summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas Haller <thaller@redhat.com>2019-04-07 11:34:30 +0200
committerThomas Haller <thaller@redhat.com>2019-04-09 20:40:18 +0200
commit2ab90719a213a3373546469c4c89907a4bf09f16 (patch)
tree3021f34c1ff7a2d99797d2dbe45255f9a8003984
parent7ae434b37c9d886807acede55c675b6c82ad6db3 (diff)
downloadNetworkManager-2ab90719a213a3373546469c4c89907a4bf09f16.tar.gz
connectivity: avoid D-Bus activating systemd-resolved when we know it's not used
Every (failed) attempt to D-Bus activate a service results in log-messages from dbus-daemon. It must be avoided to spam the logs that way. Let connectivity check not only ask whether systemd-resolved is enabled (and NetworkManager would like to push information there), but also whether it looks like the service is actually available. That is, either it has a name-owner or it's not blocked from starting. The previous workaround was to configure main.systemd-resolved=no in NetworkManager.conf. But that requires explict configuration.
-rw-r--r--src/dns/nm-dns-manager.c11
-rw-r--r--src/dns/nm-dns-systemd-resolved.c16
-rw-r--r--src/dns/nm-dns-systemd-resolved.h2
-rw-r--r--src/nm-connectivity.c13
4 files changed, 39 insertions, 3 deletions
diff --git a/src/dns/nm-dns-manager.c b/src/dns/nm-dns-manager.c
index c7c561c459..27c3e7109c 100644
--- a/src/dns/nm-dns-manager.c
+++ b/src/dns/nm-dns-manager.c
@@ -347,13 +347,20 @@ gboolean
nm_dns_manager_has_systemd_resolved (NMDnsManager *self)
{
NMDnsManagerPrivate *priv;
+ NMDnsSystemdResolved *plugin = NULL;
g_return_val_if_fail (NM_IS_DNS_MANAGER (self), FALSE);
priv = NM_DNS_MANAGER_GET_PRIVATE (self);
- return priv->sd_resolve_plugin
- || NM_IS_DNS_SYSTEMD_RESOLVED (priv->plugin);
+ if (priv->sd_resolve_plugin) {
+ nm_assert (!NM_IS_DNS_SYSTEMD_RESOLVED (priv->plugin));
+ plugin = NM_DNS_SYSTEMD_RESOLVED (priv->sd_resolve_plugin);
+ } else if (NM_IS_DNS_SYSTEMD_RESOLVED (priv->plugin))
+ plugin = NM_DNS_SYSTEMD_RESOLVED (priv->plugin);
+
+ return plugin
+ && nm_dns_systemd_resolved_is_running (plugin);
}
/*****************************************************************************/
diff --git a/src/dns/nm-dns-systemd-resolved.c b/src/dns/nm-dns-systemd-resolved.c
index 140776a598..a1cf4f89df 100644
--- a/src/dns/nm-dns-systemd-resolved.c
+++ b/src/dns/nm-dns-systemd-resolved.c
@@ -476,6 +476,22 @@ resolved_proxy_created (GObject *source, GAsyncResult *r, gpointer user_data)
/*****************************************************************************/
+gboolean
+nm_dns_systemd_resolved_is_running (NMDnsSystemdResolved *self)
+{
+ NMDnsSystemdResolvedPrivate *priv;
+
+ g_return_val_if_fail (NM_IS_DNS_SYSTEMD_RESOLVED (self), FALSE);
+
+ priv = NM_DNS_SYSTEMD_RESOLVED_GET_PRIVATE (self);
+
+ return priv->resolve
+ && ( priv->dbus_has_owner
+ || !priv->try_start_blocked);
+}
+
+/*****************************************************************************/
+
static void
nm_dns_systemd_resolved_init (NMDnsSystemdResolved *self)
{
diff --git a/src/dns/nm-dns-systemd-resolved.h b/src/dns/nm-dns-systemd-resolved.h
index 800a60c154..b79ff5e4ec 100644
--- a/src/dns/nm-dns-systemd-resolved.h
+++ b/src/dns/nm-dns-systemd-resolved.h
@@ -36,4 +36,6 @@ GType nm_dns_systemd_resolved_get_type (void);
NMDnsPlugin *nm_dns_systemd_resolved_new (void);
+gboolean nm_dns_systemd_resolved_is_running (NMDnsSystemdResolved *self);
+
#endif /* __NETWORKMANAGER_DNS_SYSTEMD_RESOLVED_H__ */
diff --git a/src/nm-connectivity.c b/src/nm-connectivity.c
index b72413d2f3..2aab23862b 100644
--- a/src/nm-connectivity.c
+++ b/src/nm-connectivity.c
@@ -840,7 +840,18 @@ nm_connectivity_check_start (NMConnectivity *self,
*
* Yes, this makes NMConnectivity singleton dependent on NMDnsManager singleton.
* Well, not really: it makes connectivity-check-start dependent on NMDnsManager
- * which merely means, not to start a connectivity check, late during shutdown. */
+ * which merely means, not to start a connectivity check, late during shutdown.
+ *
+ * NMDnsSystemdResolved tries to D-Bus activate systemd-resolved only once,
+ * to not spam syslog with failures messages from dbus-daemon.
+ * Note that unless NMDnsSystemdResolved tried and failed to start systemd-resolved,
+ * it guesses that systemd-resolved is activatable and returns %TRUE here. That
+ * means, while NMDnsSystemdResolved would not try to D-Bus activate systemd-resolved
+ * more than once, NMConnectivity might -- until NMDnsSystemdResolved tried itself
+ * and noticed that systemd-resolved is not available.
+ * This is relatively cumbersome to avoid, because we would have to go through
+ * NMDnsSystemdResolved trying to asynchronously start the service, to ensure there
+ * is only one attempt to start the service. */
has_systemd_resolved = nm_dns_manager_has_systemd_resolved (nm_dns_manager_get ());
if (has_systemd_resolved) {