mirror of
https://gitlab.freedesktop.org/NetworkManager/NetworkManager.git
synced 2026-01-18 18:00:57 +01:00
dns: fix tracking of best ip config
When a IP configuration has type "best", it is the configuration with the best (lowest) metric default route for the specific address family. Therefore, there can be only one best configuration for address family. When a new configuration is added as best, make sure it is the only one for the address family. This reverts commit0abc14b3a0. Fixes:0abc14b3a0('core: remove unused best_ip_config_[46] field in NMDnsManager') https://lists.freedesktop.org/archives/networkmanager/2023-June/000123.html https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/issues/1331 https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/1683 (cherry picked from commit646e041523) (cherry picked from commit2ddb4e5942)
This commit is contained in:
parent
a33c4c1f51
commit
9cb9dfa77b
1 changed files with 26 additions and 0 deletions
|
|
@ -125,6 +125,9 @@ typedef struct {
|
|||
|
||||
NMConfig *config;
|
||||
|
||||
NMDnsConfigIPData *best_ip_config_4;
|
||||
NMDnsConfigIPData *best_ip_config_6;
|
||||
|
||||
struct {
|
||||
guint64 ts;
|
||||
guint num_restarts;
|
||||
|
|
@ -1940,6 +1943,7 @@ nm_dns_manager_set_ip_config(NMDnsManager *self,
|
|||
NMDnsConfigIPData *ip_data = NULL;
|
||||
int dns_priority;
|
||||
gboolean any_removed = FALSE;
|
||||
NMDnsConfigIPData **p_best;
|
||||
|
||||
g_return_val_if_fail(NM_IS_DNS_MANAGER(self), FALSE);
|
||||
g_return_val_if_fail(!l3cd || NM_IS_L3_CONFIG_DATA(l3cd), FALSE);
|
||||
|
|
@ -2007,6 +2011,12 @@ nm_dns_manager_set_ip_config(NMDnsManager *self,
|
|||
}
|
||||
|
||||
any_removed = TRUE;
|
||||
|
||||
if (priv->best_ip_config_4 == ip_data_iter)
|
||||
priv->best_ip_config_4 = NULL;
|
||||
if (priv->best_ip_config_6 == ip_data_iter)
|
||||
priv->best_ip_config_6 = NULL;
|
||||
|
||||
_dns_config_ip_data_free(ip_data_iter);
|
||||
}
|
||||
}
|
||||
|
|
@ -2057,6 +2067,19 @@ nm_dns_manager_set_ip_config(NMDnsManager *self,
|
|||
changed = TRUE;
|
||||
}
|
||||
|
||||
p_best = NM_IS_IPv4(addr_family) ? &priv->best_ip_config_4 : &priv->best_ip_config_6;
|
||||
if (ip_config_type == NM_DNS_IP_CONFIG_TYPE_BEST_DEVICE) {
|
||||
/* Only one best-device per IP version is allowed */
|
||||
if (*p_best != ip_data) {
|
||||
if (*p_best)
|
||||
(*p_best)->ip_config_type = NM_DNS_IP_CONFIG_TYPE_DEFAULT;
|
||||
*p_best = ip_data;
|
||||
}
|
||||
} else {
|
||||
if (*p_best == ip_data)
|
||||
*p_best = NULL;
|
||||
}
|
||||
|
||||
if (changed)
|
||||
priv->ip_data_lst_need_sort = TRUE;
|
||||
|
||||
|
|
@ -2781,6 +2804,9 @@ dispose(GObject *object)
|
|||
|
||||
nm_clear_g_source_inst(&priv->update_pending_unblock);
|
||||
|
||||
priv->best_ip_config_4 = NULL;
|
||||
priv->best_ip_config_6 = NULL;
|
||||
|
||||
c_list_for_each_entry_safe (ip_data, ip_data_safe, &priv->ip_data_lst_head, ip_data_lst)
|
||||
_dns_config_ip_data_free(ip_data);
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue