From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp2.migadu.com ([2001:41d0:403:58f0::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms13.migadu.com with LMTPS id qLdsODF2bGda3AAAe85BDQ:P1 (envelope-from ) for ; Wed, 25 Dec 2024 21:16:34 +0000 Received: from aspmx1.migadu.com ([2001:41d0:403:58f0::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp2.migadu.com with LMTPS id qLdsODF2bGda3AAAe85BDQ (envelope-from ) for ; Wed, 25 Dec 2024 22:16:34 +0100 X-Envelope-To: larch@yhetil.org Authentication-Results: aspmx1.migadu.com; dkim=fail ("body hash did not verify") header.d=debbugs.gnu.org header.s=debbugs-gnu-org header.b=SU2EEfQE; dkim=fail ("body hash did not verify") header.d=gnu.org header.s=fencepost-gnu-org header.b=ki1KI7zU; spf=pass (aspmx1.migadu.com: domain of "guix-patches-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="guix-patches-bounces+larch=yhetil.org@gnu.org"; dmarc=pass (policy=none) header.from=gnu.org ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1735161393; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding:resent-cc: resent-from:resent-sender:resent-message-id:in-reply-to:in-reply-to: references:references:list-id:list-help:list-unsubscribe: list-subscribe:list-post:dkim-signature; bh=/vIcPjEKvEumYb349STuHYR7tz8s3gV7ljNvJH4hsjo=; b=pipt1sHDlXYEr8AfbDjuPWzGHsLsYq6MTBqFd/XuxPU5nHU5lAwBlRIOwlVistljAEUnCF x1KpGEGVUQ8HaL4KmTt5lEzdgA2O00zN8zTJnzyQCmteIL+M+rQ+drAjhOzuFa26ZJxQ9W gZThVIEQUSzi6C0bbSMMScHcDukL/eMJoywEdFiXvX3G3F9AEHlmmdalq24byfpA+rNBBP N+qwCcT36BBJ6VEIDFx5tbju7Gz6BTDE7a91NV7jY49fSHkYpiUxNJffLzXmGrbw1EMa/K yIQusJHOqR4UWr43YIX77AHnIpdHacUn0mZh50LRsAGw/jMCggotTFfDM4n0qQ== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=fail ("body hash did not verify") header.d=debbugs.gnu.org header.s=debbugs-gnu-org header.b=SU2EEfQE; dkim=fail ("body hash did not verify") header.d=gnu.org header.s=fencepost-gnu-org header.b=ki1KI7zU; spf=pass (aspmx1.migadu.com: domain of "guix-patches-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="guix-patches-bounces+larch=yhetil.org@gnu.org"; dmarc=pass (policy=none) header.from=gnu.org ARC-Seal: i=1; s=key1; d=yhetil.org; t=1735161393; a=rsa-sha256; cv=none; b=NVB0nlQSPBYMNi2Ic8RAxKiEYHBuCJfQ92Cs+eBdvS8hLDX7kWLDDPYhbbHki2RAhRSTJs c5ShFS4EdsLdTTlmcdvsUd86zXw7FcIY9Od/BEZNkO/Ga5cBKPobe51EV3zBDK7iWo7IBv naGJ90JJ90OBAlFn2PoN1fdwEKAp00O2WkT11inJImhIqan7o/dRhMh/V+4bMZY32dJTfs ih1u2QygWaYAfSox5sVbz6A3OTzmc+K972k/c3d42DvvuSOxNqvbTngKUnRYAWxKBMRI1a IN++X0eatCoBJG8XSNuQMjlQX044Y9CkLZWSWGHr+vT5NrClim/zE1ZdynLx3w== Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by aspmx1.migadu.com (Postfix) with ESMTPS id 249B8436C9 for ; Wed, 25 Dec 2024 22:16:33 +0100 (CET) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tQYjd-00014R-5R; Wed, 25 Dec 2024 16:16:05 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1tQYjb-00013t-IH for guix-patches@gnu.org; Wed, 25 Dec 2024 16:16:03 -0500 Received: from debbugs.gnu.org ([2001:470:142:5::43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1tQYjb-0001nM-4a for guix-patches@gnu.org; Wed, 25 Dec 2024 16:16:03 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=debbugs.gnu.org; s=debbugs-gnu-org; h=MIME-Version:References:In-Reply-To:Date:From:To:Subject; bh=D4eim0hLV76tbw/BpRi80aW2dYz9ZnpNh61wWqjcz4M=; b=SU2EEfQEL6JxYxYwb1BU+vrs7bv8x+RpMwbObfAFEI5fYBWXZwy5++qC7G+2BVnTWQFxi0n1hnvX4vCGGjoPUZ3rg1Y7swaroEbXD5Y8b4uMFmgeRl6TmaT7fTEnErYiBjxY9kBVRT/VfFF3ZhPqjAR2R71FhK/6ua+tJG/kk42kdDo350dmEE5DKsdQgVCR3sQuOS2E6xlyANlCuAvNBSH/v/YeFJ8V4QNXiGrzKmhbUSg3OLAG5oesd9sLmJeG/epwZlrEhzuuhW67hqYskiTOuADe1odju2Fqdl3Nlsy/3YH3P/0i2xTvMOYZSeXei+3F4hZTuCCnkTcf6BJtQA==; Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1tQYjb-00015f-0H for guix-patches@gnu.org; Wed, 25 Dec 2024 16:16:03 -0500 X-Loop: help-debbugs@gnu.org Subject: [bug#75100] [PATCH 2/3] services: static-networking: Fail when devices =?UTF-8?Q?don=E2=80=99t?= show up. Resent-From: Ludovic =?UTF-8?Q?Court=C3=A8s?= Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Wed, 25 Dec 2024 21:16:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 75100 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: 75100@debbugs.gnu.org Cc: Ludovic =?UTF-8?Q?Court=C3=A8s?= Received: via spool by 75100-submit@debbugs.gnu.org id=B75100.17351613564155 (code B ref 75100); Wed, 25 Dec 2024 21:16:02 +0000 Received: (at 75100) by debbugs.gnu.org; 25 Dec 2024 21:15:56 +0000 Received: from localhost ([127.0.0.1]:39081 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1tQYjT-00014w-Gs for submit@debbugs.gnu.org; Wed, 25 Dec 2024 16:15:56 -0500 Received: from eggs.gnu.org ([209.51.188.92]:35710) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1tQYjO-00014P-0f for 75100@debbugs.gnu.org; Wed, 25 Dec 2024 16:15:50 -0500 Received: from fencepost.gnu.org ([2001:470:142:3::e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1tQYjI-0001lN-Ey; Wed, 25 Dec 2024 16:15:44 -0500 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=D4eim0hLV76tbw/BpRi80aW2dYz9ZnpNh61wWqjcz4M=; b=ki1KI7zUbITSPXDjmzE/ L35VT3XY3v9BWUd2ww2nbTDqh9RG+TWtWRMpdbKk5IECyeyMNm7QMrXZSx1vjFOkgIZupjta7dASB ujeqxIiaqld2xSBa/lyq0rSQ7692n1z6bBT7qHPSC7BCKM7NcHbpLDRHPqgXh1voQCfz7L7lo8O63 3rDKTN7oQ9quQUrCeI/1UHAJkvPKQzeiTOTsut2MHlCsKotGGYAPo/iAp7kq0jLAuw6z9LOhXOc9M CCfCwVKuF0Oz722R2+Mi++5w23p9BwZpEPTGasxzltJ/cPx+yciS2AkFjucrfGV6Hvhdea90lOctt ugyLJFoRMcr/fw==; From: Ludovic =?UTF-8?Q?Court=C3=A8s?= Date: Wed, 25 Dec 2024 22:15:32 +0100 Message-ID: <700b204dd526e7b7c13b11759191306587f7d6ec.1735160803.git.ludo@gnu.org> X-Mailer: git-send-email 2.46.0 In-Reply-To: References: MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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+larch=yhetil.org@gnu.org Sender: guix-patches-bounces+larch=yhetil.org@gnu.org X-Migadu-Flow: FLOW_IN X-Migadu-Country: US X-Migadu-Scanner: mx11.migadu.com X-Migadu-Spam-Score: -3.11 X-Spam-Score: -3.11 X-Migadu-Queue-Id: 249B8436C9 X-TUID: 385ius0QzuQy Fixes . * gnu/services/base.scm (network-set-up/linux): Define ‘max-set-up-duration’ and use it. * gnu/tests/networking.scm (%static-networking-with-nonexistent-device): New variable. (run-static-networking-failure-test): New procedure. (%test-static-networking-failure): New variable. Change-Id: Idba9b36750aa8c6368c8f6d1bc1358066f7432e4 --- gnu/services/base.scm | 17 ++++++++-- gnu/tests/networking.scm | 71 +++++++++++++++++++++++++++++++++++++++- 2 files changed, 84 insertions(+), 4 deletions(-) diff --git a/gnu/services/base.scm b/gnu/services/base.scm index f6d1da61cd..15497b23f7 100644 --- a/gnu/services/base.scm +++ b/gnu/services/base.scm @@ -3092,6 +3092,10 @@ (define (network-tear-down/hurd config) #f)))) (define (network-set-up/linux config) + (define max-set-up-duration + ;; Maximum waiting time in seconds for devices to be up. + 60) + (match-record config (addresses links routes) (program-file "set-up-network" @@ -3169,12 +3173,19 @@ (define (network-set-up/linux config) (format #t (G_ "Interface with mac-address '~a' not found~%") #$mac-address))))))) links) + ;; 'wait-for-link' below could wait forever when + ;; passed a non-existent device. To ensure timely + ;; completion, install an alarm. + (alarm #$max-set-up-duration) + #$@(map (lambda (address) - #~(begin + #~(let ((device + #$(network-address-device address))) ;; Before going any further, wait for the ;; device to show up. - (wait-for-link - #$(network-address-device address)) + (format #t "Waiting for network device '~a'...~%" + device) + (wait-for-link device) (addr-add #$(network-address-device address) #$(network-address-value address) diff --git a/gnu/tests/networking.scm b/gnu/tests/networking.scm index b1ab43efb6..e7c02b9e00 100644 --- a/gnu/tests/networking.scm +++ b/gnu/tests/networking.scm @@ -4,7 +4,7 @@ ;;; Copyright © 2018 Chris Marusich ;;; Copyright © 2018 Arun Isaac ;;; Copyright © 2021 Maxime Devos -;;; Copyright © 2021, 2023 Ludovic Courtès +;;; Copyright © 2021, 2023-2024 Ludovic Courtès ;;; ;;; This file is part of GNU Guix. ;;; @@ -39,6 +39,7 @@ (define-module (gnu tests networking) #:use-module (gnu services shepherd) #:use-module (ice-9 match) #:export (%test-static-networking + %test-static-networking-failure %test-static-networking-advanced %test-inetd %test-openvswitch @@ -124,7 +125,75 @@ (define %test-static-networking #:imported-modules '((gnu services herd) (guix combinators))))) (run-static-networking-test (virtual-machine os)))))) + +(define %static-networking-with-nonexistent-device + ;; Similar to %QEMU-STATIC-NETWORKING except that the device does not exist. + (static-networking + (addresses (list (network-address + (device "does-not-exist") ;<- really + (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 (run-static-networking-failure-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))) + + (test-runner-current (system-test-runner #$output)) + (test-begin "static-networking") + + (test-equal "service fails to start" + #f + ;; The 'start' method of the 'networking' service should fail + ;; within a minute or so. Previously it would never complete: + ;; . + (marionette-eval + '(begin + (use-modules (gnu services herd)) + (alarm 180) ;must complete in a timely fashion + (start-service 'networking)) + marionette)) + + (test-equal "network interfaces" + '("lo") + (marionette-eval + '(begin + (use-modules (guix build syscalls)) + (network-interface-names)) + marionette)) + + (test-end)))) + + (gexp->derivation "static-networking-failure" test)) + +(define %test-static-networking-failure + (system-test + (name "static-networking-failure") + (description "Test the behavior of the 'static-networking' service when +passed an invalid device.") + (value + (let ((os (marionette-operating-system + (simple-operating-system + (service static-networking-service-type + (list %static-networking-with-nonexistent-device))) + #:imported-modules '((gnu services herd) + (guix combinators))))) + (run-static-networking-failure-test (virtual-machine os)))))) + + (define (run-static-networking-advanced-test vm) (define test (with-imported-modules '((gnu build marionette) -- 2.46.0