Fix losing static forwarders configuration after dbus update

Correct loop updates of up pointer. Do not lose server records prior to
first marked server on update.

Modified for 2.86 version.

Resolves: rhbz#2061944
This commit is contained in:
Petr Menšík 2022-06-17 12:01:07 +02:00
parent f9d6c726e6
commit ef60adb63e
2 changed files with 96 additions and 1 deletions

View File

@ -0,0 +1,90 @@
From f0d061c9977d6c9bc2ddd4e6cf6ffe1ed9cd285a Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Petr=20Men=C5=A1=C3=ADk?= <pemensik@redhat.com>
Date: Fri, 17 Jun 2022 11:40:56 +0200
Subject: [PATCH] Correct add_update_server losing first unmarked entries
Beginning of servers list were updated when first server(s) record is
not marked. That was a mistake, which forgot updating also up pointer to
correct value. Move that loop to separate reuse_server function, which
is close to similar loop in cleanup_servers. Makes it easier to compare
and do correct. Removed tmp variable, because this code does not
invalidate previous serv pointer.
Modified for 2.86
---
src/domain-match.c | 52 ++++++++++++++++++++++++++--------------------
1 file changed, 29 insertions(+), 23 deletions(-)
diff --git a/src/domain-match.c b/src/domain-match.c
index f4fd093..8409c4d 100644
--- a/src/domain-match.c
+++ b/src/domain-match.c
@@ -600,6 +600,34 @@ void cleanup_servers(void)
build_server_array();
}
+/* Upstream servers. See if there is a suitable candidate, if so unmark
+ and move to the end of the list, for order. The entry found may already
+ be at the end. */
+static struct server *reuse_server(char *alloc_domain)
+{
+ struct server **up, *serv;
+
+ for (serv = daemon->servers, up = &daemon->servers; serv; serv = serv->next)
+ {
+ if ((serv->flags & SERV_MARK) &&
+ hostname_isequal(alloc_domain, serv->domain))
+ {
+ /* Need to move down? */
+ if (serv->next)
+ {
+ struct server *s;
+ *up = serv->next;
+ for (s = daemon->servers; s->next; s = s->next);
+ s->next = serv;
+ serv->next = NULL;
+ }
+ return serv;
+ }
+ up = &serv->next;
+ }
+ return NULL;
+}
+
int add_update_server(int flags,
union mysockaddr *addr,
union mysockaddr *source_addr,
@@ -659,29 +687,7 @@ int add_update_server(int flags,
}
else
{
- /* Upstream servers. See if there is a suitable candidate, if so unmark
- and move to the end of the list, for order. The entry found may already
- be at the end. */
- struct server **up, *tmp;
-
- for (serv = daemon->servers, up = &daemon->servers; serv; serv = tmp)
- {
- tmp = serv->next;
- if ((serv->flags & SERV_MARK) &&
- hostname_isequal(alloc_domain, serv->domain))
- {
- /* Need to move down? */
- if (serv->next)
- {
- struct server *s;
- *up = serv->next;
- for (s = daemon->servers; s->next; s = s->next);
- s->next = serv;
- serv->next = NULL;
- }
- break;
- }
- }
+ serv = reuse_server(alloc_domain);
if (serv)
{
--
2.35.3

View File

@ -20,7 +20,7 @@
Name: dnsmasq
Version: 2.86
Release: 8%{?extraversion:.%{extraversion}}%{?dist}
Release: 9%{?extraversion:.%{extraversion}}%{?dist}
Summary: A lightweight DHCP/caching DNS server
License: GPLv2 or GPLv3
@ -72,6 +72,8 @@ Patch29: dnsmasq-2.87-root-log-writeable.patch
# https://lists.thekelleys.org.uk/pipermail/dnsmasq-discuss/2022q1/016166.html
# https://thekelleys.org.uk/gitweb/?p=dnsmasq.git;a=commit;h=553c4c99cca173e9964d0edbd0676ed96c30f62b
Patch30: https://thekelleys.org.uk/gitweb/?p=dnsmasq.git;a=patch;h=553c4c99cca173e9964d0edbd0676ed96c30f62b#/dnsmasq-2.87-resolv.conf-reread.patch
# https://bugzilla.redhat.com/show_bug.cgi?id=2061944
Patch31: dnsmasq-2.87-reuse-server.patch
@ -218,6 +220,9 @@ install -Dpm 644 %{SOURCE2} %{buildroot}%{_sysusersdir}/%{name}.conf
%{_mandir}/man1/dhcp_*
%changelog
* Fri Jun 17 2022 Petr Menšík <pemensik@redhat.com> - 2.86-9
- Do not drop static forwarders on DBus reconfiguration (#2061944)
* Fri Apr 29 2022 Anssi Hannula <anssi.hannula@iki.fi> - 2.86-8
- Enable conntrack support