1
0
mirror of https://git.savannah.gnu.org/git/guix.git synced 2026-04-06 21:20:33 +02:00

services: static-networking: Fail when devices don’t show up.

Fixes <https://issues.guix.gnu.org/71173>.

* 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
This commit is contained in:
Ludovic Courtès
2024-12-25 21:54:16 +01:00
parent 8d649a8d17
commit 431ab10344
2 changed files with 84 additions and 4 deletions

View File

@@ -3092,6 +3092,10 @@ to 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 <static-networking>
(addresses links routes)
(program-file "set-up-network"
@@ -3169,12 +3173,19 @@ to 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)