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:
@@ -61,7 +61,11 @@ G_DEFINE_TYPE(NMDnsDnsconfd, nm_dns_dnsconfd, NM_TYPE_DNS_PLUGIN)
|
|||||||
|
|
||||||
#define DNSCONFD_DBUS_SERVICE "com.redhat.dnsconfd"
|
#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
|
static void
|
||||||
server_builder_append_interface_info(GVariantBuilder *argument_builder,
|
server_builder_append_interface_info(GVariantBuilder *argument_builder,
|
||||||
const char *interface,
|
const char *interface,
|
||||||
char **networks,
|
char **networks)
|
||||||
const char *connection_id,
|
|
||||||
const char *connection_uuid,
|
|
||||||
const char *dbus_path)
|
|
||||||
{
|
{
|
||||||
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) {
|
if (interface) {
|
||||||
g_variant_builder_add(argument_builder, "{sv}", "interface", g_variant_new("s", 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 CList *ip_data_lst_head,
|
||||||
const char *ca)
|
const char *ca)
|
||||||
{
|
{
|
||||||
NMDnsConfigIPData *ip_data;
|
NMDnsConfigIPData *ip_data;
|
||||||
const char *const *dns_server_strings;
|
const char *const *dns_server_strings;
|
||||||
guint nameserver_count;
|
guint nameserver_count;
|
||||||
const char *ifname;
|
const char *ifname;
|
||||||
NMDevice *device;
|
gboolean explicit_default = is_default_interface_explicit(ip_data_lst_head);
|
||||||
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);
|
|
||||||
|
|
||||||
c_list_for_each_entry (ip_data, ip_data_lst_head, ip_data_lst) {
|
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
|
/* 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);
|
&nameserver_count);
|
||||||
if (!nameserver_count)
|
if (!nameserver_count)
|
||||||
continue;
|
continue;
|
||||||
ifname = nm_platform_link_get_name(NM_PLATFORM_GET, ip_data->data->ifindex);
|
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);
|
|
||||||
|
|
||||||
gather_interface_domains(ip_data, explicit_default, &routing_domains, &search_domains);
|
gather_interface_domains(ip_data, explicit_default, &routing_domains, &search_domains);
|
||||||
get_networks(ip_data, &networks);
|
get_networks(ip_data, &networks);
|
||||||
@@ -643,12 +603,7 @@ parse_all_interface_config(GVariantBuilder *argument_builder,
|
|||||||
routing_domains,
|
routing_domains,
|
||||||
search_domains,
|
search_domains,
|
||||||
ca)) {
|
ca)) {
|
||||||
server_builder_append_interface_info(argument_builder,
|
server_builder_append_interface_info(argument_builder, ifname, networks);
|
||||||
ifname,
|
|
||||||
networks,
|
|
||||||
connection_id,
|
|
||||||
connection_uuid,
|
|
||||||
dbus_path);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -696,7 +651,10 @@ update(NMDnsPlugin *plugin,
|
|||||||
|
|
||||||
/* We need to consider only whether we are connected, because newer update call
|
/* We need to consider only whether we are connected, because newer update call
|
||||||
* overrides the old one */
|
* 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;
|
priv->plugin_state = DNSCONFD_PLUGIN_WAIT_CONNECT;
|
||||||
_LOGT("not connected, waiting to connect");
|
_LOGT("not connected, waiting to connect");
|
||||||
} else {
|
} else {
|
||||||
@@ -704,6 +662,8 @@ update(NMDnsPlugin *plugin,
|
|||||||
_LOGT("connected, waiting for update to finish");
|
_LOGT("connected, waiting for update to finish");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
_nm_dns_plugin_update_pending_maybe_changed(plugin);
|
||||||
|
|
||||||
if (all_connected == CONNECTION_FAIL) {
|
if (all_connected == CONNECTION_FAIL) {
|
||||||
nm_utils_error_set(error,
|
nm_utils_error_set(error,
|
||||||
NM_UTILS_ERROR_UNKNOWN,
|
NM_UTILS_ERROR_UNKNOWN,
|
||||||
@@ -717,8 +677,6 @@ update(NMDnsPlugin *plugin,
|
|||||||
|
|
||||||
send_dnsconfd_update(self);
|
send_dnsconfd_update(self);
|
||||||
|
|
||||||
_nm_dns_plugin_update_pending_maybe_changed(NM_DNS_PLUGIN(self));
|
|
||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user