From debbugs-submit-bounces@debbugs.gnu.org Sun Mar 23 06:26:06 2025 Received: (at submit) by debbugs.gnu.org; 23 Mar 2025 10:26:06 +0000 Received: from localhost ([127.0.0.1]:47806 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1twIWs-0005uN-AM for submit@debbugs.gnu.org; Sun, 23 Mar 2025 06:26:06 -0400 Received: from lists.gnu.org ([2001:470:142::17]:34594) by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1twIWo-0005rg-Cu for submit@debbugs.gnu.org; Sun, 23 Mar 2025 06:26:03 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1twIWc-00011c-S0 for guix-patches@gnu.org; Sun, 23 Mar 2025 06:25:51 -0400 Received: from mail.mmer.org ([178.22.65.174]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1twIWY-00045U-GJ for guix-patches@gnu.org; Sun, 23 Mar 2025 06:25:49 -0400 Received: from mail.mmer.org (localhost [127.0.0.1]) by mail.mmer.org (OpenSMTPD) with ESMTP id ddabe32b for ; Sun, 23 Mar 2025 10:25:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed; d=mmer.org; h=from:to :subject:date:message-id:mime-version:content-transfer-encoding; s=dkim; bh=4X5Hf7GoYvaPjhIK5J56RD3Kep4Kjn63FUKAgn5hTNA=; b=pt/R I5x3h25I3E2Nn7FjsPuDqhqb6O/zlAhYIyEvEJTptzYAe5bpoZiwbn68wC+DZmTd wjSOj/hCUrq0O3H2K7jhUKPaMrb0rKeAhFtqS+XrKtxLIr75d9/LQsLqcTdITzhi v3GrP7GorOsaMsPQYsKJSRTTxppe7HTTMfjRc+k= Received: from delta (16-254-250-62.ftth.glasoperator.nl [62.250.254.16]) by mail.mmer.org (OpenSMTPD) with ESMTPSA id f419e6a3 (TLSv1.3:TLS_AES_256_GCM_SHA384:256:NO) for ; Sun, 23 Mar 2025 10:25:38 +0000 (UTC) From: Alexey Abramov To: guix-patches@gnu.org Subject: [PATCH 0/3] dnsmasq service changes Date: Sun, 23 Mar 2025 11:24:30 +0100 Message-ID: X-Mailer: git-send-email 2.48.1 MIME-Version: 1.0 X-Debbugs-Cc: Ludovic Courtès , Maxim Cournoyer Content-Transfer-Encoding: 8bit Received-SPF: pass client-ip=178.22.65.174; envelope-from=levenson@mmer.org; helo=mail.mmer.org X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-Spam-Score: 0.9 (/) X-Debbugs-Envelope-To: submit X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -0.1 (/) Hi all, With these patches, I would like to add extra fields to be able to run multiple instances of dnsmasq. I am using dnsmasq as a local dns server and also as a dhcp for bootstraping nodes over the network. The important thing is that I renamed `provision' field here to shepherd-provision. AFAIK `shepherd-provision' and `shepherd-requirement' are the names we use with other services. Alexey Abramov (3): services: dnsmasq: Provide shepherd-provision and shepherd-requirement fields. services: dnsmasq: Provide pid-file, conf-file and conf-dir configuration fields. services: dnsmasq: Provide stats and reload actions. doc/guix.texi | 35 ++++++- gnu/services/dns.scm | 196 ++++++++++++++++++++++++++------------- gnu/tests/networking.scm | 98 ++++++++++++++++++++ 3 files changed, 263 insertions(+), 66 deletions(-) -- 2.48.1 From debbugs-submit-bounces@debbugs.gnu.org Sun Mar 23 06:28:08 2025 Received: (at 77204) by debbugs.gnu.org; 23 Mar 2025 10:28:08 +0000 Received: from localhost ([127.0.0.1]:47813 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1twIYn-0006Eb-2A for submit@debbugs.gnu.org; Sun, 23 Mar 2025 06:28:07 -0400 Received: from mail.mmer.org ([178.22.65.174]:57980) by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1twIYk-0006Co-35 for 77204@debbugs.gnu.org; Sun, 23 Mar 2025 06:28:03 -0400 Received: from mail.mmer.org (localhost [127.0.0.1]) by mail.mmer.org (OpenSMTPD) with ESMTP id 0b255a0c for <77204@debbugs.gnu.org>; Sun, 23 Mar 2025 10:27:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed; d=mmer.org; h=from:to :subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; s=dkim; bh=nZ492XzQdNs8jTvundVjer889 g/FWnLnE9bmrl0fEn8=; b=yGFFRBxj9zpU8WUlln4lmfFdNCGS2Zo7Xl7OGzOjG fmwxRraABI90qHrKOb9vX3U7U2B9JC9fFC+mmwwpuxgfhmoWmXX7lentIxx9nRgj dgI3j9weD7Qfj0b82o8IWJFKbHWYdk1iNI3S9J+PGQMzsTdWnDQHYtb0Ahn90Zu4 04= Received: from delta (16-254-250-62.ftth.glasoperator.nl [62.250.254.16]) by mail.mmer.org (OpenSMTPD) with ESMTPSA id c3efe54d (TLSv1.3:TLS_AES_256_GCM_SHA384:256:NO) for <77204@debbugs.gnu.org>; Sun, 23 Mar 2025 10:27:54 +0000 (UTC) From: Alexey Abramov To: 77204@debbugs.gnu.org Subject: [PATCH 1/3] services: dnsmasq: Provide shepherd-provision and shepherd-requirement fields. Date: Sun, 23 Mar 2025 11:27:50 +0100 Message-ID: <242697cdc4ed0e257df4ba35500ae2a3b3a00a0b.1742725327.git.levenson@mmer.org> X-Mailer: git-send-email 2.48.1 In-Reply-To: References: MIME-Version: 1.0 X-Debbugs-Cc: Ludovic Courtès , Maxim Cournoyer Content-Transfer-Encoding: 8bit X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: 77204 X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) * doc/guix.texi: Document the change. * gnu/services/dns.scm ()[provision]: Rename the field to [shepherd-provision] for consistency with other services. * gnu/services/dns.scm ()[shepherd-requirement]: New field. * gnu/services/dns.scm (dnsmasq-shepherd-service): Use newly-created fields. --- doc/guix.texi | 11 ++++++++--- gnu/services/dns.scm | 12 ++++++++---- 2 files changed, 16 insertions(+), 7 deletions(-) diff --git a/doc/guix.texi b/doc/guix.texi index eecc0aec52c..fd6a0176348 100644 --- a/doc/guix.texi +++ b/doc/guix.texi @@ -35172,9 +35172,14 @@ DNS Services @item @code{package} (default: @var{dnsmasq}) Package object of the dnsmasq server. -@item @code{provision} (default: @code{'(dnsmasq)}) -A list of symbols for the Shepherd service corresponding to this dnsmasq -configuration. +@item @code{shepherd-provision} (default: @code{'(dnsmasq)}) +@itemx @code{shepherd-requirement} (default: @code{'(user-processes networking)}) +This option can be used to provide a list of Shepherd service names +(symbols) provided by this service. You might want to change the default +value if you intend to run several @command{dnsmasq} instances. + +Likewise, @code{shepherd-requirement} is a list of Shepherd service names +(symbols) that this service will depend on. @item @code{no-hosts?} (default: @code{#f}) When true, don't read the hostnames in /etc/hosts. diff --git a/gnu/services/dns.scm b/gnu/services/dns.scm index 05291eb65d9..9276504ffd0 100644 --- a/gnu/services/dns.scm +++ b/gnu/services/dns.scm @@ -742,8 +742,10 @@ (define-record-type* dnsmasq-configuration? (package dnsmasq-configuration-package (default dnsmasq)) ;file-like - (provision dnsmasq-provision - (default '(dnsmasq))) + (shepherd-provision dnsmasq-configuration-shepherd-provision + (default '(dnsmasq))) + (shepherd-requirement dnsmasq-configuration-shepherd-requirement + (default '(user-processes networking))) (no-hosts? dnsmasq-configuration-no-hosts? (default #f)) ;boolean (port dnsmasq-configuration-port @@ -802,6 +804,8 @@ (define-record-type* (define (dnsmasq-shepherd-service config) (match-record config (package + shepherd-provision + shepherd-requirement no-hosts? port local-service? listen-addresses resolv-file no-resolv? @@ -815,8 +819,8 @@ (define (dnsmasq-shepherd-service config) tftp-lowercase? tftp-port-range tftp-root tftp-unique-root extra-options) (shepherd-service - (provision (dnsmasq-provision config)) - (requirement '(user-processes networking)) + (provision shepherd-provision) + (requirement shepherd-requirement) (documentation "Run the dnsmasq DNS server.") (start #~(make-forkexec-constructor (list -- 2.48.1 From debbugs-submit-bounces@debbugs.gnu.org Sun Mar 23 06:28:19 2025 Received: (at 77204) by debbugs.gnu.org; 23 Mar 2025 10:28:19 +0000 Received: from localhost ([127.0.0.1]:47816 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1twIZ0-0006GC-5U for submit@debbugs.gnu.org; Sun, 23 Mar 2025 06:28:19 -0400 Received: from mail.mmer.org ([178.22.65.174]:57980) by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1twIYl-0006Co-Nm for 77204@debbugs.gnu.org; Sun, 23 Mar 2025 06:28:08 -0400 Received: from mail.mmer.org (localhost [127.0.0.1]) by mail.mmer.org (OpenSMTPD) with ESMTP id 0999a66f for <77204@debbugs.gnu.org>; Sun, 23 Mar 2025 10:27:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed; d=mmer.org; h=from:to :subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; s=dkim; bh=5y4A3GRIfCOY0LjwBg+3T3se5 jzSHyW8aFz5ToPBT/Q=; b=63HWdeACuytkIhLMKzdwDAhmTcoyIL4RiTaXMUJH1 zPLuEuN1dXrPGbaOWAcQOgClMVr5Gevw5po9iT8KVLouKAE3+I6ll50+7lO1SE/3 RAOVFXRzyPlLb19vLnWDJbM5vMS0CKuFF2KZs9q/Hr3W59e50Uc1/rKRMkVQb+sZ Qo= Received: from delta (16-254-250-62.ftth.glasoperator.nl [62.250.254.16]) by mail.mmer.org (OpenSMTPD) with ESMTPSA id f62bf9f7 (TLSv1.3:TLS_AES_256_GCM_SHA384:256:NO) for <77204@debbugs.gnu.org>; Sun, 23 Mar 2025 10:27:54 +0000 (UTC) From: Alexey Abramov To: 77204@debbugs.gnu.org Subject: [PATCH 2/3] services: dnsmasq: Provide pid-file, conf-file and conf-dir configuration fields. Date: Sun, 23 Mar 2025 11:27:51 +0100 Message-ID: <84d4829a1add2c0960b36c4af3cb0ff2c240645f.1742725327.git.levenson@mmer.org> X-Mailer: git-send-email 2.48.1 In-Reply-To: References: MIME-Version: 1.0 X-Debbugs-Cc: Ludovic Courtès , Maxim Cournoyer Content-Transfer-Encoding: 8bit X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: 77204 X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) * doc/guix.texi: Document it. * gnu/services/dns.scm: Export all record accessors. * gnu/services/dns.scm ()[pid-file]: New field. * gnu/services/dns.scm ()[conf-file]: New field. * gnu/services/dns.scm ()[conf-dir]: New field. * gnu/services/dns.scm ()[extra-options]: Move it to the end of the definition, because it is a last resort. * gnu/services/dns.scm (dnsmasq-shepherd-service): Use newly-created fields. --- doc/guix.texi | 14 ++++ gnu/services/dns.scm | 162 +++++++++++++++++++++++++++---------------- 2 files changed, 117 insertions(+), 59 deletions(-) diff --git a/doc/guix.texi b/doc/guix.texi index fd6a0176348..a6996e30358 100644 --- a/doc/guix.texi +++ b/doc/guix.texi @@ -35181,6 +35181,9 @@ DNS Services Likewise, @code{shepherd-requirement} is a list of Shepherd service names (symbols) that this service will depend on. +@item @code{pid-file} (default: @code{"/run/dnsmasq.pid"}) +Specify an alternate path for dnsmasq to record its process-id in. + @item @code{no-hosts?} (default: @code{#f}) When true, don't read the hostnames in /etc/hosts. @@ -35301,6 +35304,17 @@ DNS Services resolving MAC addresses is only possible if the client is in the local network or obtained a DHCP lease from dnsmasq. +@item @code{conf-file} (default: @code{'()}) +Specify a configuration file or multiple. The given value should be a list of +string paths to the configuration files. File-like objects are also supported. + +@item @code{conf-dir} (default: @code{#f}) +Read all the files in the given directory as configuration +files. @command{dnsmasq} also supports extensions for the field, but +here it is not implemented. It is more convenient to make +@code{computed-file} directory in the store and use that. Files are +loaded in alphabetical order of filename. + @item @code{extra-options} (default: @code{'()}) This option provides an ``escape hatch'' for the user to provide arbitrary command-line arguments to @command{dnsmasq} as a list of strings. diff --git a/gnu/services/dns.scm b/gnu/services/dns.scm index 9276504ffd0..6e2ec7c2067 100644 --- a/gnu/services/dns.scm +++ b/gnu/services/dns.scm @@ -54,6 +54,38 @@ (define-module (gnu services dns) dnsmasq-service-type dnsmasq-configuration + dnsmasq-configuration-package + dnsmasq-configuration-shepherd-provision + dnsmasq-configuration-shepherd-requirement + dnsmasq-configuration-pid-file + dnsmasq-configuration-no-hosts? + dnsmasq-configuration-port + dnsmasq-configuration-local-service? + dnsmasq-configuration-listen-address + dnsmasq-configuration-resolv-file + dnsmasq-configuration-no-resolv? + dnsmasq-configuration-forward-private-reverse-lookup? + dnsmasq-configuration-query-servers-in-order? + dnsmasq-configuration-servers + dnsmasq-configuration-servers-file + dnsmasq-configuration-addresses + dnsmasq-configuration-cache-size + dnsmasq-configuration-negative-cache? + dnsmasq-configuration-cpe-id + dnsmasq-configuration-tftp-enable? + dnsmasq-configuration-tftp-no-fail? + dnsmasq-configuration-tftp-single-port? + dnsmasq-tftp-secure? + dnsmasq-tftp-max + dnsmasq-tftp-mtu + dnsmasq-tftp-no-blocksize? + dnsmasq-tftp-lowercase? + dnsmasq-tftp-port-range + dnsmasq-tftp-root + dnsmasq-tftp-unique-root + dnsmasq-configuration-conf-file + dnsmasq-configuration-conf-dir + dnsmasq-configuration-extra-options unbound-service-type unbound-configuration @@ -740,72 +772,77 @@ (define knot-resolver-service-type (define-record-type* dnsmasq-configuration make-dnsmasq-configuration dnsmasq-configuration? - (package dnsmasq-configuration-package - (default dnsmasq)) ;file-like + (package dnsmasq-configuration-package + (default dnsmasq)) ;file-like (shepherd-provision dnsmasq-configuration-shepherd-provision (default '(dnsmasq))) (shepherd-requirement dnsmasq-configuration-shepherd-requirement (default '(user-processes networking))) - (no-hosts? dnsmasq-configuration-no-hosts? - (default #f)) ;boolean - (port dnsmasq-configuration-port - (default 53)) ;integer - (local-service? dnsmasq-configuration-local-service? - (default #t)) ;boolean - (listen-addresses dnsmasq-configuration-listen-address - (default '())) ;list of string - (extra-options dnsmasq-configuration-extra-options - (default '())) ;list of string - (resolv-file dnsmasq-configuration-resolv-file - (default "/etc/resolv.conf")) ;string - (no-resolv? dnsmasq-configuration-no-resolv? - (default #f)) ;boolean + (pid-file dnsmasq-configuration-pid-file + (default "/run/dnsmasq.pid")) ;string + (no-hosts? dnsmasq-configuration-no-hosts? + (default #f)) ;boolean + (port dnsmasq-configuration-port + (default 53)) ;integer + (local-service? dnsmasq-configuration-local-service? + (default #t)) ;boolean + (listen-addresses dnsmasq-configuration-listen-address + (default '())) ;list of string + (resolv-file dnsmasq-configuration-resolv-file + (default "/etc/resolv.conf")) ;string + (no-resolv? dnsmasq-configuration-no-resolv? + (default #f)) ;boolean (forward-private-reverse-lookup? - dnsmasq-configuration-forward-private-reverse-lookup? - (default #t)) ;boolean - (query-servers-in-order? - dnsmasq-configuration-query-servers-in-order? - (default #f)) ;boolean - (servers dnsmasq-configuration-servers - (default '())) ;list of string - (servers-file dnsmasq-configuration-servers-file - (default #f)) ;string|file-like - (addresses dnsmasq-configuration-addresses - (default '())) ;list of string - (cache-size dnsmasq-configuration-cache-size - (default 150)) ;integer - (negative-cache? dnsmasq-configuration-negative-cache? - (default #t)) ;boolean - (cpe-id dnsmasq-configuration-cpe-id - (default #f)) ;string - (tftp-enable? dnsmasq-configuration-tftp-enable? - (default #f)) ;boolean - (tftp-no-fail? dnsmasq-configuration-tftp-no-fail? - (default #f)) ;boolean - (tftp-single-port? dnsmasq-configuration-tftp-single-port? - (default #f)) ;boolean - (tftp-secure? dnsmasq-tftp-secure? - (default #f)) ;boolean - (tftp-max dnsmasq-tftp-max - (default #f)) ;integer - (tftp-mtu dnsmasq-tftp-mtu - (default #f)) ;integer - (tftp-no-blocksize? dnsmasq-tftp-no-blocksize? - (default #f)) ;boolean - (tftp-lowercase? dnsmasq-tftp-lowercase? - (default #f)) ;boolean - (tftp-port-range dnsmasq-tftp-port-range - (default #f)) ;string - (tftp-root dnsmasq-tftp-root - (default "/var/empty,lo")) ;string - (tftp-unique-root dnsmasq-tftp-unique-root - (default #f))) ;"" or "ip" or "mac" - + dnsmasq-configuration-forward-private-reverse-lookup? + (default #t)) ;boolean + (query-servers-in-order? dnsmasq-configuration-query-servers-in-order? + (default #f)) ;boolean + (servers dnsmasq-configuration-servers + (default '())) ;list of string + (servers-file dnsmasq-configuration-servers-file + (default #f)) ;string|file-like + (addresses dnsmasq-configuration-addresses + (default '())) ;list of string + (cache-size dnsmasq-configuration-cache-size + (default 150)) ;integer + (negative-cache? dnsmasq-configuration-negative-cache? + (default #t)) ;boolean + (cpe-id dnsmasq-configuration-cpe-id + (default #f)) ;string + (tftp-enable? dnsmasq-configuration-tftp-enable? + (default #f)) ;boolean + (tftp-no-fail? dnsmasq-configuration-tftp-no-fail? + (default #f)) ;boolean + (tftp-single-port? dnsmasq-configuration-tftp-single-port? + (default #f)) ;boolean + (tftp-secure? dnsmasq-tftp-secure? + (default #f)) ;boolean + (tftp-max dnsmasq-tftp-max + (default #f)) ;integer + (tftp-mtu dnsmasq-tftp-mtu + (default #f)) ;integer + (tftp-no-blocksize? dnsmasq-tftp-no-blocksize? + (default #f)) ;boolean + (tftp-lowercase? dnsmasq-tftp-lowercase? + (default #f)) ;boolean + (tftp-port-range dnsmasq-tftp-port-range + (default #f)) ;string + (tftp-root dnsmasq-tftp-root + (default "/var/empty,lo")) ;string + (tftp-unique-root dnsmasq-tftp-unique-root + (default #f)) ;"" or "ip" or "mac" + (conf-file dnsmasq-configuration-conf-file + (default '())) ;list of string|file-like + (conf-dir dnsmasq-configuration-conf-dir + (default #f)) ;string|file-like + (extra-options dnsmasq-configuration-extra-options + (default '()))) (define (dnsmasq-shepherd-service config) (match-record config (package shepherd-provision shepherd-requirement + pid-file no-hosts? port local-service? listen-addresses resolv-file no-resolv? @@ -817,7 +854,8 @@ (define (dnsmasq-shepherd-service config) tftp-single-port? tftp-secure? tftp-max tftp-mtu tftp-no-blocksize? tftp-lowercase? tftp-port-range - tftp-root tftp-unique-root extra-options) + tftp-root tftp-unique-root + conf-file conf-dir extra-options) (shepherd-service (provision shepherd-provision) (requirement shepherd-requirement) @@ -826,7 +864,7 @@ (define (dnsmasq-shepherd-service config) (list #$(file-append package "/sbin/dnsmasq") "--keep-in-foreground" - "--pid-file=/run/dnsmasq.pid" + (string-append "--pid-file=" #$pid-file) #$@(if no-hosts? '("--no-hosts") '()) @@ -897,8 +935,14 @@ (define (dnsmasq-shepherd-service config) (format #f "--tftp-unique-root=~a" tftp-unique-root) (format #f "--tftp-unique-root"))) '()) + #$@(map (lambda (conf-file) + #~(string-append "--conf-file=" #$conf-file)) + conf-file) + #$@(if conf-dir + (list #~(string-append "--conf-dir=" #$conf-dir)) + '()) #$@extra-options) - #:pid-file "/run/dnsmasq.pid")) + #:pid-file #$pid-file)) (stop #~(make-kill-destructor))))) (define (dnsmasq-activation config) -- 2.48.1 From debbugs-submit-bounces@debbugs.gnu.org Sun Mar 23 06:28:20 2025 Received: (at 77204) by debbugs.gnu.org; 23 Mar 2025 10:28:20 +0000 Received: from localhost ([127.0.0.1]:47818 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1twIZ1-0006GN-HB for submit@debbugs.gnu.org; Sun, 23 Mar 2025 06:28:20 -0400 Received: from mail.mmer.org ([178.22.65.174]:52648) by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1twIYq-0006Dx-1U for 77204@debbugs.gnu.org; Sun, 23 Mar 2025 06:28:12 -0400 Received: from mail.mmer.org (localhost [127.0.0.1]) by mail.mmer.org (OpenSMTPD) with ESMTP id a7476dc5 for <77204@debbugs.gnu.org>; Sun, 23 Mar 2025 10:27:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed; d=mmer.org; h=from:to :subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; s=dkim; bh=9QW5hBEOsyjJQR9wIafBpV6R6 VdGlnwwVOxlf+Sk1R8=; b=N5HqafytSVTXIsB+n30okupWVcn8tyUeNxP14PYfC QQQpAb+tC6azCP5JTWY+yMDBtYiWwFy12vdFb1ReJpHmbxpXv65Y7xWfglh9rPKE VXJy/p+l8q4fRg9SoWqeFFSBnxTnAGOYpbrlnN9rW5uGTjhbj73s98nk/SC8bFfj yQ= Received: from delta (16-254-250-62.ftth.glasoperator.nl [62.250.254.16]) by mail.mmer.org (OpenSMTPD) with ESMTPSA id ec96279c (TLSv1.3:TLS_AES_256_GCM_SHA384:256:NO) for <77204@debbugs.gnu.org>; Sun, 23 Mar 2025 10:27:54 +0000 (UTC) From: Alexey Abramov To: 77204@debbugs.gnu.org Subject: [PATCH 3/3] services: dnsmasq: Provide stats and reload actions. Date: Sun, 23 Mar 2025 11:27:52 +0100 Message-ID: <2769b5461f5882a9429042aa5650ba1a982fdfff.1742725327.git.levenson@mmer.org> X-Mailer: git-send-email 2.48.1 In-Reply-To: References: MIME-Version: 1.0 X-Debbugs-Cc: Ludovic Courtès , Maxim Cournoyer Content-Transfer-Encoding: 8bit X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: 77204 X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) * gnu/services/dns.scm (dnsmasq-service-reload-action) (dnsmasq-service-stats-action): New functions. * doc/guix.texi: Document the change. * gnu/tests/networking.scm: Add tests. --- doc/guix.texi | 10 ++++ gnu/services/dns.scm | 22 +++++++++ gnu/tests/networking.scm | 98 ++++++++++++++++++++++++++++++++++++++++ 3 files changed, 130 insertions(+) diff --git a/doc/guix.texi b/doc/guix.texi index a6996e30358..1583ad36c89 100644 --- a/doc/guix.texi +++ b/doc/guix.texi @@ -35165,6 +35165,16 @@ DNS Services @end lisp @end defvar +@code{dnsmasq-service-type} also provides few helpful actions which are +@code{reload} and @code{stats}. For example: + +@example +herd stats dnsmasq +@end example + +Will ask @command{dnsmasq} service to dump its statistics to the system log, which +is usually @file{/var/log/messages}. + @deftp {Data Type} dnsmasq-configuration Data type representing the configuration of dnsmasq. diff --git a/gnu/services/dns.scm b/gnu/services/dns.scm index 6e2ec7c2067..a091dbfb86c 100644 --- a/gnu/services/dns.scm +++ b/gnu/services/dns.scm @@ -860,6 +860,8 @@ (define (dnsmasq-shepherd-service config) (provision shepherd-provision) (requirement shepherd-requirement) (documentation "Run the dnsmasq DNS server.") + (actions (list (dnsmasq-service-reload-action config) + (dnsmasq-service-stats-action config))) (start #~(make-forkexec-constructor (list #$(file-append package "/sbin/dnsmasq") @@ -951,6 +953,26 @@ (define (dnsmasq-activation config) ;; create directory to store dnsmasq lease file (mkdir-p "/var/lib/misc"))) +(define (dnsmasq-service-reload-action config) + (match-record config () + (shepherd-action + (name 'reload) + (documentation "Send a SIGHUP signal to re-load /etc/hosts and /etc/ethers and any +file given by --dhcp-hostsfile, --dhcp-hostsdir, --dhcp-optsfile, --dhcp-optsdir, +--addn-hosts or --hostsdir. SIGHUP does NOT re-read the configuration file.") + (procedure #~(lambda (running) + (let ((pid (process-id running))) + (kill pid SIGHUP))))))) + +(define (dnsmasq-service-stats-action config) + (match-record config () + (shepherd-action + (name 'stats) + (documentation "Send a SIGUSR1 to write statistics to the system log.") + (procedure #~(lambda (running) + (let ((pid (process-id running))) + (kill pid SIGUSR1))))))) + (define dnsmasq-service-type (service-type (name 'dnsmasq) diff --git a/gnu/tests/networking.scm b/gnu/tests/networking.scm index 7d54ebba50e..fdc515ceb04 100644 --- a/gnu/tests/networking.scm +++ b/gnu/tests/networking.scm @@ -27,6 +27,7 @@ (define-module (gnu tests networking) #:use-module (gnu system vm) #:use-module (gnu services) #:use-module (gnu services base) + #:use-module (gnu services dns) #:use-module (gnu services networking) #:use-module (guix gexp) #:use-module (guix store) @@ -46,6 +47,7 @@ (define-module (gnu tests networking) %test-openvswitch %test-dhcpd %test-dhcpcd + %test-dnsmasq %test-tor %test-iptables %test-ipfs)) @@ -675,6 +677,102 @@ (define %test-dhcpd (description "Test a running DHCP daemon configuration.") (value (run-dhcpd-test)))) + + +;;; +;;; dnsmasq tests +;;; + + +(define dnsmasq-os-configuration + (dnsmasq-configuration)) + +(define %dnsmasq-os + (simple-operating-system + (service dhcp-client-service-type) + (service dnsmasq-service-type + (dnsmasq-configuration + (extra-options + (list "--log-facility=/tmp/dnsmasq.log")))))) + + +(define (run-dnsmasq-test) + (define os + (marionette-operating-system %dnsmasq-os + #:imported-modules '((gnu services herd)))) + + (define test + (with-imported-modules '((gnu build marionette)) + #~(begin + (use-modules (gnu build marionette) + (srfi srfi-64)) + + (define marionette + (make-marionette (list #$(virtual-machine os)))) + + (test-runner-current (system-test-runner #$output)) + (test-begin "dnsmasq") + + (test-assert "dnsmasq is alive" + (marionette-eval + '(begin + (use-modules (gnu services herd)) + (wait-for-service 'dnsmasq)) + marionette)) + + (test-assert "pid file exists" + (wait-for-file + '#$(dnsmasq-configuration-pid-file dnsmasq-os-configuration) + marionette)) + + (test-assert "send SIGHUP" + (positive? + (marionette-eval + '(begin + (use-modules (ice-9 rdelim)) + (system* "sync") + (let* ((port (open-input-file "/tmp/dnsmasq.log"))) + (seek port 0 SEEK_END) + (system* "herd" "reload" "dnsmasq") + (system* "sync") + (let ((line (read-line port))) + (close-port port) + (string-contains line "read /etc/hosts")))) + marionette))) + + (test-assert "send SIGUSR1" + (positive? + (marionette-eval + '(begin + (use-modules (ice-9 rdelim)) + (system* "sync") + (let* ((port (open-input-file "/tmp/dnsmasq.log"))) + (seek port 0 SEEK_END) + (system* "herd" "stats" "dnsmasq") + (system* "sync") + (let ((line (read-line port))) + (close-port port) + (string-contains-ci line "time")))) + marionette))) + + (test-assert "dnsmasq is alive" + (marionette-eval + '(begin + (use-modules (gnu services herd)) + (wait-for-service 'dnsmasq)) + marionette)) + + (test-end)))) + + (gexp->derivation "dnsmasq-test" test)) + +(define %test-dnsmasq + (system-test + (name "dnsmasq") + (description "Test a running dnsmasq daemon configuration.") + (value (run-dnsmasq-test)))) + + ;;; ;;; DHCPCD Daemon -- 2.48.1 From debbugs-submit-bounces@debbugs.gnu.org Sun Mar 23 06:51:04 2025 Received: (at 77204) by debbugs.gnu.org; 23 Mar 2025 10:51:05 +0000 Received: from localhost ([127.0.0.1]:47920 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1twIv0-0007EU-37 for submit@debbugs.gnu.org; Sun, 23 Mar 2025 06:51:04 -0400 Received: from mail-pl1-x643.google.com ([2607:f8b0:4864:20::643]:44167) by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.84_2) (envelope-from <45mg.writes@gmail.com>) id 1twIuv-0007Cs-NU for 77204@debbugs.gnu.org; Sun, 23 Mar 2025 06:50:59 -0400 Received: by mail-pl1-x643.google.com with SMTP id d9443c01a7336-2255003f4c6so64459915ad.0 for <77204@debbugs.gnu.org>; Sun, 23 Mar 2025 03:50:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1742727051; x=1743331851; darn=debbugs.gnu.org; h=mime-version:message-id:date:references:in-reply-to:subject:cc:to :from:from:to:cc:subject:date:message-id:reply-to; bh=x4BpKiesdIXb4qdaKbWEZHXnM6UZRVZFN9fk5DBnTUo=; b=D34MAszx9ksOosGQWJOaXF7NkfIOAL4scXBvuyTZgsE8oG4YpbVByhZIHK8NCwW0K6 OQASJPGMDk7bWyENJKTGJWlyhX3MwOqGCRmhdz2bzTUQtgtgvSrbPD7dQeA1I1SPB6yS wLe/RiYZcM3oONPuZPbwjD7+vsyA/tr9cUKGnNQ7g82UGncpoUW9hMcWYeqfilUiZ1AJ +RFt0lj78waTK1altJGTgkIC1lUsANIQQOtUtAlz+qMS7bjwVN7nteTUJvVVPqoNU61t HO2vLMGSdzRv+sl/WSOlq2XKZUR+YrhvIMr/QDVGD1+fgOMhIvxu6R7kY/Bp3mbR8GWs j/Xg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1742727051; x=1743331851; h=mime-version:message-id:date:references:in-reply-to:subject:cc:to :from:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=x4BpKiesdIXb4qdaKbWEZHXnM6UZRVZFN9fk5DBnTUo=; b=La7H/c0a1fMQxevdm5nQ1KIa++pMxCky56bzbMNQgVo49GICgEeVvG2BgAJzZ71EwJ WmZJ9/XPfgWI6bQLs8lQHL+HHlpP3rkpnk44b7wRQ0i4c/oiC+rxte/+7YXWgBoKrCFf hsCs6AnWQZKHMcsyykoHDwxPa7zZ1lPXNDO7ASfJymj7xhGVXw0G/OX0R1WIiv9j9oia sEfv4IhGEQySJpYNle/KgUiqD4yi3QZjK7uSKRXuSB2FLqcRg+c6oDgkTc7oQbaZw7VB qqHLTilPP3smA1wCh4Kgg3L9yYQtAtfbI8dSg+6Xj+SZjtgQEzl43rkg92bkJdlQoMZE +RYg== X-Forwarded-Encrypted: i=1; AJvYcCVgmNrouDYsGLzlRF/ng1nidW/hZVJE05mPIwVRuz431JlFzjQpFCRPIKjLU+djNjqrfUMp0w==@debbugs.gnu.org X-Gm-Message-State: AOJu0Yxn0KtipRBUKpmeqisaaQovd0LK2VyVdFj+uvH0Y5BtSnXsnZoa oES6xu42UVQFJX3LM0rroYAPmAGPnCDyuo8YpDo3zYxuiJ/nQggYdXBx/o7P X-Gm-Gg: ASbGnctaQ9YDOiRn+a+B/tXeJikSD66qba0In2kPlGGO2OhCtRNMZ1G4qcxLHPn2hwr 8T/6gQUoq/6K0tb0LFfj2SB0q5twZdAeAeyaMXA/l3rQ5wxvvOJZlCPCK1ajLfx3OJhX81e4RQr 3jUTrV5RZKkPDcjpm/fukt3wdAm9U2en5zOVlZ2ArW3sGvmzhna2ry2i4ra5/08FzcduQekwU1g lMMYU4ZixP+x4Tt698RWZiX/Sc7CgeQikGBHLtrl2Hi4ooackbT7CJvHBZq8YnxvlzarmqBimxy OqbyCXgyeIfdYp25olA3lFfpmbZ5FpF/DjNNgQ9Han3T8w== X-Google-Smtp-Source: AGHT+IEYyMIXw6MeZ9Zf6QRjfDrex9C9JASMalzd93XYK37Vr+W2T+i5Aw0OVuSpDSbikEavGDrkeA== X-Received: by 2002:a05:6a21:6e01:b0:1f3:3804:9740 with SMTP id adf61e73a8af0-1fe42f2ccb6mr15223120637.15.1742727051601; Sun, 23 Mar 2025 03:50:51 -0700 (PDT) Received: from guix1 (utm3.nitt.edu. [14.139.162.2]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-7390611d573sm5692576b3a.100.2025.03.23.03.50.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 23 Mar 2025 03:50:51 -0700 (PDT) From: 45mg <45mg.writes@gmail.com> To: Alexey Abramov , 77204@debbugs.gnu.org Subject: Re: [bug#77204] [PATCH 1/3] services: dnsmasq: Provide shepherd-provision and shepherd-requirement fields. In-Reply-To: <242697cdc4ed0e257df4ba35500ae2a3b3a00a0b.1742725327.git.levenson@mmer.org> References: <242697cdc4ed0e257df4ba35500ae2a3b3a00a0b.1742725327.git.levenson@mmer.org> Date: Sun, 23 Mar 2025 10:50:47 +0000 Message-ID: <878qowm35k.fsf@gmail.com> MIME-Version: 1.0 Content-Type: text/plain X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: 77204 Cc: Ludovic =?utf-8?Q?Court=C3=A8s?= , Maxim Cournoyer X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) Hi, Alexey Abramov via Guix-patches via writes: > * gnu/services/dns.scm ()[provision]: Rename the field to > [shepherd-provision] for consistency with other services. If this is accepted, you'll probably need to add an entry to etc/news.scm, since it's a breaking change. You'll also need to update the Guix Cookbook. Specifically, the recent commit da090138028894c6b00c21730aa3a02cda57fb24 uses the existing 'provision' field of `dnsmasq-service-type` in an example. With that said, I think the rename is a sensible change. (Just in case it matters, I was the one who introduced the 'provision' field, as well as that Cookbook example). From debbugs-submit-bounces@debbugs.gnu.org Sun Mar 23 08:28:44 2025 Received: (at 77204) by debbugs.gnu.org; 23 Mar 2025 12:28:44 +0000 Received: from localhost ([127.0.0.1]:48064 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1twKRX-00007A-E1 for submit@debbugs.gnu.org; Sun, 23 Mar 2025 08:28:44 -0400 Received: from mail.mmer.org ([178.22.65.174]:46940) by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1twKRT-00005P-H6 for 77204@debbugs.gnu.org; Sun, 23 Mar 2025 08:28:41 -0400 Received: from mail.mmer.org (localhost [127.0.0.1]) by mail.mmer.org (OpenSMTPD) with ESMTP id 0fa52525; Sun, 23 Mar 2025 12:28:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed; d=mmer.org; h=from:to:cc :subject:in-reply-to:references:date:message-id:mime-version :content-type; s=dkim; bh=U8FBbcLBybbecEfJfyvnLm8zL3eSgM98mSI6D+ cPpJ0=; b=T8LkFFutEV53egVZ7qQxFYSPqESTNvLn2k3NfB4iVEy+ZdEvdxeL76 +Es1mCmg+suUp6OK43M+/UOJPVtfQnxz8trVKEMXZy4lhiyP5KUOr0la01PlZyeq wvaaJy0an/oX7wzP8HpIwVh0qzghzWIc/3PTk1X4ENbM6YU6C3X0Y= Received: from zeta.lan ( [10.147.19.24]) by mail.mmer.org (OpenSMTPD) with ESMTPSA id a89b2f0b (TLSv1.3:TLS_AES_256_GCM_SHA384:256:NO); Sun, 23 Mar 2025 12:28:30 +0000 (UTC) From: Alexey Abramov To: 45mg <45mg.writes@gmail.com> Subject: Re: [bug#77204] [PATCH 1/3] services: dnsmasq: Provide shepherd-provision and shepherd-requirement fields. In-Reply-To: <878qowm35k.fsf@gmail.com> (45mg.writes@gmail.com's message of "Sun, 23 Mar 2025 10:50:47 +0000") References: <242697cdc4ed0e257df4ba35500ae2a3b3a00a0b.1742725327.git.levenson@mmer.org> <878qowm35k.fsf@gmail.com> Date: Sun, 23 Mar 2025 13:28:29 +0100 Message-ID: <87wmcg2aoi.fsf@zeta.lan> User-Agent: Gnus/5.13 (Gnus v5.13) MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: 77204 Cc: Ludovic =?utf-8?Q?Court=C3=A8s?= , Maxim Cournoyer , 77204@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) --=-=-= Content-Type: text/plain Hi, 45mg <45mg.writes@gmail.com> writes: > Hi, > > Alexey Abramov via Guix-patches via writes: > >> * gnu/services/dns.scm ()[provision]: Rename the field to >> [shepherd-provision] for consistency with other services. > > If this is accepted, you'll probably need to add an entry to > etc/news.scm, since it's a breaking change. > > You'll also need to update the Guix Cookbook. Specifically, the recent > commit da090138028894c6b00c21730aa3a02cda57fb24 uses the existing > 'provision' field of `dnsmasq-service-type` in an example. Thanks for letting me know. > With that said, I think the rename is a sensible change. (Just in case > it matters, I was the one who introduced the 'provision' field, as well > as that Cookbook example). I see. I guess there are not that many users who overrides provision for dnsmasq at the moment. AFAIK we do want shepherd-provision and shepherd-requirement insead of just provision/requirement. I have this script (see attachements) and run it withing the repo as ./pre-inst-env guix repl guix-services-info.scm --8<---------------cut here---------------start------------->8--- ( (provision requirement)) ( (shepherd-requirement)) ( (shepherd-requirement)) ( (requirement)) ( (shepherd-requirement)) ( (shepherd-requirement)) ( (provision requirement)) ( (provision)) ( (provision requirement)) ( (provision requirement)) ( (shepherd-requirement)) ( (shepherd-requirement)) ( (shepherd-requirement)) ( (requirement)) ( (shepherd-requirement shepherd-provision)) ( (provision requirement)) ( (provision requirement)) ( (shepherd)) ( (shepherd-requirement)) ( (shepherd-requirement)) ( (shepherd)) --8<---------------cut here---------------end--------------->8--- I will add the change for the cookbook no problem. Regarding the news, I am not sure if I can do this, because it requires 'commit'. -- Alexey --=-=-= Content-Type: application/octet-stream Content-Disposition: attachment; filename=guix-services-info.scm Content-Transfer-Encoding: base64 Ozs7IGd1aXgtc2VydmljZXMtaW5mby5zY20gLS0tCgoodXNlLW1vZHVsZXMgKHNyZmkgc3JmaS0x KQogICAgICAgICAgICAgKHNyZmkgc3JmaS0yKQogICAgICAgICAgICAgKGljZS05IGZ0dykpCgoo ZGVmaW5lIChyZWQgc3RyaW5nKQogIChmb3JtYXQgI2YgIlx4MWJbfmRtfkFceDFiWzBtIiAzMSBz dHJpbmcpKQooZGVmaW5lIChncmVlbiBzdHJpbmcpCiAgKGZvcm1hdCAjZiAiXHgxYlt+ZG1+QVx4 MWJbMG0iIDMyIHN0cmluZykpCihkZWZpbmUgKHllbGxvdyBzdHJpbmcpCiAgKGZvcm1hdCAjZiAi XHgxYlt+ZG1+QVx4MWJbMG0iIDMzIHN0cmluZykpCihkZWZpbmUgKG1hZ2VudGEgc3RyaW5nKQog IChmb3JtYXQgI2YgIlx4MWJbfmRtfkFceDFiWzBtIiA0NSBzdHJpbmcpKQoKKGRlZmluZSBnbnUt c2VydmljZXMtbW9kdWxlcwogIChmaWx0ZXItbWFwIChsYW1iZGEgKGZpbGUpCiAgICAgICAgICAg ICAgICAoaWYgKG9yIChzdHJpbmc9PyAiLiIgZmlsZSkKICAgICAgICAgICAgICAgICAgICAgICAg KHN0cmluZz0/ICIuLiIgZmlsZSkKICAgICAgICAgICAgICAgICAgICAgICAgOzsgQXZvaWQgbWF0 Y2hpbmcgd2l0aCBzb21lIHRlbXAgZmlsZXMKICAgICAgICAgICAgICAgICAgICAgICAgKHN0cmlu Zy1zdWZmaXgtY2k/ICIuc2NtIiBmaWxlKSkKICAgICAgICAgICAgICAgICAgICAjZgogICAgICAg ICAgICAgICAgICAgIChzdHJpbmctPnN5bWJvbCAoYmFzZW5hbWUgZmlsZSAiLmdvIikpKSkKICAg ICAgICAgICAgICAoc2NhbmRpciAoc3RyaW5nLWFwcGVuZCAoZ2V0Y3dkKSAiL2dudS9zZXJ2aWNl cyIpKSkpCgooZGVmaW5lIChpbnNwZWN0LXJlY29yZCByKQogIChsZXQqICgobmFtZSAocmVjb3Jk LXR5cGUtbmFtZSByKSkKICAgICAgICAgKGZpZWxkcyAocmVjb3JkLXR5cGUtZmllbGRzIHIpKQog ICAgICAgICAocHJvdmlzaW9uL3JlcXVpcmVtZW50LWZpZWxkCiAgICAgICAgICAoZmlsdGVyLW1h cCAobGFtYmRhIChmaWVsZCkKICAgICAgICAgICAgICAgICAgICAgICAgKGNhc2UgZmllbGQKICAg ICAgICAgICAgICAgICAgICAgICAgICAoKHNoZXBoZXJkLXByb3Zpc2lvbiBzaGVwaGVyZC1yZXF1 aXJlbWVudCkKICAgICAgICAgICAgICAgICAgICAgICAgICAgKGdyZWVuIChzeW1ib2wtPnN0cmlu ZyBmaWVsZCkpKQogICAgICAgICAgICAgICAgICAgICAgICAgICgocHJvdmlzaW9uIHJlcXVpcmVt ZW50KQogICAgICAgICAgICAgICAgICAgICAgICAgICAocmVkIChzeW1ib2wtPnN0cmluZyBmaWVs ZCkpKQogICAgICAgICAgICAgICAgICAgICAgICAgICgoc2hlcGhlcmQpCiAgICAgICAgICAgICAg ICAgICAgICAgICAgIChtYWdlbnRhIChzeW1ib2wtPnN0cmluZyBmaWVsZCkpKQogICAgICAgICAg ICAgICAgICAgICAgICAgIChlbHNlICNmKSkpCiAgICAgICAgICAgICAgICAgICAgICBmaWVsZHMp KSkKICAgICh1bmxlc3MgKG51bGw/IHByb3Zpc2lvbi9yZXF1aXJlbWVudC1maWVsZCkKICAgICAg KGRpc3BsYXkgKGxpc3QgKHllbGxvdyBuYW1lKSBwcm92aXNpb24vcmVxdWlyZW1lbnQtZmllbGQp KQogICAgICAobmV3bGluZSkpKSkKCihkZWZpbmUgKG1vZHVsZS1mb3ItZWFjaC1yZWNvcmQtdHlw ZSBwcm9jIG1vZHVsZSkKICAobW9kdWxlLWZvci1lYWNoIChsYW1iZGEgKF8gdmFyaWFibGUpCiAg ICAgICAgICAgICAgICAgICAgIChhbmQtbGV0KiAoKGZhbHNlLWlmLWV4Y2VwdGlvbiAodmFyaWFi bGUtYm91bmQ/IHZhcmlhYmxlKSkKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAodmFs dWUgKHZhcmlhYmxlLXJlZiB2YXJpYWJsZSkpCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAg ICAgKGZhbHNlLWlmLWV4Y2VwdGlvbiAocmVjb3JkLXR5cGU/IHZhbHVlKSkpCiAgICAgICAgICAg ICAgICAgICAgICAgKHByb2MgdmFsdWUpKSkKICAgICAgICAgICAgICAgICAgIG1vZHVsZSkpCgoK KGZvci1lYWNoIChsYW1iZGEgKHNlcnZpY2UpCiAgICAgICAgICAgIChsZXQgKChtb2R1bGUgKHJl c29sdmUtbW9kdWxlIGAoZ251IHNlcnZpY2VzICxzZXJ2aWNlKSkpKQogICAgICAgICAgICAgICht b2R1bGUtZm9yLWVhY2gtcmVjb3JkLXR5cGUgaW5zcGVjdC1yZWNvcmQgbW9kdWxlKSkpCiAgICAg ICAgICBnbnUtc2VydmljZXMtbW9kdWxlcykKCgo7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7 Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Cjs7OyBndWl4LXNlcnZp Y2VzLWluZm8uc2NtIGVuZHMgaGVyZQo= --=-=-=-- From debbugs-submit-bounces@debbugs.gnu.org Sun Mar 23 09:03:55 2025 Received: (at 77204) by debbugs.gnu.org; 23 Mar 2025 13:03:55 +0000 Received: from localhost ([127.0.0.1]:48153 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1twKza-0000I2-CH for submit@debbugs.gnu.org; Sun, 23 Mar 2025 09:03:55 -0400 Received: from mail.mmer.org ([178.22.65.174]:38658) by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1twKzX-0000GI-0h for 77204@debbugs.gnu.org; Sun, 23 Mar 2025 09:03:51 -0400 Received: from mail.mmer.org (localhost [127.0.0.1]) by mail.mmer.org (OpenSMTPD) with ESMTP id e1011d34 for <77204@debbugs.gnu.org>; Sun, 23 Mar 2025 13:03:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed; d=mmer.org; h=from:to :subject:date:message-id:mime-version:content-transfer-encoding; s=dkim; bh=2RSh+l9bZM1aCI/A39yMHhztCyQQdoc3AwDEVSh0GZs=; b=DI0l K4wYNXkZ8gsp0aX+dR/SKLZWgT6pR+uW7cwBWDs9GjTGfv6KkRmC2EcKERUqoTy4 T5ChkVU/sD9//1hPF2YB8/NxYuDRJHfKo2P/1hFb2Ufj0LPEQJfIeSv5Y7hC6JfF n1vv7bxj4KWfRHMmQbIrqXqJ342XoJd8NWVt8x8= Received: from delta (16-254-250-62.ftth.glasoperator.nl [62.250.254.16]) by mail.mmer.org (OpenSMTPD) with ESMTPSA id b2b55d93 (TLSv1.3:TLS_AES_256_GCM_SHA384:256:NO) for <77204@debbugs.gnu.org>; Sun, 23 Mar 2025 13:03:42 +0000 (UTC) From: Alexey Abramov To: 77204@debbugs.gnu.org Subject: [PATCH v2 0/3] dnsmasq service changes Date: Sun, 23 Mar 2025 14:00:51 +0100 Message-ID: X-Mailer: git-send-email 2.48.1 MIME-Version: 1.0 X-Debbugs-Cc: Ludovic Courtès , Maxim Cournoyer Content-Transfer-Encoding: 8bit X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: 77204 X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) The difference between v1 and v2 is a small change to the guix-cookbook where I change provision to shepherd-provision field. Alexey Abramov (3): services: dnsmasq: Provide shepherd-provision and shepherd-requirement fields. services: dnsmasq: Provide pid-file, conf-file and conf-dir configuration fields. services: dnsmasq: Provide stats and reload actions. doc/guix-cookbook.texi | 4 +- doc/guix.texi | 35 ++++++- gnu/services/dns.scm | 196 ++++++++++++++++++++++++++------------- gnu/tests/networking.scm | 98 ++++++++++++++++++++ 4 files changed, 265 insertions(+), 68 deletions(-) base-commit: 4ea012fc6ddcb32574fbd4a854b11808c34fbca8 -- 2.48.1 From debbugs-submit-bounces@debbugs.gnu.org Sun Mar 23 09:04:13 2025 Received: (at 77204) by debbugs.gnu.org; 23 Mar 2025 13:04:13 +0000 Received: from localhost ([127.0.0.1]:48158 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1twKzs-0000Ky-B9 for submit@debbugs.gnu.org; Sun, 23 Mar 2025 09:04:13 -0400 Received: from mail.mmer.org ([178.22.65.174]:38658) by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1twKzY-0000GI-8E for 77204@debbugs.gnu.org; Sun, 23 Mar 2025 09:03:53 -0400 Received: from mail.mmer.org (localhost [127.0.0.1]) by mail.mmer.org (OpenSMTPD) with ESMTP id 736852d5 for <77204@debbugs.gnu.org>; Sun, 23 Mar 2025 13:03:43 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed; d=mmer.org; h=from:to :subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; s=dkim; bh=dRi8RcgD1EP48s9FzDoF3aujQ dDnzYg7duPbtZy63DE=; b=OqF6xiqgMew6SQ7iwH4oNHOTS+RA34ietiLXNJZJT Ws488F6MSSEMN4eqhoPIhCa8Qo1tQO7YnGIzheuHjS337aLjUbemkFiwzSziWLoK B2faH2V0AxUNZI6YZ4fAbPZMWhQwviGF2fRmGCHTLWTrzSgImyjzmQM3Dnu1Hbdc xM= Received: from delta (16-254-250-62.ftth.glasoperator.nl [62.250.254.16]) by mail.mmer.org (OpenSMTPD) with ESMTPSA id f6a4121d (TLSv1.3:TLS_AES_256_GCM_SHA384:256:NO) for <77204@debbugs.gnu.org>; Sun, 23 Mar 2025 13:03:42 +0000 (UTC) From: Alexey Abramov To: 77204@debbugs.gnu.org Subject: [PATCH v2 1/3] services: dnsmasq: Provide shepherd-provision and shepherd-requirement fields. Date: Sun, 23 Mar 2025 14:00:52 +0100 Message-ID: X-Mailer: git-send-email 2.48.1 In-Reply-To: References: MIME-Version: 1.0 X-Debbugs-Cc: Ludovic Courtès , Maxim Cournoyer Content-Transfer-Encoding: 8bit X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: 77204 X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) * doc/guix.texi: Document the change. * gnu/services/dns.scm ()[provision]: Rename the field to [shepherd-provision] for consistency with other services. * gnu/services/dns.scm ()[shepherd-requirement]: New field. * gnu/services/dns.scm (dnsmasq-shepherd-service): Use newly-created fields. * doc/guix-cookbook.texi (Custom NAT-based network for libvirt): Rename `provision' field record to shepherd-provision. --- doc/guix-cookbook.texi | 4 ++-- doc/guix.texi | 11 ++++++++--- gnu/services/dns.scm | 12 ++++++++---- 3 files changed, 18 insertions(+), 9 deletions(-) diff --git a/doc/guix-cookbook.texi b/doc/guix-cookbook.texi index fe4cac79c3a..d4832b9bb40 100644 --- a/doc/guix-cookbook.texi +++ b/doc/guix-cookbook.texi @@ -4031,8 +4031,8 @@ Custom NAT-based network for libvirt (service dnsmasq-service-type (dnsmasq-configuration ;; You can have multiple instances of `dnsmasq-service-type` as long - ;; as each one has a different provision. - (provision '(dnsmasq-virbr0)) + ;; as each one has a different shepherd-provision. + (shepherd-provision '(dnsmasq-virbr0)) (extra-options (list ;; Only bind to the virtual bridge. This ;; avoids conflicts with other running diff --git a/doc/guix.texi b/doc/guix.texi index bcb1f9d9cf8..90fa6779657 100644 --- a/doc/guix.texi +++ b/doc/guix.texi @@ -35067,9 +35067,14 @@ DNS Services @item @code{package} (default: @var{dnsmasq}) Package object of the dnsmasq server. -@item @code{provision} (default: @code{'(dnsmasq)}) -A list of symbols for the Shepherd service corresponding to this dnsmasq -configuration. +@item @code{shepherd-provision} (default: @code{'(dnsmasq)}) +@itemx @code{shepherd-requirement} (default: @code{'(user-processes networking)}) +This option can be used to provide a list of Shepherd service names +(symbols) provided by this service. You might want to change the default +value if you intend to run several @command{dnsmasq} instances. + +Likewise, @code{shepherd-requirement} is a list of Shepherd service names +(symbols) that this service will depend on. @item @code{no-hosts?} (default: @code{#f}) When true, don't read the hostnames in /etc/hosts. diff --git a/gnu/services/dns.scm b/gnu/services/dns.scm index 05291eb65d9..9276504ffd0 100644 --- a/gnu/services/dns.scm +++ b/gnu/services/dns.scm @@ -742,8 +742,10 @@ (define-record-type* dnsmasq-configuration? (package dnsmasq-configuration-package (default dnsmasq)) ;file-like - (provision dnsmasq-provision - (default '(dnsmasq))) + (shepherd-provision dnsmasq-configuration-shepherd-provision + (default '(dnsmasq))) + (shepherd-requirement dnsmasq-configuration-shepherd-requirement + (default '(user-processes networking))) (no-hosts? dnsmasq-configuration-no-hosts? (default #f)) ;boolean (port dnsmasq-configuration-port @@ -802,6 +804,8 @@ (define-record-type* (define (dnsmasq-shepherd-service config) (match-record config (package + shepherd-provision + shepherd-requirement no-hosts? port local-service? listen-addresses resolv-file no-resolv? @@ -815,8 +819,8 @@ (define (dnsmasq-shepherd-service config) tftp-lowercase? tftp-port-range tftp-root tftp-unique-root extra-options) (shepherd-service - (provision (dnsmasq-provision config)) - (requirement '(user-processes networking)) + (provision shepherd-provision) + (requirement shepherd-requirement) (documentation "Run the dnsmasq DNS server.") (start #~(make-forkexec-constructor (list -- 2.48.1 From debbugs-submit-bounces@debbugs.gnu.org Sun Mar 23 09:04:15 2025 Received: (at 77204) by debbugs.gnu.org; 23 Mar 2025 13:04:15 +0000 Received: from localhost ([127.0.0.1]:48160 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1twKzt-0000L5-C7 for submit@debbugs.gnu.org; Sun, 23 Mar 2025 09:04:15 -0400 Received: from mail.mmer.org ([178.22.65.174]:38658) by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1twKzZ-0000GI-QE for 77204@debbugs.gnu.org; Sun, 23 Mar 2025 09:03:57 -0400 Received: from mail.mmer.org (localhost [127.0.0.1]) by mail.mmer.org (OpenSMTPD) with ESMTP id 57139c71 for <77204@debbugs.gnu.org>; Sun, 23 Mar 2025 13:03:43 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed; d=mmer.org; h=from:to :subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; s=dkim; bh=wud+yZMr1JkwM2qSLU9KIyfFu r+k4DCRk+EIg2LcdXE=; b=LnoBJWnlWwUyYgfWMsNplzDVOLCDXftPATsNHp74O AAhfGjPrBiFZnYrgE9vFraqGL5c+4KN7ZUFgm/wvIRzCjK8W6uFDsPffw5LrBi7S q2FCSijav/TR3Ajs+h9YA4OwIDxigYstrB4RJ7b+gllGmojBqH2+IcUm3AWOk061 1k= Received: from delta (16-254-250-62.ftth.glasoperator.nl [62.250.254.16]) by mail.mmer.org (OpenSMTPD) with ESMTPSA id 1d99c4f6 (TLSv1.3:TLS_AES_256_GCM_SHA384:256:NO) for <77204@debbugs.gnu.org>; Sun, 23 Mar 2025 13:03:43 +0000 (UTC) From: Alexey Abramov To: 77204@debbugs.gnu.org Subject: [PATCH v2 2/3] services: dnsmasq: Provide pid-file, conf-file and conf-dir configuration fields. Date: Sun, 23 Mar 2025 14:00:53 +0100 Message-ID: <1832a2647a2c1dff6d066e413f76b40cad59ce06.1742734854.git.levenson@mmer.org> X-Mailer: git-send-email 2.48.1 In-Reply-To: References: MIME-Version: 1.0 X-Debbugs-Cc: Ludovic Courtès , Maxim Cournoyer Content-Transfer-Encoding: 8bit X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: 77204 X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) * doc/guix.texi: Document it. * gnu/services/dns.scm: Export all record accessors. * gnu/services/dns.scm ()[pid-file]: New field. * gnu/services/dns.scm ()[conf-file]: New field. * gnu/services/dns.scm ()[conf-dir]: New field. * gnu/services/dns.scm ()[extra-options]: Move it to the end of the definition, because it is a last resort. * gnu/services/dns.scm (dnsmasq-shepherd-service): Use newly-created fields. --- doc/guix.texi | 14 ++++ gnu/services/dns.scm | 162 +++++++++++++++++++++++++++---------------- 2 files changed, 117 insertions(+), 59 deletions(-) diff --git a/doc/guix.texi b/doc/guix.texi index 90fa6779657..1bbd1824a87 100644 --- a/doc/guix.texi +++ b/doc/guix.texi @@ -35076,6 +35076,9 @@ DNS Services Likewise, @code{shepherd-requirement} is a list of Shepherd service names (symbols) that this service will depend on. +@item @code{pid-file} (default: @code{"/run/dnsmasq.pid"}) +Specify an alternate path for dnsmasq to record its process-id in. + @item @code{no-hosts?} (default: @code{#f}) When true, don't read the hostnames in /etc/hosts. @@ -35196,6 +35199,17 @@ DNS Services resolving MAC addresses is only possible if the client is in the local network or obtained a DHCP lease from dnsmasq. +@item @code{conf-file} (default: @code{'()}) +Specify a configuration file or multiple. The given value should be a list of +string paths to the configuration files. File-like objects are also supported. + +@item @code{conf-dir} (default: @code{#f}) +Read all the files in the given directory as configuration +files. @command{dnsmasq} also supports extensions for the field, but +here it is not implemented. It is more convenient to make +@code{computed-file} directory in the store and use that. Files are +loaded in alphabetical order of filename. + @item @code{extra-options} (default: @code{'()}) This option provides an ``escape hatch'' for the user to provide arbitrary command-line arguments to @command{dnsmasq} as a list of strings. diff --git a/gnu/services/dns.scm b/gnu/services/dns.scm index 9276504ffd0..6e2ec7c2067 100644 --- a/gnu/services/dns.scm +++ b/gnu/services/dns.scm @@ -54,6 +54,38 @@ (define-module (gnu services dns) dnsmasq-service-type dnsmasq-configuration + dnsmasq-configuration-package + dnsmasq-configuration-shepherd-provision + dnsmasq-configuration-shepherd-requirement + dnsmasq-configuration-pid-file + dnsmasq-configuration-no-hosts? + dnsmasq-configuration-port + dnsmasq-configuration-local-service? + dnsmasq-configuration-listen-address + dnsmasq-configuration-resolv-file + dnsmasq-configuration-no-resolv? + dnsmasq-configuration-forward-private-reverse-lookup? + dnsmasq-configuration-query-servers-in-order? + dnsmasq-configuration-servers + dnsmasq-configuration-servers-file + dnsmasq-configuration-addresses + dnsmasq-configuration-cache-size + dnsmasq-configuration-negative-cache? + dnsmasq-configuration-cpe-id + dnsmasq-configuration-tftp-enable? + dnsmasq-configuration-tftp-no-fail? + dnsmasq-configuration-tftp-single-port? + dnsmasq-tftp-secure? + dnsmasq-tftp-max + dnsmasq-tftp-mtu + dnsmasq-tftp-no-blocksize? + dnsmasq-tftp-lowercase? + dnsmasq-tftp-port-range + dnsmasq-tftp-root + dnsmasq-tftp-unique-root + dnsmasq-configuration-conf-file + dnsmasq-configuration-conf-dir + dnsmasq-configuration-extra-options unbound-service-type unbound-configuration @@ -740,72 +772,77 @@ (define knot-resolver-service-type (define-record-type* dnsmasq-configuration make-dnsmasq-configuration dnsmasq-configuration? - (package dnsmasq-configuration-package - (default dnsmasq)) ;file-like + (package dnsmasq-configuration-package + (default dnsmasq)) ;file-like (shepherd-provision dnsmasq-configuration-shepherd-provision (default '(dnsmasq))) (shepherd-requirement dnsmasq-configuration-shepherd-requirement (default '(user-processes networking))) - (no-hosts? dnsmasq-configuration-no-hosts? - (default #f)) ;boolean - (port dnsmasq-configuration-port - (default 53)) ;integer - (local-service? dnsmasq-configuration-local-service? - (default #t)) ;boolean - (listen-addresses dnsmasq-configuration-listen-address - (default '())) ;list of string - (extra-options dnsmasq-configuration-extra-options - (default '())) ;list of string - (resolv-file dnsmasq-configuration-resolv-file - (default "/etc/resolv.conf")) ;string - (no-resolv? dnsmasq-configuration-no-resolv? - (default #f)) ;boolean + (pid-file dnsmasq-configuration-pid-file + (default "/run/dnsmasq.pid")) ;string + (no-hosts? dnsmasq-configuration-no-hosts? + (default #f)) ;boolean + (port dnsmasq-configuration-port + (default 53)) ;integer + (local-service? dnsmasq-configuration-local-service? + (default #t)) ;boolean + (listen-addresses dnsmasq-configuration-listen-address + (default '())) ;list of string + (resolv-file dnsmasq-configuration-resolv-file + (default "/etc/resolv.conf")) ;string + (no-resolv? dnsmasq-configuration-no-resolv? + (default #f)) ;boolean (forward-private-reverse-lookup? - dnsmasq-configuration-forward-private-reverse-lookup? - (default #t)) ;boolean - (query-servers-in-order? - dnsmasq-configuration-query-servers-in-order? - (default #f)) ;boolean - (servers dnsmasq-configuration-servers - (default '())) ;list of string - (servers-file dnsmasq-configuration-servers-file - (default #f)) ;string|file-like - (addresses dnsmasq-configuration-addresses - (default '())) ;list of string - (cache-size dnsmasq-configuration-cache-size - (default 150)) ;integer - (negative-cache? dnsmasq-configuration-negative-cache? - (default #t)) ;boolean - (cpe-id dnsmasq-configuration-cpe-id - (default #f)) ;string - (tftp-enable? dnsmasq-configuration-tftp-enable? - (default #f)) ;boolean - (tftp-no-fail? dnsmasq-configuration-tftp-no-fail? - (default #f)) ;boolean - (tftp-single-port? dnsmasq-configuration-tftp-single-port? - (default #f)) ;boolean - (tftp-secure? dnsmasq-tftp-secure? - (default #f)) ;boolean - (tftp-max dnsmasq-tftp-max - (default #f)) ;integer - (tftp-mtu dnsmasq-tftp-mtu - (default #f)) ;integer - (tftp-no-blocksize? dnsmasq-tftp-no-blocksize? - (default #f)) ;boolean - (tftp-lowercase? dnsmasq-tftp-lowercase? - (default #f)) ;boolean - (tftp-port-range dnsmasq-tftp-port-range - (default #f)) ;string - (tftp-root dnsmasq-tftp-root - (default "/var/empty,lo")) ;string - (tftp-unique-root dnsmasq-tftp-unique-root - (default #f))) ;"" or "ip" or "mac" - + dnsmasq-configuration-forward-private-reverse-lookup? + (default #t)) ;boolean + (query-servers-in-order? dnsmasq-configuration-query-servers-in-order? + (default #f)) ;boolean + (servers dnsmasq-configuration-servers + (default '())) ;list of string + (servers-file dnsmasq-configuration-servers-file + (default #f)) ;string|file-like + (addresses dnsmasq-configuration-addresses + (default '())) ;list of string + (cache-size dnsmasq-configuration-cache-size + (default 150)) ;integer + (negative-cache? dnsmasq-configuration-negative-cache? + (default #t)) ;boolean + (cpe-id dnsmasq-configuration-cpe-id + (default #f)) ;string + (tftp-enable? dnsmasq-configuration-tftp-enable? + (default #f)) ;boolean + (tftp-no-fail? dnsmasq-configuration-tftp-no-fail? + (default #f)) ;boolean + (tftp-single-port? dnsmasq-configuration-tftp-single-port? + (default #f)) ;boolean + (tftp-secure? dnsmasq-tftp-secure? + (default #f)) ;boolean + (tftp-max dnsmasq-tftp-max + (default #f)) ;integer + (tftp-mtu dnsmasq-tftp-mtu + (default #f)) ;integer + (tftp-no-blocksize? dnsmasq-tftp-no-blocksize? + (default #f)) ;boolean + (tftp-lowercase? dnsmasq-tftp-lowercase? + (default #f)) ;boolean + (tftp-port-range dnsmasq-tftp-port-range + (default #f)) ;string + (tftp-root dnsmasq-tftp-root + (default "/var/empty,lo")) ;string + (tftp-unique-root dnsmasq-tftp-unique-root + (default #f)) ;"" or "ip" or "mac" + (conf-file dnsmasq-configuration-conf-file + (default '())) ;list of string|file-like + (conf-dir dnsmasq-configuration-conf-dir + (default #f)) ;string|file-like + (extra-options dnsmasq-configuration-extra-options + (default '()))) (define (dnsmasq-shepherd-service config) (match-record config (package shepherd-provision shepherd-requirement + pid-file no-hosts? port local-service? listen-addresses resolv-file no-resolv? @@ -817,7 +854,8 @@ (define (dnsmasq-shepherd-service config) tftp-single-port? tftp-secure? tftp-max tftp-mtu tftp-no-blocksize? tftp-lowercase? tftp-port-range - tftp-root tftp-unique-root extra-options) + tftp-root tftp-unique-root + conf-file conf-dir extra-options) (shepherd-service (provision shepherd-provision) (requirement shepherd-requirement) @@ -826,7 +864,7 @@ (define (dnsmasq-shepherd-service config) (list #$(file-append package "/sbin/dnsmasq") "--keep-in-foreground" - "--pid-file=/run/dnsmasq.pid" + (string-append "--pid-file=" #$pid-file) #$@(if no-hosts? '("--no-hosts") '()) @@ -897,8 +935,14 @@ (define (dnsmasq-shepherd-service config) (format #f "--tftp-unique-root=~a" tftp-unique-root) (format #f "--tftp-unique-root"))) '()) + #$@(map (lambda (conf-file) + #~(string-append "--conf-file=" #$conf-file)) + conf-file) + #$@(if conf-dir + (list #~(string-append "--conf-dir=" #$conf-dir)) + '()) #$@extra-options) - #:pid-file "/run/dnsmasq.pid")) + #:pid-file #$pid-file)) (stop #~(make-kill-destructor))))) (define (dnsmasq-activation config) -- 2.48.1 From debbugs-submit-bounces@debbugs.gnu.org Sun Mar 23 09:04:35 2025 Received: (at 77204) by debbugs.gnu.org; 23 Mar 2025 13:04:35 +0000 Received: from localhost ([127.0.0.1]:48162 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1twL0D-0000Nx-ET for submit@debbugs.gnu.org; Sun, 23 Mar 2025 09:04:34 -0400 Received: from mail.mmer.org ([178.22.65.174]:45906) by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1twKzc-0000HS-Tm for 77204@debbugs.gnu.org; Sun, 23 Mar 2025 09:04:00 -0400 Received: from mail.mmer.org (localhost [127.0.0.1]) by mail.mmer.org (OpenSMTPD) with ESMTP id c634ca5c for <77204@debbugs.gnu.org>; Sun, 23 Mar 2025 13:03:43 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed; d=mmer.org; h=from:to :subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; s=dkim; bh=sGUPfFte1ktzdr8NyQTWJgIqd IGcmu2Ru1y2OEjD4CQ=; b=NR52XOKqV0Hju4G0ECKRAAD1gn/GygGkQq6D4wLS+ JEiRbaaGVQWuFHbdnROgJ9H58rTpvsh1pdsYy9GuHbJH1ocGqAT1UvLg14DgjAbJ rLxslCgPzJMjt9tNeXyW5hAzZwDEQ+ZfXDjW3E0IJOrPOuqcjhb5qXhUqIoknaan Lw= Received: from delta (16-254-250-62.ftth.glasoperator.nl [62.250.254.16]) by mail.mmer.org (OpenSMTPD) with ESMTPSA id 841c2d5e (TLSv1.3:TLS_AES_256_GCM_SHA384:256:NO) for <77204@debbugs.gnu.org>; Sun, 23 Mar 2025 13:03:43 +0000 (UTC) From: Alexey Abramov To: 77204@debbugs.gnu.org Subject: [PATCH v2 3/3] services: dnsmasq: Provide stats and reload actions. Date: Sun, 23 Mar 2025 14:00:54 +0100 Message-ID: X-Mailer: git-send-email 2.48.1 In-Reply-To: References: MIME-Version: 1.0 X-Debbugs-Cc: Ludovic Courtès , Maxim Cournoyer Content-Transfer-Encoding: 8bit X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: 77204 X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) * gnu/services/dns.scm (dnsmasq-service-reload-action) (dnsmasq-service-stats-action): New functions. * doc/guix.texi: Document the change. * gnu/tests/networking.scm: Add tests. --- doc/guix.texi | 10 ++++ gnu/services/dns.scm | 22 +++++++++ gnu/tests/networking.scm | 98 ++++++++++++++++++++++++++++++++++++++++ 3 files changed, 130 insertions(+) diff --git a/doc/guix.texi b/doc/guix.texi index 1bbd1824a87..816a9ed57d0 100644 --- a/doc/guix.texi +++ b/doc/guix.texi @@ -35060,6 +35060,16 @@ DNS Services @end lisp @end defvar +@code{dnsmasq-service-type} also provides few helpful actions which are +@code{reload} and @code{stats}. For example: + +@example +herd stats dnsmasq +@end example + +Will ask @command{dnsmasq} service to dump its statistics to the system log, which +is usually @file{/var/log/messages}. + @deftp {Data Type} dnsmasq-configuration Data type representing the configuration of dnsmasq. diff --git a/gnu/services/dns.scm b/gnu/services/dns.scm index 6e2ec7c2067..a091dbfb86c 100644 --- a/gnu/services/dns.scm +++ b/gnu/services/dns.scm @@ -860,6 +860,8 @@ (define (dnsmasq-shepherd-service config) (provision shepherd-provision) (requirement shepherd-requirement) (documentation "Run the dnsmasq DNS server.") + (actions (list (dnsmasq-service-reload-action config) + (dnsmasq-service-stats-action config))) (start #~(make-forkexec-constructor (list #$(file-append package "/sbin/dnsmasq") @@ -951,6 +953,26 @@ (define (dnsmasq-activation config) ;; create directory to store dnsmasq lease file (mkdir-p "/var/lib/misc"))) +(define (dnsmasq-service-reload-action config) + (match-record config () + (shepherd-action + (name 'reload) + (documentation "Send a SIGHUP signal to re-load /etc/hosts and /etc/ethers and any +file given by --dhcp-hostsfile, --dhcp-hostsdir, --dhcp-optsfile, --dhcp-optsdir, +--addn-hosts or --hostsdir. SIGHUP does NOT re-read the configuration file.") + (procedure #~(lambda (running) + (let ((pid (process-id running))) + (kill pid SIGHUP))))))) + +(define (dnsmasq-service-stats-action config) + (match-record config () + (shepherd-action + (name 'stats) + (documentation "Send a SIGUSR1 to write statistics to the system log.") + (procedure #~(lambda (running) + (let ((pid (process-id running))) + (kill pid SIGUSR1))))))) + (define dnsmasq-service-type (service-type (name 'dnsmasq) diff --git a/gnu/tests/networking.scm b/gnu/tests/networking.scm index 7d54ebba50e..fdc515ceb04 100644 --- a/gnu/tests/networking.scm +++ b/gnu/tests/networking.scm @@ -27,6 +27,7 @@ (define-module (gnu tests networking) #:use-module (gnu system vm) #:use-module (gnu services) #:use-module (gnu services base) + #:use-module (gnu services dns) #:use-module (gnu services networking) #:use-module (guix gexp) #:use-module (guix store) @@ -46,6 +47,7 @@ (define-module (gnu tests networking) %test-openvswitch %test-dhcpd %test-dhcpcd + %test-dnsmasq %test-tor %test-iptables %test-ipfs)) @@ -675,6 +677,102 @@ (define %test-dhcpd (description "Test a running DHCP daemon configuration.") (value (run-dhcpd-test)))) + + +;;; +;;; dnsmasq tests +;;; + + +(define dnsmasq-os-configuration + (dnsmasq-configuration)) + +(define %dnsmasq-os + (simple-operating-system + (service dhcp-client-service-type) + (service dnsmasq-service-type + (dnsmasq-configuration + (extra-options + (list "--log-facility=/tmp/dnsmasq.log")))))) + + +(define (run-dnsmasq-test) + (define os + (marionette-operating-system %dnsmasq-os + #:imported-modules '((gnu services herd)))) + + (define test + (with-imported-modules '((gnu build marionette)) + #~(begin + (use-modules (gnu build marionette) + (srfi srfi-64)) + + (define marionette + (make-marionette (list #$(virtual-machine os)))) + + (test-runner-current (system-test-runner #$output)) + (test-begin "dnsmasq") + + (test-assert "dnsmasq is alive" + (marionette-eval + '(begin + (use-modules (gnu services herd)) + (wait-for-service 'dnsmasq)) + marionette)) + + (test-assert "pid file exists" + (wait-for-file + '#$(dnsmasq-configuration-pid-file dnsmasq-os-configuration) + marionette)) + + (test-assert "send SIGHUP" + (positive? + (marionette-eval + '(begin + (use-modules (ice-9 rdelim)) + (system* "sync") + (let* ((port (open-input-file "/tmp/dnsmasq.log"))) + (seek port 0 SEEK_END) + (system* "herd" "reload" "dnsmasq") + (system* "sync") + (let ((line (read-line port))) + (close-port port) + (string-contains line "read /etc/hosts")))) + marionette))) + + (test-assert "send SIGUSR1" + (positive? + (marionette-eval + '(begin + (use-modules (ice-9 rdelim)) + (system* "sync") + (let* ((port (open-input-file "/tmp/dnsmasq.log"))) + (seek port 0 SEEK_END) + (system* "herd" "stats" "dnsmasq") + (system* "sync") + (let ((line (read-line port))) + (close-port port) + (string-contains-ci line "time")))) + marionette))) + + (test-assert "dnsmasq is alive" + (marionette-eval + '(begin + (use-modules (gnu services herd)) + (wait-for-service 'dnsmasq)) + marionette)) + + (test-end)))) + + (gexp->derivation "dnsmasq-test" test)) + +(define %test-dnsmasq + (system-test + (name "dnsmasq") + (description "Test a running dnsmasq daemon configuration.") + (value (run-dnsmasq-test)))) + + ;;; ;;; DHCPCD Daemon -- 2.48.1 From debbugs-submit-bounces@debbugs.gnu.org Sun Mar 23 09:05:24 2025 Received: (at 77204) by debbugs.gnu.org; 23 Mar 2025 13:05:24 +0000 Received: from localhost ([127.0.0.1]:48180 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1twL12-0000b2-5B for submit@debbugs.gnu.org; Sun, 23 Mar 2025 09:05:24 -0400 Received: from mail-pj1-x1033.google.com ([2607:f8b0:4864:20::1033]:60643) by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.84_2) (envelope-from ) id 1twL0z-0000YM-Ex for 77204@debbugs.gnu.org; Sun, 23 Mar 2025 09:05:22 -0400 Received: by mail-pj1-x1033.google.com with SMTP id 98e67ed59e1d1-2ff694d2d4dso5221225a91.0 for <77204@debbugs.gnu.org>; Sun, 23 Mar 2025 06:05:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1742735115; x=1743339915; darn=debbugs.gnu.org; h=mime-version:user-agent:message-id:date:references:in-reply-to :subject:cc:to:from:from:to:cc:subject:date:message-id:reply-to; bh=sgbm5iwlkXdAQ9iRPD8g32Inn9766X4hVufGw62z+PE=; b=ENpMAfa2gigLqa5rOyD+M7dCtgiq8UYESnpibvywerOnMr4nuHVw3k/2qlsn4tZJk1 TDcTq6BfJsUZ3GkEZYyflQ/eN66dTvkCj5bI9rycDXjT3mzXzT2/UYig3pT/FQ37PJbJ 6EUzzUZFSvVhqkKcfM2AErf/D0D++CcqQOjtVNm+xP1IwHEAaruwpYuMZ3oux9wrnInV ZID0elaFCIKBwC+EuSrh3o+mLbn//ycgxV9j6+9nrQz1T27TJCMsRI6E+pPTMCvurBcL eRZzeD2nF+tC7o+nH3MYaW1KHmwsv7ON+Y/nSo/Q+5NTWBtVDhAv7q4CJkfcKQIWTKuT iFbQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1742735115; x=1743339915; h=mime-version:user-agent:message-id:date:references:in-reply-to :subject:cc:to:from:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=sgbm5iwlkXdAQ9iRPD8g32Inn9766X4hVufGw62z+PE=; b=ZUZOHI79GhtliJCmEj6m00Gkvr9oHckgDkzSoWSPjkV9XJ+WgGy0cB6h5ynDyAyNCF kxgERVxF2dGWK2fGd5rQQEVYQsBEYUCPjmFdNpUuJGatiwpQKxT2KMrORfBHL2hFOuwt PC9ME1/NEUpsN21ttA0H7mKD3dAxyEhbRTNnMda7/1WUZU6+RMM7tG2LtgfFAsJN3xI2 EXyd5KCPh3+M61ddGSjX8wle1bPF97dIFgvwU738qjkXvVidsarf6AOAQ1gMyBJ54/n4 A1FlUvrWdjchx/9pB9BQrNuWzJxOtEMGXGN0zW4a/tfEja81wZd5ySPdL1NXcuxW3hgN gtRw== X-Forwarded-Encrypted: i=1; AJvYcCW72ZX08k0igKdTcdvlco3JeerMgYKc9mTBt+lTMfe/t74ZkJKBIaSHIcjYs4X4waENBMRgtg==@debbugs.gnu.org X-Gm-Message-State: AOJu0Yxwx0eIV9DFf8lWnY38kFoyOdq/IvfXkkro8baN9MFNx/om+5ZV 7Z5u5vh+eNg0TEIE+T4v0WxAEWdr5hfwDhceslUzPMLMa5w8kWe2LhFnKHla X-Gm-Gg: ASbGncu1N23+AuieZ1I3L4/pS3CNLM/lnmohut0yeujLStwtKsHWTq6YvmFg88XivqO IQ2tqn6i+8spLQZ3ZndkyPk7KQYXXn0kLn2EORnST/gfJ+OZI3hK9hKs7c3UQ/9g2GY+vLGkBRC l/dbDyMd2zw+VvTOmHDqZAYKkVo3skwcVxapkmjWEgk/ZHNfYMCPXzXQS5yg+TxVxRoIWTCVnsy hbh/PChW8cME29Q3usHxwMCckCsRjVsWByyBBj+RCMqe8bWA1cNaffFriDwlTcVN09uRb6nIzjG lVUeyhdr8VNt5WWf/Sbq6fAeW6KsEuVOSlC6PPJ38v0= X-Google-Smtp-Source: AGHT+IGtPgYdUnWhJv47jSQZYkgcDQRb+MyEax/zsbjEGNyXaG1n+neJHoDu4MDR79BGOjPxr3Eo4A== X-Received: by 2002:a17:90b:1f86:b0:2fe:e0a9:49d4 with SMTP id 98e67ed59e1d1-3030fe56b0fmr16210596a91.2.1742735114839; Sun, 23 Mar 2025 06:05:14 -0700 (PDT) Received: from terra ([2405:6586:be0:0:83c8:d31d:2cec:f542]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-227811d9efcsm51093835ad.169.2025.03.23.06.05.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 23 Mar 2025 06:05:14 -0700 (PDT) From: Maxim Cournoyer To: Alexey Abramov Subject: Re: [bug#77204] [PATCH 1/3] services: dnsmasq: Provide shepherd-provision and shepherd-requirement fields. In-Reply-To: <87wmcg2aoi.fsf@zeta.lan> (Alexey Abramov's message of "Sun, 23 Mar 2025 13:28:29 +0100") References: <242697cdc4ed0e257df4ba35500ae2a3b3a00a0b.1742725327.git.levenson@mmer.org> <878qowm35k.fsf@gmail.com> <87wmcg2aoi.fsf@zeta.lan> Date: Sun, 23 Mar 2025 22:04:59 +0900 Message-ID: <87msdbew3o.fsf@gmail.com> User-Agent: Gnus/5.13 (Gnus v5.13) MIME-Version: 1.0 Content-Type: text/plain X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: 77204 Cc: Ludovic =?utf-8?Q?Court=C3=A8s?= , 45mg <45mg.writes@gmail.com>, 77204@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) Hi, Alexey Abramov writes: > Hi, > 45mg <45mg.writes@gmail.com> writes: > >> Hi, >> >> Alexey Abramov via Guix-patches via writes: >> >>> * gnu/services/dns.scm ()[provision]: Rename the field to >>> [shepherd-provision] for consistency with other services. >> >> If this is accepted, you'll probably need to add an entry to >> etc/news.scm, since it's a breaking change. Instead of a news item, I'd add a deprecated alias for the old field, so that it remains usable but warns. There should be various examples in the code. -- Thanks, Maxim From debbugs-submit-bounces@debbugs.gnu.org Mon Mar 24 02:57:39 2025 Received: (at 77204) by debbugs.gnu.org; 24 Mar 2025 06:57:39 +0000 Received: from localhost ([127.0.0.1]:53891 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1twbkf-0003rF-GG for submit@debbugs.gnu.org; Mon, 24 Mar 2025 02:57:39 -0400 Received: from mail.mmer.org ([178.22.65.174]:37052) by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1twbka-0003qk-P7 for 77204@debbugs.gnu.org; Mon, 24 Mar 2025 02:57:35 -0400 Received: from mail.mmer.org (localhost [127.0.0.1]) by mail.mmer.org (OpenSMTPD) with ESMTP id f2d2eb53 for <77204@debbugs.gnu.org>; Mon, 24 Mar 2025 06:57:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed; d=mmer.org; h=from:to :subject:date:message-id:mime-version:content-transfer-encoding; s=dkim; bh=YRWIQlUSsse5ej83OPNGNrjSWMQdlV8hvU7hakzsACo=; b=figQ 3+SQyyiYuv+RU+a9ZW4Xuu0uMUY2+xflEJIMGCjXkyfIYxjImEzXNn2s/Tt7InoV PPtRfyqP0ZJ15kRthidNJDe7Fjysz2gWUzrDqd4TBN0WT6kVR4kDokj/lS/swscK E7rWXvhndqH8sBhQlNWkfbueHOxVo7a4CcZUcDo= Received: from delta (16-254-250-62.ftth.glasoperator.nl [62.250.254.16]) by mail.mmer.org (OpenSMTPD) with ESMTPSA id 01e7d01f (TLSv1.3:TLS_AES_256_GCM_SHA384:256:NO) for <77204@debbugs.gnu.org>; Mon, 24 Mar 2025 06:57:22 +0000 (UTC) From: Alexey Abramov To: 77204@debbugs.gnu.org Subject: [PATCH v3 0/3] dnsmasq service changes Date: Mon, 24 Mar 2025 07:48:42 +0100 Message-ID: X-Mailer: git-send-email 2.48.1 MIME-Version: 1.0 X-Debbugs-Cc: Ludovic Courtès , Maxim Cournoyer Content-Transfer-Encoding: 8bit X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: 77204 X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) This is a v3 of series patches. The difference from v2 is that I resurrect the `provision' field but marked it as deprecated. As a test provision can be defined withing the current test and warning message will appear. No source location unfortunately. I am curious why there is no deprecated field property in guix record? We do i18n though and it is not in (guix record). Alexey Abramov (3): services: dnsmasq: Add shepherd-provision and shepherd-requirement fields. services: dnsmasq: Add pid-file, conf-file and conf-dir configuration fields. services: dnsmasq: Add stats and reload shepherd actions. doc/guix-cookbook.texi | 4 +- doc/guix.texi | 35 ++++++- gnu/services/dns.scm | 203 +++++++++++++++++++++++++++------------ gnu/tests/networking.scm | 98 +++++++++++++++++++ 4 files changed, 275 insertions(+), 65 deletions(-) base-commit: 4ea012fc6ddcb32574fbd4a854b11808c34fbca8 -- 2.48.1 From debbugs-submit-bounces@debbugs.gnu.org Mon Mar 24 02:57:45 2025 Received: (at 77204) by debbugs.gnu.org; 24 Mar 2025 06:57:45 +0000 Received: from localhost ([127.0.0.1]:53894 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1twbkn-0003rh-5T for submit@debbugs.gnu.org; Mon, 24 Mar 2025 02:57:45 -0400 Received: from mail.mmer.org ([178.22.65.174]:37052) by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1twbkd-0003qk-Sg for 77204@debbugs.gnu.org; Mon, 24 Mar 2025 02:57:36 -0400 Received: from mail.mmer.org (localhost [127.0.0.1]) by mail.mmer.org (OpenSMTPD) with ESMTP id b3bda45a for <77204@debbugs.gnu.org>; Mon, 24 Mar 2025 06:57:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed; d=mmer.org; h=from:to :subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; s=dkim; bh=7nK10HbWeFycpyyOh8/uAB02T hWJOcF2PNrPL57ucmc=; b=DhsqJJNcuOzbuT8ZobmjTNNlBTnyr8UjYkdwIPU7q Vg1+tu2AOWvDn3v9lhuvEE78xdlmuEPM5t3gob/OREbLkxF7L+5VR2xP9bdfQNAI uCvJ0g1l+tkeo3HnvLuoZx3kpLuv3GC6bjMIxznvcRFyYxmIFu6FwF8mTcXjvHG6 1I= Received: from delta (16-254-250-62.ftth.glasoperator.nl [62.250.254.16]) by mail.mmer.org (OpenSMTPD) with ESMTPSA id 29642204 (TLSv1.3:TLS_AES_256_GCM_SHA384:256:NO) for <77204@debbugs.gnu.org>; Mon, 24 Mar 2025 06:57:23 +0000 (UTC) From: Alexey Abramov To: 77204@debbugs.gnu.org Subject: [PATCH v3 1/3] services: dnsmasq: Add shepherd-provision and shepherd-requirement fields. Date: Mon, 24 Mar 2025 07:48:43 +0100 Message-ID: <851bb58170d7919aee98ec70ccc63ef08a1bd75a.1742798925.git.levenson@mmer.org> X-Mailer: git-send-email 2.48.1 In-Reply-To: References: MIME-Version: 1.0 X-Debbugs-Cc: Ludovic Courtès , Maxim Cournoyer Content-Transfer-Encoding: 8bit X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: 77204 X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) * gnu/services/dns.scm ()[provision]: Mark as deprecated with a warning. Set default to #f. * gnu/services/dns.scm ()[shepherd-provision]: Add new field for consistency with other services. * gnu/services/dns.scm ()[shepherd-requirement]: Add new field. * gnu/services/dns.scm (dnsmasq-shepherd-service): Use the new fields. * doc/guix.texi: Document these changes. * doc/guix-cookbook.texi (Custom NAT-based network for libvirt): Update example to use shepherd-provision instead of provision. --- doc/guix-cookbook.texi | 4 ++-- doc/guix.texi | 11 ++++++++--- gnu/services/dns.scm | 24 ++++++++++++++++++++---- 3 files changed, 30 insertions(+), 9 deletions(-) diff --git a/doc/guix-cookbook.texi b/doc/guix-cookbook.texi index fe4cac79c3a..d4832b9bb40 100644 --- a/doc/guix-cookbook.texi +++ b/doc/guix-cookbook.texi @@ -4031,8 +4031,8 @@ Custom NAT-based network for libvirt (service dnsmasq-service-type (dnsmasq-configuration ;; You can have multiple instances of `dnsmasq-service-type` as long - ;; as each one has a different provision. - (provision '(dnsmasq-virbr0)) + ;; as each one has a different shepherd-provision. + (shepherd-provision '(dnsmasq-virbr0)) (extra-options (list ;; Only bind to the virtual bridge. This ;; avoids conflicts with other running diff --git a/doc/guix.texi b/doc/guix.texi index bcb1f9d9cf8..90fa6779657 100644 --- a/doc/guix.texi +++ b/doc/guix.texi @@ -35067,9 +35067,14 @@ DNS Services @item @code{package} (default: @var{dnsmasq}) Package object of the dnsmasq server. -@item @code{provision} (default: @code{'(dnsmasq)}) -A list of symbols for the Shepherd service corresponding to this dnsmasq -configuration. +@item @code{shepherd-provision} (default: @code{'(dnsmasq)}) +@itemx @code{shepherd-requirement} (default: @code{'(user-processes networking)}) +This option can be used to provide a list of Shepherd service names +(symbols) provided by this service. You might want to change the default +value if you intend to run several @command{dnsmasq} instances. + +Likewise, @code{shepherd-requirement} is a list of Shepherd service names +(symbols) that this service will depend on. @item @code{no-hosts?} (default: @code{#f}) When true, don't read the hostnames in /etc/hosts. diff --git a/gnu/services/dns.scm b/gnu/services/dns.scm index 05291eb65d9..f617f26891d 100644 --- a/gnu/services/dns.scm +++ b/gnu/services/dns.scm @@ -27,6 +27,7 @@ (define-module (gnu services dns) #:use-module (gnu system shadow) #:use-module (gnu packages admin) #:use-module (gnu packages dns) + #:use-module (guix deprecation) #:use-module (guix packages) #:use-module (guix records) #:use-module (guix gexp) @@ -742,8 +743,13 @@ (define-record-type* dnsmasq-configuration? (package dnsmasq-configuration-package (default dnsmasq)) ;file-like - (provision dnsmasq-provision - (default '(dnsmasq))) + (provision dnsmasq-configuration-provision ; deprecated + (default #f) + (sanitize warn-deprecated-dnsmasq-configuration-provision)) + (shepherd-provision dnsmasq-configuration-shepherd-provision + (default '(dnsmasq))) + (shepherd-requirement dnsmasq-configuration-shepherd-requirement + (default '(user-processes networking))) (no-hosts? dnsmasq-configuration-no-hosts? (default #f)) ;boolean (port dnsmasq-configuration-port @@ -799,9 +805,19 @@ (define-record-type* (tftp-unique-root dnsmasq-tftp-unique-root (default #f))) ;"" or "ip" or "mac" +(define (warn-deprecated-dnsmasq-configuration-provision value) + (when (pair? value) + (warn-about-deprecation + 'provision #f + #:replacement 'shepherd-provision)) + value) + (define (dnsmasq-shepherd-service config) (match-record config (package + provision + shepherd-provision + shepherd-requirement no-hosts? port local-service? listen-addresses resolv-file no-resolv? @@ -815,8 +831,8 @@ (define (dnsmasq-shepherd-service config) tftp-lowercase? tftp-port-range tftp-root tftp-unique-root extra-options) (shepherd-service - (provision (dnsmasq-provision config)) - (requirement '(user-processes networking)) + (provision (or provision shepherd-provision)) + (requirement shepherd-requirement) (documentation "Run the dnsmasq DNS server.") (start #~(make-forkexec-constructor (list -- 2.48.1 From debbugs-submit-bounces@debbugs.gnu.org Mon Mar 24 02:57:46 2025 Received: (at 77204) by debbugs.gnu.org; 24 Mar 2025 06:57:46 +0000 Received: from localhost ([127.0.0.1]:53896 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1twbkn-0003rk-Su for submit@debbugs.gnu.org; Mon, 24 Mar 2025 02:57:46 -0400 Received: from mail.mmer.org ([178.22.65.174]:37052) by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1twbke-0003qk-V2 for 77204@debbugs.gnu.org; Mon, 24 Mar 2025 02:57:37 -0400 Received: from mail.mmer.org (localhost [127.0.0.1]) by mail.mmer.org (OpenSMTPD) with ESMTP id 7221137c for <77204@debbugs.gnu.org>; Mon, 24 Mar 2025 06:57:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed; d=mmer.org; h=from:to :subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; s=dkim; bh=Uj+HU48PjLDOseErri4C/3BaW YuEuuN7QsKy57UxOAk=; b=sVjpXDKxh5XxzfdQie7p4iwWZbH8lMWLQIzY8t2Q9 V3nNQeZdsXQmSb6peaXySy3zFpV2Rr4i4KK6pdkYKDDstcT3VsnmH3Ghrr95zs4b HKjHDZcC9OSYG+pSS3Xj8Y2rN74NuTPLbDfXIhMKxuhQVRdX4NfR6vMfRvVLoWY5 7g= Received: from delta (16-254-250-62.ftth.glasoperator.nl [62.250.254.16]) by mail.mmer.org (OpenSMTPD) with ESMTPSA id b29add7e (TLSv1.3:TLS_AES_256_GCM_SHA384:256:NO) for <77204@debbugs.gnu.org>; Mon, 24 Mar 2025 06:57:23 +0000 (UTC) From: Alexey Abramov To: 77204@debbugs.gnu.org Subject: [PATCH v3 2/3] services: dnsmasq: Add pid-file, conf-file and conf-dir configuration fields. Date: Mon, 24 Mar 2025 07:48:44 +0100 Message-ID: <7810552190c816a3100153b85ab2fb9c736ab5e1.1742798925.git.levenson@mmer.org> X-Mailer: git-send-email 2.48.1 In-Reply-To: References: MIME-Version: 1.0 X-Debbugs-Cc: Ludovic Courtès , Maxim Cournoyer Content-Transfer-Encoding: 8bit X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: 77204 X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) * gnu/services/dns.scm ()[pid-file]: New field to specify alternate path for dnsmasq PID. * gnu/services/dns.scm ()[conf-file]: New field to specify one or more configuration files. * gnu/services/dns.scm ()[conf-dir]: New field to read configuration files from a directory. * gnu/services/dns.scm ()[extra-options]: Move to the end of the definition as a last resort option. * gnu/services/dns.scm (dnsmasq-shepherd-service): Use the new fields instead of hardcoded values. * gnu/services/dns.scm: Export all record accessors. * doc/guix.texi: Document the new configuration options. --- doc/guix.texi | 14 ++++ gnu/services/dns.scm | 157 ++++++++++++++++++++++++++++--------------- 2 files changed, 115 insertions(+), 56 deletions(-) diff --git a/doc/guix.texi b/doc/guix.texi index 90fa6779657..1bbd1824a87 100644 --- a/doc/guix.texi +++ b/doc/guix.texi @@ -35076,6 +35076,9 @@ DNS Services Likewise, @code{shepherd-requirement} is a list of Shepherd service names (symbols) that this service will depend on. +@item @code{pid-file} (default: @code{"/run/dnsmasq.pid"}) +Specify an alternate path for dnsmasq to record its process-id in. + @item @code{no-hosts?} (default: @code{#f}) When true, don't read the hostnames in /etc/hosts. @@ -35196,6 +35199,17 @@ DNS Services resolving MAC addresses is only possible if the client is in the local network or obtained a DHCP lease from dnsmasq. +@item @code{conf-file} (default: @code{'()}) +Specify a configuration file or multiple. The given value should be a list of +string paths to the configuration files. File-like objects are also supported. + +@item @code{conf-dir} (default: @code{#f}) +Read all the files in the given directory as configuration +files. @command{dnsmasq} also supports extensions for the field, but +here it is not implemented. It is more convenient to make +@code{computed-file} directory in the store and use that. Files are +loaded in alphabetical order of filename. + @item @code{extra-options} (default: @code{'()}) This option provides an ``escape hatch'' for the user to provide arbitrary command-line arguments to @command{dnsmasq} as a list of strings. diff --git a/gnu/services/dns.scm b/gnu/services/dns.scm index f617f26891d..210fef4ece2 100644 --- a/gnu/services/dns.scm +++ b/gnu/services/dns.scm @@ -55,6 +55,38 @@ (define-module (gnu services dns) dnsmasq-service-type dnsmasq-configuration + dnsmasq-configuration-package + dnsmasq-configuration-shepherd-provision + dnsmasq-configuration-shepherd-requirement + dnsmasq-configuration-pid-file + dnsmasq-configuration-no-hosts? + dnsmasq-configuration-port + dnsmasq-configuration-local-service? + dnsmasq-configuration-listen-address + dnsmasq-configuration-resolv-file + dnsmasq-configuration-no-resolv? + dnsmasq-configuration-forward-private-reverse-lookup? + dnsmasq-configuration-query-servers-in-order? + dnsmasq-configuration-servers + dnsmasq-configuration-servers-file + dnsmasq-configuration-addresses + dnsmasq-configuration-cache-size + dnsmasq-configuration-negative-cache? + dnsmasq-configuration-cpe-id + dnsmasq-configuration-tftp-enable? + dnsmasq-configuration-tftp-no-fail? + dnsmasq-configuration-tftp-single-port? + dnsmasq-tftp-secure? + dnsmasq-tftp-max + dnsmasq-tftp-mtu + dnsmasq-tftp-no-blocksize? + dnsmasq-tftp-lowercase? + dnsmasq-tftp-port-range + dnsmasq-tftp-root + dnsmasq-tftp-unique-root + dnsmasq-configuration-conf-file + dnsmasq-configuration-conf-dir + dnsmasq-configuration-extra-options unbound-service-type unbound-configuration @@ -750,60 +782,65 @@ (define-record-type* (default '(dnsmasq))) (shepherd-requirement dnsmasq-configuration-shepherd-requirement (default '(user-processes networking))) - (no-hosts? dnsmasq-configuration-no-hosts? - (default #f)) ;boolean - (port dnsmasq-configuration-port - (default 53)) ;integer - (local-service? dnsmasq-configuration-local-service? - (default #t)) ;boolean - (listen-addresses dnsmasq-configuration-listen-address - (default '())) ;list of string - (extra-options dnsmasq-configuration-extra-options - (default '())) ;list of string - (resolv-file dnsmasq-configuration-resolv-file - (default "/etc/resolv.conf")) ;string - (no-resolv? dnsmasq-configuration-no-resolv? - (default #f)) ;boolean + (pid-file dnsmasq-configuration-pid-file + (default "/run/dnsmasq.pid")) ;string + (no-hosts? dnsmasq-configuration-no-hosts? + (default #f)) ;boolean + (port dnsmasq-configuration-port + (default 53)) ;integer + (local-service? dnsmasq-configuration-local-service? + (default #t)) ;boolean + (listen-addresses dnsmasq-configuration-listen-address + (default '())) ;list of string + (resolv-file dnsmasq-configuration-resolv-file + (default "/etc/resolv.conf")) ;string + (no-resolv? dnsmasq-configuration-no-resolv? + (default #f)) ;boolean (forward-private-reverse-lookup? - dnsmasq-configuration-forward-private-reverse-lookup? - (default #t)) ;boolean - (query-servers-in-order? - dnsmasq-configuration-query-servers-in-order? - (default #f)) ;boolean - (servers dnsmasq-configuration-servers - (default '())) ;list of string - (servers-file dnsmasq-configuration-servers-file - (default #f)) ;string|file-like - (addresses dnsmasq-configuration-addresses - (default '())) ;list of string - (cache-size dnsmasq-configuration-cache-size - (default 150)) ;integer - (negative-cache? dnsmasq-configuration-negative-cache? - (default #t)) ;boolean - (cpe-id dnsmasq-configuration-cpe-id - (default #f)) ;string - (tftp-enable? dnsmasq-configuration-tftp-enable? - (default #f)) ;boolean - (tftp-no-fail? dnsmasq-configuration-tftp-no-fail? - (default #f)) ;boolean - (tftp-single-port? dnsmasq-configuration-tftp-single-port? - (default #f)) ;boolean - (tftp-secure? dnsmasq-tftp-secure? - (default #f)) ;boolean - (tftp-max dnsmasq-tftp-max - (default #f)) ;integer - (tftp-mtu dnsmasq-tftp-mtu - (default #f)) ;integer - (tftp-no-blocksize? dnsmasq-tftp-no-blocksize? - (default #f)) ;boolean - (tftp-lowercase? dnsmasq-tftp-lowercase? - (default #f)) ;boolean - (tftp-port-range dnsmasq-tftp-port-range - (default #f)) ;string - (tftp-root dnsmasq-tftp-root - (default "/var/empty,lo")) ;string - (tftp-unique-root dnsmasq-tftp-unique-root - (default #f))) ;"" or "ip" or "mac" + dnsmasq-configuration-forward-private-reverse-lookup? + (default #t)) ;boolean + (query-servers-in-order? dnsmasq-configuration-query-servers-in-order? + (default #f)) ;boolean + (servers dnsmasq-configuration-servers + (default '())) ;list of string + (servers-file dnsmasq-configuration-servers-file + (default #f)) ;string|file-like + (addresses dnsmasq-configuration-addresses + (default '())) ;list of string + (cache-size dnsmasq-configuration-cache-size + (default 150)) ;integer + (negative-cache? dnsmasq-configuration-negative-cache? + (default #t)) ;boolean + (cpe-id dnsmasq-configuration-cpe-id + (default #f)) ;string + (tftp-enable? dnsmasq-configuration-tftp-enable? + (default #f)) ;boolean + (tftp-no-fail? dnsmasq-configuration-tftp-no-fail? + (default #f)) ;boolean + (tftp-single-port? dnsmasq-configuration-tftp-single-port? + (default #f)) ;boolean + (tftp-secure? dnsmasq-tftp-secure? + (default #f)) ;boolean + (tftp-max dnsmasq-tftp-max + (default #f)) ;integer + (tftp-mtu dnsmasq-tftp-mtu + (default #f)) ;integer + (tftp-no-blocksize? dnsmasq-tftp-no-blocksize? + (default #f)) ;boolean + (tftp-lowercase? dnsmasq-tftp-lowercase? + (default #f)) ;boolean + (tftp-port-range dnsmasq-tftp-port-range + (default #f)) ;string + (tftp-root dnsmasq-tftp-root + (default "/var/empty,lo")) ;string + (tftp-unique-root dnsmasq-tftp-unique-root + (default #f)) ;"" or "ip" or "mac" + (conf-file dnsmasq-configuration-conf-file + (default '())) ;list of string|file-like + (conf-dir dnsmasq-configuration-conf-dir + (default #f)) ;string|file-like + (extra-options dnsmasq-configuration-extra-options + (default '()))) (define (warn-deprecated-dnsmasq-configuration-provision value) (when (pair? value) @@ -818,6 +855,7 @@ (define (dnsmasq-shepherd-service config) provision shepherd-provision shepherd-requirement + pid-file no-hosts? port local-service? listen-addresses resolv-file no-resolv? @@ -829,7 +867,8 @@ (define (dnsmasq-shepherd-service config) tftp-single-port? tftp-secure? tftp-max tftp-mtu tftp-no-blocksize? tftp-lowercase? tftp-port-range - tftp-root tftp-unique-root extra-options) + tftp-root tftp-unique-root + conf-file conf-dir extra-options) (shepherd-service (provision (or provision shepherd-provision)) (requirement shepherd-requirement) @@ -838,7 +877,7 @@ (define (dnsmasq-shepherd-service config) (list #$(file-append package "/sbin/dnsmasq") "--keep-in-foreground" - "--pid-file=/run/dnsmasq.pid" + (string-append "--pid-file=" #$pid-file) #$@(if no-hosts? '("--no-hosts") '()) @@ -909,8 +948,14 @@ (define (dnsmasq-shepherd-service config) (format #f "--tftp-unique-root=~a" tftp-unique-root) (format #f "--tftp-unique-root"))) '()) + #$@(map (lambda (conf-file) + #~(string-append "--conf-file=" #$conf-file)) + conf-file) + #$@(if conf-dir + (list #~(string-append "--conf-dir=" #$conf-dir)) + '()) #$@extra-options) - #:pid-file "/run/dnsmasq.pid")) + #:pid-file #$pid-file)) (stop #~(make-kill-destructor))))) (define (dnsmasq-activation config) -- 2.48.1 From debbugs-submit-bounces@debbugs.gnu.org Mon Mar 24 02:57:47 2025 Received: (at 77204) by debbugs.gnu.org; 24 Mar 2025 06:57:47 +0000 Received: from localhost ([127.0.0.1]:53898 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1twbko-0003rs-Jo for submit@debbugs.gnu.org; Mon, 24 Mar 2025 02:57:47 -0400 Received: from mail.mmer.org ([178.22.65.174]:37052) by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1twbkg-0003qk-9Y for 77204@debbugs.gnu.org; Mon, 24 Mar 2025 02:57:39 -0400 Received: from mail.mmer.org (localhost [127.0.0.1]) by mail.mmer.org (OpenSMTPD) with ESMTP id 576c3a40 for <77204@debbugs.gnu.org>; Mon, 24 Mar 2025 06:57:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed; d=mmer.org; h=from:to :subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; s=dkim; bh=3o8c56Rawq7QGi+p8QOCoeZxg MDpcja1DPDNTby1ajA=; b=WnY3NHDCIGsUrByhNSP9JZVh+JmPHR+FHm3wPSpTO J8bzKRnxS5rZ2a1wYFdaPRbXS36RhCP6pAXcwTZcWnC5W1dgztOgnhJZwMF/hYcU bVoeANZ92bhIH3sdxk/9w5Q9dQFU2VhNJoNzH6fqhIGTbTqegNFsqVKkAX5YrXuU sI= Received: from delta (16-254-250-62.ftth.glasoperator.nl [62.250.254.16]) by mail.mmer.org (OpenSMTPD) with ESMTPSA id 80e06739 (TLSv1.3:TLS_AES_256_GCM_SHA384:256:NO) for <77204@debbugs.gnu.org>; Mon, 24 Mar 2025 06:57:24 +0000 (UTC) From: Alexey Abramov To: 77204@debbugs.gnu.org Subject: [PATCH v3 3/3] services: dnsmasq: Add stats and reload shepherd actions. Date: Mon, 24 Mar 2025 07:48:45 +0100 Message-ID: <641725f2e41a49ae455517df3873ce0cafa7e7e2.1742798925.git.levenson@mmer.org> X-Mailer: git-send-email 2.48.1 In-Reply-To: References: MIME-Version: 1.0 X-Debbugs-Cc: Ludovic Courtès , Maxim Cournoyer Content-Transfer-Encoding: 8bit X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: 77204 X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) * gnu/services/dns.scm (dnsmasq-service-reload-action): New function to implement SIGHUP handling for reloading configurations. * gnu/services/dns.scm (dnsmasq-service-stats-action): New function to implement SIGUSR1 handling for dumping statistics. * gnu/services/dns.scm (dnsmasq-shepherd-service): Use the new actions. * doc/guix.texi: Document the new actions with examples. * gnu/tests/networking.scm (%test-dnsmasq): Add tests to verify the functionality of the new actions. --- doc/guix.texi | 10 ++++ gnu/services/dns.scm | 22 +++++++++ gnu/tests/networking.scm | 98 ++++++++++++++++++++++++++++++++++++++++ 3 files changed, 130 insertions(+) diff --git a/doc/guix.texi b/doc/guix.texi index 1bbd1824a87..816a9ed57d0 100644 --- a/doc/guix.texi +++ b/doc/guix.texi @@ -35060,6 +35060,16 @@ DNS Services @end lisp @end defvar +@code{dnsmasq-service-type} also provides few helpful actions which are +@code{reload} and @code{stats}. For example: + +@example +herd stats dnsmasq +@end example + +Will ask @command{dnsmasq} service to dump its statistics to the system log, which +is usually @file{/var/log/messages}. + @deftp {Data Type} dnsmasq-configuration Data type representing the configuration of dnsmasq. diff --git a/gnu/services/dns.scm b/gnu/services/dns.scm index 210fef4ece2..f96d6dbb158 100644 --- a/gnu/services/dns.scm +++ b/gnu/services/dns.scm @@ -873,6 +873,8 @@ (define (dnsmasq-shepherd-service config) (provision (or provision shepherd-provision)) (requirement shepherd-requirement) (documentation "Run the dnsmasq DNS server.") + (actions (list (dnsmasq-service-reload-action config) + (dnsmasq-service-stats-action config))) (start #~(make-forkexec-constructor (list #$(file-append package "/sbin/dnsmasq") @@ -964,6 +966,26 @@ (define (dnsmasq-activation config) ;; create directory to store dnsmasq lease file (mkdir-p "/var/lib/misc"))) +(define (dnsmasq-service-reload-action config) + (match-record config () + (shepherd-action + (name 'reload) + (documentation "Send a SIGHUP signal to re-load /etc/hosts and /etc/ethers and any +file given by --dhcp-hostsfile, --dhcp-hostsdir, --dhcp-optsfile, --dhcp-optsdir, +--addn-hosts or --hostsdir. SIGHUP does NOT re-read the configuration file.") + (procedure #~(lambda (running) + (let ((pid (process-id running))) + (kill pid SIGHUP))))))) + +(define (dnsmasq-service-stats-action config) + (match-record config () + (shepherd-action + (name 'stats) + (documentation "Send a SIGUSR1 to write statistics to the system log.") + (procedure #~(lambda (running) + (let ((pid (process-id running))) + (kill pid SIGUSR1))))))) + (define dnsmasq-service-type (service-type (name 'dnsmasq) diff --git a/gnu/tests/networking.scm b/gnu/tests/networking.scm index 7d54ebba50e..fdc515ceb04 100644 --- a/gnu/tests/networking.scm +++ b/gnu/tests/networking.scm @@ -27,6 +27,7 @@ (define-module (gnu tests networking) #:use-module (gnu system vm) #:use-module (gnu services) #:use-module (gnu services base) + #:use-module (gnu services dns) #:use-module (gnu services networking) #:use-module (guix gexp) #:use-module (guix store) @@ -46,6 +47,7 @@ (define-module (gnu tests networking) %test-openvswitch %test-dhcpd %test-dhcpcd + %test-dnsmasq %test-tor %test-iptables %test-ipfs)) @@ -675,6 +677,102 @@ (define %test-dhcpd (description "Test a running DHCP daemon configuration.") (value (run-dhcpd-test)))) + + +;;; +;;; dnsmasq tests +;;; + + +(define dnsmasq-os-configuration + (dnsmasq-configuration)) + +(define %dnsmasq-os + (simple-operating-system + (service dhcp-client-service-type) + (service dnsmasq-service-type + (dnsmasq-configuration + (extra-options + (list "--log-facility=/tmp/dnsmasq.log")))))) + + +(define (run-dnsmasq-test) + (define os + (marionette-operating-system %dnsmasq-os + #:imported-modules '((gnu services herd)))) + + (define test + (with-imported-modules '((gnu build marionette)) + #~(begin + (use-modules (gnu build marionette) + (srfi srfi-64)) + + (define marionette + (make-marionette (list #$(virtual-machine os)))) + + (test-runner-current (system-test-runner #$output)) + (test-begin "dnsmasq") + + (test-assert "dnsmasq is alive" + (marionette-eval + '(begin + (use-modules (gnu services herd)) + (wait-for-service 'dnsmasq)) + marionette)) + + (test-assert "pid file exists" + (wait-for-file + '#$(dnsmasq-configuration-pid-file dnsmasq-os-configuration) + marionette)) + + (test-assert "send SIGHUP" + (positive? + (marionette-eval + '(begin + (use-modules (ice-9 rdelim)) + (system* "sync") + (let* ((port (open-input-file "/tmp/dnsmasq.log"))) + (seek port 0 SEEK_END) + (system* "herd" "reload" "dnsmasq") + (system* "sync") + (let ((line (read-line port))) + (close-port port) + (string-contains line "read /etc/hosts")))) + marionette))) + + (test-assert "send SIGUSR1" + (positive? + (marionette-eval + '(begin + (use-modules (ice-9 rdelim)) + (system* "sync") + (let* ((port (open-input-file "/tmp/dnsmasq.log"))) + (seek port 0 SEEK_END) + (system* "herd" "stats" "dnsmasq") + (system* "sync") + (let ((line (read-line port))) + (close-port port) + (string-contains-ci line "time")))) + marionette))) + + (test-assert "dnsmasq is alive" + (marionette-eval + '(begin + (use-modules (gnu services herd)) + (wait-for-service 'dnsmasq)) + marionette)) + + (test-end)))) + + (gexp->derivation "dnsmasq-test" test)) + +(define %test-dnsmasq + (system-test + (name "dnsmasq") + (description "Test a running dnsmasq daemon configuration.") + (value (run-dnsmasq-test)))) + + ;;; ;;; DHCPCD Daemon -- 2.48.1 From debbugs-submit-bounces@debbugs.gnu.org Tue Apr 22 01:30:34 2025 Received: (at 77204) by debbugs.gnu.org; 22 Apr 2025 05:30:34 +0000 Received: from localhost ([127.0.0.1]:43288 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1u76DJ-000518-Dz for submit@debbugs.gnu.org; Tue, 22 Apr 2025 01:30:34 -0400 Received: from mail-pf1-x435.google.com ([2607:f8b0:4864:20::435]:42355) by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.84_2) (envelope-from ) id 1u76DE-00050p-8Z for 77204@debbugs.gnu.org; Tue, 22 Apr 2025 01:30:30 -0400 Received: by mail-pf1-x435.google.com with SMTP id d2e1a72fcca58-7398d65476eso3738196b3a.1 for <77204@debbugs.gnu.org>; Mon, 21 Apr 2025 22:30:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1745299822; x=1745904622; darn=debbugs.gnu.org; h=mime-version:user-agent:message-id:date:references:in-reply-to :subject:cc:to:from:from:to:cc:subject:date:message-id:reply-to; bh=bpWWy+kDTWeJS1Tbsw09gOpVrp7OBJD4BBi79ns2r38=; b=jKzaesQLykrfGVvbtN3pZOJgxkqaAKBbxmX7HbMEdmxty+K9OdcWbF+l+REcdnVaBD 06v1h5BtdNw7iNSiGH47Ey9DVgPpxKO/A0zdIsuVZmotC6nUspHeNv/dOnmQw1ONrfUP rUfuhrwomr8KgWzjLqbwORhnYp52cnnokuRxLq7Wr/CWciN/86AszmDpEiTQsc122Si7 FOltvSiBk7VSBc1pI8rF9/XZuDHLXcD/FgZJjtQWur4sinIXbzZFga4BPCRzbNXZUc2X TnHa5kvwTFbu2TDtsRZiS6DOWj9aSFK8Fwii/9UndLDMvEGhL8kz6Q4Pbt7mwBjBK9fb Cw4g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1745299822; x=1745904622; h=mime-version:user-agent:message-id:date:references:in-reply-to :subject:cc:to:from:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=bpWWy+kDTWeJS1Tbsw09gOpVrp7OBJD4BBi79ns2r38=; b=HsshiCVOL6zz8/LdcJn4AvqCAAUmudGxCMETpotgpE14U7x19vP4MRUOq2Mbo+cf3X igYLbWExANVnCUh/lOKzLYI3cufR3vVBEjqc9eklDLSjVCLhSlgorRU8VK0n5gGnZLuz HEfo35modXzP/H+emP9mmacC+azxSqdeWkHZe7rDrKgkEeLAQRDFpJgGB89oGV0TowKN Z4Nb13BqkoHf0c3wKwcgBykv3GwKNKyN2Mu/OPbMuRhmrXoldgw1E8pNvTdDH7llEPIl 65Qx2wKMvrnjUywes+L6BQfB7C+yvs09ykv2tpvaSj7zVeQi5aVXkXr8EPeY2boqHFIP g9zw== X-Gm-Message-State: AOJu0YypqTv7RWbdGTk56Wq/IE4mMxDDkxf2SyaT1VVtllwTnBJGHpgY 5+/d0Y59EiVTA+Bb0701AxxGlXaGMrGxdLvIjqMZoPG1bucG7nt9FElVrQ== X-Gm-Gg: ASbGncuHlhDBiMor/Q5FZEBCD2txWAM2qTBtZx/amEIiHvWR67ykAg4SMsEfjLqiT/P Mec/byHTXW5v2Oa6yVgMHn6JQiE7hh7Gw+NZPojrGmRz0Nnj2xwSXNF8dtgYZIwp7bpPk/VnhL/ EurQT8ixnYBpSgjMMCt6ybmAYiDANTgStX57V/Pm3AL0jwmk8udWwqSWVRgmLPZ3RqZe2bHFnBj OOunRywa2SUWU3PuY+6e+yKuTKdkEwpiSxk/2nkEMEMSe/ZMFt9UeAPwe2P8ef/cw301CldqwHm CSAjuHUglma9UztMUoN82k4XIJOyTFrIFxKMgxB0l3YqJqgNoA== X-Google-Smtp-Source: AGHT+IEg2EJ4Dt2wFVE+iRkMxQcRNgZjSopdpqwxMwpMjm6VFSY9vdltLLlwUZNj5dsqWPPRdTgQ5A== X-Received: by 2002:a05:6a00:aa06:b0:736:aea8:c9b7 with SMTP id d2e1a72fcca58-73dbe4e45fbmr23272595b3a.2.1745299821996; Mon, 21 Apr 2025 22:30:21 -0700 (PDT) Received: from terra ([2405:6586:be0:0:83c8:d31d:2cec:f542]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-73dbf8e3ba8sm7889656b3a.68.2025.04.21.22.30.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 21 Apr 2025 22:30:21 -0700 (PDT) From: Maxim Cournoyer To: Alexey Abramov Subject: Re: [bug#77204] [PATCH v3 1/3] services: dnsmasq: Add shepherd-provision and shepherd-requirement fields. In-Reply-To: <851bb58170d7919aee98ec70ccc63ef08a1bd75a.1742798925.git.levenson@mmer.org> (Alexey Abramov's message of "Mon, 24 Mar 2025 07:48:43 +0100") References: <851bb58170d7919aee98ec70ccc63ef08a1bd75a.1742798925.git.levenson@mmer.org> Date: Tue, 22 Apr 2025 14:30:18 +0900 Message-ID: <87ikmwlq51.fsf@gmail.com> User-Agent: Gnus/5.13 (Gnus v5.13) MIME-Version: 1.0 Content-Type: text/plain X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: 77204 Cc: Ludovic =?utf-8?Q?Court=C3=A8s?= , 77204@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) Hi Alexey, Alexey Abramov writes: > * gnu/services/dns.scm ()[provision]: Mark as > deprecated with a warning. Set default to #f. > * gnu/services/dns.scm ()[shepherd-provision]: > Add new field for consistency with other services. > * gnu/services/dns.scm ()[shepherd-requirement]: > Add new field. > * gnu/services/dns.scm (dnsmasq-shepherd-service): Use the new fields. > * doc/guix.texi: Document these changes. > * doc/guix-cookbook.texi (Custom NAT-based network for libvirt): > Update example to use shepherd-provision instead of provision. Same file names in changelog should only appear once. See (info "(standards) Style of Change Logs") (that's a manual part of our 'gnu-standards' package) for more guidance, or 'git log' for examples. > --- > doc/guix-cookbook.texi | 4 ++-- > doc/guix.texi | 11 ++++++++--- > gnu/services/dns.scm | 24 ++++++++++++++++++++---- > 3 files changed, 30 insertions(+), 9 deletions(-) > > diff --git a/doc/guix-cookbook.texi b/doc/guix-cookbook.texi > index fe4cac79c3a..d4832b9bb40 100644 > --- a/doc/guix-cookbook.texi > +++ b/doc/guix-cookbook.texi > @@ -4031,8 +4031,8 @@ Custom NAT-based network for libvirt > (service dnsmasq-service-type > (dnsmasq-configuration > ;; You can have multiple instances of `dnsmasq-service-type` as long > - ;; as each one has a different provision. > - (provision '(dnsmasq-virbr0)) > + ;; as each one has a different shepherd-provision. > + (shepherd-provision '(dnsmasq-virbr0)) > (extra-options (list > ;; Only bind to the virtual bridge. This > ;; avoids conflicts with other running Looks reasonable; it does seem like 'shepherd-provision' and 'shepherd-requirement' are the prevalent and preferable names to distinguish them from other configuration options. > diff --git a/doc/guix.texi b/doc/guix.texi > index bcb1f9d9cf8..90fa6779657 100644 > --- a/doc/guix.texi > +++ b/doc/guix.texi > @@ -35067,9 +35067,14 @@ DNS Services > @item @code{package} (default: @var{dnsmasq}) > Package object of the dnsmasq server. > > -@item @code{provision} (default: @code{'(dnsmasq)}) > -A list of symbols for the Shepherd service corresponding to this dnsmasq > -configuration. > +@item @code{shepherd-provision} (default: @code{'(dnsmasq)}) > +@itemx @code{shepherd-requirement} (default: @code{'(user-processes networking)}) > +This option can be used to provide a list of Shepherd service names > +(symbols) provided by this service. You might want to change the default ^ Use double space to separate sentences in the Guix sources (whether in doc or comments, etc); see (info "(standards) Comments"). > +value if you intend to run several @command{dnsmasq} instances. > + > +Likewise, @code{shepherd-requirement} is a list of Shepherd service names > +(symbols) that this service will depend on. > > @item @code{no-hosts?} (default: @code{#f}) > When true, don't read the hostnames in /etc/hosts. > diff --git a/gnu/services/dns.scm b/gnu/services/dns.scm > index 05291eb65d9..f617f26891d 100644 > --- a/gnu/services/dns.scm > +++ b/gnu/services/dns.scm > @@ -27,6 +27,7 @@ (define-module (gnu services dns) > #:use-module (gnu system shadow) > #:use-module (gnu packages admin) > #:use-module (gnu packages dns) > + #:use-module (guix deprecation) > #:use-module (guix packages) > #:use-module (guix records) > #:use-module (guix gexp) > @@ -742,8 +743,13 @@ (define-record-type* > dnsmasq-configuration? > (package dnsmasq-configuration-package > (default dnsmasq)) ;file-like > - (provision dnsmasq-provision > - (default '(dnsmasq))) > + (provision dnsmasq-configuration-provision ; deprecated > + (default #f) > + (sanitize warn-deprecated-dnsmasq-configuration-provision)) > + (shepherd-provision dnsmasq-configuration-shepherd-provision > + (default '(dnsmasq))) > + (shepherd-requirement dnsmasq-configuration-shepherd-requirement > + (default '(user-processes networking))) Since we're busting our 80 columns max width coding style here, I'd refrain from indenting the right hand side as a block. You may need to reformat lines (break them) so that it fits under 80 chars too. > (no-hosts? dnsmasq-configuration-no-hosts? > (default #f)) ;boolean > (port dnsmasq-configuration-port > @@ -799,9 +805,19 @@ (define-record-type* > (tftp-unique-root dnsmasq-tftp-unique-root > (default #f))) ;"" or "ip" or "mac" > > +(define (warn-deprecated-dnsmasq-configuration-provision value) > + (when (pair? value) > + (warn-about-deprecation > + 'provision #f > + #:replacement 'shepherd-provision)) > + value) > + Yeah, I think that's the best we can do currently with deprecation for guix record fields. It'd be nice to add deprecation support builtin and have source info, maybe. > (define (dnsmasq-shepherd-service config) > (match-record config > (package > + provision > + shepherd-provision > + shepherd-requirement > no-hosts? > port local-service? listen-addresses > resolv-file no-resolv? > @@ -815,8 +831,8 @@ (define (dnsmasq-shepherd-service config) > tftp-lowercase? tftp-port-range > tftp-root tftp-unique-root extra-options) > (shepherd-service > - (provision (dnsmasq-provision config)) > - (requirement '(user-processes networking)) > + (provision (or provision shepherd-provision)) > + (requirement shepherd-requirement) > (documentation "Run the dnsmasq DNS server.") > (start #~(make-forkexec-constructor > (list Other than these nitpicks, it LGTM. I'm not done reviewing 2 and 3, but after I do so, could you please send a v2 with the above adjusted? -- Thanks, Maxim From debbugs-submit-bounces@debbugs.gnu.org Tue Apr 22 01:35:46 2025 Received: (at 77204) by debbugs.gnu.org; 22 Apr 2025 05:35:46 +0000 Received: from localhost ([127.0.0.1]:43335 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1u76IL-0005UQ-9l for submit@debbugs.gnu.org; Tue, 22 Apr 2025 01:35:46 -0400 Received: from mail-pj1-x1031.google.com ([2607:f8b0:4864:20::1031]:53551) by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.84_2) (envelope-from ) id 1u76IF-0005U4-Kq for 77204@debbugs.gnu.org; Tue, 22 Apr 2025 01:35:43 -0400 Received: by mail-pj1-x1031.google.com with SMTP id 98e67ed59e1d1-3081fe5987eso4028055a91.3 for <77204@debbugs.gnu.org>; Mon, 21 Apr 2025 22:35:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1745300133; x=1745904933; darn=debbugs.gnu.org; h=mime-version:user-agent:message-id:date:references:in-reply-to :subject:cc:to:from:from:to:cc:subject:date:message-id:reply-to; bh=E81jeErcQ+SI7n7Bu1VwDhQJefnJ8VJmnxMGLafQc5k=; b=kM8KVCmgxZiCZb813fE9ojjG09jNi6M7Km/t6zNRhR7mbrQfOGti8GEstYqau7i0NG fRoQkyLZ/1uNb96uBXGB1JQfWgZms25mQzGbABV2MVOEVnsFB+8BUcu2nQ1mh8TSo+px Wh0MP10cke7lNniuOOt1oTcRQrSS+tIb9oUQ9ijxqQxQ3D7AEdNpuqe/q/suCQ3b5BE8 6QAAQEC3QBXyKz9hCQw//hXTuAf4XM38tutUKnOl1iHlwDnvxlo3p9qdfbFsE9yBfyOw tTWgW5iKW3qeTZEtMNwjtHxpzR0KmON017ASSjK9UdDF0ZXs6czuha7ubV2aXEAHyKaX EjnQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1745300133; x=1745904933; h=mime-version:user-agent:message-id:date:references:in-reply-to :subject:cc:to:from:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=E81jeErcQ+SI7n7Bu1VwDhQJefnJ8VJmnxMGLafQc5k=; b=kV9MYFbFIrTLBzHVLM/xyCAOlpMl2icXBnsCwGEDdhZcJXB73Qb4P1WxFNWYjlZT99 GJpRXUdtpuWhglDhw5MN2FXXpthFIuGGZWasnfjLKza/c/FvyQ7H9FyJQ3+wik9aKlId 0RyFrAchXxs3TPaQLOlm0DLA8aP3GtcuUosJevrYrvbsQ1ZGY1tQixQFtil+eFlwJPc3 YqKl62O8G6gZ2Wz5X7Gg29aq4MJRoASs3qcfvljNtWED46cvyrRUrM53PEljYLDtFIDM JFtWOGnvuSQb6korp3lZxszf7CQ4Ns4xF/HZX32WwFEnerD+BUfKR7EiFGkE4eSDG4f8 xj+Q== X-Gm-Message-State: AOJu0YxY2Eo5kDL08sL3Kgxlr1DDDnMYLZnkmd9W5dU8Qk5FPh4Xo/TX TJNqE99p/2SM86fuj2VSZerCvcyOHGMGFUl8N0+6bfGp3dP4M0/E+9NP7g== X-Gm-Gg: ASbGnctb77rw5wOKTeJP0lalhCweTiFmfYa0gnUjm5IpfOCnYj4PkBNrF9PCik9xnAZ kEFUss768BaawnQIpi8PXDdUmSCqcChzaGpNgqwOVTpSG1H99hP85n7JUsApdUOe1h460GlZG98 JgXcjzll2KgfSDdUYzifxRYAUEGfC9ai483+KX1dATnzLkK7tWDcAs3zaqjwEtUU2ZEg89mOiui jdeT/qPHtkngc1zyo79H/dl8R8xwIhaaeidfcGAyj15Lejp/MfsL12jZw8m0gUZMy4gGUmBe1tQ 20WrYNd5Y2njsdOu9RNBQjHgJobS5SHSzzEpWo8= X-Google-Smtp-Source: AGHT+IG3oGaTrtb0GiEY4GVu/P5r9of6W5Ukf1GqQcTv98CBkDhCos2u1nH+s1AvbhjrPsckeOkhdg== X-Received: by 2002:a17:90b:3a4e:b0:301:1d9f:4ba2 with SMTP id 98e67ed59e1d1-3087bbbd12cmr19758659a91.28.1745300133214; Mon, 21 Apr 2025 22:35:33 -0700 (PDT) Received: from terra ([2405:6586:be0:0:83c8:d31d:2cec:f542]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-22c50eb4a46sm75889275ad.147.2025.04.21.22.35.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 21 Apr 2025 22:35:32 -0700 (PDT) From: Maxim Cournoyer To: Alexey Abramov Subject: Re: [bug#77204] [PATCH v3 2/3] services: dnsmasq: Add pid-file, conf-file and conf-dir configuration fields. In-Reply-To: <7810552190c816a3100153b85ab2fb9c736ab5e1.1742798925.git.levenson@mmer.org> (Alexey Abramov's message of "Mon, 24 Mar 2025 07:48:44 +0100") References: <7810552190c816a3100153b85ab2fb9c736ab5e1.1742798925.git.levenson@mmer.org> Date: Tue, 22 Apr 2025 14:35:30 +0900 Message-ID: <87ecxklpwd.fsf@gmail.com> User-Agent: Gnus/5.13 (Gnus v5.13) MIME-Version: 1.0 Content-Type: text/plain X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: 77204 Cc: Ludovic =?utf-8?Q?Court=C3=A8s?= , 77204@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) Hi, Alexey Abramov writes: > * gnu/services/dns.scm ()[pid-file]: New field to > specify alternate path for dnsmasq PID. > * gnu/services/dns.scm ()[conf-file]: New field to > specify one or more configuration files. > * gnu/services/dns.scm ()[conf-dir]: New field to > read configuration files from a directory. > * gnu/services/dns.scm ()[extra-options]: Move > to the end of the definition as a last resort option. > * gnu/services/dns.scm (dnsmasq-shepherd-service): Use the new fields > instead of hardcoded values. > * gnu/services/dns.scm: Export all record accessors. > * doc/guix.texi: Document the new configuration options. As mentioned earlier, file names should only appear once. > --- > doc/guix.texi | 14 ++++ > gnu/services/dns.scm | 157 ++++++++++++++++++++++++++++--------------- > 2 files changed, 115 insertions(+), 56 deletions(-) > > diff --git a/doc/guix.texi b/doc/guix.texi > index 90fa6779657..1bbd1824a87 100644 > --- a/doc/guix.texi > +++ b/doc/guix.texi > @@ -35076,6 +35076,9 @@ DNS Services > Likewise, @code{shepherd-requirement} is a list of Shepherd service names > (symbols) that this service will depend on. > > +@item @code{pid-file} (default: @code{"/run/dnsmasq.pid"}) > +Specify an alternate path for dnsmasq to record its process-id in. > + > @item @code{no-hosts?} (default: @code{#f}) > When true, don't read the hostnames in /etc/hosts. > > @@ -35196,6 +35199,17 @@ DNS Services > resolving MAC addresses is only possible if the client is in the local > network or obtained a DHCP lease from dnsmasq. > > +@item @code{conf-file} (default: @code{'()}) > +Specify a configuration file or multiple. The given value should be a list of > +string paths to the configuration files. File-like objects are also supported. > + > +@item @code{conf-dir} (default: @code{#f}) > +Read all the files in the given directory as configuration > +files. @command{dnsmasq} also supports extensions for the field, but > +here it is not implemented. It is more convenient to make > +@code{computed-file} directory in the store and use that. Files are > +loaded in alphabetical order of filename. > + > @item @code{extra-options} (default: @code{'()}) > This option provides an ``escape hatch'' for the user to provide arbitrary > command-line arguments to @command{dnsmasq} as a list of strings. > diff --git a/gnu/services/dns.scm b/gnu/services/dns.scm > index f617f26891d..210fef4ece2 100644 > --- a/gnu/services/dns.scm > +++ b/gnu/services/dns.scm > @@ -55,6 +55,38 @@ (define-module (gnu services dns) > > dnsmasq-service-type > dnsmasq-configuration > + dnsmasq-configuration-package > + dnsmasq-configuration-shepherd-provision > + dnsmasq-configuration-shepherd-requirement > + dnsmasq-configuration-pid-file > + dnsmasq-configuration-no-hosts? > + dnsmasq-configuration-port > + dnsmasq-configuration-local-service? > + dnsmasq-configuration-listen-address > + dnsmasq-configuration-resolv-file > + dnsmasq-configuration-no-resolv? > + dnsmasq-configuration-forward-private-reverse-lookup? > + dnsmasq-configuration-query-servers-in-order? > + dnsmasq-configuration-servers > + dnsmasq-configuration-servers-file > + dnsmasq-configuration-addresses > + dnsmasq-configuration-cache-size > + dnsmasq-configuration-negative-cache? > + dnsmasq-configuration-cpe-id > + dnsmasq-configuration-tftp-enable? > + dnsmasq-configuration-tftp-no-fail? > + dnsmasq-configuration-tftp-single-port? > + dnsmasq-tftp-secure? > + dnsmasq-tftp-max > + dnsmasq-tftp-mtu > + dnsmasq-tftp-no-blocksize? > + dnsmasq-tftp-lowercase? > + dnsmasq-tftp-port-range > + dnsmasq-tftp-root > + dnsmasq-tftp-unique-root > + dnsmasq-configuration-conf-file > + dnsmasq-configuration-conf-dir > + dnsmasq-configuration-extra-options > > unbound-service-type > unbound-configuration > @@ -750,60 +782,65 @@ (define-record-type* > (default '(dnsmasq))) > (shepherd-requirement dnsmasq-configuration-shepherd-requirement > (default '(user-processes networking))) > - (no-hosts? dnsmasq-configuration-no-hosts? > - (default #f)) ;boolean > - (port dnsmasq-configuration-port > - (default 53)) ;integer > - (local-service? dnsmasq-configuration-local-service? > - (default #t)) ;boolean > - (listen-addresses dnsmasq-configuration-listen-address > - (default '())) ;list of string > - (extra-options dnsmasq-configuration-extra-options > - (default '())) ;list of string > - (resolv-file dnsmasq-configuration-resolv-file > - (default "/etc/resolv.conf")) ;string > - (no-resolv? dnsmasq-configuration-no-resolv? > - (default #f)) ;boolean > + (pid-file dnsmasq-configuration-pid-file > + (default "/run/dnsmasq.pid")) ;string > + (no-hosts? dnsmasq-configuration-no-hosts? > + (default #f)) ;boolean > + (port dnsmasq-configuration-port > + (default 53)) ;integer > + (local-service? dnsmasq-configuration-local-service? > + (default #t)) ;boolean > + (listen-addresses dnsmasq-configuration-listen-address > + (default '())) ;list of string > + (resolv-file dnsmasq-configuration-resolv-file > + (default "/etc/resolv.conf")) ;string > + (no-resolv? dnsmasq-configuration-no-resolv? > + (default #f)) ;boolean > (forward-private-reverse-lookup? > - dnsmasq-configuration-forward-private-reverse-lookup? > - (default #t)) ;boolean > - (query-servers-in-order? > - dnsmasq-configuration-query-servers-in-order? > - (default #f)) ;boolean > - (servers dnsmasq-configuration-servers > - (default '())) ;list of string > - (servers-file dnsmasq-configuration-servers-file > - (default #f)) ;string|file-like > - (addresses dnsmasq-configuration-addresses > - (default '())) ;list of string > - (cache-size dnsmasq-configuration-cache-size > - (default 150)) ;integer > - (negative-cache? dnsmasq-configuration-negative-cache? > - (default #t)) ;boolean > - (cpe-id dnsmasq-configuration-cpe-id > - (default #f)) ;string > - (tftp-enable? dnsmasq-configuration-tftp-enable? > - (default #f)) ;boolean > - (tftp-no-fail? dnsmasq-configuration-tftp-no-fail? > - (default #f)) ;boolean > - (tftp-single-port? dnsmasq-configuration-tftp-single-port? > - (default #f)) ;boolean > - (tftp-secure? dnsmasq-tftp-secure? > - (default #f)) ;boolean > - (tftp-max dnsmasq-tftp-max > - (default #f)) ;integer > - (tftp-mtu dnsmasq-tftp-mtu > - (default #f)) ;integer > - (tftp-no-blocksize? dnsmasq-tftp-no-blocksize? > - (default #f)) ;boolean > - (tftp-lowercase? dnsmasq-tftp-lowercase? > - (default #f)) ;boolean > - (tftp-port-range dnsmasq-tftp-port-range > - (default #f)) ;string > - (tftp-root dnsmasq-tftp-root > - (default "/var/empty,lo")) ;string > - (tftp-unique-root dnsmasq-tftp-unique-root > - (default #f))) ;"" or "ip" or "mac" > + dnsmasq-configuration-forward-private-reverse-lookup? > + (default #t)) ;boolean > + (query-servers-in-order? dnsmasq-configuration-query-servers-in-order? > + (default #f)) ;boolean > + (servers dnsmasq-configuration-servers > + (default '())) ;list of string > + (servers-file dnsmasq-configuration-servers-file > + (default #f)) ;string|file-like > + (addresses dnsmasq-configuration-addresses > + (default '())) ;list of string > + (cache-size dnsmasq-configuration-cache-size > + (default 150)) ;integer > + (negative-cache? dnsmasq-configuration-negative-cache? > + (default #t)) ;boolean > + (cpe-id dnsmasq-configuration-cpe-id > + (default #f)) ;string > + (tftp-enable? dnsmasq-configuration-tftp-enable? > + (default #f)) ;boolean > + (tftp-no-fail? dnsmasq-configuration-tftp-no-fail? > + (default #f)) ;boolean > + (tftp-single-port? dnsmasq-configuration-tftp-single-port? > + (default #f)) ;boolean > + (tftp-secure? dnsmasq-tftp-secure? > + (default #f)) ;boolean > + (tftp-max dnsmasq-tftp-max > + (default #f)) ;integer > + (tftp-mtu dnsmasq-tftp-mtu > + (default #f)) ;integer > + (tftp-no-blocksize? dnsmasq-tftp-no-blocksize? > + (default #f)) ;boolean > + (tftp-lowercase? dnsmasq-tftp-lowercase? > + (default #f)) ;boolean > + (tftp-port-range dnsmasq-tftp-port-range > + (default #f)) ;string > + (tftp-root dnsmasq-tftp-root > + (default "/var/empty,lo")) ;string > + (tftp-unique-root dnsmasq-tftp-unique-root > + (default #f)) ;"" or "ip" or "mac" > + (conf-file dnsmasq-configuration-conf-file > + (default '())) ;list of string|file-like > + (conf-dir dnsmasq-configuration-conf-dir > + (default #f)) ;string|file-like > + (extra-options dnsmasq-configuration-extra-options > + (default '()))) Please refrain from adjusting the indentation like this; it makes reviewing difficult and here also breaks our max width of 80 columns. > (define (warn-deprecated-dnsmasq-configuration-provision value) > (when (pair? value) > @@ -818,6 +855,7 @@ (define (dnsmasq-shepherd-service config) > provision > shepherd-provision > shepherd-requirement > + pid-file > no-hosts? > port local-service? listen-addresses > resolv-file no-resolv? > @@ -829,7 +867,8 @@ (define (dnsmasq-shepherd-service config) > tftp-single-port? tftp-secure? > tftp-max tftp-mtu tftp-no-blocksize? > tftp-lowercase? tftp-port-range > - tftp-root tftp-unique-root extra-options) > + tftp-root tftp-unique-root > + conf-file conf-dir extra-options) > (shepherd-service > (provision (or provision shepherd-provision)) > (requirement shepherd-requirement) > @@ -838,7 +877,7 @@ (define (dnsmasq-shepherd-service config) > (list > #$(file-append package "/sbin/dnsmasq") > "--keep-in-foreground" > - "--pid-file=/run/dnsmasq.pid" > + (string-append "--pid-file=" #$pid-file) > #$@(if no-hosts? > '("--no-hosts") > '()) > @@ -909,8 +948,14 @@ (define (dnsmasq-shepherd-service config) > (format #f "--tftp-unique-root=~a" tftp-unique-root) > (format #f "--tftp-unique-root"))) > '()) > + #$@(map (lambda (conf-file) > + #~(string-append "--conf-file=" #$conf-file)) > + conf-file) > + #$@(if conf-dir > + (list #~(string-append "--conf-dir=" #$conf-dir)) > + '()) > #$@extra-options) > - #:pid-file "/run/dnsmasq.pid")) > + #:pid-file #$pid-file)) > (stop #~(make-kill-destructor))))) Other than that, it looks like a good change! Thank you. -- Thanks, Maxim From debbugs-submit-bounces@debbugs.gnu.org Tue Apr 22 02:20:26 2025 Received: (at 77204) by debbugs.gnu.org; 22 Apr 2025 06:20:26 +0000 Received: from localhost ([127.0.0.1]:43656 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1u76za-0000KF-0W for submit@debbugs.gnu.org; Tue, 22 Apr 2025 02:20:26 -0400 Received: from mail-pf1-x42b.google.com ([2607:f8b0:4864:20::42b]:51467) by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.84_2) (envelope-from ) id 1u76zU-0000JL-4J for 77204@debbugs.gnu.org; Tue, 22 Apr 2025 02:20:23 -0400 Received: by mail-pf1-x42b.google.com with SMTP id d2e1a72fcca58-7394945d37eso3810559b3a.3 for <77204@debbugs.gnu.org>; Mon, 21 Apr 2025 23:20:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1745302814; x=1745907614; darn=debbugs.gnu.org; h=mime-version:user-agent:message-id:date:references:in-reply-to :subject:cc:to:from:from:to:cc:subject:date:message-id:reply-to; bh=Rgny9avjjcjNmFV3gO2nVhE4goBTGnH79FEAyLwLqtQ=; b=Zsy5nZnfzhxY2NJj+3MZ88fTCcGIMcDucL/ii88NRGGqGi/wcDeAOsQV5Hh1HLStZH MHMobSYrRPzDSX00LpvCbal3y0I2Uv8H0o+PFbFotEMRN2vbxSJXJCAYGBvWkqh6Uynl 2yCMNa9TQcIEBWxcNoUYZe6ykffReRfjv4F/c8JMRTPq7s+dls8n1SzOT7UYmguKJkVs 5qQQbh/d07PGVkaXRtvD4uxEoxFbKnTeOhs6KrluDub6Jy1SyZomS+fn3bCNwqSaOIUH RUnTcZSYf/SegY2d9jWAtm4EuLHr+lCt91HEZvXkL4sjR2+VXMF2UAlL3bWmjSdLqeYq uw1Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1745302814; x=1745907614; h=mime-version:user-agent:message-id:date:references:in-reply-to :subject:cc:to:from:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=Rgny9avjjcjNmFV3gO2nVhE4goBTGnH79FEAyLwLqtQ=; b=EfEideck/i1ohpX9HF8nFCMk0n8GAc7OuCGpP+tVt3goFbueQWPN6jyKODS1vRZ030 LwHraRsP5BIJkKxNEwZ0CIPrWB6owCRGWyWBORKRZ+lpF/Ger8OjJ5iViVFhzHMHfamh pzm6mZ18MU5aLeUWR9KplU1AG1tDgp4RNZ0UY/BsKydomxzn5w16e8LFVQr9eEBw68lJ YmcvRN3w/66ixW4cDmw8wc6lp/eyXmL6DW66xQY8yytkTiU5yNSmDtnfqgV8ZgO18G4K wOLfTPdiKXYDrf+o8Jen6Ntzsus6RmBE1i10PyWCBZcqtJ6T27AxLvZaS5uaY1hkF/WN iigg== X-Gm-Message-State: AOJu0YxixnvFIoCNarVuOiY+VDJN/wys7Ze+Hu9mhBZac9q+Dt5v5GQm 4avqzVFD9WpWOQRE8/3odTTdFx6lhzo7+pEwJ6K9OIZdbThdJ+9U X-Gm-Gg: ASbGncuxrat269gQORINtQcfuUTXfaBwBFklkOcwB3Osy7YOQLWQn5coHc+LhBZrG1U MLfWe6lHXmcDLq5yqiI5uY0Ua9PTdNq96xIceI+DflIcA0JLarWy1AZQaJWxYBWICuzYsHQFtlk OK7bsPj3e0qpx28zU3JOlCc0N4NCtDaW1RiG1xgsPnp9g5pDF/USoDo9UMA1ANA0DU86KO/GiXd DvSd6SCSa4yWhJzo9RQWO7rGGnrglFZ+qmoX/+XPXva8FkOVDPytnTRyJMHTC4ch8L5t9zVVvhA 92d/Qn4s7oZB4Drq2iBXWYY5TS8zny/eW2Ldqh8= X-Google-Smtp-Source: AGHT+IF81zuwwqHn29C+In/2fLjK+YyC1nFz7/aP/fWHenLAaibilXoc/bpphcflnX5DaqRk72+1gQ== X-Received: by 2002:a05:6a21:8dc9:b0:1f5:7c6f:6c8b with SMTP id adf61e73a8af0-203cbc51b1amr20510048637.10.1745302814003; Mon, 21 Apr 2025 23:20:14 -0700 (PDT) Received: from terra ([2405:6586:be0:0:83c8:d31d:2cec:f542]) by smtp.gmail.com with ESMTPSA id 41be03b00d2f7-b0db145739fsm6573172a12.62.2025.04.21.23.20.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 21 Apr 2025 23:20:13 -0700 (PDT) From: Maxim Cournoyer To: Alexey Abramov Subject: Re: [bug#77204] [PATCH v3 3/3] services: dnsmasq: Add stats and reload shepherd actions. In-Reply-To: <641725f2e41a49ae455517df3873ce0cafa7e7e2.1742798925.git.levenson@mmer.org> (Alexey Abramov's message of "Mon, 24 Mar 2025 07:48:45 +0100") References: <641725f2e41a49ae455517df3873ce0cafa7e7e2.1742798925.git.levenson@mmer.org> Date: Tue, 22 Apr 2025 15:20:10 +0900 Message-ID: <87a588lntx.fsf@gmail.com> User-Agent: Gnus/5.13 (Gnus v5.13) MIME-Version: 1.0 Content-Type: text/plain X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: 77204 Cc: Ludovic =?utf-8?Q?Court=C3=A8s?= , 77204@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) Hi again, Alexey Abramov writes: > * gnu/services/dns.scm (dnsmasq-service-reload-action): New function to > implement SIGHUP handling for reloading configurations. > * gnu/services/dns.scm (dnsmasq-service-stats-action): New function to > implement SIGUSR1 handling for dumping statistics. > * gnu/services/dns.scm (dnsmasq-shepherd-service): Use the new actions. > * doc/guix.texi: Document the new actions with examples. > * gnu/tests/networking.scm (%test-dnsmasq): Add tests to verify the > functionality of the new actions. Looks nice! Same comment as earlier: file names should appear once. > --- > doc/guix.texi | 10 ++++ > gnu/services/dns.scm | 22 +++++++++ > gnu/tests/networking.scm | 98 ++++++++++++++++++++++++++++++++++++++++ > 3 files changed, 130 insertions(+) > > diff --git a/doc/guix.texi b/doc/guix.texi > index 1bbd1824a87..816a9ed57d0 100644 > --- a/doc/guix.texi > +++ b/doc/guix.texi > @@ -35060,6 +35060,16 @@ DNS Services > @end lisp > @end defvar The newly added dnsmasq-serice-type should be nested into the existing 'defvar' for it. > +@code{dnsmasq-service-type} also provides few helpful actions which are Then, I'd just write: Two actions are provided: > +@code{reload} and @code{stats}. For example: > + > +@example > +herd stats dnsmasq > +@end example > + > +Will ask @command{dnsmasq} service to dump its statistics to the system log, which > +is usually @file{/var/log/messages}. s/is usually// (is it configurable to be elsewhere -- I don't think so?) > + > @deftp {Data Type} dnsmasq-configuration > Data type representing the configuration of dnsmasq. > > diff --git a/gnu/services/dns.scm b/gnu/services/dns.scm > index 210fef4ece2..f96d6dbb158 100644 > --- a/gnu/services/dns.scm > +++ b/gnu/services/dns.scm > @@ -873,6 +873,8 @@ (define (dnsmasq-shepherd-service config) > (provision (or provision shepherd-provision)) > (requirement shepherd-requirement) > (documentation "Run the dnsmasq DNS server.") > + (actions (list (dnsmasq-service-reload-action config) > + (dnsmasq-service-stats-action config))) > (start #~(make-forkexec-constructor > (list > #$(file-append package "/sbin/dnsmasq") > @@ -964,6 +966,26 @@ (define (dnsmasq-activation config) > ;; create directory to store dnsmasq lease file > (mkdir-p "/var/lib/misc"))) > > +(define (dnsmasq-service-reload-action config) > + (match-record config () > + (shepherd-action > + (name 'reload) > + (documentation "Send a SIGHUP signal to re-load /etc/hosts and /etc/ethers and any > +file given by --dhcp-hostsfile, --dhcp-hostsdir, --dhcp-optsfile, --dhcp-optsdir, > +--addn-hosts or --hostsdir. SIGHUP does NOT re-read the configuration file.") s/re-load/reload/ s/re-read/reload/ Please mind maximum 80 columns coding style; I believe this is also to be formatted as Texinfo so you could use @file{/etc/hosts} and @file{/etc/ethers} for example, and @option for each listed options. Instead of emphasising with full caps, you can use @emph{not}. > + (procedure #~(lambda (running) > + (let ((pid (process-id running))) > + (kill pid SIGHUP))))))) > + > +(define (dnsmasq-service-stats-action config) > + (match-record config () > + (shepherd-action > + (name 'stats) > + (documentation "Send a SIGUSR1 to write statistics to the system log.") > + (procedure #~(lambda (running) > + (let ((pid (process-id running))) > + (kill pid SIGUSR1))))))) > + > (define dnsmasq-service-type > (service-type > (name 'dnsmasq) > diff --git a/gnu/tests/networking.scm b/gnu/tests/networking.scm > index 7d54ebba50e..fdc515ceb04 100644 > --- a/gnu/tests/networking.scm > +++ b/gnu/tests/networking.scm > @@ -27,6 +27,7 @@ (define-module (gnu tests networking) > #:use-module (gnu system vm) > #:use-module (gnu services) > #:use-module (gnu services base) > + #:use-module (gnu services dns) > #:use-module (gnu services networking) > #:use-module (guix gexp) > #:use-module (guix store) > @@ -46,6 +47,7 @@ (define-module (gnu tests networking) > %test-openvswitch > %test-dhcpd > %test-dhcpcd > + %test-dnsmasq > %test-tor > %test-iptables > %test-ipfs)) > @@ -675,6 +677,102 @@ (define %test-dhcpd > (description "Test a running DHCP daemon configuration.") > (value (run-dhcpd-test)))) > > + > + > +;;; > +;;; dnsmasq tests > +;;; > + > + > +(define dnsmasq-os-configuration > + (dnsmasq-configuration)) > + > +(define %dnsmasq-os > + (simple-operating-system > + (service dhcp-client-service-type) > + (service dnsmasq-service-type > + (dnsmasq-configuration > + (extra-options > + (list "--log-facility=/tmp/dnsmasq.log")))))) > + > + > +(define (run-dnsmasq-test) > + (define os > + (marionette-operating-system %dnsmasq-os > + #:imported-modules '((gnu services herd)))) > + > + (define test > + (with-imported-modules '((gnu build marionette)) > + #~(begin > + (use-modules (gnu build marionette) > + (srfi srfi-64)) > + > + (define marionette > + (make-marionette (list #$(virtual-machine os)))) > + > + (test-runner-current (system-test-runner #$output)) > + (test-begin "dnsmasq") > + > + (test-assert "dnsmasq is alive" > + (marionette-eval > + '(begin > + (use-modules (gnu services herd)) > + (wait-for-service 'dnsmasq)) > + marionette)) > + > + (test-assert "pid file exists" > + (wait-for-file > + '#$(dnsmasq-configuration-pid-file dnsmasq-os-configuration) > + marionette)) > + > + (test-assert "send SIGHUP" > + (positive? > + (marionette-eval > + '(begin > + (use-modules (ice-9 rdelim)) > + (system* "sync") > + (let* ((port (open-input-file "/tmp/dnsmasq.log"))) > + (seek port 0 SEEK_END) > + (system* "herd" "reload" "dnsmasq") > + (system* "sync") > + (let ((line (read-line port))) > + (close-port port) > + (string-contains line "read /etc/hosts")))) > + marionette))) Interesting! > + (test-assert "send SIGUSR1" > + (positive? > + (marionette-eval > + '(begin > + (use-modules (ice-9 rdelim)) > + (system* "sync") > + (let* ((port (open-input-file "/tmp/dnsmasq.log"))) > + (seek port 0 SEEK_END) > + (system* "herd" "stats" "dnsmasq") > + (system* "sync") > + (let ((line (read-line port))) > + (close-port port) > + (string-contains-ci line "time")))) > + marionette))) > + > + (test-assert "dnsmasq is alive" > + (marionette-eval > + '(begin > + (use-modules (gnu services herd)) > + (wait-for-service 'dnsmasq)) > + marionette)) > + > + (test-end)))) > + > + (gexp->derivation "dnsmasq-test" test)) That looks like a useful series. Could you please send a v4, integrating my requested changes? -- Thanks, Maxim From debbugs-submit-bounces@debbugs.gnu.org Thu May 08 13:50:33 2025 Received: (at 77204) by debbugs.gnu.org; 8 May 2025 17:50:33 +0000 Received: from localhost ([127.0.0.1]:59713 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1uD5OD-0007eD-9w for submit@debbugs.gnu.org; Thu, 08 May 2025 13:50:33 -0400 Received: from mail.mmer.org ([178.22.65.174]:51192) by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1uD5OA-0007dp-Ui for 77204@debbugs.gnu.org; Thu, 08 May 2025 13:50:31 -0400 Received: from mail.mmer.org (localhost [127.0.0.1]) by mail.mmer.org (OpenSMTPD) with ESMTP id 83efe286 for <77204@debbugs.gnu.org>; Thu, 8 May 2025 17:50:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed; d=mmer.org; h=from:to :subject:date:message-id:mime-version:content-transfer-encoding; s=dkim; bh=/bR/1xdqUnOecdlNp32VKD9yk0Ov6sQGQQ1+B8wdQDQ=; b=jxY/ WTbIGiF/3tKl8EukDyg+P/5TyslrcnqeNzXIVQVUP2mjP6cLvDmXHm59REV2FtEA oqaTbWwvR9PTF6Fd357OWjUBdztTdvtNJ3X5YV/Sm4BnLAiKau03KkOUeswmkEuT GTYH8n0xsTEjOIYpET2LQiSXJ7FZSOdsHvw4rZs= Received: from delta (208-91-20-31.ftth.glasoperator.nl [31.20.91.208]) by mail.mmer.org (OpenSMTPD) with ESMTPSA id 3f16029e (TLSv1.3:TLS_AES_256_GCM_SHA384:256:NO) for <77204@debbugs.gnu.org>; Thu, 8 May 2025 17:50:22 +0000 (UTC) From: Alexey Abramov To: 77204@debbugs.gnu.org Subject: [PATCH v4 0/3] dnsmasq service changes Date: Thu, 8 May 2025 19:47:40 +0200 Message-ID: X-Mailer: git-send-email 2.49.0 MIME-Version: 1.0 X-Debbugs-Cc: Gabriel Wicki , Ludovic Courtès , Maxim Cournoyer Content-Transfer-Encoding: 8bit X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: 77204 X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) Thank you, Maxim, for your thorough review. With v4 I did address all your suggestions (I hope I didn't miss anything ;)). I had an impression that `M-q' would do a proper formating of sentences, but apparently `sentence-end-double-space' is a hint to just break lines. Am i missing something? Regarding the commit messages, I kinda used to go to diff in magit and press `C' on a hunk and it does add things to the commit message. I did check git log and see people use different ways like (), [] and <>. Seems like a more personal stuff, but I would like to know more... With these v4 series: - I moved documentation of actions to the manual and not in the action procedures themselves. herd doc prints texi markups as is. - I removed indentation of fields. Alexey Abramov (3): services: dnsmasq: Add shepherd-provision and shepherd-requirement fields. services: dnsmasq: Add pid-file, conf-file and conf-dir configuration fields. services: dnsmasq: Add stats and reload shepherd actions. doc/guix-cookbook.texi | 4 +- doc/guix.texi | 78 +++++++++++++++++++++++++++-- gnu/services/dns.scm | 104 +++++++++++++++++++++++++++++++++++---- gnu/tests/networking.scm | 98 ++++++++++++++++++++++++++++++++++++ 4 files changed, 269 insertions(+), 15 deletions(-) base-commit: ac2d792aae241f5233ee3fdfa29cd3dbaeb9338c -- 2.49.0 From debbugs-submit-bounces@debbugs.gnu.org Thu May 08 13:50:35 2025 Received: (at 77204) by debbugs.gnu.org; 8 May 2025 17:50:35 +0000 Received: from localhost ([127.0.0.1]:59717 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1uD5OE-0007eT-OX for submit@debbugs.gnu.org; Thu, 08 May 2025 13:50:35 -0400 Received: from mail.mmer.org ([178.22.65.174]:51192) by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1uD5OC-0007dp-26 for 77204@debbugs.gnu.org; Thu, 08 May 2025 13:50:32 -0400 Received: from mail.mmer.org (localhost [127.0.0.1]) by mail.mmer.org (OpenSMTPD) with ESMTP id aca7030e for <77204@debbugs.gnu.org>; Thu, 8 May 2025 17:50:23 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed; d=mmer.org; h=from:to :subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; s=dkim; bh=Wo5E4PKD4t3Oa4TmO6Z44T+Gz Zo2RnDxzewPwgY7rN0=; b=7ci0lpq3khBVGqSrXy1VFiibaytDT5FATZcffJI7T /dPydygRpfeaaDOSnqCY8u33gTUGG6sIzm1ASQMDnby3p3YCEJKFu/o7qUKEVEL1 g8nBokzyQIfBIM4jYxxHvrfX9SNFTjRJU/8B9TfqjOxZAQcz4/2nps8bsee8i28e hk= Received: from delta (208-91-20-31.ftth.glasoperator.nl [31.20.91.208]) by mail.mmer.org (OpenSMTPD) with ESMTPSA id b352b3c6 (TLSv1.3:TLS_AES_256_GCM_SHA384:256:NO) for <77204@debbugs.gnu.org>; Thu, 8 May 2025 17:50:22 +0000 (UTC) From: Alexey Abramov To: 77204@debbugs.gnu.org Subject: [PATCH v4 1/3] services: dnsmasq: Add shepherd-provision and shepherd-requirement fields. Date: Thu, 8 May 2025 19:47:41 +0200 Message-ID: <50e5cf5522a10bc4f438d33847d01b5e6adfe676.1746726463.git.levenson@mmer.org> X-Mailer: git-send-email 2.49.0 In-Reply-To: References: MIME-Version: 1.0 X-Debbugs-Cc: Gabriel Wicki , Ludovic Courtès , Maxim Cournoyer Content-Transfer-Encoding: 8bit X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: 77204 X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) * gnu/services/dns.scm ()[provision]: Mark filed as deprecated with a warning. Set default to #f. [shepherd-provision]: Add new field for consistency with other services. [shepherd-requirement]: Add new field. (dnsmasq-shepherd-service): Use them * doc/guix.texi: Document these changes. * doc/guix-cookbook.texi (Custom NAT-based network for libvirt): Update example to use 'shepherd-provision' instead of 'provision'. --- doc/guix-cookbook.texi | 4 ++-- doc/guix.texi | 11 ++++++++--- gnu/services/dns.scm | 24 ++++++++++++++++++++---- 3 files changed, 30 insertions(+), 9 deletions(-) diff --git a/doc/guix-cookbook.texi b/doc/guix-cookbook.texi index fb58866d404..3ebe661a078 100644 --- a/doc/guix-cookbook.texi +++ b/doc/guix-cookbook.texi @@ -4018,8 +4018,8 @@ Custom NAT-based network for libvirt (service dnsmasq-service-type (dnsmasq-configuration ;; You can have multiple instances of `dnsmasq-service-type` as long - ;; as each one has a different provision. - (provision '(dnsmasq-virbr0)) + ;; as each one has a different shepherd-provision. + (shepherd-provision '(dnsmasq-virbr0)) (extra-options (list ;; Only bind to the virtual bridge. This ;; avoids conflicts with other running diff --git a/doc/guix.texi b/doc/guix.texi index 889eab2ab35..279bbda9ac4 100644 --- a/doc/guix.texi +++ b/doc/guix.texi @@ -36086,9 +36086,14 @@ DNS Services @item @code{package} (default: @var{dnsmasq}) Package object of the dnsmasq server. -@item @code{provision} (default: @code{'(dnsmasq)}) -A list of symbols for the Shepherd service corresponding to this dnsmasq -configuration. +@item @code{shepherd-provision} (default: @code{'(dnsmasq)}) +@itemx @code{shepherd-requirement} (default: @code{'(user-processes networking)}) +This option can be used to provide a list of Shepherd service names +(symbols) provided by this service. You might want to change the default +value if you intend to run several @command{dnsmasq} instances. + +Likewise, @code{shepherd-requirement} is a list of Shepherd service names +(symbols) that this service will depend on. @item @code{no-hosts?} (default: @code{#f}) When true, don't read the hostnames in /etc/hosts. diff --git a/gnu/services/dns.scm b/gnu/services/dns.scm index 05291eb65d9..fd849d08e89 100644 --- a/gnu/services/dns.scm +++ b/gnu/services/dns.scm @@ -27,6 +27,7 @@ (define-module (gnu services dns) #:use-module (gnu system shadow) #:use-module (gnu packages admin) #:use-module (gnu packages dns) + #:use-module (guix deprecation) #:use-module (guix packages) #:use-module (guix records) #:use-module (guix gexp) @@ -742,8 +743,13 @@ (define-record-type* dnsmasq-configuration? (package dnsmasq-configuration-package (default dnsmasq)) ;file-like - (provision dnsmasq-provision - (default '(dnsmasq))) + (provision dnsmasq-configuration-provision ; deprecated + (default #f) + (sanitize warn-deprecated-dnsmasq-configuration-provision)) + (shepherd-provision dnsmasq-configuration-shepherd-provision + (default '(dnsmasq))) + (shepherd-requirement dnsmasq-configuration-shepherd-requirement + (default '(user-processes networking))) (no-hosts? dnsmasq-configuration-no-hosts? (default #f)) ;boolean (port dnsmasq-configuration-port @@ -799,9 +805,19 @@ (define-record-type* (tftp-unique-root dnsmasq-tftp-unique-root (default #f))) ;"" or "ip" or "mac" +(define (warn-deprecated-dnsmasq-configuration-provision value) + (when (pair? value) + (warn-about-deprecation + 'provision #f + #:replacement 'shepherd-provision)) + value) + (define (dnsmasq-shepherd-service config) (match-record config (package + provision + shepherd-provision + shepherd-requirement no-hosts? port local-service? listen-addresses resolv-file no-resolv? @@ -815,8 +831,8 @@ (define (dnsmasq-shepherd-service config) tftp-lowercase? tftp-port-range tftp-root tftp-unique-root extra-options) (shepherd-service - (provision (dnsmasq-provision config)) - (requirement '(user-processes networking)) + (provision (or provision shepherd-provision)) + (requirement shepherd-requirement) (documentation "Run the dnsmasq DNS server.") (start #~(make-forkexec-constructor (list -- 2.49.0 From debbugs-submit-bounces@debbugs.gnu.org Thu May 08 13:50:37 2025 Received: (at 77204) by debbugs.gnu.org; 8 May 2025 17:50:38 +0000 Received: from localhost ([127.0.0.1]:59719 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1uD5OH-0007ei-8C for submit@debbugs.gnu.org; Thu, 08 May 2025 13:50:37 -0400 Received: from mail.mmer.org ([178.22.65.174]:51192) by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1uD5OD-0007dp-4w for 77204@debbugs.gnu.org; Thu, 08 May 2025 13:50:34 -0400 Received: from mail.mmer.org (localhost [127.0.0.1]) by mail.mmer.org (OpenSMTPD) with ESMTP id 17053eea for <77204@debbugs.gnu.org>; Thu, 8 May 2025 17:50:23 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed; d=mmer.org; h=from:to :subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; s=dkim; bh=mqVb+k7Gc2KNY5iCWfTvZI8Qf cm/xmU4sjQE7+WttJQ=; b=rFAwixrnzabSslFJ4X3TYXLVMSdsM6rjH3dJ1HqhU o8Kq3YZ3Qku1SNnHaWnLFEGLw0Zk5ITHJd03s4s41HWdWiaZEnpw2JpnDH66oBH9 6Ak19OufFSKoU8I+kRA+ek9NCASOXjTGAg3/RNCsUUNN7NN57bp+UQ49iF6Nc+bt AA= Received: from delta (208-91-20-31.ftth.glasoperator.nl [31.20.91.208]) by mail.mmer.org (OpenSMTPD) with ESMTPSA id 217c7244 (TLSv1.3:TLS_AES_256_GCM_SHA384:256:NO) for <77204@debbugs.gnu.org>; Thu, 8 May 2025 17:50:23 +0000 (UTC) From: Alexey Abramov To: 77204@debbugs.gnu.org Subject: [PATCH v4 2/3] services: dnsmasq: Add pid-file, conf-file and conf-dir configuration fields. Date: Thu, 8 May 2025 19:47:42 +0200 Message-ID: <7546c2197d7d36a1a8682823cd5c6224e475addc.1746726463.git.levenson@mmer.org> X-Mailer: git-send-email 2.49.0 In-Reply-To: References: MIME-Version: 1.0 X-Debbugs-Cc: Gabriel Wicki , Ludovic Courtès , Maxim Cournoyer Content-Transfer-Encoding: 8bit X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: 77204 X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) * gnu/services/dns.scm ()[pid-file]: New field to specify alternate path for dnsmasq PID. [conf-file]: New field to specify one or more configuration files. [conf-dir]: New field to read configuration files from a directory. [extra-options]: Move to the end of the definition as a last resort option. (dnsmasq-shepherd-service): Use new fields instead of hardcoded values. * gnu/services/dns.scm: Export all record accessors. * doc/guix.texi: Document new configuration options. --- doc/guix.texi | 15 ++++++++++++ gnu/services/dns.scm | 58 +++++++++++++++++++++++++++++++++++++++----- 2 files changed, 67 insertions(+), 6 deletions(-) diff --git a/doc/guix.texi b/doc/guix.texi index 279bbda9ac4..ec096643eaa 100644 --- a/doc/guix.texi +++ b/doc/guix.texi @@ -36095,6 +36095,9 @@ DNS Services Likewise, @code{shepherd-requirement} is a list of Shepherd service names (symbols) that this service will depend on. +@item @code{pid-file} (default: @code{"/run/dnsmasq.pid"}) +Specify an alternate path for dnsmasq to record its process-id in. + @item @code{no-hosts?} (default: @code{#f}) When true, don't read the hostnames in /etc/hosts. @@ -36215,6 +36218,18 @@ DNS Services resolving MAC addresses is only possible if the client is in the local network or obtained a DHCP lease from dnsmasq. +@item @code{conf-file} (default: @code{'()}) +Specify a configuration file or multiple. The given value should be a +list of string paths to the configuration files. File-like objects are +also supported. + +@item @code{conf-dir} (default: @code{#f}) +Read all the files in the given directory as configuration files. +@command{dnsmasq} also supports extensions for the field, but here it is +not implemented. It is more convenient to make @code{computed-file} +directory in the store and use that. Files are loaded in alphabetical +order of filename. + @item @code{extra-options} (default: @code{'()}) This option provides an ``escape hatch'' for the user to provide arbitrary command-line arguments to @command{dnsmasq} as a list of strings. diff --git a/gnu/services/dns.scm b/gnu/services/dns.scm index fd849d08e89..d55ee3e4fcb 100644 --- a/gnu/services/dns.scm +++ b/gnu/services/dns.scm @@ -55,6 +55,38 @@ (define-module (gnu services dns) dnsmasq-service-type dnsmasq-configuration + dnsmasq-configuration-package + dnsmasq-configuration-shepherd-provision + dnsmasq-configuration-shepherd-requirement + dnsmasq-configuration-pid-file + dnsmasq-configuration-no-hosts? + dnsmasq-configuration-port + dnsmasq-configuration-local-service? + dnsmasq-configuration-listen-address + dnsmasq-configuration-resolv-file + dnsmasq-configuration-no-resolv? + dnsmasq-configuration-forward-private-reverse-lookup? + dnsmasq-configuration-query-servers-in-order? + dnsmasq-configuration-servers + dnsmasq-configuration-servers-file + dnsmasq-configuration-addresses + dnsmasq-configuration-cache-size + dnsmasq-configuration-negative-cache? + dnsmasq-configuration-cpe-id + dnsmasq-configuration-tftp-enable? + dnsmasq-configuration-tftp-no-fail? + dnsmasq-configuration-tftp-single-port? + dnsmasq-tftp-secure? + dnsmasq-tftp-max + dnsmasq-tftp-mtu + dnsmasq-tftp-no-blocksize? + dnsmasq-tftp-lowercase? + dnsmasq-tftp-port-range + dnsmasq-tftp-root + dnsmasq-tftp-unique-root + dnsmasq-configuration-conf-file + dnsmasq-configuration-conf-dir + dnsmasq-configuration-extra-options unbound-service-type unbound-configuration @@ -752,14 +784,14 @@ (define-record-type* (default '(user-processes networking))) (no-hosts? dnsmasq-configuration-no-hosts? (default #f)) ;boolean + (pid-file dnsmasq-configuration-pid-file + (default "/run/dnsmasq.pid")) ;string (port dnsmasq-configuration-port (default 53)) ;integer (local-service? dnsmasq-configuration-local-service? (default #t)) ;boolean (listen-addresses dnsmasq-configuration-listen-address (default '())) ;list of string - (extra-options dnsmasq-configuration-extra-options - (default '())) ;list of string (resolv-file dnsmasq-configuration-resolv-file (default "/etc/resolv.conf")) ;string (no-resolv? dnsmasq-configuration-no-resolv? @@ -803,7 +835,13 @@ (define-record-type* (tftp-root dnsmasq-tftp-root (default "/var/empty,lo")) ;string (tftp-unique-root dnsmasq-tftp-unique-root - (default #f))) ;"" or "ip" or "mac" + (default #f)) ;"" or "ip" or "mac" + (conf-file dnsmasq-configuration-conf-file + (default '())) ;list of string|file-like + (conf-dir dnsmasq-configuration-conf-dir + (default #f)) ;string|file-like + (extra-options dnsmasq-configuration-extra-options + (default '()))) ;list of string (define (warn-deprecated-dnsmasq-configuration-provision value) (when (pair? value) @@ -818,6 +856,7 @@ (define (dnsmasq-shepherd-service config) provision shepherd-provision shepherd-requirement + pid-file no-hosts? port local-service? listen-addresses resolv-file no-resolv? @@ -829,7 +868,8 @@ (define (dnsmasq-shepherd-service config) tftp-single-port? tftp-secure? tftp-max tftp-mtu tftp-no-blocksize? tftp-lowercase? tftp-port-range - tftp-root tftp-unique-root extra-options) + tftp-root tftp-unique-root + conf-file conf-dir extra-options) (shepherd-service (provision (or provision shepherd-provision)) (requirement shepherd-requirement) @@ -838,7 +878,7 @@ (define (dnsmasq-shepherd-service config) (list #$(file-append package "/sbin/dnsmasq") "--keep-in-foreground" - "--pid-file=/run/dnsmasq.pid" + (string-append "--pid-file=" #$pid-file) #$@(if no-hosts? '("--no-hosts") '()) @@ -909,8 +949,14 @@ (define (dnsmasq-shepherd-service config) (format #f "--tftp-unique-root=~a" tftp-unique-root) (format #f "--tftp-unique-root"))) '()) + #$@(map (lambda (conf-file) + #~(string-append "--conf-file=" #$conf-file)) + conf-file) + #$@(if conf-dir + (list #~(string-append "--conf-dir=" #$conf-dir)) + '()) #$@extra-options) - #:pid-file "/run/dnsmasq.pid")) + #:pid-file #$pid-file)) (stop #~(make-kill-destructor))))) (define (dnsmasq-activation config) -- 2.49.0 From debbugs-submit-bounces@debbugs.gnu.org Thu May 08 13:50:38 2025 Received: (at 77204) by debbugs.gnu.org; 8 May 2025 17:50:38 +0000 Received: from localhost ([127.0.0.1]:59721 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1uD5OH-0007em-RI for submit@debbugs.gnu.org; Thu, 08 May 2025 13:50:38 -0400 Received: from mail.mmer.org ([178.22.65.174]:51192) by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1uD5OE-0007dp-CL for 77204@debbugs.gnu.org; Thu, 08 May 2025 13:50:35 -0400 Received: from mail.mmer.org (localhost [127.0.0.1]) by mail.mmer.org (OpenSMTPD) with ESMTP id 56ba2924 for <77204@debbugs.gnu.org>; Thu, 8 May 2025 17:50:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed; d=mmer.org; h=from:to :subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; s=dkim; bh=hjkpYhLz3nO4nCid3HAjVGLsZ I5kVK+2gr7GZ/FyksU=; b=Jv1fHwvTf+0hjqTvN+vxdszLixw8GKlOQNQPOMBo6 PvwR3QcbhNv7D5yS+X81IYLjI4FYt+8CrjRko3YH3CC+5lA3Zot1uqjpqQV3afmH Rwul1pd8BXMpm7UVza2EXHIsxxHtsWiq2o7z97TKGWnkxYfFjDU/DFu83DxufIFB Qs= Received: from delta (208-91-20-31.ftth.glasoperator.nl [31.20.91.208]) by mail.mmer.org (OpenSMTPD) with ESMTPSA id fc22e554 (TLSv1.3:TLS_AES_256_GCM_SHA384:256:NO) for <77204@debbugs.gnu.org>; Thu, 8 May 2025 17:50:23 +0000 (UTC) From: Alexey Abramov To: 77204@debbugs.gnu.org Subject: [PATCH v4 3/3] services: dnsmasq: Add stats and reload shepherd actions. Date: Thu, 8 May 2025 19:47:43 +0200 Message-ID: <0780b834d037ca669f1f6edfb67b4b671aac8d58.1746726463.git.levenson@mmer.org> X-Mailer: git-send-email 2.49.0 In-Reply-To: References: MIME-Version: 1.0 X-Debbugs-Cc: Gabriel Wicki , Ludovic Courtès , Maxim Cournoyer Content-Transfer-Encoding: 8bit X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: 77204 X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) * gnu/services/dns.scm (dnsmasq-service-reload-action): New function. Implements SIGHUP handling for reloading configurations. (dnsmasq-service-stats-action): New function. Implements SIGUSR1 handling for dumping statistics. (dnsmasq-shepherd-service): Use new actions. * doc/guix.texi: Document new actions with examples. * gnu/tests/networking.scm (%test-dnsmasq): Add tests to verify the functionality of new actions. --- doc/guix.texi | 52 +++++++++++++++++++++ gnu/services/dns.scm | 22 +++++++++ gnu/tests/networking.scm | 98 ++++++++++++++++++++++++++++++++++++++++ 3 files changed, 172 insertions(+) diff --git a/doc/guix.texi b/doc/guix.texi index ec096643eaa..fa34eb4a8bc 100644 --- a/doc/guix.texi +++ b/doc/guix.texi @@ -36077,6 +36077,58 @@ DNS Services (no-resolv? #t) (servers '("192.168.1.1")))) @end lisp + +@code{dnsmasq-service-type} provides two actions: + +@table @code +@item reload +Send a @code{SIGHUP} signal to @command{dnsmasq} to clear cache and +reload hosts files which triggers the following actions: + +@itemize @bullet +@item +Clears the DNS cache +@item +Reloads @file{/etc/hosts} and @file{/etc/ethers} +@item +Reloads files specified by @option{--dhcp-hostsfile}, @option{--dhcp-hostsdir}, +@option{--dhcp-optsfile}, @option{--dhcp-optsdir}, @option{--addn-hosts}, +or @option{--hostsdir} +@item +Executes DHCP lease change scripts for all existing leases +@item +Rereads @file{/etc/resolv.conf} (only if @option{--no-poll} is configured) +@end itemize + +@emph{Note:} The @code{SIGHUP} signal does not trigger a reread of the main +configuration file. + +Example usage: +@example +herd reload dnsmasq +@end example + +@item stats +When @command{dnsmasq} receives a @code{SIGUSR1} signal, it writes +statistics to the system log including: + +@itemize @bullet +@item +Cache size and number of evicted entries +@item +Cache hits, misses, and authoritative queries answered +@item +For each upstream server: queries sent and errors received +@item +TCP connection fork statistics +@end itemize + +Example usage: +@example +herd stats dnsmasq +@end example +@end table + @end defvar @deftp {Data Type} dnsmasq-configuration diff --git a/gnu/services/dns.scm b/gnu/services/dns.scm index d55ee3e4fcb..9a9b78d877b 100644 --- a/gnu/services/dns.scm +++ b/gnu/services/dns.scm @@ -874,6 +874,8 @@ (define (dnsmasq-shepherd-service config) (provision (or provision shepherd-provision)) (requirement shepherd-requirement) (documentation "Run the dnsmasq DNS server.") + (actions (list (dnsmasq-service-reload-action config) + (dnsmasq-service-stats-action config))) (start #~(make-forkexec-constructor (list #$(file-append package "/sbin/dnsmasq") @@ -965,6 +967,26 @@ (define (dnsmasq-activation config) ;; create directory to store dnsmasq lease file (mkdir-p "/var/lib/misc"))) +(define (dnsmasq-service-reload-action config) + (match-record config () + (shepherd-action + (name 'reload) + (documentation "Send a @code{SIGHUP} signal to @command{dnsmasq} to clear +cache and reload hosts files.") + (procedure #~(lambda (running) + (let ((pid (process-id running))) + (kill pid SIGHUP))))))) + +(define (dnsmasq-service-stats-action config) + (match-record config () + (shepherd-action + (name 'stats) + (documentation "Send a @code{SIGUSR1} to write statistics to the system +log.") + (procedure #~(lambda (running) + (let ((pid (process-id running))) + (kill pid SIGUSR1))))))) + (define dnsmasq-service-type (service-type (name 'dnsmasq) diff --git a/gnu/tests/networking.scm b/gnu/tests/networking.scm index 7d54ebba50e..fdc515ceb04 100644 --- a/gnu/tests/networking.scm +++ b/gnu/tests/networking.scm @@ -27,6 +27,7 @@ (define-module (gnu tests networking) #:use-module (gnu system vm) #:use-module (gnu services) #:use-module (gnu services base) + #:use-module (gnu services dns) #:use-module (gnu services networking) #:use-module (guix gexp) #:use-module (guix store) @@ -46,6 +47,7 @@ (define-module (gnu tests networking) %test-openvswitch %test-dhcpd %test-dhcpcd + %test-dnsmasq %test-tor %test-iptables %test-ipfs)) @@ -675,6 +677,102 @@ (define %test-dhcpd (description "Test a running DHCP daemon configuration.") (value (run-dhcpd-test)))) + + +;;; +;;; dnsmasq tests +;;; + + +(define dnsmasq-os-configuration + (dnsmasq-configuration)) + +(define %dnsmasq-os + (simple-operating-system + (service dhcp-client-service-type) + (service dnsmasq-service-type + (dnsmasq-configuration + (extra-options + (list "--log-facility=/tmp/dnsmasq.log")))))) + + +(define (run-dnsmasq-test) + (define os + (marionette-operating-system %dnsmasq-os + #:imported-modules '((gnu services herd)))) + + (define test + (with-imported-modules '((gnu build marionette)) + #~(begin + (use-modules (gnu build marionette) + (srfi srfi-64)) + + (define marionette + (make-marionette (list #$(virtual-machine os)))) + + (test-runner-current (system-test-runner #$output)) + (test-begin "dnsmasq") + + (test-assert "dnsmasq is alive" + (marionette-eval + '(begin + (use-modules (gnu services herd)) + (wait-for-service 'dnsmasq)) + marionette)) + + (test-assert "pid file exists" + (wait-for-file + '#$(dnsmasq-configuration-pid-file dnsmasq-os-configuration) + marionette)) + + (test-assert "send SIGHUP" + (positive? + (marionette-eval + '(begin + (use-modules (ice-9 rdelim)) + (system* "sync") + (let* ((port (open-input-file "/tmp/dnsmasq.log"))) + (seek port 0 SEEK_END) + (system* "herd" "reload" "dnsmasq") + (system* "sync") + (let ((line (read-line port))) + (close-port port) + (string-contains line "read /etc/hosts")))) + marionette))) + + (test-assert "send SIGUSR1" + (positive? + (marionette-eval + '(begin + (use-modules (ice-9 rdelim)) + (system* "sync") + (let* ((port (open-input-file "/tmp/dnsmasq.log"))) + (seek port 0 SEEK_END) + (system* "herd" "stats" "dnsmasq") + (system* "sync") + (let ((line (read-line port))) + (close-port port) + (string-contains-ci line "time")))) + marionette))) + + (test-assert "dnsmasq is alive" + (marionette-eval + '(begin + (use-modules (gnu services herd)) + (wait-for-service 'dnsmasq)) + marionette)) + + (test-end)))) + + (gexp->derivation "dnsmasq-test" test)) + +(define %test-dnsmasq + (system-test + (name "dnsmasq") + (description "Test a running dnsmasq daemon configuration.") + (value (run-dnsmasq-test)))) + + ;;; ;;; DHCPCD Daemon -- 2.49.0 From debbugs-submit-bounces@debbugs.gnu.org Fri May 16 09:04:19 2025 Received: (at 77204-done) by debbugs.gnu.org; 16 May 2025 13:04:19 +0000 Received: from localhost ([127.0.0.1]:37111 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1uFuja-0004Jf-OP for submit@debbugs.gnu.org; Fri, 16 May 2025 09:04:19 -0400 Received: from mail-pf1-x429.google.com ([2607:f8b0:4864:20::429]:50629) by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.84_2) (envelope-from ) id 1uFujX-0004J2-Q8 for 77204-done@debbugs.gnu.org; Fri, 16 May 2025 09:04:16 -0400 Received: by mail-pf1-x429.google.com with SMTP id d2e1a72fcca58-73712952e1cso2067703b3a.1 for <77204-done@debbugs.gnu.org>; Fri, 16 May 2025 06:04:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1747400650; x=1748005450; darn=debbugs.gnu.org; h=mime-version:user-agent:message-id:date:references:in-reply-to :subject:cc:to:from:from:to:cc:subject:date:message-id:reply-to; bh=1QZWyEtD8ye0pPs+tjcY5v4VR9rz1BTM13oMmFgIKlI=; b=Zgd/+836m2NMaM0xSdKhl7Xk7h4WsJvtGG+ZidReMP/2EicmHoZCnI89L2PRAltpV1 qRG8JUwf8/1MRhvkavho6uySNijXzHNrYcsqE0SuE/eCvqbyPzQsua1oCNJjBn6N5YOj +/DjtWBb79YEwhh6XaTzq5CgMkXBqOGQC66HZav63Lp9fjJR7Ov/iaomzWW6L5RW7dWN dkedrxIYuopZfQGHwa8Q2Z+YY7LZT4D7H3Q/9sDzkskRhf7JzPgEnWw9noFEgWEn9+mZ 81O34i7GG/X+AQp8fjI4qFUZhdUdWs1f0sYCPPpoFzbHqmzZIPmKc/vkA70M1XYZDGK4 XLbw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1747400650; x=1748005450; h=mime-version:user-agent:message-id:date:references:in-reply-to :subject:cc:to:from:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=1QZWyEtD8ye0pPs+tjcY5v4VR9rz1BTM13oMmFgIKlI=; b=weaAXbH0qDr65S0aQENhcKChIj/WZitCH3QU4PNGOygP/C6p54osc5szM8+g/lY8/u 7Rby5j3GQICMoou9XO+4zB0u5cT1ML9FQrCVi/maNJcqc/UkPReiJwqG23X3q1yBlU6z koD5dvJqNRnghlPwdLZGrKoMSLM39FHSFYEqgOpMmVSy0/ntjeErTaOr2LFluYlB2OZ/ f05ShHg7//IkRPmsCV1YW7SU4aK+NYewwQ0tHlIUzpqPhjB87z+xpzyNfzaLg7q5e2LI te4V5iU8FDn9iciTR2It+qfA/i3TE3ZoAbY4CjT5mxdK4GntRirl7n2ZKeZWemWxPZ+9 BE3Q== X-Gm-Message-State: AOJu0YzY6MztKyrcC5TGiwLhV3eJJ1t84XxxFYdP0bj3OMYpUj7v0qoI 6rO15iWz81/aJFJXpEoL2uBY9RmmUjeLePSMxf48WCmcc/Q0yfSSK47owsYSww== X-Gm-Gg: ASbGnctkYj2r0dNqhUtMXUZJzFD76pZPtn1eFuVA9WlVjoNYhutf8d1gxFpAXKLu0FJ 4qT4DVWuSgUFNiYHVprkR8vDvUPDKPZ0nY9vcw6/oK/uGdfRVTgdi6zfTDqp5iaD7/fSG+eSfkS RioCEL3WXd9Z7OUTonyzMT5cb88aATuG3bo9oxQdTDYOCLNop6nHLLpQhT5oSS6qpat/DPIeL51 CQ29HSpnJgxGnjHAbe5PnATwPsmUA+xja5jp42uaZL3e7AezbRFOfHAR640NdaxFZpZmRx7ZjBT BBfZ5ZGx9e9mjztk3C48N/3y5yiSs1eOmxjn77TJg+/l+Kenag== X-Google-Smtp-Source: AGHT+IGwEyTCw6EcTMhtm/FPbtCWk9rqI12WEhlxqX0EpVsxYAdemdyAdFRCdvSt50/LTBMgx6LjsQ== X-Received: by 2002:a05:6a21:710a:b0:1f5:8179:4f47 with SMTP id adf61e73a8af0-2170ccabe9emr3474763637.20.1747400649561; Fri, 16 May 2025 06:04:09 -0700 (PDT) Received: from terra ([2405:6586:be0:0:83c8:d31d:2cec:f542]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-231daf86899sm12519815ad.105.2025.05.16.06.04.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 16 May 2025 06:04:08 -0700 (PDT) From: Maxim Cournoyer To: Alexey Abramov Subject: Re: [bug#77204] [PATCH v4 0/3] dnsmasq service changes In-Reply-To: (Alexey Abramov's message of "Thu, 8 May 2025 19:47:40 +0200") References: Date: Fri, 16 May 2025 22:04:05 +0900 Message-ID: <87a57chflm.fsf@gmail.com> User-Agent: Gnus/5.13 (Gnus v5.13) MIME-Version: 1.0 Content-Type: text/plain X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: 77204-done Cc: 77204-done@debbugs.gnu.org, Ludovic =?utf-8?Q?Court=C3=A8s?= , Gabriel Wicki X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) Hi Alexey! Alexey Abramov writes: > Thank you, Maxim, for your thorough review. With v4 I did address all > your suggestions (I hope I didn't miss anything ;)). Thank you! > I had an impression that `M-q' would do a proper formating of > sentences, but apparently `sentence-end-double-space' is a hint to > just break lines. Am i missing something? That's what it does for me. I do use paredit-mode, which rebinds this to paredit-reindent-defun. > Regarding the commit messages, I kinda used to go to diff in magit and > press `C' on a hunk and it does add things to the commit message. I > did check git log and see people use different ways like (), [] and > <>. Seems like a more personal stuff, but I would like to know > more... You are right that there are various preferences/dialect in use. [ ] are documented as for conditional changes, but we use that in Guix to denote record's fields. (info "(standards) Style of Change Logs") has more examples about it. Some people like to preserve the hierarchy of things, e.g. --8<---------------cut here---------------start------------->8--- [arguments] <#:phases>: Add X phases. --8<---------------cut here---------------end--------------->8--- Some others prefer to flatten things a bit: --8<---------------cut here---------------start------------->8--- [phases] {patch-commands}: New phase. --8<---------------cut here---------------end--------------->8--- Both are acceptable in my opinion, as long as it is unambiguous. > With these v4 series: > > - I moved documentation of actions to the manual and not in the action > procedures themselves. herd doc prints texi markups as is. > > - I removed indentation of fields. Sounds good. I've done a few light touch ups/rewording in the change logs/documentation, such as: > Alexey Abramov (3): > services: dnsmasq: Add shepherd-provision and shepherd-requirement > fields. > services: dnsmasq: Add pid-file, conf-file and conf-dir configuration > fields. --8<---------------cut here---------------start------------->8--- modified doc/guix.texi @@ -36305,16 +36305,14 @@ DNS Services network or obtained a DHCP lease from dnsmasq. @item @code{conf-file} (default: @code{'()}) -Specify a configuration file or multiple. The given value should be a -list of string paths to the configuration files. File-like objects are -also supported. +File names of configuration files to use. Strings and file-like objects +are accepted. @item @code{conf-dir} (default: @code{#f}) Read all the files in the given directory as configuration files. -@command{dnsmasq} also supports extensions for the field, but here it is -not implemented. It is more convenient to make @code{computed-file} -directory in the store and use that. Files are loaded in alphabetical -order of filename. +Support for @command{dnsmasq} field extensions is not implemented; users +can use @code{computed-file} to build a directory of files instead. The +configuration files are loaded in alphabetical order of file name. @item @code{extra-options} (default: @code{'()}) This option provides an ``escape hatch'' for the user to provide arbitrary --8<---------------cut here---------------end--------------->8--- > services: dnsmasq: Add stats and reload shepherd actions. --8<---------------cut here---------------start------------->8--- modified doc/guix.texi @@ -36121,21 +36121,24 @@ DNS Services @itemize @bullet @item -Clears the DNS cache +Clear the DNS cache @item -Reloads @file{/etc/hosts} and @file{/etc/ethers} +Reload @file{/etc/hosts} and @file{/etc/ethers} @item -Reloads files specified by @option{--dhcp-hostsfile}, @option{--dhcp-hostsdir}, +Reload files specified by @option{--dhcp-hostsfile}, @option{--dhcp-hostsdir}, @option{--dhcp-optsfile}, @option{--dhcp-optsdir}, @option{--addn-hosts}, or @option{--hostsdir} @item -Executes DHCP lease change scripts for all existing leases +Execute DHCP lease change scripts for all existing leases @item -Rereads @file{/etc/resolv.conf} (only if @option{--no-poll} is configured) +Reread @file{/etc/resolv.conf} (only if @option{--no-poll} is +configured). @end itemize -@emph{Note:} The @code{SIGHUP} signal does not trigger a reread of the main +@quotation Note +The @code{SIGHUP} signal does not trigger a reload of the main configuration file. +@end quotation Example usage: @example @@ -36154,7 +36157,7 @@ DNS Services @item For each upstream server: queries sent and errors received @item -TCP connection fork statistics +TCP connection fork statistics. @end itemize Example usage: modified gnu/tests/networking.scm @@ -680,7 +680,7 @@ (define %test-dhcpd ;;; -;;; dnsmasq tests +;;; dnsmasq tests. ;;; --8<---------------cut here---------------end--------------->8--- And pushed! Thank you! -- Maxim From unknown Tue Jun 17 01:44:01 2025 Received: (at fakecontrol) by fakecontrolmessage; To: internal_control@debbugs.gnu.org From: Debbugs Internal Request Subject: Internal Control Message-Id: bug archived. Date: Sat, 14 Jun 2025 11:24:05 +0000 User-Agent: Fakemail v42.6.9 # This is a fake control message. # # The action: # bug archived. thanks # This fakemail brought to you by your local debbugs # administrator