Print error when they occur and return boolean in link-set
ip/link.scm
| 24 | 24 | #:use-module (netlink data) | |
| 25 | 25 | #:use-module (netlink deserialize) | |
| 26 | 26 | #:use-module (netlink message) | |
| 27 | + | #:use-module (netlink standard) | |
| 28 | + | #:use-module (srfi srfi-1) | |
| 27 | 29 | #:use-module (srfi srfi-9) | |
| 28 | 30 | #:export (link-set | |
| 29 | 31 | link-show)) | |
… | |||
| 161 | 163 | (link-id link) | |
| 162 | 164 | (loop links)))))) | |
| 163 | 165 | ||
| 166 | + | (define (answer-ok? answer) | |
| 167 | + | (cond | |
| 168 | + | ((equal? (message-kind answer) NLMSG_DONE) | |
| 169 | + | #t) | |
| 170 | + | ((equal? (message-kind answer) NLMSG_ERROR) | |
| 171 | + | (let ((data (message-data answer))) | |
| 172 | + | (if (nl-data-data data) | |
| 173 | + | (let ((err (error-message-err data))) | |
| 174 | + | (if (equal? err 0) | |
| 175 | + | #t | |
| 176 | + | (begin | |
| 177 | + | (format #t "RTNETLINK answers: ~a~%" (strerror (- err))) | |
| 178 | + | #f))) | |
| 179 | + | #f))))) | |
| 180 | + | ||
| 164 | 181 | (define* (link-set device #:key (up #f) (down #f) (type #f) | |
| 165 | 182 | (arp-on #f) (arp-off #f) | |
| 166 | 183 | (dynamic-on #f) (dynamic-off #f) | |
… | |||
| 247 | 264 | (when netnsfd | |
| 248 | 265 | (close netnsfd)) | |
| 249 | 266 | (close-socket sock) | |
| 250 | - | answer))) | |
| 267 | + | (answer-ok? (last answer))))) | |