diff options
-rw-r--r-- | src/dns/nm-dns-systemd-resolved.c | 31 |
1 files changed, 28 insertions, 3 deletions
diff --git a/src/dns/nm-dns-systemd-resolved.c b/src/dns/nm-dns-systemd-resolved.c index 3ae50ba719..e99e13b665 100644 --- a/src/dns/nm-dns-systemd-resolved.c +++ b/src/dns/nm-dns-systemd-resolved.c @@ -65,6 +65,7 @@ typedef struct { bool dbus_has_owner : 1; bool dbus_initied : 1; bool request_queue_to_send : 1; + NMTernary has_link_default_route : 3; } NMDnsSystemdResolvedPrivate; struct _NMDnsSystemdResolved { @@ -143,17 +144,29 @@ call_done(GObject *source, GAsyncResult *r, gpointer user_data) priv = NM_DNS_SYSTEMD_RESOLVED_GET_PRIVATE(self); if (v) { + if (request_item->operation == DBUS_OP_SET_LINK_DEFAULT_ROUTE + && priv->has_link_default_route == NM_TERNARY_DEFAULT) { + priv->has_link_default_route = NM_TERNARY_TRUE; + _LOGD("systemd-resolved support for SetLinkDefaultRoute(): API supported"); + } priv->send_updates_warn_ratelimited = FALSE; return; } - log_level = LOGL_DEBUG; + if (request_item->operation == DBUS_OP_SET_LINK_DEFAULT_ROUTE + && nm_g_error_matches(error, G_DBUS_ERROR, G_DBUS_ERROR_UNKNOWN_METHOD)) { + if (priv->has_link_default_route == NM_TERNARY_DEFAULT) { + priv->has_link_default_route = NM_TERNARY_FALSE; + _LOGD("systemd-resolved support for SetLinkDefaultRoute(): API not supported"); + } + return; + } + log_level = LOGL_DEBUG; if (!priv->send_updates_warn_ratelimited) { priv->send_updates_warn_ratelimited = TRUE; log_level = LOGL_WARN; } - _NMLOG(log_level, "send-updates %s@%d failed: %s", request_item->operation, @@ -363,6 +376,15 @@ send_updates(NMDnsSystemdResolved *self) priv->request_queue_to_send = FALSE; c_list_for_each_entry (request_item, &priv->request_queue_lst_head, request_queue_lst) { + if (request_item->operation == DBUS_OP_SET_LINK_DEFAULT_ROUTE + && priv->has_link_default_route == NM_TERNARY_FALSE) { + /* The "SetLinkDefaultRoute" API is only supported since v240. + * We detected that it is not supported, and skip the call. There + * is no special workaround, because in this case we rely on systemd-resolved + * to do the right thing automatically. */ + continue; + } + /* Above we explicitly call "StartServiceByName" trying to avoid D-Bus activating systmd-resolved * multiple times. There is still a race, were we might hit this line although actually * the service just quit this very moment. In that case, we would try to D-Bus activate the @@ -477,7 +499,8 @@ name_owner_changed(NMDnsSystemdResolved *self, const char *owner) if (owner) { priv->try_start_blocked = FALSE; priv->request_queue_to_send = TRUE; - } + } else + priv->has_link_default_route = NM_TERNARY_DEFAULT; send_updates(self); } @@ -550,6 +573,8 @@ nm_dns_systemd_resolved_init(NMDnsSystemdResolved *self) { NMDnsSystemdResolvedPrivate *priv = NM_DNS_SYSTEMD_RESOLVED_GET_PRIVATE(self); + priv->has_link_default_route = NM_TERNARY_DEFAULT; + c_list_init(&priv->request_queue_lst_head); priv->dirty_interfaces = g_hash_table_new(nm_direct_hash, NULL); |