From 9b3a96f82153fc0461bbd1924c7547116193714c Mon Sep 17 00:00:00 2001 From: Wen Liang Date: Thu, 25 Aug 2022 10:54:19 -0400 Subject: [PATCH 1/2] dnsmasq: silently ignore if pid file is not existed when killing --- src/core/dns/nm-dns-dnsmasq.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/core/dns/nm-dns-dnsmasq.c b/src/core/dns/nm-dns-dnsmasq.c index 7d0f0490e0..d88d3de681 100644 --- a/src/core/dns/nm-dns-dnsmasq.c +++ b/src/core/dns/nm-dns-dnsmasq.c @@ -191,7 +191,8 @@ _gl_pid_kill_external(void) if (!g_file_get_contents(PIDFILE, &contents, NULL, &error)) { if (g_error_matches(error, G_FILE_ERROR, G_FILE_ERROR_NOENT)) do_unlink = FALSE; - _LOGD("spawn: failure to read pidfile %s: %s", PIDFILE, error->message); + else + _LOGD("spawn: failure to read pidfile %s: %s", PIDFILE, error->message); g_clear_error(&error); goto handle_kill; } From 6058445aea1e1db0ff2369bd1b2c628063faf5e8 Mon Sep 17 00:00:00 2001 From: Wen Liang Date: Wed, 24 Aug 2022 11:39:21 -0400 Subject: [PATCH 2/2] dns: kill pending dnsmasq process when mode is not 'dnsmasq' When NM starts, if `main.dns` is not `dnsmasq`, then the pending dnsmasq process should be killed by NM. https://bugzilla.redhat.com/show_bug.cgi?id=2120763 https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/1344 --- src/core/dns/nm-dns-dnsmasq.c | 8 ++++++++ src/core/dns/nm-dns-dnsmasq.h | 2 ++ src/core/dns/nm-dns-manager.c | 3 +++ 3 files changed, 13 insertions(+) diff --git a/src/core/dns/nm-dns-dnsmasq.c b/src/core/dns/nm-dns-dnsmasq.c index d88d3de681..cc7c03a21b 100644 --- a/src/core/dns/nm-dns-dnsmasq.c +++ b/src/core/dns/nm-dns-dnsmasq.c @@ -668,6 +668,14 @@ _gl_pid_spawn(const char *dm_binary, /*****************************************************************************/ +void +nm_dnsmasq_kill_external(void) +{ + _gl_pid_kill_external(); +} + +/*****************************************************************************/ + typedef struct { GDBusConnection *dbus_connection; diff --git a/src/core/dns/nm-dns-dnsmasq.h b/src/core/dns/nm-dns-dnsmasq.h index 575b0b263f..98761d3d9f 100644 --- a/src/core/dns/nm-dns-dnsmasq.h +++ b/src/core/dns/nm-dns-dnsmasq.h @@ -25,4 +25,6 @@ GType nm_dns_dnsmasq_get_type(void); NMDnsPlugin *nm_dns_dnsmasq_new(void); +void nm_dnsmasq_kill_external(void); + #endif /* __NETWORKMANAGER_DNS_DNSMASQ_H__ */ diff --git a/src/core/dns/nm-dns-manager.c b/src/core/dns/nm-dns-manager.c index 1e54452aa4..16af1d2dfe 100644 --- a/src/core/dns/nm-dns-manager.c +++ b/src/core/dns/nm-dns-manager.c @@ -2506,6 +2506,9 @@ again: self); } + if (!NM_IS_DNS_DNSMASQ(priv->plugin)) + nm_dnsmasq_kill_external(); + _update_pending_maybe_changed(self); g_object_thaw_notify(G_OBJECT(self));