From unknown Fri Jul 18 00:43:33 2025 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-Mailer: MIME-tools 5.509 (Entity 5.509) Content-Type: text/plain; charset=utf-8 From: bug#58223 <58223@debbugs.gnu.org> To: bug#58223 <58223@debbugs.gnu.org> Subject: Status: [PATCH 0/1] dhclient record configuration Reply-To: bug#58223 <58223@debbugs.gnu.org> Date: Fri, 18 Jul 2025 07:43:33 +0000 retitle 58223 [PATCH 0/1] dhclient record configuration reassign 58223 guix-patches submitter 58223 Alexey Abramov severity 58223 normal tag 58223 patch thanks From debbugs-submit-bounces@debbugs.gnu.org Sat Oct 01 09:11:39 2022 Received: (at submit) by debbugs.gnu.org; 1 Oct 2022 13:11:39 +0000 Received: from localhost ([127.0.0.1]:43953 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1oecHL-0000OU-Cj for submit@debbugs.gnu.org; Sat, 01 Oct 2022 09:11:39 -0400 Received: from lists.gnu.org ([209.51.188.17]:49386) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1oecHJ-0000OM-Kt for submit@debbugs.gnu.org; Sat, 01 Oct 2022 09:11:38 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:58674) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oecHJ-0007zQ-Fz for guix-patches@gnu.org; Sat, 01 Oct 2022 09:11:37 -0400 Received: from mail.mmer.org ([178.22.65.174]:39216) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oecHH-0003pa-SP for guix-patches@gnu.org; Sat, 01 Oct 2022 09:11:37 -0400 Received: from mail.mmer.org (localhost [127.0.0.1]) by mail.mmer.org (OpenSMTPD) with ESMTP id 4225233b for ; Sat, 1 Oct 2022 13:11:30 +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=8fCoUZW7TMIMj4uQap/uy3y7AG/qsKS6/wX5UT4vgKw=; b=L6wD Wwg5e+atYtWsLaaurzRUnOaS7233occblNCKwh2+nMlYr5Xr4aOz2VtZ2KA/WS4A L1eTUGkE7vsSo+rYMTEeWbilNHP/XyDiIf+lW4cVWUNXiYoEsC0QhgYlDJLE9Ci+ WzfQ3wOTKwpsjcuEGB187DcZOAfm1VaISgAXkaM= Received: from delta (j74210.upc-j.chello.nl [24.132.74.210]) by mail.mmer.org (OpenSMTPD) with ESMTPSA id d66160e6 (TLSv1.3:AEAD-AES256-GCM-SHA384:256:NO) for ; Sat, 1 Oct 2022 13:11:30 +0000 (UTC) From: Alexey Abramov To: guix-patches@gnu.org Subject: [PATCH 0/1] dhclient record configuration Date: Sat, 1 Oct 2022 15:11:12 +0200 Message-Id: <20221001131112.2649-1-levenson@mmer.org> X-Mailer: git-send-email 2.36.1 MIME-Version: 1.0 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, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-Spam-Score: -1.4 (-) 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: -2.4 (--) With this patch, dhclient will get its configuration record. The main reason for this is to be able to define a list of interfaces dhclient should be listening to. Such cases are common for routers and other network devices. This patch provides a deprecation message in case someone uses a custom dhclient package for this service, and recommends switching to a proper configuration. However, there is one thing that is not clear to me. I am configuring my router, where I have to have dhclient service which has to get an IP from the upstream, and also have dhcpd configuration for my private internal networks. Both services provision '(networking), which is not allowed right now. Alexey Abramov (1): services: dhcp-client: Implement and use a configuration record doc/guix.texi | 18 +++++- gnu/services/networking.scm | 114 ++++++++++++++++++++++-------------- 2 files changed, 85 insertions(+), 47 deletions(-) -- 2.36.1 From debbugs-submit-bounces@debbugs.gnu.org Sat Oct 01 09:13:17 2022 Received: (at 58223) by debbugs.gnu.org; 1 Oct 2022 13:13:17 +0000 Received: from localhost ([127.0.0.1]:43958 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1oecIu-0000RQ-QG for submit@debbugs.gnu.org; Sat, 01 Oct 2022 09:13:17 -0400 Received: from mail.mmer.org ([178.22.65.174]:46322) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1oecIs-0000RC-NG for 58223@debbugs.gnu.org; Sat, 01 Oct 2022 09:13:15 -0400 Received: from mail.mmer.org (localhost [127.0.0.1]) by mail.mmer.org (OpenSMTPD) with ESMTP id 3310f5a9 for <58223@debbugs.gnu.org>; Sat, 1 Oct 2022 13:13:08 +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=GH9nkz9Ya1sD0QqXy1KfAVmXSU9IDN5F/hY5FYxiZUg=; b=QNr9 MzHaMsUu1g+tMqjJqng2huw2E878CupS93kfPYPMCxTIwjwv4cJoPIUVPqEo36ry gyoj9KcT4vb789MYI78tRqjnRDSZQaQadT60tZ2UunIgFHtA/krCQDmXF6e7A1wx hLcC8Bozt9Yb+KZEDRFKXrSDogv+JEEywjTryj0= Received: from delta (j74210.upc-j.chello.nl [24.132.74.210]) by mail.mmer.org (OpenSMTPD) with ESMTPSA id 8bad73e5 (TLSv1.3:AEAD-AES256-GCM-SHA384:256:NO) for <58223@debbugs.gnu.org>; Sat, 1 Oct 2022 13:13:08 +0000 (UTC) From: Alexey Abramov To: 58223@debbugs.gnu.org Subject: [PATCH 1/1] services: dhcp-client: Implement and use a configuration record Date: Sat, 1 Oct 2022 15:12:57 +0200 Message-Id: <20221001131257.3407-1-levenson@mmer.org> X-Mailer: git-send-email 2.36.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: 58223 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/networking.scm (dhcp-client-configuration): New record configuration. (dhcp-client-shepherd-service): Implement a shepher service. Provide a deprication message for legacy configurations. (dhcp-client-service-type): Use dhcp-client-shepherd-service. * doc/guix.texi: Update documentation --- doc/guix.texi | 18 +++++- gnu/services/networking.scm | 114 ++++++++++++++++++++++-------------- 2 files changed, 85 insertions(+), 47 deletions(-) diff --git a/doc/guix.texi b/doc/guix.texi index 30eb7f4cbf..e425d98d26 100644 --- a/doc/guix.texi +++ b/doc/guix.texi @@ -19227,10 +19227,24 @@ the user mode network stack,,, QEMU, QEMU Documentation}). @cindex DHCP, networking service @defvr {Scheme Variable} dhcp-client-service-type This is the type of services that run @var{dhcp}, a Dynamic Host Configuration -Protocol (DHCP) client, on all the non-loopback network interfaces. Its value -is the DHCP client package to use, @code{isc-dhcp} by default. +Protocol (DHCP) client. @end defvr +@deftp {Data Type} dhcp-client-configuration +Data type representing the configuration of dhcp client network service. + +@table @asis +@item @code{package} (default: @code{isc-dhcp}) +DHCP client package to use. + +@item @code{interfaces} (default: @code{'()}) +List of strings of interface names that dhcp client should listen on. By +default dhcp client will listen on all available non-loopback interfaces +that can be activated (meaning, to set them up). (default: @code{'()}) + +@end table +@end deftp + @cindex NetworkManager @defvr {Scheme Variable} network-manager-service-type diff --git a/gnu/services/networking.scm b/gnu/services/networking.scm index 9d85728371..1185f7e57d 100644 --- a/gnu/services/networking.scm +++ b/gnu/services/networking.scm @@ -77,6 +77,10 @@ (define-module (gnu services networking) static-networking-service-type) #:export (%facebook-host-aliases dhcp-client-service-type + dhcp-client-configuration + dhcp-client-configuration? + dhcp-client-configuration-package + dhcp-client-configuration-interfaces dhcpd-service-type dhcpd-configuration @@ -259,52 +263,72 @@ (define %facebook-host-aliases fe80::1%lo0 www.connect.facebook.net fe80::1%lo0 apps.facebook.com\n") + +(define-record-type* + dhcp-client-configuration make-dhcp-client-configuration + dhcp-client-configuration? + (package dhcp-client-configuration-package ;file-like + (default isc-dhcp)) + ;; Empty list (means any) or a list of valid interfaces + (interfaces dhcp-client-configuration-interfaces + (default '()))) + +(define dhcp-client-shepherd-service + (match-lambda + (($ package interfaces) + (let ((pid-file "/var/run/dhclient.pid")) + (list (shepherd-service + (documentation "Set up networking via DHCP.") + (requirement '(user-processes udev)) + + ;; XXX: Running with '-nw' ("no wait") avoids blocking for a minute when + ;; networking is unavailable, but also means that the interface is not up + ;; yet when 'start' completes. To wait for the interface to be ready, one + ;; should instead monitor udev events. + (provision '(networking)) + + (start #~(lambda _ + (define dhclient + (string-append #$package "/sbin/dhclient")) + + ;; When invoked without any arguments, 'dhclient' discovers all + ;; non-loopback interfaces *that are up*. However, the relevant + ;; interfaces are typically down at this point. Thus we perform + ;; our own interface discovery here. + (define valid? + (lambda (interface) + (and (arp-network-interface? interface) + (not (loopback-network-interface? interface)) + ;; XXX: Make sure the interfaces are up so that + ;; 'dhclient' can actually send/receive over them. + ;; Ignore those that cannot be activated. + (false-if-exception + (set-network-interface-up interface))))) + (define ifaces + (filter valid? (or '#$interfaces + (all-network-interface-names)))) + + (false-if-exception (delete-file #$pid-file)) + (let ((pid (fork+exec-command + (cons* dhclient "-nw" + "-pf" #$pid-file ifaces)))) + (and (zero? (cdr (waitpid pid))) + (read-pid-file #$pid-file))))) + (stop #~(make-kill-destructor)))))) + (anything + (format (current-error-port) "warning: Defining dhcp-client service with +a single argument value being a client package to use, is deprecated. Please +use record instead.\n") + (dhcp-client-shepherd-service + (dhcp-client-configuration + (package anything)))))) + (define dhcp-client-service-type - (shepherd-service-type - 'dhcp-client - (lambda (dhcp) - (define dhclient - (file-append dhcp "/sbin/dhclient")) - - (define pid-file - "/var/run/dhclient.pid") - - (shepherd-service - (documentation "Set up networking via DHCP.") - (requirement '(user-processes udev)) - - ;; XXX: Running with '-nw' ("no wait") avoids blocking for a minute when - ;; networking is unavailable, but also means that the interface is not up - ;; yet when 'start' completes. To wait for the interface to be ready, one - ;; should instead monitor udev events. - (provision '(networking)) - - (start #~(lambda _ - ;; When invoked without any arguments, 'dhclient' discovers all - ;; non-loopback interfaces *that are up*. However, the relevant - ;; interfaces are typically down at this point. Thus we perform - ;; our own interface discovery here. - (define valid? - (lambda (interface) - (and (arp-network-interface? interface) - (not (loopback-network-interface? interface)) - ;; XXX: Make sure the interfaces are up so that - ;; 'dhclient' can actually send/receive over them. - ;; Ignore those that cannot be activated. - (false-if-exception - (set-network-interface-up interface))))) - (define ifaces - (filter valid? (all-network-interface-names))) - - (false-if-exception (delete-file #$pid-file)) - (let ((pid (fork+exec-command - (cons* #$dhclient "-nw" - "-pf" #$pid-file ifaces)))) - (and (zero? (cdr (waitpid pid))) - (read-pid-file #$pid-file))))) - (stop #~(make-kill-destructor)))) - isc-dhcp - (description "Run @command{dhcp}, a Dynamic Host Configuration + (service-type (name 'dhcp-client) + (extensions + (list (service-extension shepherd-root-service-type dhcp-client-shepherd-service))) + (default-value (dhcp-client-configuration)) + (description "Run @command{dhcp}, a Dynamic Host Configuration Protocol (DHCP) client, on all the non-loopback network interfaces."))) (define-record-type* -- 2.36.1 From debbugs-submit-bounces@debbugs.gnu.org Wed Oct 05 18:05:05 2022 Received: (at 58223-done) by debbugs.gnu.org; 5 Oct 2022 22:05:05 +0000 Received: from localhost ([127.0.0.1]:58270 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ogCVk-0007Yh-NN for submit@debbugs.gnu.org; Wed, 05 Oct 2022 18:05:05 -0400 Received: from eggs.gnu.org ([209.51.188.92]:37688) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ogCVh-0007Y7-Lb for 58223-done@debbugs.gnu.org; Wed, 05 Oct 2022 18:05:02 -0400 Received: from fencepost.gnu.org ([2001:470:142:3::e]:45608) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ogCVc-000498-D4; Wed, 05 Oct 2022 18:04:56 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=MIME-Version:In-Reply-To:Date:References:Subject:To: From; bh=cGrCAi6K9aSaJMh512ubSqNsN4HVjdQYohya/iA2xfA=; b=e/dj98b/ErqI069bTzu6 fA2ewS0CNaTQJJjldkiZmnWaR5Ps9EFDh8e0QNDcgLbyJeYWJINBMpaFSFT7dtnhoJc4jZfZMK1Px PrSV34hAK8btN/AJlVokZUK1KLDt4+cIifTx/M5UEMZHNpbMgWz3VBSTKxpyGy+8QWFSdRdWJvcXY uQvAlOQms6c4Dn2d+JQn+JszlA8OYQ/3rFrvINcsvFmNh0t/dLd9HgYLcHPgvpAnTbx/TrqZCQI/r WColpwulK1Md7npqD0EsxecDtfQhm73RR1k7aFD560YQM/D01e/7+Wpq8k9FLyD7BCHREnb5a9YyL 1Z+0g1FsdMAhOw==; Received: from 91-160-117-201.subs.proxad.net ([91.160.117.201]:65059 helo=ribbon) by fencepost.gnu.org with esmtpsa (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ogCVb-0004T6-RY; Wed, 05 Oct 2022 18:04:56 -0400 From: =?utf-8?Q?Ludovic_Court=C3=A8s?= To: Alexey Abramov Subject: Re: bug#58223: [PATCH 0/1] dhclient record configuration References: <20221001131112.2649-1-levenson@mmer.org> <20221001131257.3407-1-levenson@mmer.org> Date: Thu, 06 Oct 2022 00:04:53 +0200 In-Reply-To: <20221001131257.3407-1-levenson@mmer.org> (Alexey Abramov's message of "Sat, 1 Oct 2022 15:12:57 +0200") Message-ID: <87edvmorju.fsf_-_@gnu.org> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.1 (gnu/linux) MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: 58223-done Cc: 58223-done@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: -3.3 (---) --=-=-= Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Hi, Alexey Abramov skribis: > * gnu/services/networking.scm (dhcp-client-configuration): New record > configuration. > (dhcp-client-shepherd-service): Implement a shepher service. Provide a > deprication message for legacy configurations. > (dhcp-client-service-type): Use dhcp-client-shepherd-service. > * doc/guix.texi: Update documentation [...] > + ;; Empty list (means any) or a list of valid interfaces > + (interfaces dhcp-client-configuration-interfaces > + (default '()))) [...] > + (define ifaces > + (filter valid? (or '#$interfaces > + (all-network-interface-nam= es)))) This isn=E2=80=99t quite right since '() is always true. For this and for aesthetic reasons, I changed =E2=80=98interfaces=E2=80=99 = such that it must be either 'all or a list. Applied with the changes below, thanks! Ludo=E2=80=99. --=-=-= Content-Type: text/x-patch Content-Disposition: inline diff --git a/doc/guix.texi b/doc/guix.texi index afc18239d4..6691ae5844 100644 --- a/doc/guix.texi +++ b/doc/guix.texi @@ -19234,17 +19234,19 @@ Protocol (DHCP) client. @end defvr @deftp {Data Type} dhcp-client-configuration -Data type representing the configuration of dhcp client network service. +Data type representing the configuration of the DHCP client service. @table @asis @item @code{package} (default: @code{isc-dhcp}) DHCP client package to use. -@item @code{interfaces} (default: @code{'()}) -List of strings of interface names that dhcp client should listen on. By -default dhcp client will listen on all available non-loopback interfaces -that can be activated (meaning, to set them up). (default: @code{'()}) +@item @code{interfaces} (default: @code{'all}) +Either @code{'all} or the list of interface names that the DHCP client +should listen on---e.g., @code{'("eno1")}. +When set to @code{'all}, the DHCP client listens on all the available +non-loopback interfaces that can be activated. Otherwise the DHCP +client listens only on the specified interfaces. @end table @end deftp diff --git a/gnu/services/networking.scm b/gnu/services/networking.scm index 1185f7e57d..19aba8c266 100644 --- a/gnu/services/networking.scm +++ b/gnu/services/networking.scm @@ -66,6 +66,9 @@ (define-module (gnu services networking) #:use-module (guix modules) #:use-module (guix packages) #:use-module (guix deprecation) + #:use-module (guix diagnostics) + #:autoload (guix ui) (display-hint) + #:use-module (guix i18n) #:use-module (rnrs enums) #:use-module (srfi srfi-1) #:use-module (srfi srfi-9) @@ -269,9 +272,8 @@ (define-record-type* dhcp-client-configuration? (package dhcp-client-configuration-package ;file-like (default isc-dhcp)) - ;; Empty list (means any) or a list of valid interfaces (interfaces dhcp-client-configuration-interfaces - (default '()))) + (default 'all))) ;'all | list of strings (define dhcp-client-shepherd-service (match-lambda @@ -305,8 +307,12 @@ (define valid? (false-if-exception (set-network-interface-up interface))))) (define ifaces - (filter valid? (or '#$interfaces - (all-network-interface-names)))) + (filter valid? + #$(match interfaces + ('all + #~(all-network-interface-names)) + (_ + #~'#$interfaces)))) (false-if-exception (delete-file #$pid-file)) (let ((pid (fork+exec-command @@ -315,18 +321,21 @@ (define ifaces (and (zero? (cdr (waitpid pid))) (read-pid-file #$pid-file))))) (stop #~(make-kill-destructor)))))) - (anything - (format (current-error-port) "warning: Defining dhcp-client service with -a single argument value being a client package to use, is deprecated. Please -use record instead.\n") + (package + (warning (G_ "'dhcp-client' service now expects a \ +'dhcp-client-configuration' record~%")) + (display-hint (G_ "The value associated with instances of +@code{dhcp-client-service-type} must now be a @code{dhcp-client-configuration} +record instead of a package. Please adjust your configuration accordingly.")) (dhcp-client-shepherd-service (dhcp-client-configuration - (package anything)))))) + (package package)))))) (define dhcp-client-service-type (service-type (name 'dhcp-client) (extensions - (list (service-extension shepherd-root-service-type dhcp-client-shepherd-service))) + (list (service-extension shepherd-root-service-type + dhcp-client-shepherd-service))) (default-value (dhcp-client-configuration)) (description "Run @command{dhcp}, a Dynamic Host Configuration Protocol (DHCP) client, on all the non-loopback network interfaces."))) diff --git a/po/guix/POTFILES.in b/po/guix/POTFILES.in index 4050a4c7ae..ed3fdb6be0 100644 --- a/po/guix/POTFILES.in +++ b/po/guix/POTFILES.in @@ -5,6 +5,7 @@ gnu/packages.scm gnu/services.scm gnu/system.scm gnu/services/configuration.scm +gnu/services/networking.scm gnu/services/shepherd.scm gnu/services/samba.scm gnu/home/services.scm --=-=-=-- From unknown Fri Jul 18 00:43:33 2025 Received: (at fakecontrol) by fakecontrolmessage; To: internal_control@debbugs.gnu.org From: Debbugs Internal Request Subject: Internal Control Message-Id: bug archived. Date: Thu, 03 Nov 2022 11:24:06 +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