Commit 2ab90719 authored by Thomas Haller's avatar Thomas Haller

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.
parent 7ae434b3
......@@ -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);
}
/*****************************************************************************/
......
......@@ -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)
{
......
......@@ -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__ */
......@@ -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) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment