GNU bug report logs -
#63516
Static networking should wait for interfaces to be up
Previous Next
Full log
Message #31 received at 63516 <at> debbugs.gnu.org (full text, mbox):
* ip/link.scm (new-link-message->link): New procedure.
(get-links): Use it, and use 'filter-map' instead of 'filter' followed
by 'map'.
---
ip/link.scm | 42 ++++++++++++++++++++----------------------
1 file changed, 20 insertions(+), 22 deletions(-)
diff --git a/ip/link.scm b/ip/link.scm
index 814a008..7e0ae6b 100644
--- a/ip/link.scm
+++ b/ip/link.scm
@@ -59,6 +59,25 @@
(addr link-addr)
(brd link-brd))
+(define (new-link-message->link msg)
+ "If MSG has type 'RTM_NEWLINK', return the corresponding <link> object.
+Otherwise return #f."
+ (and (eqv? (message-kind msg) RTM_NEWLINK)
+ (let* ((data (message-data msg))
+ (attrs (link-message-attrs data)))
+ (make-link (get-attr attrs IFLA_IFNAME)
+ (link-message-index data)
+ (link-message-kind data)
+ (map int->device-flags (split-flags (link-message-flags data)))
+ (get-attr attrs IFLA_MTU)
+ (get-attr attrs IFLA_QDISC)
+ (get-attr attrs IFLA_OPERSTATE)
+ (get-attr attrs IFLA_LINKMODE)
+ (get-attr attrs IFLA_GROUP)
+ (get-attr attrs IFLA_TXQLEN)
+ (get-attr attrs IFLA_ADDRESS)
+ (get-attr attrs IFLA_BROADCAST)))))
+
(define (get-links)
(define request-num (random 65535))
(define message
@@ -72,28 +91,7 @@
(let ((sock (connect-route)))
(send-msg message sock)
(let* ((answer (receive-and-decode-msg sock %default-route-decoder))
- (links (filter
- (lambda (msg) (equal? (message-kind msg) RTM_NEWLINK))
- answer))
- (links
- (map
- (lambda (msg)
- (let* ((data (message-data msg))
- (attrs (link-message-attrs data)))
- (make-link
- (get-attr attrs IFLA_IFNAME)
- (link-message-index data)
- (link-message-kind data)
- (map int->device-flags (split-flags (link-message-flags data)))
- (get-attr attrs IFLA_MTU)
- (get-attr attrs IFLA_QDISC)
- (get-attr attrs IFLA_OPERSTATE)
- (get-attr attrs IFLA_LINKMODE)
- (get-attr attrs IFLA_GROUP)
- (get-attr attrs IFLA_TXQLEN)
- (get-attr attrs IFLA_ADDRESS)
- (get-attr attrs IFLA_BROADCAST))))
- links)))
+ (links (filter-map new-link-message->link answer)))
(close-port sock)
links)))
--
2.40.1
This bug report was last modified 2 years and 55 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.