merge: branch 'bg/dnsconfd-fix-pending'

Some fixes for the dnsconfd plugin

https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/2137

(cherry picked from commit 006a3fb51a)
This commit is contained in:
Beniamino Galvani
2025-02-13 09:37:24 +00:00

View File

@@ -61,7 +61,11 @@ G_DEFINE_TYPE(NMDnsDnsconfd, nm_dns_dnsconfd, NM_TYPE_DNS_PLUGIN)
#define DNSCONFD_DBUS_SERVICE "com.redhat.dnsconfd"
typedef enum { CONNECTION_FAIL, CONNECTION_SUCCESS, CONNECTION_WAIT } ConnectionState;
typedef enum {
CONNECTION_FAIL,
CONNECTION_SUCCESS,
CONNECTION_WAIT,
} ConnectionState;
/*****************************************************************************/
@@ -329,29 +333,8 @@ get_networks(NMDnsConfigIPData *ip_data, char ***networks)
static void
server_builder_append_interface_info(GVariantBuilder *argument_builder,
const char *interface,
char **networks,
const char *connection_id,
const char *connection_uuid,
const char *dbus_path)
char **networks)
{
if (connection_id) {
g_variant_builder_add(argument_builder,
"{sv}",
"connection-id",
g_variant_new("s", connection_id));
}
if (connection_uuid) {
g_variant_builder_add(argument_builder,
"{sv}",
"connection-uuid",
g_variant_new("s", connection_uuid));
}
if (dbus_path) {
g_variant_builder_add(argument_builder,
"{sv}",
"connection-object",
g_variant_new("s", dbus_path));
}
if (interface) {
g_variant_builder_add(argument_builder, "{sv}", "interface", g_variant_new("s", interface));
}
@@ -589,18 +572,11 @@ parse_all_interface_config(GVariantBuilder *argument_builder,
const CList *ip_data_lst_head,
const char *ca)
{
NMDnsConfigIPData *ip_data;
const char *const *dns_server_strings;
guint nameserver_count;
const char *ifname;
NMDevice *device;
NMActiveConnection *active_connection;
NMSettingsConnection *settings_connection;
NMActRequest *act_request;
const char *connection_id;
const char *connection_uuid;
const char *dbus_path;
gboolean explicit_default = is_default_interface_explicit(ip_data_lst_head);
NMDnsConfigIPData *ip_data;
const char *const *dns_server_strings;
guint nameserver_count;
const char *ifname;
gboolean explicit_default = is_default_interface_explicit(ip_data_lst_head);
c_list_for_each_entry (ip_data, ip_data_lst_head, ip_data_lst) {
/* No need to free insides of routing and search domains, as they point to data
@@ -615,23 +591,7 @@ parse_all_interface_config(GVariantBuilder *argument_builder,
&nameserver_count);
if (!nameserver_count)
continue;
ifname = nm_platform_link_get_name(NM_PLATFORM_GET, ip_data->data->ifindex);
device = nm_manager_get_device_by_ifindex(NM_MANAGER_GET, ip_data->data->ifindex);
act_request = nm_device_get_act_request(device);
active_connection = NM_ACTIVE_CONNECTION(act_request);
/* Presume that when we have server of this interface then the interface has to have
* an active connection */
nm_assert(active_connection);
settings_connection = nm_active_connection_get_settings_connection(active_connection);
connection_id = nm_settings_connection_get_id(settings_connection);
connection_uuid = nm_settings_connection_get_uuid(settings_connection);
dbus_path = nm_dbus_object_get_path_still_exported(NM_DBUS_OBJECT(act_request));
/* dbus_path also should be set, because if we are parsing this connection then we
* expect it to be active and exported on dbus */
nm_assert(dbus_path && dbus_path[0] != 0);
ifname = nm_platform_link_get_name(NM_PLATFORM_GET, ip_data->data->ifindex);
gather_interface_domains(ip_data, explicit_default, &routing_domains, &search_domains);
get_networks(ip_data, &networks);
@@ -643,12 +603,7 @@ parse_all_interface_config(GVariantBuilder *argument_builder,
routing_domains,
search_domains,
ca)) {
server_builder_append_interface_info(argument_builder,
ifname,
networks,
connection_id,
connection_uuid,
dbus_path);
server_builder_append_interface_info(argument_builder, ifname, networks);
}
}
}
@@ -696,7 +651,10 @@ update(NMDnsPlugin *plugin,
/* We need to consider only whether we are connected, because newer update call
* overrides the old one */
if (all_connected != CONNECTION_SUCCESS) {
if (all_connected == CONNECTION_FAIL) {
priv->plugin_state = DNSCONFD_PLUGIN_IDLE;
_LOGT("failed to connect");
} else if (all_connected == CONNECTION_WAIT) {
priv->plugin_state = DNSCONFD_PLUGIN_WAIT_CONNECT;
_LOGT("not connected, waiting to connect");
} else {
@@ -704,6 +662,8 @@ update(NMDnsPlugin *plugin,
_LOGT("connected, waiting for update to finish");
}
_nm_dns_plugin_update_pending_maybe_changed(plugin);
if (all_connected == CONNECTION_FAIL) {
nm_utils_error_set(error,
NM_UTILS_ERROR_UNKNOWN,
@@ -717,8 +677,6 @@ update(NMDnsPlugin *plugin,
send_dnsconfd_update(self);
_nm_dns_plugin_update_pending_maybe_changed(NM_DNS_PLUGIN(self));
return TRUE;
}