diff --git a/gnu/services/base.scm b/gnu/services/base.scm index fd79c9e232..5d43d998c3 100644 --- a/gnu/services/base.scm +++ b/gnu/services/base.scm @@ -2794,10 +2794,39 @@ (define (network-set-up/linux config) (scheme-file "set-up-network" (with-extensions (list guile-netlink) #~(begin - (use-modules (ip addr) (ip link) (ip route)) + (use-modules (ip addr) (ip link) (ip route) + (srfi srfi-1)) + + (define (wait-for-device device) + ;; Wait for DEVICE to show up. + ;; XXX: Polling is ridiculous. We should open a + ;; SOCK_NONBLOCK netlink socket and wait on it. + (let loop ((attempts 0)) + (unless (find (lambda (link) + (string=? (link-name link) + device)) + (get-links)) + (if (< attempts 30) + (begin + (format #t + "waiting for \ +networking device '~a'...~%" + device) + ((@ (fibers) sleep) 1) + (loop (+ 1 attempts))) + (begin + (format #t "networking device '~a' \ +did not show up; bailing out~%" + device) + #f))))) #$@(map (lambda (address) #~(begin + ;; Before going any further, wait for the + ;; device to show up. + (wait-for-device + #$(network-address-device address)) + (addr-add #$(network-address-device address) #$(network-address-value address) #:ipv6?