mirror of
https://gitlab.freedesktop.org/NetworkManager/NetworkManager.git
synced 2025-12-25 20:00:09 +01:00
dns: don't clone DNS configs list for nm_dns_plugin_update()
No need to clone the list anymore. Unfortunately, GPtrArray is not NULL
terminated (without extra effort), so we have to pass on the GPtrArray
instance for the length.
(cherry picked from commit 19a98c6f61)
This commit is contained in:
parent
4c81a447cc
commit
24f4caebec
6 changed files with 16 additions and 26 deletions
|
|
@ -554,7 +554,7 @@ start_dnsmasq (NMDnsDnsmasq *self)
|
|||
|
||||
static gboolean
|
||||
update (NMDnsPlugin *plugin,
|
||||
const NMDnsIPConfigData *const*configs,
|
||||
const GPtrArray *configs,
|
||||
const NMGlobalDnsConfig *global_config,
|
||||
const char *hostname)
|
||||
{
|
||||
|
|
@ -571,13 +571,13 @@ update (NMDnsPlugin *plugin,
|
|||
if (global_config)
|
||||
add_global_config (self, &servers, global_config);
|
||||
else {
|
||||
for (i = 0; configs[i]; i++) {
|
||||
prio = nm_dns_ip_config_data_get_dns_priority (configs[i]);
|
||||
for (i = 0; i < configs->len; i++) {
|
||||
prio = nm_dns_ip_config_data_get_dns_priority (configs->pdata[i]);
|
||||
if (i == 0)
|
||||
first_prio = prio;
|
||||
else if (first_prio < 0 && first_prio != prio)
|
||||
break;
|
||||
add_ip_config_data (self, &servers, configs[i]);
|
||||
add_ip_config_data (self, &servers, configs->pdata[i]);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -994,10 +994,8 @@ _collect_resolv_conf_data (NMDnsManager *self, /* only for logging context, no o
|
|||
char ***out_options,
|
||||
char ***out_nameservers,
|
||||
char ***out_nis_servers,
|
||||
const char **out_nis_domain,
|
||||
NMDnsIPConfigData ***out_plugin_confs)
|
||||
const char **out_nis_domain)
|
||||
{
|
||||
NMDnsIPConfigData **plugin_confs = NULL;
|
||||
guint i, j, num, len;
|
||||
NMResolvConfData rc = {
|
||||
.nameservers = g_ptr_array_new (),
|
||||
|
|
@ -1015,8 +1013,6 @@ _collect_resolv_conf_data (NMDnsManager *self, /* only for logging context, no o
|
|||
NMDnsIPConfigData *current;
|
||||
gboolean v4;
|
||||
|
||||
plugin_confs = g_new (NMDnsIPConfigData *, configs->len + 1);
|
||||
|
||||
for (i = 0, j = 0; i < configs->len; i++) {
|
||||
gboolean skip = FALSE;
|
||||
|
||||
|
|
@ -1043,10 +1039,7 @@ _collect_resolv_conf_data (NMDnsManager *self, /* only for logging context, no o
|
|||
|
||||
if (!skip)
|
||||
merge_one_ip_config_data (&rc, current);
|
||||
|
||||
plugin_confs[j++] = current;
|
||||
}
|
||||
plugin_confs[j++] = NULL;
|
||||
}
|
||||
|
||||
/* If the hostname is a FQDN ("dcbw.example.com"), then add the domain part of it
|
||||
|
|
@ -1080,7 +1073,6 @@ _collect_resolv_conf_data (NMDnsManager *self, /* only for logging context, no o
|
|||
}
|
||||
g_ptr_array_set_size (rc.searches, i);
|
||||
|
||||
*out_plugin_confs = plugin_confs;
|
||||
*out_searches = _ptrarray_to_strv (rc.searches);
|
||||
*out_options = _ptrarray_to_strv (rc.options);
|
||||
*out_nameservers = _ptrarray_to_strv (rc.nameservers);
|
||||
|
|
@ -1104,7 +1096,6 @@ update_dns (NMDnsManager *self,
|
|||
SpawnResult result = SR_ERROR;
|
||||
NMConfigData *data;
|
||||
NMGlobalDnsConfig *global_config;
|
||||
gs_free NMDnsIPConfigData **plugin_confs = NULL;
|
||||
|
||||
g_return_val_if_fail (!error || !*error, FALSE);
|
||||
|
||||
|
|
@ -1138,8 +1129,7 @@ update_dns (NMDnsManager *self,
|
|||
compute_hash (self, global_config, priv->hash);
|
||||
|
||||
_collect_resolv_conf_data (self, global_config, priv->configs, priv->hostname,
|
||||
&searches, &options, &nameservers, &nis_servers, &nis_domain,
|
||||
&plugin_confs);
|
||||
&searches, &options, &nameservers, &nis_servers, &nis_domain);
|
||||
|
||||
/* Let any plugins do their thing first */
|
||||
if (priv->plugin) {
|
||||
|
|
@ -1157,7 +1147,7 @@ update_dns (NMDnsManager *self,
|
|||
|
||||
_LOGD ("update-dns: updating plugin %s", plugin_name);
|
||||
if (!nm_dns_plugin_update (plugin,
|
||||
(const NMDnsIPConfigData **) plugin_confs,
|
||||
priv->configs,
|
||||
global_config,
|
||||
priv->hostname)) {
|
||||
_LOGW ("update-dns: plugin %s update failed", plugin_name);
|
||||
|
|
|
|||
|
|
@ -77,14 +77,14 @@ G_DEFINE_TYPE_EXTENDED (NMDnsPlugin, nm_dns_plugin, G_TYPE_OBJECT, G_TYPE_FLAG_A
|
|||
|
||||
gboolean
|
||||
nm_dns_plugin_update (NMDnsPlugin *self,
|
||||
const NMDnsIPConfigData *const*configs,
|
||||
const GPtrArray *configs,
|
||||
const NMGlobalDnsConfig *global_config,
|
||||
const char *hostname)
|
||||
{
|
||||
g_return_val_if_fail (NM_DNS_PLUGIN_GET_CLASS (self)->update != NULL, FALSE);
|
||||
|
||||
return NM_DNS_PLUGIN_GET_CLASS (self)->update (self,
|
||||
configs ?: NM_PTRARRAY_EMPTY (const NMDnsIPConfigData *),
|
||||
configs,
|
||||
global_config,
|
||||
hostname);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -50,7 +50,7 @@ typedef struct {
|
|||
* configuration.
|
||||
*/
|
||||
gboolean (*update) (NMDnsPlugin *self,
|
||||
const NMDnsIPConfigData *const*configs,
|
||||
const GPtrArray *configs,
|
||||
const NMGlobalDnsConfig *global_config,
|
||||
const char *hostname);
|
||||
|
||||
|
|
@ -80,7 +80,7 @@ gboolean nm_dns_plugin_is_caching (NMDnsPlugin *self);
|
|||
const char *nm_dns_plugin_get_name (NMDnsPlugin *self);
|
||||
|
||||
gboolean nm_dns_plugin_update (NMDnsPlugin *self,
|
||||
const NMDnsIPConfigData *const*configs,
|
||||
const GPtrArray *configs,
|
||||
const NMGlobalDnsConfig *global_config,
|
||||
const char *hostname);
|
||||
|
||||
|
|
|
|||
|
|
@ -290,7 +290,7 @@ send_updates (NMDnsSystemdResolved *self)
|
|||
|
||||
static gboolean
|
||||
update (NMDnsPlugin *plugin,
|
||||
const NMDnsIPConfigData *const*configs,
|
||||
const GPtrArray *configs,
|
||||
const NMGlobalDnsConfig *global_config,
|
||||
const char *hostname)
|
||||
{
|
||||
|
|
@ -299,15 +299,15 @@ update (NMDnsPlugin *plugin,
|
|||
guint i;
|
||||
int prio, first_prio = 0;
|
||||
|
||||
for (i = 0; configs[i]; i++) {
|
||||
for (i = 0; i < configs->len; i++) {
|
||||
gboolean skip = FALSE;
|
||||
|
||||
prio = nm_dns_ip_config_data_get_dns_priority (configs[i]);
|
||||
prio = nm_dns_ip_config_data_get_dns_priority (configs->pdata[i]);
|
||||
if (i == 0)
|
||||
first_prio = prio;
|
||||
else if (first_prio < 0 && first_prio != prio)
|
||||
skip = TRUE;
|
||||
add_interface_configuration (self, interfaces, configs[i], skip);
|
||||
add_interface_configuration (self, interfaces, configs->pdata[i], skip);
|
||||
}
|
||||
|
||||
free_pending_updates (self);
|
||||
|
|
|
|||
|
|
@ -39,7 +39,7 @@ G_DEFINE_TYPE (NMDnsUnbound, nm_dns_unbound, NM_TYPE_DNS_PLUGIN)
|
|||
|
||||
static gboolean
|
||||
update (NMDnsPlugin *plugin,
|
||||
const NMDnsIPConfigData *const*configs,
|
||||
const GPtrArray *configs,
|
||||
const NMGlobalDnsConfig *global_config,
|
||||
const char *hostname)
|
||||
{
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue