From debbugs-submit-bounces@debbugs.gnu.org Sun Sep 08 08:07:13 2024 Received: (at submit) by debbugs.gnu.org; 8 Sep 2024 12:07:13 +0000 Received: from localhost ([127.0.0.1]:58113 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1snGhE-0000OQ-Kk for submit@debbugs.gnu.org; Sun, 08 Sep 2024 08:07:13 -0400 Received: from lists.gnu.org ([209.51.188.17]:51200) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1snGhB-0000OI-Jm for submit@debbugs.gnu.org; Sun, 08 Sep 2024 08:07:10 -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 1snGh9-0002i2-7v for guix-patches@gnu.org; Sun, 08 Sep 2024 08:07:07 -0400 Received: from mail-pf1-x429.google.com ([2607:f8b0:4864:20::429]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1snGh6-00029s-8q for guix-patches@gnu.org; Sun, 08 Sep 2024 08:07:06 -0400 Received: by mail-pf1-x429.google.com with SMTP id d2e1a72fcca58-718d606726cso1579365b3a.3 for ; Sun, 08 Sep 2024 05:07:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1725797219; x=1726402019; darn=gnu.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=jEm5QJhQImRZzg2yZvW/FOX5KG1PEinUogh8q+/KDEQ=; b=YI8z/ql2KOazOGixvoUTMxCHT2HwQTiKXWnN0Egx0++9CFf694pnZh+9MVZhI9jZsO B4Sfmc8gotTgy7RTMlqWsv9pwR4XBdc0+xtYsAzt0KHpns/ejIeqvuz2gidyZQlGIMxR 03RpBOMFQumnx346JSj71ejwsHgaseAq6K8Cyg/K6EYGzRHzzScSXPkcDIpmy3CoGKOm XwuZfPA1DDDpARm7CYoWcGZO3j2V/qIrneXQpskEl4y1T9YywfOaVIXhrVZXkrelXQ3O te35p4PlsmHAJq5n2pqCTGzRlI6fFdc22/MfUg8c4yX/Li7JbRFjUW0bn+L4pajlICZc LbTQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1725797219; x=1726402019; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=jEm5QJhQImRZzg2yZvW/FOX5KG1PEinUogh8q+/KDEQ=; b=qGytKIlzkBmlKdhCCCEbtlgF7NDwlHgsG3XUsh7OGe4pLp3v8nGxkkS60xG1yjtHcV 6uwIyyCcQLp3fq1J4BbYoNNX+wt1R7EVx7ItcagFLhajAgzrZ/gFpvA7R+ihgbxfSoVy 5FLARORNZ5LSzFzDtidDatPbhiCC3LIodjDYPHZkDzNxheoOjHSeLJgCtjIiap58Kd0Q /z7FkQkdjv7YV16JuZgbHshkqWCW3lC4VwwvXvXRsQukW1XDZOATEVMmg+XwW+t1svCn IwOukHBqS12Pxu+AQ4oRjPG4F+wamF16dhgytArIxey2btcX5Nj8h8Cl5IDgm+7O9Fe5 cpzw== X-Gm-Message-State: AOJu0Yyj4hzdK6Tsk9TZMF2eZR/F2s1KFHXkkTtDCqDANky9uEa5qcyx R992hz8RIJyNboYbRIwrgRaqFf6rBY3J7V+DtwxsJo3rfLTZ6QxVv3a2GnwC X-Google-Smtp-Source: AGHT+IHwclOSblOHOznsgUh4gioJnGmMvYc6TMcd9L0A8u6RdZHTjKfERdAq9kRPa8UkPUZRexdZgg== X-Received: by 2002:a05:6a21:a24c:b0:1cf:339e:a8d1 with SMTP id adf61e73a8af0-1cf339eabb3mr5114193637.10.1725797219049; Sun, 08 Sep 2024 05:06:59 -0700 (PDT) Received: from hurd.lan (vps-6234970c.vps.ovh.ca. [51.222.13.224]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-718e5896712sm1994241b3a.2.2024.09.08.05.06.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 08 Sep 2024 05:06:58 -0700 (PDT) From: Maxim Cournoyer To: guix-patches@gnu.org Subject: [PATCH] services: networking: Add 'version' field to dhcp-client-configuration. Date: Sun, 8 Sep 2024 21:06:44 +0900 Message-ID: <84f485d05604a93a5563d77f418c2a4981f21bba.1725797204.git.maxim.cournoyer@gmail.com> X-Mailer: git-send-email 2.46.0 MIME-Version: 1.0 X-Debbugs-Cc: Florian Pelz , Ludovic Courtès , Maxim Cournoyer Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit Received-SPF: pass client-ip=2607:f8b0:4864:20::429; envelope-from=maxim.cournoyer@gmail.com; helo=mail-pf1-x429.google.com 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, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-Spam-Score: -1.3 (-) X-Debbugs-Envelope-To: submit Cc: 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: -2.3 (--) * gnu/services/networking.scm () [version]: New field. (dhcp-client-shepherd-service): Use 'match-record' instead of various accessors. Honor the new 'version field'. Include the version the PID file name when a non-default version is used. * doc/guix.texi (Networking Setup) [version]: Document it. Change-Id: I6236ae160967c95fe7a2c1785821cc9b0c183e77 --- doc/guix.texi | 7 +- gnu/services/networking.scm | 131 +++++++++++++++++++----------------- 2 files changed, 76 insertions(+), 62 deletions(-) diff --git a/doc/guix.texi b/doc/guix.texi index 981ffb8c58..fe3f03e9da 100644 --- a/doc/guix.texi +++ b/doc/guix.texi @@ -49,7 +49,7 @@ Copyright @copyright{} 2017, 2021 Christine Lemmer-Webber@* Copyright @copyright{} 2017, 2018, 2019, 2020, 2021, 2022 Marius Bakke@* Copyright @copyright{} 2017, 2019, 2020, 2022 Hartmut Goebel@* -Copyright @copyright{} 2017, 2019, 2020, 2021, 2022, 2023 Maxim Cournoyer@* +Copyright @copyright{} 2017, 2019, 2020, 2021, 2022, 2023, 2024 Maxim Cournoyer@* Copyright @copyright{} 2017–2022 Tobias Geerinckx-Rice@* Copyright @copyright{} 2017 George Clemmer@* Copyright @copyright{} 2017 Andy Wingo@* @@ -21085,6 +21085,11 @@ Networking Setup @item @code{config-file} (default: @code{#f}) The configuration file for the ISC DHCP client. +@item @code{version} (default: @code{"4"}) +The DHCP protocol version to use, as a string. Accepted values are +@code{"4"} or @code{"6"} for DHCPv4 or DHCPv6, respectively, as well as +@code{"4o6"}, for DHCPv4 over DHCPv6 (as specified by RFC 7341). + @item @code{shepherd-requirement} (default: @code{'()}) @itemx @code{shepherd-provision} (default: @code{'(networking)}) This option can be used to provide a list of symbols naming Shepherd services diff --git a/gnu/services/networking.scm b/gnu/services/networking.scm index 12d8934e43..a1f5f37564 100644 --- a/gnu/services/networking.scm +++ b/gnu/services/networking.scm @@ -10,7 +10,7 @@ ;;; Copyright © 2018 Chris Marusich ;;; Copyright © 2018 Arun Isaac ;;; Copyright © 2019 Florian Pelz -;;; Copyright © 2019, 2021 Maxim Cournoyer +;;; Copyright © 2019, 2021, 2024 Maxim Cournoyer ;;; Copyright © 2019 Sou Bunnbu ;;; Copyright © 2019 Alex Griffin ;;; Copyright © 2020 Brice Waegeneire @@ -94,6 +94,7 @@ (define-module (gnu services networking) dhcp-client-configuration-config-file dhcp-client-configuration-shepherd-provision dhcp-client-configuration-shepherd-requirement + dhcp-client-configuration-version dhcpd-service-type dhcpd-configuration @@ -323,70 +324,78 @@ (define-record-type* (config-file dhcp-client-configuration-config-file (default #f)) (interfaces dhcp-client-configuration-interfaces - (default 'all))) ;'all | list of strings + (default 'all)) ;'all | list of strings + (version dhcp-client-configuration-version ;"4", "6", or "4o6" + (default "4"))) (define dhcp-client-shepherd-service (match-lambda ((? dhcp-client-configuration? config) - (let ((package (dhcp-client-configuration-package config)) - (requirement (dhcp-client-configuration-shepherd-requirement config)) - (provision (dhcp-client-configuration-shepherd-provision config)) - (interfaces (dhcp-client-configuration-interfaces config)) - (config-file (dhcp-client-configuration-config-file config)) - (pid-file "/var/run/dhclient.pid")) - (list (shepherd-service - (documentation "Set up networking via DHCP.") - (requirement `(user-processes udev ,@requirement)) - (provision provision) - - ;; 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. - (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? - #$(match interfaces - ('all - #~(all-network-interface-names)) - (_ - #~'#$interfaces)))) - - (define config-file-args - (if #$config-file - (list "-cf" #$config-file) - '())) - - (false-if-exception (delete-file #$pid-file)) - (let ((pid (fork+exec-command - ;; By default dhclient uses a - ;; pre-standardization implementation of - ;; DDNS, which is incompatable with - ;; non-ISC DHCP servers; thus, pass '-I'. - ;; . - `(,dhclient "-nw" "-I" - "-pf" ,#$pid-file - ,@config-file-args - ,@ifaces)))) - (and (zero? (cdr (waitpid pid))) - (read-pid-file #$pid-file))))) - (stop #~(make-kill-destructor)))))) + (match-record config + (package shepherd-requirement shepherd-provision + interfaces config-file version) + ;; Version the PID file to avoid conflicts in case multiple DHCP + ;; clients are run concurrently. + (let ((pid-file (if (string=? "4" version) + "/var/run/dhclient.pid" + (string-append "/var/run/dhclient-" version ".pid")))) + (list (shepherd-service + (documentation "Set up networking via DHCP.") + (requirement `(user-processes udev ,@shepherd-requirement)) + (provision shepherd-provision) + + ;; 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. + (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? + #$(match interfaces + ('all + #~(all-network-interface-names)) + (_ + #~'#$interfaces)))) + + (define config-file-args + (if #$config-file + (list "-cf" #$config-file) + '())) + + (false-if-exception (delete-file #$pid-file)) + (let ((pid (fork+exec-command + ;; By default dhclient uses a + ;; pre-standardization implementation of + ;; DDNS, which is incompatable with + ;; non-ISC DHCP servers; thus, pass '-I'. + ;; . + `(,dhclient "-nw" "-I" + #$(string-append "-" version) + "-pf" ,#$pid-file + ,@config-file-args + ,@ifaces)))) + (and (zero? (cdr (waitpid pid))) + (read-pid-file #$pid-file))))) + (stop #~(make-kill-destructor))))))) (package (warning (G_ "'dhcp-client' service now expects a \ 'dhcp-client-configuration' record~%")) base-commit: d0e361f50d927910c722cddda67b5a98168de36e -- 2.46.0 From debbugs-submit-bounces@debbugs.gnu.org Sun Oct 06 12:38:01 2024 Received: (at control) by debbugs.gnu.org; 6 Oct 2024 16:38:01 +0000 Received: from localhost ([127.0.0.1]:42160 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1sxUGf-0003Kl-2a for submit@debbugs.gnu.org; Sun, 06 Oct 2024 12:38:01 -0400 Received: from mail-pg1-f169.google.com ([209.85.215.169]:59421) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1sxUGd-0003Kd-CA for control@debbugs.gnu.org; Sun, 06 Oct 2024 12:37:59 -0400 Received: by mail-pg1-f169.google.com with SMTP id 41be03b00d2f7-7db238d07b3so3065380a12.2 for ; Sun, 06 Oct 2024 09:37:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1728232612; x=1728837412; darn=debbugs.gnu.org; h=subject:from:to:message-id:date:from:to:cc:subject:date:message-id :reply-to; bh=bU0lnRvUN87pElG4+0H6r5XnZQ9641HCsgY5vhedlu0=; b=Num7tsPRVz2HmSxEkvGZOWpq0+GCE4kf2h8+MIkutE9tYHGXDfrDlRI7eaAwVrIvcv QIxFjwvG1iIBDbtrH9wb82Dk6R+1VE5UWj7zsG77M8jYXSQdfsLuho2Vz9QR/zK4c2v1 XLkFapqIxVrbJEBljPADnxnqQwM9fJvUgZj1FCXvMsQ4MJKUFAWXJL6ci2znrmSJ9rA/ izA8+6R2ISGrkx5AxWClphz8VT6L2U/kv1e9cNIEqxtVtArQrnQUYmOlwN9IvZ/rBE25 x2NUVW2Y5t7ZxhPZHurm05abkBQBGt0qf6mZEyhjdRDWOG5qt7+rWmb8CS3U1oNQjioH FdUA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1728232612; x=1728837412; h=subject:from:to:message-id:date:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=bU0lnRvUN87pElG4+0H6r5XnZQ9641HCsgY5vhedlu0=; b=eJTlEwIamfz2XU1vzS3+hTklskrR25Bha5wKPaG9fxomu2Hsbk4kkav6V3r9cbA1Iz ExYdivj0bnVE+rjtUqiVuCMkXv/lLsNCEcr4heXX2uun6JG2L5+LvoyBJzJD2NOxS1uS yZcr/mRZ673bXEfh417fTxo28R/ELTMIOWJrqFXN+6sc22+Ij+F3/XHUv+laWr4XOMM0 VOvlbv2KNyQw2rSUyHKqqJdsWXsT/vwVa1C6zns8p5ySEX37Cc9kDQFbb/c0VEe+Ml7u xiMxrdSm4aM/XTW26d0h3MfYiZYbFhHyDj12KnlcDNc6WIvHpC6oF2X3tBZNW5KMABHu 3BMA== X-Gm-Message-State: AOJu0Yw87/70ic6Lov1QdRQ7gIJbhfbZhZy53iDOltZTOEcRvwR5cSp/ 4JwVF9nFFifzfE8hZB+oDN0hK3zzwfjBNoXm4tG4gcvlPhDJfTjiFlMeew== X-Google-Smtp-Source: AGHT+IE4zc21C+JburQDmktvDWeZ2ff+rA8qRgLrEdqH6ACUcOmS+PYfidSo4bsn6YtxRIzTQwnHNg== X-Received: by 2002:a05:6a21:3414:b0:1d4:e68c:2eb9 with SMTP id adf61e73a8af0-1d6dfa37653mr11858964637.20.1728232612151; Sun, 06 Oct 2024 09:36:52 -0700 (PDT) Received: from hurd ([2405:6586:be0:0:c8ff:1707:9b9:af89]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-71df0d66475sm3060522b3a.149.2024.10.06.09.36.50 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 06 Oct 2024 09:36:51 -0700 (PDT) Date: Mon, 07 Oct 2024 01:36:48 +0900 Message-Id: <87r08ti3xb.fsf@gmail.com> To: control@debbugs.gnu.org From: Maxim Cournoyer Subject: control message for bug #73120 X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: control 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 (-) close 73120 quit From unknown Tue Jun 17 01:44:26 2025 Received: (at fakecontrol) by fakecontrolmessage; To: internal_control@debbugs.gnu.org From: Debbugs Internal Request Subject: Internal Control Message-Id: bug archived. Date: Mon, 04 Nov 2024 12: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