From patchwork Wed Oct 27 14:02:36 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Ludovic_Court=C3=A8s?= X-Patchwork-Id: 34108 Return-Path: X-Original-To: patchwork@mira.cbaines.net Delivered-To: patchwork@mira.cbaines.net Received: by mira.cbaines.net (Postfix, from userid 113) id 99DEA27BBE3; Wed, 27 Oct 2021 15:52:07 +0100 (BST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on mira.cbaines.net X-Spam-Level: X-Spam-Status: No, score=-2.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, MAILING_LIST_MULTI,RCVD_IN_MSPIKE_H2,SPF_HELO_PASS,T_DKIM_INVALID, URIBL_BLOCKED autolearn=unavailable autolearn_force=no version=3.4.2 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mira.cbaines.net (Postfix) with ESMTPS id 1AF3027BBE1 for ; Wed, 27 Oct 2021 15:52:07 +0100 (BST) Received: from localhost ([::1]:54538 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mfkHd-0001i6-5v for patchwork@mira.cbaines.net; Wed, 27 Oct 2021 10:52:05 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:43120) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mfjX8-0008Je-Ba for guix-patches@gnu.org; Wed, 27 Oct 2021 10:04:03 -0400 Received: from debbugs.gnu.org ([209.51.188.43]:38540) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mfjX8-0005Fc-2Q for guix-patches@gnu.org; Wed, 27 Oct 2021 10:04:02 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1mfjX7-0002Yl-UM for guix-patches@gnu.org; Wed, 27 Oct 2021 10:04:01 -0400 X-Loop: help-debbugs@gnu.org Subject: [bug#51440] [PATCH 01/10] tests: Add 'static-networking' test. References: <20211027135918.18833-1-ludo@gnu.org> In-Reply-To: <20211027135918.18833-1-ludo@gnu.org> Resent-From: Ludovic =?utf-8?q?Court=C3=A8s?= Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Wed, 27 Oct 2021 14:04:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 51440 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: 51440@debbugs.gnu.org Cc: Ludovic =?utf-8?q?Court=C3=A8s?= Received: via spool by 51440-submit@debbugs.gnu.org id=B51440.16353433839630 (code B ref 51440); Wed, 27 Oct 2021 14:04:01 +0000 Received: (at 51440) by debbugs.gnu.org; 27 Oct 2021 14:03:03 +0000 Received: from localhost ([127.0.0.1]:50052 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1mfjWB-0002VG-AZ for submit@debbugs.gnu.org; Wed, 27 Oct 2021 10:03:03 -0400 Received: from eggs.gnu.org ([209.51.188.92]:45524) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1mfjW9-0002UZ-60 for 51440@debbugs.gnu.org; Wed, 27 Oct 2021 10:03:01 -0400 Received: from fencepost.gnu.org ([2001:470:142:3::e]:37962) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mfjW3-00057C-Jr; Wed, 27 Oct 2021 10:02:55 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=MIME-Version:Date:Subject:To:From:in-reply-to: references; bh=nIMYMSxGuVBBp0yBxrJ8NiTzp8VkdLuICWMDvMaM/7M=; b=LQDQbBJ8WERjiw r26s9bCgxillYF+2glRFmODt+dSJZDomJGnVODNMkZO6EHApZBZd2FAaARGeaPh5KGJ/v2olUrZKP 5V9RPgiWfqp3c5kc9OTdWNOBdEmedD00lRhvRWZbHF4L8LSj8tlGNM3wKF3NA9/UWTOVV6JKrvJCE eWLTxpKLDIOrnMhjRN2KY6n+0SPv0yjd1XkYL/gIh71VeNjXr6ru/XHgxh5fUBCljMAZgaaxqMEhE 1M8FwO4uYn0ZMIG1logivZVbNM1+KbrTmRY+HmRaEvvLjAo0Vpu+K1p8g9uxQyOCELJQIo2X1msw+ HaQnw+CZBcv6HjR51rJQ==; Received: from [2a01:e0a:1d:7270:af76:b9b:ca24:c465] (port=55004 helo=gnu.org) by fencepost.gnu.org with esmtpsa (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mfjW1-0002Tf-0w; Wed, 27 Oct 2021 10:02:53 -0400 From: Ludovic =?utf-8?q?Court=C3=A8s?= Date: Wed, 27 Oct 2021 16:02:36 +0200 Message-Id: <20211027140245.18970-1-ludo@gnu.org> X-Mailer: git-send-email 2.33.0 MIME-Version: 1.0 X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: guix-patches@gnu.org List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guix-patches-bounces+patchwork=mira.cbaines.net@gnu.org Sender: "Guix-patches" X-getmail-retrieved-from-mailbox: Patches * gnu/tests/networking.scm (run-static-networking-test): New procedure. (%test-static-networking): New variable. --- gnu/tests/networking.scm | 99 +++++++++++++++++++++++++++++++++++++++- 1 file changed, 97 insertions(+), 2 deletions(-) diff --git a/gnu/tests/networking.scm b/gnu/tests/networking.scm index 453e63f52d..5da1c91da6 100644 --- a/gnu/tests/networking.scm +++ b/gnu/tests/networking.scm @@ -4,6 +4,7 @@ ;;; Copyright © 2018 Chris Marusich ;;; Copyright © 2018 Arun Isaac ;;; Copyright © 2021 Maxime Devos +;;; Copyright © 2021 Ludovic Courtès ;;; ;;; This file is part of GNU Guix. ;;; @@ -37,8 +38,102 @@ (define-module (gnu tests networking) #:use-module (gnu packages guile) #:use-module (gnu services shepherd) #:use-module (ice-9 match) - #:export (%test-inetd %test-openvswitch %test-dhcpd %test-tor %test-iptables - %test-ipfs)) + #:export (%test-static-networking + %test-inetd + %test-openvswitch + %test-dhcpd + %test-tor + %test-iptables + %test-ipfs)) + + +;;; +;;; Static networking. +;;; + +(define (run-static-networking-test vm) + (define test + (with-imported-modules '((gnu build marionette) + (guix build syscalls)) + #~(begin + (use-modules (gnu build marionette) + (guix build syscalls) + (srfi srfi-64)) + + (define marionette + (make-marionette + '(#$vm "-nic" "user,model=virtio-net-pci"))) + + (mkdir #$output) + (chdir #$output) + + (test-begin "static-networking") + + (test-assert "service is up" + (marionette-eval + '(begin + (use-modules (gnu services herd)) + (start-service 'networking)) + marionette)) + + (test-assert "network interfaces" + (marionette-eval + '(begin + (use-modules (guix build syscalls)) + (network-interface-names)) + marionette)) + + (test-equal "address of eth0" + "10.0.2.15" + (marionette-eval + '(let* ((sock (socket AF_INET SOCK_STREAM 0)) + (addr (network-interface-address sock "eth0"))) + (close-port sock) + (inet-ntop (sockaddr:fam addr) (sockaddr:addr addr))) + marionette)) + + (test-equal "netmask of eth0" + "255.255.255.0" + (marionette-eval + '(let* ((sock (socket AF_INET SOCK_STREAM 0)) + (mask (network-interface-netmask sock "eth0"))) + (close-port sock) + (inet-ntop (sockaddr:fam mask) (sockaddr:addr mask))) + marionette)) + + (test-equal "eth0 is up" + IFF_UP + (marionette-eval + '(let* ((sock (socket AF_INET SOCK_STREAM 0)) + (flags (network-interface-flags sock "eth0"))) + (logand flags IFF_UP)) + marionette)) + + (test-end) + + (exit (= (test-runner-fail-count (test-runner-current)) 0))))) + + (gexp->derivation "static-networking" test)) + +(define %test-static-networking + (system-test + (name "static-networking") + (description "Test the 'static-networking' service.") + (value + (let ((os (marionette-operating-system + (simple-operating-system + (static-networking-service "eth0" "10.0.2.15" + #:netmask "255.255.255.0" + #:gateway "10.0.2.2" + #:name-servers '("10.0.2.2"))) + #:imported-modules '((gnu services herd) + (guix combinators))))) + (run-static-networking-test (virtual-machine os)))))) + + +;;; +;;; Inetd. +;;; (define %inetd-os ;; Operating system with 2 inetd services. From patchwork Wed Oct 27 14:02:37 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?q?Ludovic_Court=C3=A8s?= X-Patchwork-Id: 34114 Return-Path: X-Original-To: patchwork@mira.cbaines.net Delivered-To: patchwork@mira.cbaines.net Received: by mira.cbaines.net (Postfix, from userid 113) id 2B2CD27BBE3; Wed, 27 Oct 2021 16:08:11 +0100 (BST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on mira.cbaines.net X-Spam-Level: X-Spam-Status: No, score=-2.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, MAILING_LIST_MULTI,RCVD_IN_MSPIKE_H2,SPF_HELO_PASS,T_DKIM_INVALID, URIBL_BLOCKED autolearn=unavailable autolearn_force=no version=3.4.2 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mira.cbaines.net (Postfix) with ESMTPS id C1DFD27BBE1 for ; Wed, 27 Oct 2021 16:08:10 +0100 (BST) Received: from localhost ([::1]:33204 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mfkXB-0000FK-S7 for patchwork@mira.cbaines.net; Wed, 27 Oct 2021 11:08:09 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:43122) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mfjX8-0008Jj-Pa for guix-patches@gnu.org; Wed, 27 Oct 2021 10:04:03 -0400 Received: from debbugs.gnu.org ([209.51.188.43]:38541) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mfjX8-0005Fi-GD for guix-patches@gnu.org; Wed, 27 Oct 2021 10:04:02 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1mfjX8-0002Yt-Ba for guix-patches@gnu.org; Wed, 27 Oct 2021 10:04:02 -0400 X-Loop: help-debbugs@gnu.org Subject: [bug#51440] [PATCH 02/10] tests: openvswitch: Check whether ovs0 is up. Resent-From: Ludovic =?utf-8?q?Court=C3=A8s?= Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Wed, 27 Oct 2021 14:04:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 51440 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: 51440@debbugs.gnu.org Cc: Ludovic =?utf-8?q?Court=C3=A8s?= Received: via spool by 51440-submit@debbugs.gnu.org id=B51440.16353433879660 (code B ref 51440); Wed, 27 Oct 2021 14:04:02 +0000 Received: (at 51440) by debbugs.gnu.org; 27 Oct 2021 14:03:07 +0000 Received: from localhost ([127.0.0.1]:50058 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1mfjWE-0002Vc-Mt for submit@debbugs.gnu.org; Wed, 27 Oct 2021 10:03:07 -0400 Received: from eggs.gnu.org ([209.51.188.92]:45536) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1mfjWA-0002Ue-W9 for 51440@debbugs.gnu.org; Wed, 27 Oct 2021 10:03:03 -0400 Received: from fencepost.gnu.org ([2001:470:142:3::e]:37964) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mfjW5-00057L-8r; Wed, 27 Oct 2021 10:02:57 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=MIME-Version:References:In-Reply-To:Date:Subject:To: From; bh=edqJOsScW5bI/S3HqRrJmuoSxiZ5+fBAqUe91M9zBi0=; b=hO1wrPq/fnoi7zljCB+V r/0ndYaQF51tWbdJjFwrjDw4kglBct13GXKELej1uAJiutZY5xgegz7z512IIgNWKA+L62ph9NhAk oQOli0+XiHgvmYLOyAKRlyLCDdHw3DQyZCmXmOjmdGB9hm1yobPX5HiWv6Tgm2DV1av/nSkynq2HK XTeu3WtbNniIUhLC9qtb2HrCOsZcBlXWv1AYf5Cm5ZLwM4bT7ONIU+cVbH6OsbPzWIKCQvxxB6WmK 9qDCN26fzk2pNVwZWkS3jVtOPXs+5gylRXvlgs8UzEOJdj5D/bxidw6t9JMTY7Tfaf3eBNGgzEuyf 5okRlqP3KFyStw==; Received: from [2a01:e0a:1d:7270:af76:b9b:ca24:c465] (port=55004 helo=gnu.org) by fencepost.gnu.org with esmtpsa (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mfjW3-0002Tf-Rs; Wed, 27 Oct 2021 10:02:56 -0400 From: Ludovic =?utf-8?q?Court=C3=A8s?= Date: Wed, 27 Oct 2021 16:02:37 +0200 Message-Id: <20211027140245.18970-2-ludo@gnu.org> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20211027140245.18970-1-ludo@gnu.org> References: <20211027140245.18970-1-ludo@gnu.org> MIME-Version: 1.0 X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: guix-patches@gnu.org List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guix-patches-bounces+patchwork=mira.cbaines.net@gnu.org Sender: "Guix-patches" X-getmail-retrieved-from-mailbox: Patches * gnu/tests/networking.scm (run-openvswitch-test)["ovs0 is up"]: New test. --- gnu/tests/networking.scm | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/gnu/tests/networking.scm b/gnu/tests/networking.scm index 5da1c91da6..131428c128 100644 --- a/gnu/tests/networking.scm +++ b/gnu/tests/networking.scm @@ -286,12 +286,15 @@ (define %openvswitch-os (define (run-openvswitch-test) (define os (marionette-operating-system %openvswitch-os - #:imported-modules '((gnu services herd)))) + #:imported-modules '((gnu services herd) + (guix build syscalls)))) (define test - (with-imported-modules '((gnu build marionette)) + (with-imported-modules '((gnu build marionette) + (guix build syscalls)) #~(begin (use-modules (gnu build marionette) + (guix build syscalls) (ice-9 popen) (ice-9 rdelim) (srfi srfi-64)) @@ -339,6 +342,18 @@ (define marionette (current-services)))) marionette)) + (test-equal "ovs0 is up" + IFF_UP + (marionette-eval + '(begin + (use-modules (guix build syscalls)) + + (let* ((sock (socket AF_INET SOCK_STREAM 0)) + (flags (network-interface-flags sock "ovs0"))) + (close-port sock) + (logand flags IFF_UP))) + marionette)) + (test-end) (exit (= (test-runner-fail-count (test-runner-current)) 0))))) From patchwork Wed Oct 27 14:02:38 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?q?Ludovic_Court=C3=A8s?= X-Patchwork-Id: 34111 Return-Path: X-Original-To: patchwork@mira.cbaines.net Delivered-To: patchwork@mira.cbaines.net Received: by mira.cbaines.net (Postfix, from userid 113) id BD72627BBE3; Wed, 27 Oct 2021 16:06:31 +0100 (BST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on mira.cbaines.net X-Spam-Level: X-Spam-Status: No, score=-2.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, MAILING_LIST_MULTI,RCVD_IN_MSPIKE_H2,SPF_HELO_PASS,T_DKIM_INVALID, URIBL_BLOCKED autolearn=unavailable autolearn_force=no version=3.4.2 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mira.cbaines.net (Postfix) with ESMTPS id AFBF527BBE1 for ; Wed, 27 Oct 2021 16:06:30 +0100 (BST) Received: from localhost ([::1]:58168 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mfkVZ-0006V0-PE for patchwork@mira.cbaines.net; Wed, 27 Oct 2021 11:06:29 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:43140) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mfjX9-0008KR-Lv for guix-patches@gnu.org; Wed, 27 Oct 2021 10:04:03 -0400 Received: from debbugs.gnu.org ([209.51.188.43]:38543) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mfjX9-0005G9-8v for guix-patches@gnu.org; Wed, 27 Oct 2021 10:04:03 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1mfjX9-0002Z8-4n for guix-patches@gnu.org; Wed, 27 Oct 2021 10:04:03 -0400 X-Loop: help-debbugs@gnu.org Subject: [bug#51440] [PATCH 03/10] doc: Add new "Networking Setup" node for the main setup options. Resent-From: Ludovic =?utf-8?q?Court=C3=A8s?= Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Wed, 27 Oct 2021 14:04:03 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 51440 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: 51440@debbugs.gnu.org Cc: Ludovic =?utf-8?q?Court=C3=A8s?= Received: via spool by 51440-submit@debbugs.gnu.org id=B51440.16353433989725 (code B ref 51440); Wed, 27 Oct 2021 14:04:03 +0000 Received: (at 51440) by debbugs.gnu.org; 27 Oct 2021 14:03:18 +0000 Received: from localhost ([127.0.0.1]:50072 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1mfjWM-0002Wb-Ki for submit@debbugs.gnu.org; Wed, 27 Oct 2021 10:03:18 -0400 Received: from eggs.gnu.org ([209.51.188.92]:45544) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1mfjWD-0002Uj-0c for 51440@debbugs.gnu.org; Wed, 27 Oct 2021 10:03:06 -0400 Received: from fencepost.gnu.org ([2001:470:142:3::e]:37966) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mfjW6-00057W-PD; Wed, 27 Oct 2021 10:02:58 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=MIME-Version:References:In-Reply-To:Date:Subject:To: From; bh=An33jywAnh0CXNFaHA9/3PoKi7M+6kESv8rS/zZPC60=; b=R1OKx9P76IFv0AjePiH3 dd08XIxWG850dRPPBi2/iWrcRxv8k7DGCrapq963UFM2+sf1MKZPpLC56RdStmlBKvkub74eQLmnY vyFr80ivqkzEJ0L+XajyKbajTUZhMk6Ilq1kWh+DhIwKq8Mo3l1GSKtmFWclkbzAl38lUWZdj+Rcc 4WlwctkXjTW0fMuB6w0QUAmObjBbjqjpH3Gx+o5jQMhTMB/DYG8zbbdfqejHJJLPszYwXxqpoa21C c2ymCiE9IKjz80ito6e8AT2kmsNCKtTfDFmcsYC2tJRtwY+YY/pTlva3RFHdj2xpEihY4/MIwB4Tv E3YSVN19w26lNg==; Received: from [2a01:e0a:1d:7270:af76:b9b:ca24:c465] (port=55004 helo=gnu.org) by fencepost.gnu.org with esmtpsa (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mfjW5-0002Tf-Gi; Wed, 27 Oct 2021 10:02:58 -0400 From: Ludovic =?utf-8?q?Court=C3=A8s?= Date: Wed, 27 Oct 2021 16:02:38 +0200 Message-Id: <20211027140245.18970-3-ludo@gnu.org> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20211027140245.18970-1-ludo@gnu.org> References: <20211027140245.18970-1-ludo@gnu.org> MIME-Version: 1.0 X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: guix-patches@gnu.org List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guix-patches-bounces+patchwork=mira.cbaines.net@gnu.org Sender: "Guix-patches" X-getmail-retrieved-from-mailbox: Patches This should make it easier to find how to get started setting up networking. * doc/guix.texi (Networking Setup): New section. (Networking Services): Remove 'static-networking-service', 'dhcp-client-service-type', 'network-manager-service-type', 'connman-service-type', 'wicd-service', 'modem-manager-service-type', 'usb-modeswitch-service-type', and 'wpa-supplicant-service-type'. --- doc/guix.texi | 289 ++++++++++++++++++++++++++++---------------------- 1 file changed, 160 insertions(+), 129 deletions(-) diff --git a/doc/guix.texi b/doc/guix.texi index 22215214e0..f7de378bdd 100644 --- a/doc/guix.texi +++ b/doc/guix.texi @@ -342,7 +342,8 @@ Services * Base Services:: Essential system services. * Scheduled Job Execution:: The mcron service. * Log Rotation:: The rottlog service. -* Networking Services:: Network setup, SSH daemon, etc. +* Networking Setup:: Setting up network interfaces. +* Networking Services:: Firewall, SSH daemon, etc. * Unattended Upgrades:: Automated system upgrades. * X Window:: Graphical display. * Printing Services:: Local and remote printer support. @@ -15516,7 +15517,8 @@ declaration. * Base Services:: Essential system services. * Scheduled Job Execution:: The mcron service. * Log Rotation:: The rottlog service. -* Networking Services:: Network setup, SSH daemon, etc. +* Networking Setup:: Setting up network interfaces. +* Networking Services:: Firewall, SSH daemon, etc. * Unattended Upgrades:: Automated system upgrades. * X Window:: Graphical display. * Printing Services:: Local and remote printer support. @@ -16738,63 +16740,26 @@ The list of syslog-controlled files to be rotated. By default it is: "/var/log/maillog")}. @end defvr -@node Networking Services -@subsection Networking Services +@node Networking Setup +@subsection Networking Setup -The @code{(gnu services networking)} module provides services to configure -the network interface. +The @code{(gnu services networking)} module provides services to +configure network interfaces and set up networking on your machine. +Those services provide different ways for you to set up your machine: by +declaring a static network configuration, by running a Dynamic Host +Configuration Protocol (DHCP) client, or by running daemons such as +NetworkManager and Connman that automate the whole process, +automatically adapt to connectivity changes, and provide a high-level +user interface. -@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. -@end defvr +On a laptop, NetworkManager and Connman are by far the most convenient +options, which is why the default desktop services include +NetworkManager (@pxref{Desktop Services, @code{%desktop-services}}). +For a server, or for a virtual machine or a container, static network +configuration or a simple DHCP client are often more appropriate. -@deffn {Scheme Procedure} dhcpd-service-type -This type defines a service that runs a DHCP daemon. To create a -service of this type, you must supply a @code{}. -For example: - -@lisp -(service dhcpd-service-type - (dhcpd-configuration - (config-file (local-file "my-dhcpd.conf")) - (interfaces '("enp0s25")))) -@end lisp -@end deffn - -@deftp {Data Type} dhcpd-configuration -@table @asis -@item @code{package} (default: @code{isc-dhcp}) -The package that provides the DHCP daemon. This package is expected to -provide the daemon at @file{sbin/dhcpd} relative to its output -directory. The default package is the -@uref{https://www.isc.org/products/DHCP, ISC's DHCP server}. -@item @code{config-file} (default: @code{#f}) -The configuration file to use. This is required. It will be passed to -@code{dhcpd} via its @code{-cf} option. This may be any ``file-like'' -object (@pxref{G-Expressions, file-like objects}). See @code{man -dhcpd.conf} for details on the configuration file syntax. -@item @code{version} (default: @code{"4"}) -The DHCP version to use. The ISC DHCP server supports the values ``4'', -``6'', and ``4o6''. These correspond to the @code{dhcpd} program -options @code{-4}, @code{-6}, and @code{-4o6}. See @code{man dhcpd} for -details. -@item @code{run-directory} (default: @code{"/run/dhcpd"}) -The run directory to use. At service activation time, this directory -will be created if it does not exist. -@item @code{pid-file} (default: @code{"/run/dhcpd/dhcpd.pid"}) -The PID file to use. This corresponds to the @code{-pf} option of -@code{dhcpd}. See @code{man dhcpd} for details. -@item @code{interfaces} (default: @code{'()}) -The names of the network interfaces on which dhcpd should listen for -broadcasts. If this list is not empty, then its elements (which must be -strings) will be appended to the @code{dhcpd} invocation when starting -the daemon. It may not be necessary to explicitly specify any -interfaces here; see @code{man dhcpd} for details. -@end table -@end deftp +This section describes the various network setup services available, +starting with static network configuration. @defvr {Scheme Variable} static-networking-service-type This is the type for statically-configured network interfaces. @@ -16824,81 +16789,13 @@ For example: @end lisp @end deffn -@cindex wicd -@cindex wireless -@cindex WiFi -@cindex network management -@deffn {Scheme Procedure} wicd-service [#:wicd @var{wicd}] -Return a service that runs @url{https://launchpad.net/wicd,Wicd}, a network -management daemon that aims to simplify wired and wireless networking. - -This service adds the @var{wicd} package to the global profile, providing -several commands to interact with the daemon and configure networking: -@command{wicd-client}, a graphical user interface, and the @command{wicd-cli} -and @command{wicd-curses} user interfaces. -@end deffn - -@cindex ModemManager - -@defvr {Scheme Variable} modem-manager-service-type -This is the service type for the -@uref{https://wiki.gnome.org/Projects/ModemManager, ModemManager} -service. The value for this service type is a -@code{modem-manager-configuration} record. - -This service is part of @code{%desktop-services} (@pxref{Desktop -Services}). +@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. @end defvr -@deftp {Data Type} modem-manager-configuration -Data type representing the configuration of ModemManager. - -@table @asis -@item @code{modem-manager} (default: @code{modem-manager}) -The ModemManager package to use. - -@end table -@end deftp - -@cindex USB_ModeSwitch -@cindex Modeswitching - -@defvr {Scheme Variable} usb-modeswitch-service-type -This is the service type for the -@uref{https://www.draisberghof.de/usb_modeswitch/, USB_ModeSwitch} -service. The value for this service type is -a @code{usb-modeswitch-configuration} record. - -When plugged in, some USB modems (and other USB devices) initially present -themselves as a read-only storage medium and not as a modem. They need to be -@dfn{modeswitched} before they are usable. The USB_ModeSwitch service type -installs udev rules to automatically modeswitch these devices when they are -plugged in. - -This service is part of @code{%desktop-services} (@pxref{Desktop -Services}). -@end defvr - -@deftp {Data Type} usb-modeswitch-configuration -Data type representing the configuration of USB_ModeSwitch. - -@table @asis -@item @code{usb-modeswitch} (default: @code{usb-modeswitch}) -The USB_ModeSwitch package providing the binaries for modeswitching. - -@item @code{usb-modeswitch-data} (default: @code{usb-modeswitch-data}) -The package providing the device data and udev rules file used by -USB_ModeSwitch. - -@item @code{config-file} (default: @code{#~(string-append #$usb-modeswitch:dispatcher "/etc/usb_modeswitch.conf")}) -Which config file to use for the USB_ModeSwitch dispatcher. By default the -config file shipped with USB_ModeSwitch is used which disables logging to -@file{/var/log} among other default settings. If set to @code{#f}, no config -file is used. - -@end table -@end deftp - @cindex NetworkManager @defvr {Scheme Variable} network-manager-service-type @@ -17035,6 +16932,139 @@ List of additional command-line arguments to pass to the daemon. @end table @end deftp +@cindex wicd +@cindex wireless +@cindex WiFi +@cindex network management +@deffn {Scheme Procedure} wicd-service [#:wicd @var{wicd}] +Return a service that runs @url{https://launchpad.net/wicd,Wicd}, a network +management daemon that aims to simplify wired and wireless networking. + +This service adds the @var{wicd} package to the global profile, providing +several commands to interact with the daemon and configure networking: +@command{wicd-client}, a graphical user interface, and the @command{wicd-cli} +and @command{wicd-curses} user interfaces. +@end deffn + +@cindex ModemManager +Some networking devices such as modems require special care, and this is +what the services below focus on. + +@defvr {Scheme Variable} modem-manager-service-type +This is the service type for the +@uref{https://wiki.gnome.org/Projects/ModemManager, ModemManager} +service. The value for this service type is a +@code{modem-manager-configuration} record. + +This service is part of @code{%desktop-services} (@pxref{Desktop +Services}). +@end defvr + +@deftp {Data Type} modem-manager-configuration +Data type representing the configuration of ModemManager. + +@table @asis +@item @code{modem-manager} (default: @code{modem-manager}) +The ModemManager package to use. + +@end table +@end deftp + +@cindex USB_ModeSwitch +@cindex Modeswitching + +@defvr {Scheme Variable} usb-modeswitch-service-type +This is the service type for the +@uref{https://www.draisberghof.de/usb_modeswitch/, USB_ModeSwitch} +service. The value for this service type is +a @code{usb-modeswitch-configuration} record. + +When plugged in, some USB modems (and other USB devices) initially present +themselves as a read-only storage medium and not as a modem. They need to be +@dfn{modeswitched} before they are usable. The USB_ModeSwitch service type +installs udev rules to automatically modeswitch these devices when they are +plugged in. + +This service is part of @code{%desktop-services} (@pxref{Desktop +Services}). +@end defvr + +@deftp {Data Type} usb-modeswitch-configuration +Data type representing the configuration of USB_ModeSwitch. + +@table @asis +@item @code{usb-modeswitch} (default: @code{usb-modeswitch}) +The USB_ModeSwitch package providing the binaries for modeswitching. + +@item @code{usb-modeswitch-data} (default: @code{usb-modeswitch-data}) +The package providing the device data and udev rules file used by +USB_ModeSwitch. + +@item @code{config-file} (default: @code{#~(string-append #$usb-modeswitch:dispatcher "/etc/usb_modeswitch.conf")}) +Which config file to use for the USB_ModeSwitch dispatcher. By default the +config file shipped with USB_ModeSwitch is used which disables logging to +@file{/var/log} among other default settings. If set to @code{#f}, no config +file is used. + +@end table +@end deftp + + +@node Networking Services +@subsection Networking Services + +The @code{(gnu services networking)} module discussed in the previous +section provides services for more advanced setups: providing a DHCP +service for others to use, filtering packets with iptables or nftables, +running a WiFi access point with @command{hostapd}, running the +@command{inetd} ``superdaemon'', and more. This section describes +those. + +@deffn {Scheme Procedure} dhcpd-service-type +This type defines a service that runs a DHCP daemon. To create a +service of this type, you must supply a @code{}. +For example: + +@lisp +(service dhcpd-service-type + (dhcpd-configuration + (config-file (local-file "my-dhcpd.conf")) + (interfaces '("enp0s25")))) +@end lisp +@end deffn + +@deftp {Data Type} dhcpd-configuration +@table @asis +@item @code{package} (default: @code{isc-dhcp}) +The package that provides the DHCP daemon. This package is expected to +provide the daemon at @file{sbin/dhcpd} relative to its output +directory. The default package is the +@uref{https://www.isc.org/products/DHCP, ISC's DHCP server}. +@item @code{config-file} (default: @code{#f}) +The configuration file to use. This is required. It will be passed to +@code{dhcpd} via its @code{-cf} option. This may be any ``file-like'' +object (@pxref{G-Expressions, file-like objects}). See @code{man +dhcpd.conf} for details on the configuration file syntax. +@item @code{version} (default: @code{"4"}) +The DHCP version to use. The ISC DHCP server supports the values ``4'', +``6'', and ``4o6''. These correspond to the @code{dhcpd} program +options @code{-4}, @code{-6}, and @code{-4o6}. See @code{man dhcpd} for +details. +@item @code{run-directory} (default: @code{"/run/dhcpd"}) +The run directory to use. At service activation time, this directory +will be created if it does not exist. +@item @code{pid-file} (default: @code{"/run/dhcpd/dhcpd.pid"}) +The PID file to use. This corresponds to the @code{-pf} option of +@code{dhcpd}. See @code{man dhcpd} for details. +@item @code{interfaces} (default: @code{'()}) +The names of the network interfaces on which dhcpd should listen for +broadcasts. If this list is not empty, then its elements (which must be +strings) will be appended to the @code{dhcpd} invocation when starting +the daemon. It may not be necessary to explicitly specify any +interfaces here; see @code{man dhcpd} for details. +@end table +@end deftp + @cindex hostapd service, for Wi-Fi access points @cindex Wi-Fi access points, hostapd service @defvr {Scheme Variable} hostapd-service-type @@ -17097,6 +17127,7 @@ network that can be seen on @code{wlan0}, by default. The service's value is a @code{hostapd-configuration} record. @end defvr + @cindex iptables @defvr {Scheme Variable} iptables-service-type This is the service type to set up an iptables configuration. iptables is a From patchwork Wed Oct 27 14:02:39 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?q?Ludovic_Court=C3=A8s?= X-Patchwork-Id: 34105 Return-Path: X-Original-To: patchwork@mira.cbaines.net Delivered-To: patchwork@mira.cbaines.net Received: by mira.cbaines.net (Postfix, from userid 113) id 2A30027BBE3; Wed, 27 Oct 2021 15:48:51 +0100 (BST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on mira.cbaines.net X-Spam-Level: X-Spam-Status: No, score=-2.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, MAILING_LIST_MULTI,RCVD_IN_MSPIKE_H2,SPF_HELO_PASS,T_DKIM_INVALID, URIBL_BLOCKED autolearn=unavailable autolearn_force=no version=3.4.2 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mira.cbaines.net (Postfix) with ESMTPS id E089827BBE1 for ; Wed, 27 Oct 2021 15:48:50 +0100 (BST) Received: from localhost ([::1]:49870 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mfkET-0006rP-QX for patchwork@mira.cbaines.net; Wed, 27 Oct 2021 10:48:49 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:43134) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mfjX9-0008Jk-6h for guix-patches@gnu.org; Wed, 27 Oct 2021 10:04:03 -0400 Received: from debbugs.gnu.org ([209.51.188.43]:38542) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mfjX8-0005Fr-T5 for guix-patches@gnu.org; Wed, 27 Oct 2021 10:04:02 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1mfjX8-0002Z0-OB for guix-patches@gnu.org; Wed, 27 Oct 2021 10:04:02 -0400 X-Loop: help-debbugs@gnu.org Subject: [bug#51440] [PATCH 04/10] gnu: guile-netlink: Allow cross-compilation. Resent-From: Ludovic =?utf-8?q?Court=C3=A8s?= Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Wed, 27 Oct 2021 14:04:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 51440 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: 51440@debbugs.gnu.org Cc: Ludovic =?utf-8?q?Court=C3=A8s?= Received: via spool by 51440-submit@debbugs.gnu.org id=B51440.16353433879667 (code B ref 51440); Wed, 27 Oct 2021 14:04:02 +0000 Received: (at 51440) by debbugs.gnu.org; 27 Oct 2021 14:03:07 +0000 Received: from localhost ([127.0.0.1]:50060 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1mfjWF-0002Vl-4B for submit@debbugs.gnu.org; Wed, 27 Oct 2021 10:03:07 -0400 Received: from eggs.gnu.org ([209.51.188.92]:45540) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1mfjWC-0002Ui-PH for 51440@debbugs.gnu.org; Wed, 27 Oct 2021 10:03:05 -0400 Received: from fencepost.gnu.org ([2001:470:142:3::e]:37968) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mfjW7-00057d-Fb; Wed, 27 Oct 2021 10:02:59 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=MIME-Version:References:In-Reply-To:Date:Subject:To: From; bh=9RiXGJeRtbEaSlC9HCBSii2Gml4rjEt9QiDUUVyODho=; b=qBbzfp9DjakZZsz7O2BT NPy51x2WEhHwjAJyG0FRWkE7JuWNYlUf4TFLA0xk5aHWjZi3FN5UynQpBLgqbAnBCrmhBPKPk2xRV RNtsXjXmG/Fot6Zo69AqVQDXt8Jz17AyZh3VlTtvcpl/RWivJzmrbj/NNHi2xDfV7f7jK3u1o5F39 g9vu8LJbDWxTjfQkidCwCufEALULpRkvgn8wvYFg91vt222Cjc2T/Qk+wwxDZmVGwEhBYj7C8v39c 88ERy0z/Bux/sgA2ZXH0yL9e/zhgYQqSdSye6oSHht89Sf2aIB+lcGofYjOG4SAcocqGRV2hXPJNO F7kNWlrJz1gZNQ==; Received: from [2a01:e0a:1d:7270:af76:b9b:ca24:c465] (port=55004 helo=gnu.org) by fencepost.gnu.org with esmtpsa (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mfjW6-0002Tf-Ty; Wed, 27 Oct 2021 10:02:59 -0400 From: Ludovic =?utf-8?q?Court=C3=A8s?= Date: Wed, 27 Oct 2021 16:02:39 +0200 Message-Id: <20211027140245.18970-4-ludo@gnu.org> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20211027140245.18970-1-ludo@gnu.org> References: <20211027140245.18970-1-ludo@gnu.org> MIME-Version: 1.0 X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: guix-patches@gnu.org List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guix-patches-bounces+patchwork=mira.cbaines.net@gnu.org Sender: "Guix-patches" X-getmail-retrieved-from-mailbox: Patches * gnu/packages/guile-xyz.scm (guile-netlink)[arguments]: Add #:phases. Remove unnecessary #:tests? #f. [native-inputs]: Add GUILE-3.0. --- gnu/packages/guile-xyz.scm | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/gnu/packages/guile-xyz.scm b/gnu/packages/guile-xyz.scm index 355b23f57e..daef8bbb26 100644 --- a/gnu/packages/guile-xyz.scm +++ b/gnu/packages/guile-xyz.scm @@ -4854,13 +4854,22 @@ (define-public guile-netlink "03zmsha2d7whlwb52gna83jdas9bqi18rq3sss7kkicv814qb35g")))) (build-system gnu-build-system) (arguments - `(#:tests? #f)); no tests + `(#:phases (modify-phases %standard-phases + (add-before 'bootstrap 'set-guile-target + (lambda* (#:key target #:allow-other-keys) + (when target + ;; Pass '--target=TRIPLET' to 'guild compile'. + (substitute* "guile.am" + (("\\$\\(GUILD\\) compile") + (string-append "$(GUILD) compile --target=" + target " "))))))))) (inputs `(("guile" ,guile-3.0))) (native-inputs `(("automake" ,automake) ("autoconf" ,autoconf) ("pkg-config" ,pkg-config) + ("guile" ,guile-3.0) ;for 'guild compile' + guile.m4 ("texinfo" ,texinfo))) (home-page "https://git.lepiller.eu/guile-netlink") (synopsis "Netlink protocol implementation for Guile") From patchwork Wed Oct 27 14:02:40 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?q?Ludovic_Court=C3=A8s?= X-Patchwork-Id: 34109 Return-Path: X-Original-To: patchwork@mira.cbaines.net Delivered-To: patchwork@mira.cbaines.net Received: by mira.cbaines.net (Postfix, from userid 113) id 93FE827BBE3; Wed, 27 Oct 2021 15:52:19 +0100 (BST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on mira.cbaines.net X-Spam-Level: X-Spam-Status: No, score=-2.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, MAILING_LIST_MULTI,RCVD_IN_MSPIKE_H2,SPF_HELO_PASS,T_DKIM_INVALID, URIBL_BLOCKED autolearn=unavailable autolearn_force=no version=3.4.2 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mira.cbaines.net (Postfix) with ESMTPS id 2046927BBE1 for ; Wed, 27 Oct 2021 15:52:19 +0100 (BST) Received: from localhost ([::1]:55358 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mfkHq-0002Ha-5y for patchwork@mira.cbaines.net; Wed, 27 Oct 2021 10:52:18 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:43148) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mfjXA-0008Lk-1D for guix-patches@gnu.org; Wed, 27 Oct 2021 10:04:04 -0400 Received: from debbugs.gnu.org ([209.51.188.43]:38544) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mfjX9-0005GJ-Mm for guix-patches@gnu.org; Wed, 27 Oct 2021 10:04:03 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1mfjX9-0002ZG-It for guix-patches@gnu.org; Wed, 27 Oct 2021 10:04:03 -0400 X-Loop: help-debbugs@gnu.org Subject: [bug#51440] [PATCH 05/10] services: static-networking: Use Guile-Netlink on GNU/Linux. Resent-From: Ludovic =?utf-8?q?Court=C3=A8s?= Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Wed, 27 Oct 2021 14:04:03 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 51440 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: 51440@debbugs.gnu.org Cc: Ludovic =?utf-8?q?Court=C3=A8s?= Received: via spool by 51440-submit@debbugs.gnu.org id=B51440.16353433989733 (code B ref 51440); Wed, 27 Oct 2021 14:04:03 +0000 Received: (at 51440) by debbugs.gnu.org; 27 Oct 2021 14:03:18 +0000 Received: from localhost ([127.0.0.1]:50076 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1mfjWQ-0002Wo-1m for submit@debbugs.gnu.org; Wed, 27 Oct 2021 10:03:18 -0400 Received: from eggs.gnu.org ([209.51.188.92]:45558) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1mfjWI-0002VY-S6 for 51440@debbugs.gnu.org; Wed, 27 Oct 2021 10:03:11 -0400 Received: from fencepost.gnu.org ([2001:470:142:3::e]:37970) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mfjWD-00057z-Dy; Wed, 27 Oct 2021 10:03:05 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=MIME-Version:References:In-Reply-To:Date:Subject:To: From; bh=2PZSQcBi7QvaYFLybO/4hOkFPRVIn5uFYlqQuLwxpHI=; b=crEorOcNfM/ubsO5CWY1 sqx30iyUVWg4pEjJ47oIGZBIfEtrTB9QZc5oarmGsoj9UWfr52Cr0yM+zqneD6KXZISuutVSgGtlD zbsJA63o1yEbNf+/PLfaofhrzEJiYk8w9oXjWGpmW4zOixQn9cuB+ovaGwCJCVCCCVMmhEkrHSpME Pu59CIFbaUnT7K9xvu3IiDG9h47mE930eBpUYeeqgZR10hvt3tDqf9tuSEyzMhcsBazmz+YqcvXdw Bx+ChfEmqUS2LCu372qfOq/r3COQFTwiakcPt9JbmNoE8kYyp2DQ1xP6Qh2any03xTIjzlFtDZq1t u3w/lRm+6S/vUA==; Received: from [2a01:e0a:1d:7270:af76:b9b:ca24:c465] (port=55004 helo=gnu.org) by fencepost.gnu.org with esmtpsa (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mfjW7-0002Tf-Id; Wed, 27 Oct 2021 10:03:04 -0400 From: Ludovic =?utf-8?q?Court=C3=A8s?= Date: Wed, 27 Oct 2021 16:02:40 +0200 Message-Id: <20211027140245.18970-5-ludo@gnu.org> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20211027140245.18970-1-ludo@gnu.org> References: <20211027140245.18970-1-ludo@gnu.org> MIME-Version: 1.0 X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: guix-patches@gnu.org List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guix-patches-bounces+patchwork=mira.cbaines.net@gnu.org Sender: "Guix-patches" X-getmail-retrieved-from-mailbox: Patches * gnu/services/base.scm (static-networking-shepherd-service): Define 'set-up-via-ioctl', 'tear-down-via-ioctl', 'set-up-via-netlink', 'tear-down-via-netlink', and 'helpers' and use them in 'start' and 'stop'. Add (ip *) modules to 'modules'. --- gnu/services/base.scm | 102 +++++++++++++++++++++++++++++------------- 1 file changed, 72 insertions(+), 30 deletions(-) diff --git a/gnu/services/base.scm b/gnu/services/base.scm index 50865055fe..d5ee03bbbd 100644 --- a/gnu/services/base.scm +++ b/gnu/services/base.scm @@ -53,6 +53,7 @@ (define-module (gnu services base) #:use-module (gnu packages bash) #:use-module ((gnu packages base) #:select (coreutils glibc glibc-utf8-locales)) + #:autoload (gnu packages guile-xyz) (guile-netlink) #:use-module (gnu packages package-management) #:use-module ((gnu packages gnupg) #:select (guile-gcrypt)) #:use-module (gnu packages linux) @@ -2336,6 +2337,66 @@ (define static-networking-shepherd-service (($ interface ip netmask gateway provision requirement name-servers) (let ((loopback? (and provision (memq 'loopback provision)))) + (define set-up-via-ioctl + #~(let* ((addr (inet-pton AF_INET #$ip)) + (sockaddr (make-socket-address AF_INET addr 0)) + (mask (and #$netmask (inet-pton AF_INET #$netmask))) + (maskaddr (and mask + (make-socket-address AF_INET mask 0))) + (gateway (and #$gateway + (inet-pton AF_INET #$gateway))) + (gatewayaddr (and gateway + (make-socket-address AF_INET + gateway 0)))) + (configure-network-interface #$interface sockaddr + (logior IFF_UP + #$(if loopback? + #~IFF_LOOPBACK + 0)) + #:netmask maskaddr) + (when gateway + (let ((sock (socket AF_INET SOCK_DGRAM 0))) + (add-network-route/gateway sock gatewayaddr) + (close-port sock))))) + + (define tear-down-via-ioctl + #~(let ((sock (socket AF_INET SOCK_STREAM 0))) + (when #$gateway + (delete-network-route sock + (make-socket-address AF_INET + INADDR_ANY 0))) + (set-network-interface-flags sock #$interface 0) + (close-port sock) + #f)) + + (define set-up-via-netlink + (with-extensions (list guile-netlink) + #~(let ((ip #$(if netmask + #~(ip+netmask->cidr #$ip #$netmask) + ip))) + (addr-add #$interface ip) + (when #$gateway + (route-add "default" #:device #$interface + #:via #$gateway)) + (link-set #$interface #:up #t)))) + + (define tear-down-via-netlink + (with-extensions (list guile-netlink) + #~(begin + (link-set #$interface #:down #t) + (when #$gateway + (route-del "default" #:device #$interface)) + (addr-del #$interface #$ip) + #f))) + + (define helpers + #~(define (ip+netmask->cidr ip netmask) + ;; Return the CIDR notation (a string) for IP and NETMASK, two + ;; IPv4 address strings. + (let* ((netmask (inet-pton AF_INET netmask)) + (bits (logcount netmask))) + (string-append ip "/" (number->string bits))))) + (shepherd-service (documentation @@ -2347,38 +2408,19 @@ (define static-networking-shepherd-service (start #~(lambda _ ;; Return #t if successfully started. - (let* ((addr (inet-pton AF_INET #$ip)) - (sockaddr (make-socket-address AF_INET addr 0)) - (mask (and #$netmask - (inet-pton AF_INET #$netmask))) - (maskaddr (and mask - (make-socket-address AF_INET - mask 0))) - (gateway (and #$gateway - (inet-pton AF_INET #$gateway))) - (gatewayaddr (and gateway - (make-socket-address AF_INET - gateway 0)))) - (configure-network-interface #$interface sockaddr - (logior IFF_UP - #$(if loopback? - #~IFF_LOOPBACK - 0)) - #:netmask maskaddr) - (when gateway - (let ((sock (socket AF_INET SOCK_DGRAM 0))) - (add-network-route/gateway sock gatewayaddr) - (close-port sock)))))) + #$helpers + (if (string-contains %host-type "-linux") + #$set-up-via-netlink + #$set-up-via-ioctl))) (stop #~(lambda _ ;; Return #f is successfully stopped. - (let ((sock (socket AF_INET SOCK_STREAM 0))) - (when #$gateway - (delete-network-route sock - (make-socket-address - AF_INET INADDR_ANY 0))) - (set-network-interface-flags sock #$interface 0) - (close-port sock) - #f))) + (if (string-contains %host-type "-linux") + #$tear-down-via-netlink + #$tear-down-via-ioctl))) + (modules `((ip addr) + (ip link) + (ip route) + ,@%default-modules)) (respawn? #f)))))) (define (static-networking-etc-files interfaces) From patchwork Wed Oct 27 14:02:41 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Ludovic_Court=C3=A8s?= X-Patchwork-Id: 34115 Return-Path: X-Original-To: patchwork@mira.cbaines.net Delivered-To: patchwork@mira.cbaines.net Received: by mira.cbaines.net (Postfix, from userid 113) id 12AD627BBE3; Wed, 27 Oct 2021 16:08:24 +0100 (BST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on mira.cbaines.net X-Spam-Level: X-Spam-Status: No, score=-2.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, MAILING_LIST_MULTI,RCVD_IN_MSPIKE_H2,SPF_HELO_PASS,T_DKIM_INVALID, URIBL_BLOCKED autolearn=unavailable autolearn_force=no version=3.4.2 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mira.cbaines.net (Postfix) with ESMTPS id 92E5C27BBE1 for ; Wed, 27 Oct 2021 16:08:23 +0100 (BST) Received: from localhost ([::1]:34056 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mfkXO-0000rw-Ne for patchwork@mira.cbaines.net; Wed, 27 Oct 2021 11:08:22 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:43152) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mfjXA-0008Mz-DD for guix-patches@gnu.org; Wed, 27 Oct 2021 10:04:04 -0400 Received: from debbugs.gnu.org ([209.51.188.43]:38545) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mfjXA-0005GP-2p for guix-patches@gnu.org; Wed, 27 Oct 2021 10:04:04 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1mfjX9-0002ZN-VL for guix-patches@gnu.org; Wed, 27 Oct 2021 10:04:03 -0400 X-Loop: help-debbugs@gnu.org Subject: [bug#51440] [PATCH 06/10] services: secret-service: Turn into a Shepherd service. Resent-From: Ludovic =?utf-8?q?Court=C3=A8s?= Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Wed, 27 Oct 2021 14:04:03 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 51440 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: 51440@debbugs.gnu.org Cc: Ludovic =?utf-8?q?Court=C3=A8s?= Received: via spool by 51440-submit@debbugs.gnu.org id=B51440.16353433999740 (code B ref 51440); Wed, 27 Oct 2021 14:04:03 +0000 Received: (at 51440) by debbugs.gnu.org; 27 Oct 2021 14:03:19 +0000 Received: from localhost ([127.0.0.1]:50078 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1mfjWQ-0002Wv-Fe for submit@debbugs.gnu.org; Wed, 27 Oct 2021 10:03:18 -0400 Received: from eggs.gnu.org ([209.51.188.92]:45564) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1mfjWJ-0002VZ-9G for 51440@debbugs.gnu.org; Wed, 27 Oct 2021 10:03:11 -0400 Received: from fencepost.gnu.org ([2001:470:142:3::e]:37974) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mfjWE-00058C-2T; Wed, 27 Oct 2021 10:03:06 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=MIME-Version:References:In-Reply-To:Date:Subject:To: From; bh=1jh4ueGONL6MEUTK8CSCWdtTCOUYwpUL8SHWIX5sYIA=; b=PTt0C10z1q0woPvL9CLf IoA/+VSsLLvLHsaTpPfpuWSwiz78LqoBcLWAjEq76uv6UCoKB7aWplMFChGJG3sN6xhF6jGtU8tjl CPWwT2HDFvlIqrA0/Y0fF7/xPr1ETIqYYDmuBU+6EvvQYehVQKBA0BS/7AFD1Cy48j7/c8hXiJM5x qecMtdy2H/BdCF/k4hIFTIS2nnyTTeefVRhB6HM7yAaVmqWy0nTDXD0bq3WG99vGZCOLHsOigoFdc MRmbTjRenzLL4paOukld5wOrHQunqtCvrGWMuFk7jGsj27+d0cLeLaTRYX2Brdhvknax5B9g4uq6p vJepM/SmvjC4qg==; Received: from [2a01:e0a:1d:7270:af76:b9b:ca24:c465] (port=55004 helo=gnu.org) by fencepost.gnu.org with esmtpsa (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mfjWD-0002Tf-M4; Wed, 27 Oct 2021 10:03:05 -0400 From: Ludovic =?utf-8?q?Court=C3=A8s?= Date: Wed, 27 Oct 2021 16:02:41 +0200 Message-Id: <20211027140245.18970-6-ludo@gnu.org> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20211027140245.18970-1-ludo@gnu.org> References: <20211027140245.18970-1-ludo@gnu.org> MIME-Version: 1.0 X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: guix-patches@gnu.org List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guix-patches-bounces+patchwork=mira.cbaines.net@gnu.org Sender: "Guix-patches" X-getmail-retrieved-from-mailbox: Patches * gnu/services/virtualization.scm (secret-service-activation): Remove. (secret-service-shepherd-services): New procedure. (secret-service-type)[extensions]: Remove ACTIVATION-SERVICE-TYPE extension. Add SHEPHERD-ROOT-SERVICE-TYPE and USER-PROCESSES-SERVICE-TYPE extensions. * gnu/build/secret-service.scm (delete-file*): New procedure. (secret-service-receive-secrets): Use it. --- gnu/build/secret-service.scm | 17 ++++++++++++- gnu/services/virtualization.scm | 45 ++++++++++++++++++++++++--------- 2 files changed, 49 insertions(+), 13 deletions(-) diff --git a/gnu/build/secret-service.scm b/gnu/build/secret-service.scm index 46dcf1b9c3..4e183e11e8 100644 --- a/gnu/build/secret-service.scm +++ b/gnu/build/secret-service.scm @@ -1,5 +1,5 @@ ;;; GNU Guix --- Functional package management for GNU -;;; Copyright © 2020 Ludovic Courtès +;;; Copyright © 2020, 2021 Ludovic Courtès ;;; Copyright © 2020 Jan (janneke) Nieuwenhuizen ;;; ;;; This file is part of GNU Guix. @@ -111,6 +111,15 @@ (define (send-files sock) (close-port sock) #f)))) +(define (delete-file* file) + "Ensure FILE does not exist." + (catch 'system-error + (lambda () + (delete-file file)) + (lambda args + (unless (= ENOENT (system-error-errno args)) + (apply throw args))))) + (define (secret-service-receive-secrets port) "Listen to local PORT and wait for a secret service client to send secrets. Write them to the file system. Return the list of files installed on success, @@ -170,6 +179,12 @@ (define (read-secrets port) (log "installing file '~a' (~a bytes)...~%" file size) (mkdir-p (dirname file)) + + ;; It could be that FILE already exists, for instance + ;; because it has been created by a service's activation + ;; snippet (e.g., SSH host keys). Delete it. + (delete-file* file) + (call-with-output-file file (lambda (output) (dump port output size) diff --git a/gnu/services/virtualization.scm b/gnu/services/virtualization.scm index bca5f56b87..e7d2a7b833 100644 --- a/gnu/services/virtualization.scm +++ b/gnu/services/virtualization.scm @@ -852,23 +852,44 @@ (define qemu-binfmt-service-type ;;; Secrets for guest VMs. ;;; -(define (secret-service-activation port) - "Return an activation snippet that fetches sensitive material at local PORT, +(define (secret-service-shepherd-services port) + "Return a Shepherd service that fetches sensitive material at local PORT, over TCP. Reboot upon failure." - (with-imported-modules '((gnu build secret-service) - (guix build utils)) - #~(begin - (use-modules (gnu build secret-service)) - (let ((sent (secret-service-receive-secrets #$port))) - (unless sent - (sleep 3) - (reboot)))))) + ;; This is a Shepherd service, rather than an activation snippet, to make + ;; sure it is started once 'networking' is up so it can accept incoming + ;; connections. + (list + (shepherd-service + (documentation "Fetch secrets from the host at startup time.") + (provision '(secret-service-client)) + (requirement '(loopback networking)) + (modules '((gnu build secret-service) + (guix build utils))) + (start (with-imported-modules '((gnu build secret-service) + (guix build utils)) + #~(lambda () + ;; Since shepherd's output port goes to /dev/log, write this + ;; message to stderr so it's visible on the Mach console. + (format (current-error-port) + "receiving secrets from the host...~%") + (force-output (current-error-port)) + + (let ((sent (secret-service-receive-secrets #$port))) + (unless sent + (sleep 3) + (reboot)))))) + (stop #~(const #f))))) (define secret-service-type (service-type (name 'secret-service) - (extensions (list (service-extension activation-service-type - secret-service-activation))) + (extensions (list (service-extension shepherd-root-service-type + secret-service-shepherd-services) + + ;; Make every Shepherd service depend on + ;; 'secret-service-client'. + (service-extension user-processes-service-type + (const '(secret-service-client))))) (description "This service fetches secret key and other sensitive material over TCP at boot time. This service is meant to be used by virtual machines (VMs) that From patchwork Wed Oct 27 14:02:42 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?q?Ludovic_Court=C3=A8s?= X-Patchwork-Id: 34112 Return-Path: X-Original-To: patchwork@mira.cbaines.net Delivered-To: patchwork@mira.cbaines.net Received: by mira.cbaines.net (Postfix, from userid 113) id 6ECCF27BBE3; Wed, 27 Oct 2021 16:06:54 +0100 (BST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on mira.cbaines.net X-Spam-Level: X-Spam-Status: No, score=-2.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, MAILING_LIST_MULTI,RCVD_IN_MSPIKE_H2,SPF_HELO_PASS,T_DKIM_INVALID, URIBL_BLOCKED autolearn=unavailable autolearn_force=no version=3.4.2 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mira.cbaines.net (Postfix) with ESMTPS id 2126B27BBE1 for ; Wed, 27 Oct 2021 16:06:53 +0100 (BST) Received: from localhost ([::1]:59044 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mfkVw-00075H-6N for patchwork@mira.cbaines.net; Wed, 27 Oct 2021 11:06:52 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:43154) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mfjXA-0008OY-SJ for guix-patches@gnu.org; Wed, 27 Oct 2021 10:04:04 -0400 Received: from debbugs.gnu.org ([209.51.188.43]:38546) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mfjXA-0005GW-G8 for guix-patches@gnu.org; Wed, 27 Oct 2021 10:04:04 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1mfjXA-0002ZV-C5 for guix-patches@gnu.org; Wed, 27 Oct 2021 10:04:04 -0400 X-Loop: help-debbugs@gnu.org Subject: [bug#51440] [PATCH 07/10] services: static-networking: Change interface to mimic netlink. Resent-From: Ludovic =?utf-8?q?Court=C3=A8s?= Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Wed, 27 Oct 2021 14:04:04 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 51440 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: 51440@debbugs.gnu.org Cc: Ludovic =?utf-8?q?Court=C3=A8s?= Received: via spool by 51440-submit@debbugs.gnu.org id=B51440.16353434009748 (code B ref 51440); Wed, 27 Oct 2021 14:04:04 +0000 Received: (at 51440) by debbugs.gnu.org; 27 Oct 2021 14:03:20 +0000 Received: from localhost ([127.0.0.1]:50080 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1mfjWQ-0002X3-UZ for submit@debbugs.gnu.org; Wed, 27 Oct 2021 10:03:20 -0400 Received: from eggs.gnu.org ([209.51.188.92]:45568) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1mfjWK-0002Vj-34 for 51440@debbugs.gnu.org; Wed, 27 Oct 2021 10:03:13 -0400 Received: from fencepost.gnu.org ([2001:470:142:3::e]:37976) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mfjWE-00058J-Rx; Wed, 27 Oct 2021 10:03:06 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=MIME-Version:References:In-Reply-To:Date:Subject:To: From; bh=zbIt4xF0kkuo3g5h7cxqz7CjdZNPt6hwu/7MdVLEsWY=; b=GMHfI21bkW5aDEpB1UaA Jq1p+bb2jTbipwtkmfJU7Mo4G1OfVZK3BlbrKokVePHVIRaNlZ1/3SUAF+MHLBAoX8FbPBsKilgwM 1tbE0PCPSckSjibP6d1ztPMmH/ifnwWk+UxEIDgX/9YsRJkKDAuIJPboPPduCPHcICcbADZ0eKHs7 efbZ/M6LdBPZG8O35IKWt6ZusSnBwhDLmXJAUYWDyx+G771VowF3BDXaeeHMI+0ot1qgEYSvILNJR lznSRj6XFmC1JfM9YSZaLCEZkRLLCZUeDxp6ZJA9JxBfare/T9A4Hqu+iCp9du6xoWWP6dry87Mv1 coqatHBjy72AHw==; Received: from [2a01:e0a:1d:7270:af76:b9b:ca24:c465] (port=55004 helo=gnu.org) by fencepost.gnu.org with esmtpsa (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mfjWE-0002Tf-B0; Wed, 27 Oct 2021 10:03:06 -0400 From: Ludovic =?utf-8?q?Court=C3=A8s?= Date: Wed, 27 Oct 2021 16:02:42 +0200 Message-Id: <20211027140245.18970-7-ludo@gnu.org> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20211027140245.18970-1-ludo@gnu.org> References: <20211027140245.18970-1-ludo@gnu.org> MIME-Version: 1.0 X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: guix-patches@gnu.org List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guix-patches-bounces+patchwork=mira.cbaines.net@gnu.org Sender: "Guix-patches" X-getmail-retrieved-from-mailbox: Patches * gnu/services/base.scm ()[interface, ip, netmask] [gateway]: Remove. [addresses, links, routes]: New fields. [requirement]: Default to '(udev). (, , ): New record types. (ensure-no-separate-netmask, %ensure-no-separate-netmask): Remove. (ipv6-address?, cidr->netmask, ip+netmask->cidr) (network-set-up/hurd, network-tear-down/hurd) (network-set-up/linux, network-tear-down/linux) (static-networking->hurd-pfinet-options): New procedures. (static-networking-shepherd-service): New procedure. (static-networking-shepherd-services): Rewrite in terms of the above. (static-networking-service): Deprecate. Adjust to new 'static-networking' API. (%base-services): Likewise. * gnu/system/install.scm (%installation-services): Likewise. * gnu/system/hurd.scm (%base-services/hurd): Likewise, and separate 'loopback' from 'networking'. * gnu/build/hurd-boot.scm (set-hurd-device-translators): Remove "servers/socket/2". * gnu/tests/networking.scm (run-openvswitch-test)["networking has started on ovs0"]: Check for 'networking instead of 'networking-ovs0, which is no longer provided. * doc/guix.texi (Networking Setup): Document the new interface. Remove documentation of 'static-networking-service'. (Virtualization Services): Change Ganeti example to use the new interface. --- doc/guix.texi | 191 +++++++++++++++--- gnu/build/hurd-boot.scm | 10 +- gnu/services/base.scm | 410 +++++++++++++++++++++++++++------------ gnu/system/hurd.scm | 27 ++- gnu/system/install.scm | 11 +- gnu/tests/networking.scm | 2 +- 6 files changed, 481 insertions(+), 170 deletions(-) diff --git a/doc/guix.texi b/doc/guix.texi index f7de378bdd..b529a8db6c 100644 --- a/doc/guix.texi +++ b/doc/guix.texi @@ -16762,32 +16762,166 @@ This section describes the various network setup services available, starting with static network configuration. @defvr {Scheme Variable} static-networking-service-type -This is the type for statically-configured network interfaces. -@c TODO Document data structures. +This is the type for statically-configured network interfaces. Its +value must be a list of @code{static-networking} records. Each of them +declares a set of @dfn{addresses}, @dfn{routes}, and @dfn{links}, as +show below. + +@cindex network interface controller (NIC) +@cindex NIC, networking interface controller +Here is the simplest configuration, with only one network interface +controller (NIC) and only IPv4 connectivity: + +@example +;; Static networking for one NIC, IPv4-only. +(service static-networking-service-type + (list (static-networking + (addresses + (list (network-address + (device "eno1") + (value "10.0.2.15/24")))) + (routes + (list (network-route + (destination "default") + (gateway "10.0.2.2")))) + (name-servers '("10.0.2.3"))))) +@end example + +The snippet above can be added to the @code{services} field of your +operating system configuration (@pxref{Using the Configuration System}). +It will configure your machine to have 10.0.2.15 as its IP address, with +a 24-bit netmask for the local network---meaning that any 10.0.2.@var{x} +address is on the local area network (LAN). Traffic to addresses +outside the local network is routed @i{via} 10.0.2.2. Host names are +resolved by sending domain name system (DNS) queries to 10.0.2.3. @end defvr -@deffn {Scheme Procedure} static-networking-service @var{interface} @var{ip} @ - [#:netmask #f] [#:gateway #f] [#:name-servers @code{'()}] @ - [#:requirement @code{'(udev)}] -Return a service that starts @var{interface} with address @var{ip}. If -@var{netmask} is true, use it as the network mask. If @var{gateway} is true, -it must be a string specifying the default network gateway. @var{requirement} -can be used to declare a dependency on another service before configuring the -interface. +@deftp {Data Type} static-networking +This is the data type representing a static network configuration. -This procedure can be called several times, one for each network -interface of interest. Behind the scenes what it does is extend -@code{static-networking-service-type} with additional network interfaces -to handle. - -For example: +As an example, here is how you would declare the configuration of a +machine with a single network interface controller (NIC) available as +@code{eno1}, and with one IPv4 and one IPv6 address: @lisp -(static-networking-service "eno1" "192.168.1.82" - #:gateway "192.168.1.2" - #:name-servers '("192.168.1.2")) +;; Network configuration for one NIC, IPv4 + IPv6. +(static-networking + (addresses (list (network-address + (device "eno1") + (value "10.0.2.15/24")) + (network-address + (device "eno1") + (value "2001:123:4567:101::1")))) + (routes (list (network-route + (destination "default") + (gateway "10.0.2.2")) + (network-route + (destination "default") + (gateway "2020:321:4567:42::1")))) + (name-servers '("10.0.2.3"))) @end lisp -@end deffn + +If you are familiar with the @command{ip} command of the +@uref{https://wiki.linuxfoundation.org/networking/iproute2, +@code{iproute2} package} found on Linux-based systems, the declaration +above is equivalent to typing: + +@example +ip address add 10.0.2.15/24 dev eno1 +ip address add 2001:123:4567:101::1 dev eno1 +ip route add default via inet 10.0.2.2 +ip route add default via inet6 2020:321:4567:42::1 +@end example + +Run @command{man 8 ip} for more info. Venerable GNU/Linux users will +certainly know how to do it with @command{ifconfig} and @command{route}, +but we'll spare you that. + +The available fields of this data type are as follows: + +@table @asis +@item @code{addresses} +@itemx @code{links} (default: @code{'()}) +@itemx @code{links} (default: @code{'()}) +The list of @code{network-address}, @code{network-link}, and +@code{network-route} records for this network (see below). + +@item @code{name-servers} (default: @code{'()}) +The list of IP addresses (strings) of domain name servers. These IP +addresses go to @file{/etc/resolv.conf}. + +@item @code{provision} (default: @code{#f}) +If true, this should be a list of symbols for the Shepherd service +corresponding to this network configuration. When @code{#f}, +@code{'(networking)} or @code{'(loopback)} is used. + +@item @code{requirement} (default @code{'()}) +The list of Shepherd services depended on. +@end table +@end deftp + +@deftp {Data Type} network-address +This is the data type representing the IP address of a network +interface. + +@table @code +@item device +The name of the network interface for this address---e.g., +@code{"eno1"}. + +@item value +The actual IP address and network mask, in +@uref{https://en.wikipedia.org/wiki/CIDR#CIDR_notation, @acronym{CIDR, +Classless Inter-Domain Routing} notation}, as a string. + +For example, @code{"10.0.2.15/24"} denotes IPv4 address 10.0.2.15 on a +24-bit sub-network---all 10.0.2.@var{x} addresses are on the same local +network. + +@item ipv6? +Whether @code{value} denotes an IPv6 address. By default this is +automatically determined. +@end table +@end deftp + +@deftp {Data Type} network-route +This is the data type representing a network route. + +@table @asis +@item @code{destination} +The route destination (a string), either an IP address or +@code{"default"} to denote the default route. + +@item @code{source} (default: @code{#f}) +The route source. + +@item @code{device} (default: @code{#f}) +The device used for this route---e.g., @code{"eno2"}. + +@item @code{ipv6?} (default: auto) +Whether this is an IPv6 route. By default this is automatically +determined based on @code{destination} or @code{gateway}. + +@item @code{gateway} (default: @code{#f}) +IP address (a string) through which traffic is routed. +@end table +@end deftp + +@deftp {Data Type} network-link +Data type for a network link (@pxref{Link,,, guile-netlink, +Guile-Netlink Manual}). + +@table @code +@item name +The name of the link---e.g., @code{"v0p0"}. + +@item type +A symbol denoting the type of the link---e.g., @code{'veth}. + +@item arguments +List of arguments for this type of link. +@end table +@end deftp @cindex DHCP, networking service @defvr {Scheme Variable} dhcp-client-service-type @@ -30300,11 +30434,18 @@ cluster node that supports multiple storage backends, and installs the "ganeti-instance-guix" "ganeti-instance-debootstrap")) %base-packages)) (services - (append (list (static-networking-service "eth0" "192.168.1.201" - #:netmask "255.255.255.0" - #:gateway "192.168.1.254" - #:name-servers '("192.168.1.252" - "192.168.1.253")) + (append (list (service static-networking-service-type + (list (static-networking + (addresses + (list (network-address + (device "eth0") + (value "192.168.1.201/24")))) + (routes + (list (network-route + (destination "default") + (gateway "192.168.1.254")))) + (name-servers '("192.168.1.252" + "192.168.1.253"))))) ;; Ganeti uses SSH to communicate between nodes. (service openssh-service-type diff --git a/gnu/build/hurd-boot.scm b/gnu/build/hurd-boot.scm index 8b27995438..ac36bd17d4 100644 --- a/gnu/build/hurd-boot.scm +++ b/gnu/build/hurd-boot.scm @@ -185,13 +185,9 @@ (define servers ("servers/crash-suspend" ("/hurd/crash" "--suspend")) ("servers/password" ("/hurd/password")) ("servers/socket/1" ("/hurd/pflocal")) - ("servers/socket/2" ("/hurd/pfinet" - "--interface" "eth0" - "--address" - "10.0.2.15" ;the default QEMU guest IP - "--netmask" "255.255.255.0" - "--gateway" "10.0.2.2" - "--ipv6" "/servers/socket/26")) + ;; /servers/socket/2 and /26 are created by 'static-networking-service'. + ;; XXX: Spawn pfinet without arguments on these nodes so that a DHCP + ;; client has someone to talk to? ("proc" ("/hurd/procfs" "--stat-mode=444")))) (define devices diff --git a/gnu/services/base.scm b/gnu/services/base.scm index d5ee03bbbd..03f6b388a8 100644 --- a/gnu/services/base.scm +++ b/gnu/services/base.scm @@ -35,6 +35,8 @@ (define-module (gnu services base) #:use-module (guix store) #:use-module (guix deprecation) + #:autoload (guix diagnostics) (warning) + #:autoload (guix i18n) (G_) #:use-module (gnu services) #:use-module (gnu services admin) #:use-module (gnu services shepherd) @@ -54,6 +56,7 @@ (define-module (gnu services base) #:use-module ((gnu packages base) #:select (coreutils glibc glibc-utf8-locales)) #:autoload (gnu packages guile-xyz) (guile-netlink) + #:autoload (gnu packages hurd) (hurd) #:use-module (gnu packages package-management) #:use-module ((gnu packages gnupg) #:select (guile-gcrypt)) #:use-module (gnu packages linux) @@ -81,14 +84,32 @@ (define-module (gnu services base) virtual-terminal-service-type static-networking - static-networking? - static-networking-interface - static-networking-ip - static-networking-netmask - static-networking-gateway + static-networking-addresses + static-networking-links + static-networking-routes static-networking-requirement + network-address + network-address? + network-address-device + network-address-value + network-address-ipv6? + + network-link + network-link? + network-link-name + network-link-type + network-link-arguments + + network-route + network-route? + network-route-destination + network-route-source + network-route-device + network-route-ipv6? + network-route-gateway + static-networking-service static-networking-service-type @@ -2316,113 +2337,254 @@ (define kmscon-command (description "Start the @command{kmscon} virtual terminal emulator for the Linux @dfn{kernel mode setting} (KMS)."))) + +;;; +;;; Static networking. +;;; + +(define (ipv6-address? str) + "Return true if STR denotes an IPv6 address." + (false-if-exception (->bool (inet-pton AF_INET6 str)))) + (define-record-type* static-networking make-static-networking static-networking? - (interface static-networking-interface) - (ip static-networking-ip) - (netmask static-networking-netmask - (default #f)) - (gateway static-networking-gateway ;FIXME: doesn't belong here - (default #f)) + (addresses static-networking-addresses) ;list of + (links static-networking-links (default '())) ;list of + (routes static-networking-routes (default '())) ;list of (provision static-networking-provision (default #f)) (requirement static-networking-requirement - (default '())) + (default '(udev))) (name-servers static-networking-name-servers ;FIXME: doesn't belong here (default '()))) -(define static-networking-shepherd-service +(define-record-type* + network-address make-network-address + network-address? + (device network-address-device) ;string--e.g., "en01" + (value network-address-value) ;string--CIDR notation + (ipv6? network-address-ipv6? ;Boolean + (thunked) + (default + (ipv6-address? (cidr->ip (network-address-value this-record)))))) + +(define-record-type* + network-link make-network-link + network-link? + (name network-link-name) ;string--e.g, "v0p0" + (type network-link-type) ;symbol--e.g.,'veth + (arguments network-link-arguments)) ;list + +(define-record-type* + network-route make-network-route + network-route? + (destination network-route-destination) + (source network-route-source (default #f)) + (device network-route-device (default #f)) + (ipv6? network-route-ipv6? (thunked) + (default + (or (ipv6-address? (network-route-destination this-record)) + (and=> (network-route-gateway this-record) + ipv6-address?)))) + (gateway network-route-gateway (default #f))) + +(define* (cidr->netmask str #:optional (family AF_INET)) + "Given @var{str}, a string in CIDR notation (e.g., \"1.2.3.4/24\"), return +the netmask as a string like \"255.255.255.0\"." + (match (string-split str #\/) + ((ip (= string->number bits)) + (let ((mask (ash (- (expt 2 bits) 1) + (- (if (= family AF_INET6) 128 32) + bits)))) + (inet-ntop family mask))) + (_ #f))) + +(define (cidr->ip str) + "Strip the netmask bit of @var{str}, a CIDR-notation IP/netmask address." + (match (string-split str #\/) + ((or (ip _) (ip)) + ip))) + +(define* (ip+netmask->cidr ip netmask #:optional (family AF_INET)) + "Return the CIDR notation (a string) for @var{ip} and @var{netmask}, two +@var{family} address strings, where @var{family} is @code{AF_INET} or +@code{AF_INET6}." + (let* ((netmask (inet-pton family netmask)) + (bits (logcount netmask))) + (string-append ip "/" (number->string bits)))) + +(define (static-networking->hurd-pfinet-options config) + "Return command-line options for the Hurd's pfinet translator corresponding +to CONFIG." + (unless (null? (static-networking-links config)) + ;; XXX: Presumably this is not supported, or perhaps could be approximated + ;; by running separate pfinet instances in some cases? + (warning (G_ "network links are currently ignored on GNU/Hurd~%"))) + + (match (static-networking-addresses config) + ((and addresses (first _ ...)) + `("--ipv6" "/servers/socket/26" + "--interface" ,(network-address-device first) + ,@(append-map (lambda (address) + `(,(if (network-address-ipv6? address) + "--address6" + "--address") + ,(cidr->ip (network-address-value address)) + ,@(match (cidr->netmask (network-address-value address) + (if (network-address-ipv6? address) + AF_INET6 + AF_INET)) + (#f '()) + (mask (list "--netmask" mask))))) + addresses) + ,@(append-map (lambda (route) + (match route + (($ "default" #f device _ gateway) + (if (network-route-ipv6? route) + `("--gateway6" ,gateway) + `("--gateway" ,gateway))) + (($ destination) + (warning (G_ "ignoring network route for '~a'~%") + destination) + '()))) + (static-networking-routes config)))))) + +(define (network-set-up/hurd config) + "Set up networking for the Hurd." + ;; The Hurd implements SIOCGIFADDR and other old-style ioctls, but the only + ;; way to set up IPv6 is by starting pfinet with the right options. + (if (equal? (static-networking-provision config) '(loopback)) + (scheme-file "set-up-pflocal" #~(begin 'nothing-to-do! #t)) + (scheme-file "set-up-pfinet" + (with-imported-modules '((guix build utils)) + #~(begin + (use-modules (guix build utils) + (ice-9 format)) + + ;; TODO: Do that without forking. + (let ((options '#$(static-networking->hurd-pfinet-options + config))) + (format #t "starting '~a~{ ~s~}'~%" + #$(file-append hurd "/hurd/pfinet") + options) + (apply invoke #$(file-append hurd "/bin/settrans") "-fac" + "/servers/socket/2" + #$(file-append hurd "/hurd/pfinet") + options))))))) + +(define (network-tear-down/hurd config) + (scheme-file "tear-down-pfinet" + (with-imported-modules '((guix build utils)) + #~(begin + (use-modules (guix build utils)) + + ;; Forcefully terminate pfinet. XXX: In theory this + ;; should just undo the addresses and routes of CONFIG; + ;; this could be done using ioctls like SIOCDELRT, but + ;; these are IPv4-only; another option would be to use + ;; fsysopts but that seems to crash pfinet. + (invoke #$(file-append hurd "/bin/settrans") "-fg" + "/servers/socket/2") + #f)))) + +(define network-set-up/linux (match-lambda - (($ interface ip netmask gateway provision - requirement name-servers) + (($ addresses links routes) + (scheme-file "set-up-network" + (with-extensions (list guile-netlink) + #~(begin + (use-modules (ip addr) (ip link) (ip route)) + + #$@(map (lambda (address) + #~(begin + (addr-add #$(network-address-device address) + #$(network-address-value address) + #:ipv6? + #$(network-address-ipv6? address)) + ;; FIXME: loopback? + (link-set #$(network-address-device address) + #:up #t))) + addresses) + #$@(map (match-lambda + (($ name type arguments) + #~(link-add #:device #$name #$type + #:type-args '#$arguments))) + links) + #$@(map (lambda (route) + #~(route-add #$(network-route-destination route) + #:device + #$(network-route-device route) + #:ipv6? + #$(network-route-ipv6? route) + #:via + #$(network-route-gateway route) + #:src + #$(network-route-source route))) + routes) + #t)))))) + +(define network-tear-down/linux + (match-lambda + (($ addresses links routes) + (scheme-file "set-up-network" + (with-extensions (list guile-netlink) + #~(begin + (use-modules (ip addr) (ip link) (ip route)) + + #$@(map (lambda (route) + #~(route-del #$(network-route-destination route) + #:device + #$(network-route-device route) + #:ipv6? + #$(network-route-ipv6? route) + #:via + #$(network-route-gateway route) + #:src + #$(network-route-source route))) + routes) + #$@(map (match-lambda + (($ name type arguments) + #~(link-del #$name))) + links) + #$@(map (lambda (address) + #~(addr-del #$(network-address-device + address) + #$(network-address-value address) + #:ipv6? + #$(network-address-ipv6? address))) + addresses) + #f)))))) + +(define (static-networking-shepherd-service config) + (match config + (($ addresses links routes + provision requirement name-servers) (let ((loopback? (and provision (memq 'loopback provision)))) - (define set-up-via-ioctl - #~(let* ((addr (inet-pton AF_INET #$ip)) - (sockaddr (make-socket-address AF_INET addr 0)) - (mask (and #$netmask (inet-pton AF_INET #$netmask))) - (maskaddr (and mask - (make-socket-address AF_INET mask 0))) - (gateway (and #$gateway - (inet-pton AF_INET #$gateway))) - (gatewayaddr (and gateway - (make-socket-address AF_INET - gateway 0)))) - (configure-network-interface #$interface sockaddr - (logior IFF_UP - #$(if loopback? - #~IFF_LOOPBACK - 0)) - #:netmask maskaddr) - (when gateway - (let ((sock (socket AF_INET SOCK_DGRAM 0))) - (add-network-route/gateway sock gatewayaddr) - (close-port sock))))) - - (define tear-down-via-ioctl - #~(let ((sock (socket AF_INET SOCK_STREAM 0))) - (when #$gateway - (delete-network-route sock - (make-socket-address AF_INET - INADDR_ANY 0))) - (set-network-interface-flags sock #$interface 0) - (close-port sock) - #f)) - - (define set-up-via-netlink - (with-extensions (list guile-netlink) - #~(let ((ip #$(if netmask - #~(ip+netmask->cidr #$ip #$netmask) - ip))) - (addr-add #$interface ip) - (when #$gateway - (route-add "default" #:device #$interface - #:via #$gateway)) - (link-set #$interface #:up #t)))) - - (define tear-down-via-netlink - (with-extensions (list guile-netlink) - #~(begin - (link-set #$interface #:down #t) - (when #$gateway - (route-del "default" #:device #$interface)) - (addr-del #$interface #$ip) - #f))) - - (define helpers - #~(define (ip+netmask->cidr ip netmask) - ;; Return the CIDR notation (a string) for IP and NETMASK, two - ;; IPv4 address strings. - (let* ((netmask (inet-pton AF_INET netmask)) - (bits (logcount netmask))) - (string-append ip "/" (number->string bits))))) - (shepherd-service (documentation "Bring up the networking interface using a static IP address.") (requirement requirement) - (provision (or provision - (list (symbol-append 'networking- - (string->symbol interface))))) + (provision (or provision '(networking))) (start #~(lambda _ ;; Return #t if successfully started. - #$helpers - (if (string-contains %host-type "-linux") - #$set-up-via-netlink - #$set-up-via-ioctl))) + (load #$(let-system (system target) + (if (string-contains (or target system) "-linux") + (network-set-up/linux config) + (network-set-up/hurd config)))))) (stop #~(lambda _ ;; Return #f is successfully stopped. - (if (string-contains %host-type "-linux") - #$tear-down-via-netlink - #$tear-down-via-ioctl))) - (modules `((ip addr) - (ip link) - (ip route) - ,@%default-modules)) + #$(let-system (system target) + (if (string-contains (or target system) "-linux") + (network-tear-down/linux config) + (network-tear-down/hurd config))))) (respawn? #f)))))) +(define (static-networking-shepherd-services networks) + (map static-networking-shepherd-service networks)) + (define (static-networking-etc-files interfaces) "Return a /etc/resolv.conf entry for INTERFACES or the empty list." (match (delete-duplicates @@ -2441,30 +2603,6 @@ (define (static-networking-etc-files interfaces) # Generated by 'static-networking-service'.\n" content)))))))) -(define (static-networking-shepherd-services interfaces) - "Return the list of Shepherd services to bring up INTERFACES, a list of - objects." - (define (loopback? service) - (memq 'loopback (shepherd-service-provision service))) - - (let ((services (map static-networking-shepherd-service interfaces))) - (match (remove loopback? services) - (() - ;; There's no interface other than 'loopback', so we assume that the - ;; 'networking' service will be provided by dhclient or similar. - services) - ((non-loopback ...) - ;; Assume we're providing all the interfaces, and thus, provide a - ;; 'networking' service. - (cons (shepherd-service - (provision '(networking)) - (requirement (append-map shepherd-service-provision - services)) - (start #~(const #t)) - (stop #~(const #f)) - (documentation "Bring up all the networking interfaces.")) - services))))) - (define static-networking-service-type ;; The service type for statically-defined network interfaces. (service-type (name 'static-networking) @@ -2482,12 +2620,13 @@ (define static-networking-service-type services of this type is a list of @code{static-networking} objects, one per network interface."))) -(define* (static-networking-service interface ip - #:key - netmask gateway provision - ;; Most interfaces require udev to be usable. - (requirement '(udev)) - (name-servers '())) +(define-deprecated (static-networking-service interface ip + #:key + netmask gateway provision + ;; Most interfaces require udev to be usable. + (requirement '(udev)) + (name-servers '())) + static-networking-service-type "Return a service that starts @var{interface} with address @var{ip}. If @var{netmask} is true, use it as the network mask. If @var{gateway} is true, it must be a string specifying the default network gateway. @@ -2498,11 +2637,24 @@ (define* (static-networking-service interface ip to handle." (simple-service 'static-network-interface static-networking-service-type - (list (static-networking (interface interface) (ip ip) - (netmask netmask) (gateway gateway) - (provision provision) - (requirement requirement) - (name-servers name-servers))))) + (list (static-networking + (addresses + (list (network-address + (device interface) + (value (if netmask + (ip+netmask->cidr ip netmask) + ip)) + (ipv6? #f)))) + (routes + (if gateway + (list (network-route + (destination "default") + (gateway gateway) + (ipv6? #f))) + '())) + (requirement requirement) + (provision provision) + (name-servers name-servers))))) (define %base-services @@ -2534,10 +2686,12 @@ (define %base-services (tty "tty6"))) (service static-networking-service-type - (list (static-networking (interface "lo") - (ip "127.0.0.1") - (requirement '()) - (provision '(loopback))))) + (list (static-networking + (addresses (list (network-address + (device "lo") + (value "127.0.0.1")))) + (requirement '()) + (provision '(loopback))))) (syslog-service) (service urandom-seed-service-type) (service guix-service-type) diff --git a/gnu/system/hurd.scm b/gnu/system/hurd.scm index 0794671ce4..0e73ca0d99 100644 --- a/gnu/system/hurd.scm +++ b/gnu/system/hurd.scm @@ -79,11 +79,28 @@ (define %base-services/hurd (service hurd-getty-service-type (hurd-getty-configuration (tty "tty2"))) (service static-networking-service-type - (list (static-networking (interface "lo") - (ip "127.0.0.1") - (requirement '()) - (provision '(loopback networking)) - (name-servers '("10.0.2.3"))))) + (list (static-networking + (addresses + (list (network-address + (device "lo") + (value "127.0.0.1")))) + (requirement '()) + (provision '(loopback))) + (static-networking + (addresses + ;; The default QEMU guest address. To get "eth0", + ;; you need QEMU to emulate a device for which Mach + ;; has an in-kernel driver, for instance with: + ;; --device rtl8139,netdev=net0 --netdev user,id=net0 + (list (network-address + (device "eth0") + (value "10.0.2.15/24")))) + (routes + (list (network-route + (destination "default") + (gateway "10.0.2.2")))) + (provision '(networking)) + (name-servers '("10.0.2.3"))))) (syslog-service) (service guix-service-type (guix-configuration diff --git a/gnu/system/install.scm b/gnu/system/install.scm index 7b394184ad..bdfe580145 100644 --- a/gnu/system/install.scm +++ b/gnu/system/install.scm @@ -408,10 +408,13 @@ (define bare-bones-os ;; Loopback device, needed by OpenSSH notably. (service static-networking-service-type - (list (static-networking (interface "lo") - (ip "127.0.0.1") - (requirement '()) - (provision '(loopback))))) + (list (static-networking + (addresses + (list (network-address + (device "lo") + (value "127.0.0.1")))) + (requirement '()) + (provision '(loopback))))) (service wpa-supplicant-service-type) (dbus-service) diff --git a/gnu/tests/networking.scm b/gnu/tests/networking.scm index 131428c128..c66af279f2 100644 --- a/gnu/tests/networking.scm +++ b/gnu/tests/networking.scm @@ -337,7 +337,7 @@ (define marionette (srfi srfi-1)) (live-service-running (find (lambda (live) - (memq 'networking-ovs0 + (memq 'networking (live-service-provision live))) (current-services)))) marionette)) From patchwork Wed Oct 27 14:02:43 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?q?Ludovic_Court=C3=A8s?= X-Patchwork-Id: 34106 Return-Path: X-Original-To: patchwork@mira.cbaines.net Delivered-To: patchwork@mira.cbaines.net Received: by mira.cbaines.net (Postfix, from userid 113) id 41F2C27BBE3; Wed, 27 Oct 2021 15:49:27 +0100 (BST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on mira.cbaines.net X-Spam-Level: X-Spam-Status: No, score=-2.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, MAILING_LIST_MULTI,RCVD_IN_MSPIKE_H2,SPF_HELO_PASS,T_DKIM_INVALID, URIBL_BLOCKED autolearn=unavailable autolearn_force=no version=3.4.2 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mira.cbaines.net (Postfix) with ESMTPS id 87AD027BBE1 for ; Wed, 27 Oct 2021 15:49:26 +0100 (BST) Received: from localhost ([::1]:50650 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mfkF3-0007Ov-DO for patchwork@mira.cbaines.net; Wed, 27 Oct 2021 10:49:25 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:43162) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mfjXB-0008Pe-9g for guix-patches@gnu.org; Wed, 27 Oct 2021 10:04:05 -0400 Received: from debbugs.gnu.org ([209.51.188.43]:38547) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mfjXB-0005Go-0p for guix-patches@gnu.org; Wed, 27 Oct 2021 10:04:05 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1mfjXA-0002Zc-RZ for guix-patches@gnu.org; Wed, 27 Oct 2021 10:04:04 -0400 X-Loop: help-debbugs@gnu.org Subject: [bug#51440] [PATCH 08/10] services: Define '%qemu-static-networking'. Resent-From: Ludovic =?utf-8?q?Court=C3=A8s?= Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Wed, 27 Oct 2021 14:04:04 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 51440 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: 51440@debbugs.gnu.org Cc: Ludovic =?utf-8?q?Court=C3=A8s?= Received: via spool by 51440-submit@debbugs.gnu.org id=B51440.16353434019756 (code B ref 51440); Wed, 27 Oct 2021 14:04:04 +0000 Received: (at 51440) by debbugs.gnu.org; 27 Oct 2021 14:03:21 +0000 Received: from localhost ([127.0.0.1]:50082 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1mfjWS-0002XB-Dz for submit@debbugs.gnu.org; Wed, 27 Oct 2021 10:03:20 -0400 Received: from eggs.gnu.org ([209.51.188.92]:45572) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1mfjWL-0002W0-IM for 51440@debbugs.gnu.org; Wed, 27 Oct 2021 10:03:13 -0400 Received: from fencepost.gnu.org ([2001:470:142:3::e]:37978) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mfjWG-00058Y-Ax; Wed, 27 Oct 2021 10:03:08 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=MIME-Version:References:In-Reply-To:Date:Subject:To: From; bh=NfHER5O+rtp5vUNrP/FtzUi2KACgFi9EmcB/+QS6z+0=; b=Q9DJd5RXi2MlebTEjLQZ nwkBDpruYg3uDtbFXnk1DbaewZiJbQiystcVbXG7JGTPYENlQfnBeYw3ODnzzGn+F2+xM8rVjvFQT w5I2NDGnDp62Pya00d5bSE+FEwSAxWF4aCH2R1JjPxFeFZBZu4wb/o7aLIInNMnY1/1w/SC1xWujS SRO/BLwqgjZn1Cv2yvJo+s0YFgZjJr85CUQ7JxowAkl79WzjpBF+lFbBJGQmR/hOGBSTDCRazku4G EcFxAZI1Ko1rBgvDniqWmHKFWzN3Z392PUvzvEcfq8NmWvHnieEAjxLfxZvZ/UDZzYuygiBO3swrv N95/Zhse36GEGw==; Received: from [2a01:e0a:1d:7270:af76:b9b:ca24:c465] (port=55004 helo=gnu.org) by fencepost.gnu.org with esmtpsa (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mfjWF-0002Tf-37; Wed, 27 Oct 2021 10:03:08 -0400 From: Ludovic =?utf-8?q?Court=C3=A8s?= Date: Wed, 27 Oct 2021 16:02:43 +0200 Message-Id: <20211027140245.18970-8-ludo@gnu.org> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20211027140245.18970-1-ludo@gnu.org> References: <20211027140245.18970-1-ludo@gnu.org> MIME-Version: 1.0 X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: guix-patches@gnu.org List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guix-patches-bounces+patchwork=mira.cbaines.net@gnu.org Sender: "Guix-patches" X-getmail-retrieved-from-mailbox: Patches * gnu/services/base.scm (%qemu-static-networking): New variable. * gnu/system/hurd.scm (%base-services/hurd): Use it. * doc/guix.texi (Networking Setup): Document it. --- doc/guix.texi | 8 ++++++++ gnu/services/base.scm | 16 ++++++++++++++++ gnu/system/hurd.scm | 21 ++++++--------------- 3 files changed, 30 insertions(+), 15 deletions(-) diff --git a/doc/guix.texi b/doc/guix.texi index b529a8db6c..0b23075d8c 100644 --- a/doc/guix.texi +++ b/doc/guix.texi @@ -16923,6 +16923,14 @@ List of arguments for this type of link. @end table @end deftp +@cindex networking, with QEMU +@cindex QEMU, networking +@defvr {Scheme Variable} %qemu-static-networking +This is the @code{static-networking} record representing network setup +when using QEMU's user-mode network stack on @code{eth0} (@pxref{Using +the user mode network stack,,, QEMU, QEMU Documentation}). +@end defvr + @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 diff --git a/gnu/services/base.scm b/gnu/services/base.scm index 03f6b388a8..380be1c71e 100644 --- a/gnu/services/base.scm +++ b/gnu/services/base.scm @@ -113,6 +113,8 @@ (define-module (gnu services base) static-networking-service static-networking-service-type + %qemu-static-networking + udev-configuration udev-configuration? udev-configuration-rules @@ -2656,6 +2658,20 @@ (define-deprecated (static-networking-service interface ip (provision provision) (name-servers name-servers))))) +(define %qemu-static-networking + ;; Networking configuration for QEMU's user-mode network stack (info "(QEMU) + ;; Using the user mode network stack"). + (static-networking + (addresses (list (network-address + (device "eth0") + (value "10.0.2.15/24")))) + (routes (list (network-route + (destination "default") + (gateway "10.0.2.2")))) + (requirement '()) + (provision '(networking)) + (name-servers '("10.0.2.3")))) + (define %base-services ;; Convenience variable holding the basic services. diff --git a/gnu/system/hurd.scm b/gnu/system/hurd.scm index 0e73ca0d99..ec8484d746 100644 --- a/gnu/system/hurd.scm +++ b/gnu/system/hurd.scm @@ -86,21 +86,12 @@ (define %base-services/hurd (value "127.0.0.1")))) (requirement '()) (provision '(loopback))) - (static-networking - (addresses - ;; The default QEMU guest address. To get "eth0", - ;; you need QEMU to emulate a device for which Mach - ;; has an in-kernel driver, for instance with: - ;; --device rtl8139,netdev=net0 --netdev user,id=net0 - (list (network-address - (device "eth0") - (value "10.0.2.15/24")))) - (routes - (list (network-route - (destination "default") - (gateway "10.0.2.2")))) - (provision '(networking)) - (name-servers '("10.0.2.3"))))) + + ;; QEMU user-mode networking. To get "eth0", you need + ;; QEMU to emulate a device for which Mach has an + ;; in-kernel driver, for instance with: + ;; --device rtl8139,netdev=net0 --netdev user,id=net0 + %qemu-static-networking)) (syslog-service) (service guix-service-type (guix-configuration From patchwork Wed Oct 27 14:02:44 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?q?Ludovic_Court=C3=A8s?= X-Patchwork-Id: 34107 Return-Path: X-Original-To: patchwork@mira.cbaines.net Delivered-To: patchwork@mira.cbaines.net Received: by mira.cbaines.net (Postfix, from userid 113) id 5624327BBE3; Wed, 27 Oct 2021 15:49:58 +0100 (BST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on mira.cbaines.net X-Spam-Level: X-Spam-Status: No, score=-2.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, MAILING_LIST_MULTI,RCVD_IN_MSPIKE_H2,SPF_HELO_PASS,T_DKIM_INVALID, URIBL_BLOCKED autolearn=unavailable autolearn_force=no version=3.4.2 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mira.cbaines.net (Postfix) with ESMTPS id DF35C27BBE1 for ; Wed, 27 Oct 2021 15:49:57 +0100 (BST) Received: from localhost ([::1]:51470 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mfkFY-0007xV-Ub for patchwork@mira.cbaines.net; Wed, 27 Oct 2021 10:49:56 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:43164) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mfjXB-0008Pp-OK for guix-patches@gnu.org; Wed, 27 Oct 2021 10:04:05 -0400 Received: from debbugs.gnu.org ([209.51.188.43]:38548) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mfjXB-0005Gz-Ej for guix-patches@gnu.org; Wed, 27 Oct 2021 10:04:05 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1mfjXB-0002Zj-Ak for guix-patches@gnu.org; Wed, 27 Oct 2021 10:04:05 -0400 X-Loop: help-debbugs@gnu.org Subject: [bug#51440] [PATCH 09/10] services: Define '%loopback-static-networking'. Resent-From: Ludovic =?utf-8?q?Court=C3=A8s?= Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Wed, 27 Oct 2021 14:04:05 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 51440 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: 51440@debbugs.gnu.org Cc: Ludovic =?utf-8?q?Court=C3=A8s?= Received: via spool by 51440-submit@debbugs.gnu.org id=B51440.16353434019762 (code B ref 51440); Wed, 27 Oct 2021 14:04:05 +0000 Received: (at 51440) by debbugs.gnu.org; 27 Oct 2021 14:03:21 +0000 Received: from localhost ([127.0.0.1]:50084 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1mfjWS-0002XJ-SR for submit@debbugs.gnu.org; Wed, 27 Oct 2021 10:03:21 -0400 Received: from eggs.gnu.org ([209.51.188.92]:45578) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1mfjWM-0002W2-6K for 51440@debbugs.gnu.org; Wed, 27 Oct 2021 10:03:14 -0400 Received: from fencepost.gnu.org ([2001:470:142:3::e]:37980) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mfjWG-00058g-VR; Wed, 27 Oct 2021 10:03:08 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=MIME-Version:References:In-Reply-To:Date:Subject:To: From; bh=9ixZsw9w1H86Yy9qbxjswPmAlVRihcKD1Z3y9hqnY+g=; b=Kwa8tzUTcdI/RcRHkOpe J9TLaDOhu8FZ/ccxLrmX6tQ+SXgUfEd4DBXjquf3a6jnCAMmbWkDuvRfb0foCfsSyuvVKK8ENRYM7 DYKklZ8GZTRHNPYUwKWtg4PpLIEeJy013xDOQTJ7ZgV4w6ddzhYhRyWhBn++zfBl7+ateTOV8gZl4 j69ZaKxcG6Fe1M68TlzQUE4Bp45Xw9R+qs9HyNW6pfM94wPUii7sx+cmPAmwuIj1EjTuN8KZ76Qg7 vurTQvFIhKZ3z9iWsjuPlLsGgKVyt1M3CcHXG85Gxy/Eu2SlPSiHbYhQviSkyFE6JQLqJjvA+2Lss hCvgk8NPcGZ0cA==; Received: from [2a01:e0a:1d:7270:af76:b9b:ca24:c465] (port=55004 helo=gnu.org) by fencepost.gnu.org with esmtpsa (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mfjWG-0002Tf-Iq; Wed, 27 Oct 2021 10:03:08 -0400 From: Ludovic =?utf-8?q?Court=C3=A8s?= Date: Wed, 27 Oct 2021 16:02:44 +0200 Message-Id: <20211027140245.18970-9-ludo@gnu.org> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20211027140245.18970-1-ludo@gnu.org> References: <20211027140245.18970-1-ludo@gnu.org> MIME-Version: 1.0 X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: guix-patches@gnu.org List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guix-patches-bounces+patchwork=mira.cbaines.net@gnu.org Sender: "Guix-patches" X-getmail-retrieved-from-mailbox: Patches * gnu/services/base.scm (%loopback-static-networking): New variable. (%base-services): Use it. * gnu/system/hurd.scm (%base-services/hurd): Use it. * gnu/system/install.scm (%installation-services): Use it. * doc/guix.texi (Networking Setup): Document it. --- doc/guix.texi | 7 +++++++ gnu/services/base.scm | 17 +++++++++++------ gnu/system/hurd.scm | 8 +------- gnu/system/install.scm | 8 +------- 4 files changed, 20 insertions(+), 20 deletions(-) diff --git a/doc/guix.texi b/doc/guix.texi index 0b23075d8c..b8b9cf2730 100644 --- a/doc/guix.texi +++ b/doc/guix.texi @@ -16923,6 +16923,13 @@ List of arguments for this type of link. @end table @end deftp +@cindex loopback device +@defvr {Scheme Variable} %loopback-static-networking +This is the @code{static-networking} record representing the ``loopback +device'', @code{lo}, for IP addresses 127.0.0.1 and ::1, and providing +the @code{loopback} Shepherd service. +@end defvr + @cindex networking, with QEMU @cindex QEMU, networking @defvr {Scheme Variable} %qemu-static-networking diff --git a/gnu/services/base.scm b/gnu/services/base.scm index 380be1c71e..66683f153f 100644 --- a/gnu/services/base.scm +++ b/gnu/services/base.scm @@ -113,6 +113,7 @@ (define-module (gnu services base) static-networking-service static-networking-service-type + %loopback-static-networking %qemu-static-networking udev-configuration @@ -2658,6 +2659,15 @@ (define-deprecated (static-networking-service interface ip (provision provision) (name-servers name-servers))))) +(define %loopback-static-networking + ;; The loopback device. + (static-networking + (addresses (list (network-address + (device "lo") + (value "127.0.0.1")))) + (requirement '()) + (provision '(loopback)))) + (define %qemu-static-networking ;; Networking configuration for QEMU's user-mode network stack (info "(QEMU) ;; Using the user mode network stack"). @@ -2702,12 +2712,7 @@ (define %base-services (tty "tty6"))) (service static-networking-service-type - (list (static-networking - (addresses (list (network-address - (device "lo") - (value "127.0.0.1")))) - (requirement '()) - (provision '(loopback))))) + (list %loopback-static-networking)) (syslog-service) (service urandom-seed-service-type) (service guix-service-type) diff --git a/gnu/system/hurd.scm b/gnu/system/hurd.scm index ec8484d746..2acc7b7e11 100644 --- a/gnu/system/hurd.scm +++ b/gnu/system/hurd.scm @@ -79,13 +79,7 @@ (define %base-services/hurd (service hurd-getty-service-type (hurd-getty-configuration (tty "tty2"))) (service static-networking-service-type - (list (static-networking - (addresses - (list (network-address - (device "lo") - (value "127.0.0.1")))) - (requirement '()) - (provision '(loopback))) + (list %loopback-static-networking ;; QEMU user-mode networking. To get "eth0", you need ;; QEMU to emulate a device for which Mach has an diff --git a/gnu/system/install.scm b/gnu/system/install.scm index bdfe580145..073d7df1db 100644 --- a/gnu/system/install.scm +++ b/gnu/system/install.scm @@ -408,13 +408,7 @@ (define bare-bones-os ;; Loopback device, needed by OpenSSH notably. (service static-networking-service-type - (list (static-networking - (addresses - (list (network-address - (device "lo") - (value "127.0.0.1")))) - (requirement '()) - (provision '(loopback))))) + (list %loopback-static-networking)) (service wpa-supplicant-service-type) (dbus-service) From patchwork Wed Oct 27 14:02:45 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?q?Ludovic_Court=C3=A8s?= X-Patchwork-Id: 34110 Return-Path: X-Original-To: patchwork@mira.cbaines.net Delivered-To: patchwork@mira.cbaines.net Received: by mira.cbaines.net (Postfix, from userid 113) id 9336E27BBE3; Wed, 27 Oct 2021 15:52:29 +0100 (BST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on mira.cbaines.net X-Spam-Level: X-Spam-Status: No, score=-2.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, MAILING_LIST_MULTI,RCVD_IN_MSPIKE_H2,SPF_HELO_PASS,T_DKIM_INVALID, URIBL_BLOCKED autolearn=unavailable autolearn_force=no version=3.4.2 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mira.cbaines.net (Postfix) with ESMTPS id 1F71927BBE1 for ; Wed, 27 Oct 2021 15:52:29 +0100 (BST) Received: from localhost ([::1]:56218 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mfkI0-0002qR-5x for patchwork@mira.cbaines.net; Wed, 27 Oct 2021 10:52:28 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:43166) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mfjXC-0008Qs-8L for guix-patches@gnu.org; Wed, 27 Oct 2021 10:04:06 -0400 Received: from debbugs.gnu.org ([209.51.188.43]:38549) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mfjXB-0005H7-U7 for guix-patches@gnu.org; Wed, 27 Oct 2021 10:04:05 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1mfjXB-0002Zt-Pe for guix-patches@gnu.org; Wed, 27 Oct 2021 10:04:05 -0400 X-Loop: help-debbugs@gnu.org Subject: [bug#51440] [PATCH 10/10] tests: Replace uses of deprecated 'static-networking-service'. Resent-From: Ludovic =?utf-8?q?Court=C3=A8s?= Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Wed, 27 Oct 2021 14:04:05 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 51440 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: 51440@debbugs.gnu.org Cc: Ludovic =?utf-8?q?Court=C3=A8s?= Received: via spool by 51440-submit@debbugs.gnu.org id=B51440.16353434149787 (code B ref 51440); Wed, 27 Oct 2021 14:04:05 +0000 Received: (at 51440) by debbugs.gnu.org; 27 Oct 2021 14:03:34 +0000 Received: from localhost ([127.0.0.1]:50086 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1mfjWg-0002Xn-AN for submit@debbugs.gnu.org; Wed, 27 Oct 2021 10:03:34 -0400 Received: from eggs.gnu.org ([209.51.188.92]:45582) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1mfjWN-0002W4-1f for 51440@debbugs.gnu.org; Wed, 27 Oct 2021 10:03:15 -0400 Received: from fencepost.gnu.org ([2001:470:142:3::e]:37982) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mfjWH-00058o-R2; Wed, 27 Oct 2021 10:03:09 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=MIME-Version:References:In-Reply-To:Date:Subject:To: From; bh=f0T5dgslaHqaANUOThtzyqZWhOicRkOBGFHzUtH5IrY=; b=qXujNXdaHUkz8+K+ivbi ZQJsJiQMQ7LIGNym9tuf9Ue3IjDLS+QSOzRr9wJ3PwKmOIocWSxnkYS2+Vna4tMDKEPZKB9/1OL8X mvgWDdOS7lvttdK/otf50osW0VhdF/CqVv/FaAOOrp1brZcW2tCwOaY8VTg3AxDG6y/svwpHbD+bP 2Hj7nWIGpdcGh6rrvUqQQecKoIUpNJlpEwCb2+TMjA+lJgr4LPnQ9jUvYf9ZomWV/2v9bMG3ud60Q gkgtSgJxfqYjaoyoKy9tAxHh5WPMeJ83LpnzvdA2botn50ZHZkbN0zm6I6OnkLo+bwpSrecmV40NE OGl+bnwkbE88OA==; Received: from [2a01:e0a:1d:7270:af76:b9b:ca24:c465] (port=55004 helo=gnu.org) by fencepost.gnu.org with esmtpsa (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mfjWH-0002Tf-76; Wed, 27 Oct 2021 10:03:09 -0400 From: Ludovic =?utf-8?q?Court=C3=A8s?= Date: Wed, 27 Oct 2021 16:02:45 +0200 Message-Id: <20211027140245.18970-10-ludo@gnu.org> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20211027140245.18970-1-ludo@gnu.org> References: <20211027140245.18970-1-ludo@gnu.org> MIME-Version: 1.0 X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: guix-patches@gnu.org List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guix-patches-bounces+patchwork=mira.cbaines.net@gnu.org Sender: "Guix-patches" X-getmail-retrieved-from-mailbox: Patches * gnu/tests/ganeti.scm (%ganeti-os): Replace call to 'static-networking-service' by instantiating STATIC-NETWORKING-SERVICE-TYPE. * gnu/tests/networking.scm (%test-static-networking) (%openvswitch-os, %dhcpd-os): Likewise. --- gnu/tests/ganeti.scm | 7 ++----- gnu/tests/networking.scm | 29 ++++++++++++++++++----------- 2 files changed, 20 insertions(+), 16 deletions(-) diff --git a/gnu/tests/ganeti.scm b/gnu/tests/ganeti.scm index 5ac2fd48dd..c29b885a5e 100644 --- a/gnu/tests/ganeti.scm +++ b/gnu/tests/ganeti.scm @@ -59,11 +59,8 @@ (define %ganeti-os (packages (append (list ganeti-instance-debootstrap ganeti-instance-guix) %base-packages)) (services - (append (list (static-networking-service "eth0" "10.0.2.15" - #:netmask "255.255.255.0" - #:gateway "10.0.2.2" - #:name-servers '("10.0.2.3")) - + (append (list (service static-networking-service-type + (list %qemu-static-networking)) (service openssh-service-type (openssh-configuration (permit-root-login 'prohibit-password))) diff --git a/gnu/tests/networking.scm b/gnu/tests/networking.scm index c66af279f2..246e0a15fa 100644 --- a/gnu/tests/networking.scm +++ b/gnu/tests/networking.scm @@ -122,10 +122,8 @@ (define %test-static-networking (value (let ((os (marionette-operating-system (simple-operating-system - (static-networking-service "eth0" "10.0.2.15" - #:netmask "255.255.255.0" - #:gateway "10.0.2.2" - #:name-servers '("10.0.2.2"))) + (service static-networking-service-type + (list %qemu-static-networking))) #:imported-modules '((gnu services herd) (guix combinators))))) (run-static-networking-test (virtual-machine os)))))) @@ -275,9 +273,13 @@ (define openvswitch-configuration-service (define %openvswitch-os (operating-system (inherit (simple-operating-system - (static-networking-service "ovs0" "10.1.1.1" - #:netmask "255.255.255.252" - #:requirement '(openvswitch-configuration)) + (simple-service 'openswitch-networking + static-networking-service-type + (list (static-networking + (addresses (list (network-address + (value "10.1.1.1/24") + (device "ovs0")))) + (requirement '(openvswitch-configuration))))) (service openvswitch-service-type) openvswitch-configuration-service)) ;; Ensure the interface name does not change depending on the driver. @@ -392,10 +394,15 @@ (define dhcpd-v4-configuration (define %dhcpd-os (simple-operating-system - (static-networking-service "ens3" "192.168.1.4" - #:netmask "255.255.255.0" - #:gateway "192.168.1.1" - #:name-servers '("192.168.1.2" "192.168.1.3")) + (service static-networking-service-type + (list (static-networking + (addresses (list (network-address + (value "192.168.1.4/24") + (device "ens3")))) + (routes (list (network-route + (destination "default") + (gateway "192.168.1.1")))) + (name-servers '("192.168.1.2" "192.168.1.3"))))) (service dhcpd-service-type dhcpd-v4-configuration))) (define (run-dhcpd-test)