NetworkManager/SOURCES/1002-dns-sort-according-to-...

70 lines
2.8 KiB
Diff

From c35eb06542b555523df8d7a6e1d00826deb4f625 Mon Sep 17 00:00:00 2001
From: Beniamino Galvani <bgalvani@redhat.com>
Date: Thu, 13 Oct 2022 17:23:15 +0200
Subject: [PATCH 1/2] dns: add comment explaining the purpose of `any_removed`
(cherry picked from commit 4d1ecd8d6dbe6666f9005950a95a6ba8321e653c)
(cherry picked from commit 01b4040a7ad6f0b8c4aad1aabe4827841df2fe1e)
---
src/core/dns/nm-dns-manager.c | 8 +++++++-
1 file changed, 7 insertions(+), 1 deletion(-)
diff --git a/src/core/dns/nm-dns-manager.c b/src/core/dns/nm-dns-manager.c
index 1e54452aa4..c08e2cacd7 100644
--- a/src/core/dns/nm-dns-manager.c
+++ b/src/core/dns/nm-dns-manager.c
@@ -2039,8 +2039,14 @@ nm_dns_manager_set_ip_config(NMDnsManager *self,
if (!ip_data) {
ip_data = _dns_config_ip_data_new(data, addr_family, source_tag, l3cd, ip_config_type);
- if (!any_removed)
+ if (!any_removed) {
+ /* `any_removed` tracks whether we deleted any ip_data. If that happened,
+ * we already compared the old and new l3cds and set `changed` accordingly.
+ * Here we only need to set `changed` if we are adding a new ip_data without
+ * removing the old one.
+ */
changed = TRUE;
+ }
} else {
ip_data->ip_config_type = ip_config_type;
changed = TRUE;
--
2.37.3
From b9b64e667afe4f6f55747a55a28e5f50cf352a4a Mon Sep 17 00:00:00 2001
From: Beniamino Galvani <bgalvani@redhat.com>
Date: Thu, 13 Oct 2022 17:06:19 +0200
Subject: [PATCH 2/2] dns: sort the ip-data list when a new element is added
In nm_dns_manager_set_ip_config() we try to avoid calling update_dns()
unless something changes, because updating DNS is expensive and can
trigger other actions such as a new hostname resolution.
When we add a new ip_data, even if the new element is equivalent to
the old one that was removed, we need to sort the list again.
Fixes: ce0a36d20fa6 ('dns: better track l3cd changes')
https://bugzilla.redhat.com/show_bug.cgi?id=2098574
(cherry picked from commit 3cc7801779ed05d13c3e2422f11ddb365bc37242)
(cherry picked from commit db4c55c8d32179bcaf222029469802d96312413b)
---
src/core/dns/nm-dns-manager.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/src/core/dns/nm-dns-manager.c b/src/core/dns/nm-dns-manager.c
index c08e2cacd7..a2fead3f35 100644
--- a/src/core/dns/nm-dns-manager.c
+++ b/src/core/dns/nm-dns-manager.c
@@ -2039,6 +2039,7 @@ nm_dns_manager_set_ip_config(NMDnsManager *self,
if (!ip_data) {
ip_data = _dns_config_ip_data_new(data, addr_family, source_tag, l3cd, ip_config_type);
+ priv->ip_data_lst_need_sort = TRUE;
if (!any_removed) {
/* `any_removed` tracks whether we deleted any ip_data. If that happened,
* we already compared the old and new l3cds and set `changed` accordingly.
--
2.37.3