Message ID | 87d0krd4s6.fsf@fastmail.com |
---|---|
State | Accepted |
Headers | show |
Series | [bug#35652] services: dhcp-client: Ignore non-ARP networkinterfaces. | expand |
Context | Check | Description |
---|---|---|
cbaines/applying patch | fail | Apply failed |
Hi Marius, Good catch! Marius Bakke <mbakke@fastmail.com> skribis: > From 7724f24443392fdfc2c075909d9b64350f6578b2 Mon Sep 17 00:00:00 2001 > From: Marius Bakke <mbakke@fastmail.com> > Date: Thu, 9 May 2019 17:03:03 +0200 > Subject: [PATCH] services: dhcp-client: Ignore interfaces that are not ARP > capable. > > * guix/build/syscalls.scm (IFF_NOARP): New variable. > (arp-network-interface?): New public variable. > * gnu/services/networking.scm (dhcp-client-service-type): Filter interfaces > that do not support the ARP protocol. Could you make it two patches (one for syscalls.scm, and another one for the rest)? Otherwise LGTM, thank you! Ludo’.
Ludovic Courtès <ludo@gnu.org> writes: > Hi Marius, > > Good catch! > > Marius Bakke <mbakke@fastmail.com> skribis: > >> From 7724f24443392fdfc2c075909d9b64350f6578b2 Mon Sep 17 00:00:00 2001 >> From: Marius Bakke <mbakke@fastmail.com> >> Date: Thu, 9 May 2019 17:03:03 +0200 >> Subject: [PATCH] services: dhcp-client: Ignore interfaces that are not ARP >> capable. >> >> * guix/build/syscalls.scm (IFF_NOARP): New variable. >> (arp-network-interface?): New public variable. >> * gnu/services/networking.scm (dhcp-client-service-type): Filter interfaces >> that do not support the ARP protocol. > > Could you make it two patches (one for syscalls.scm, and another one for > the rest)? > > Otherwise LGTM, thank you! Thanks for the amazingly fast review :-) Pushed in a0dc97a5..6c2180f5.
From 7724f24443392fdfc2c075909d9b64350f6578b2 Mon Sep 17 00:00:00 2001 From: Marius Bakke <mbakke@fastmail.com> Date: Thu, 9 May 2019 17:03:03 +0200 Subject: [PATCH] services: dhcp-client: Ignore interfaces that are not ARP capable. * guix/build/syscalls.scm (IFF_NOARP): New variable. (arp-network-interface?): New public variable. * gnu/services/networking.scm (dhcp-client-service-type): Filter interfaces that do not support the ARP protocol. --- gnu/services/networking.scm | 4 +++- guix/build/syscalls.scm | 9 +++++++++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/gnu/services/networking.scm b/gnu/services/networking.scm index 03b2c6e1ec..082a85f63d 100644 --- a/gnu/services/networking.scm +++ b/gnu/services/networking.scm @@ -190,7 +190,9 @@ fe80::1%lo0 apps.facebook.com\n") ;; interfaces are typically down at this point. Thus we perform ;; our own interface discovery here. (define valid? - (negate loopback-network-interface?)) + (lambda (interface) + (and (arp-network-interface? interface) + (not (loopback-network-interface? interface))))) (define ifaces (filter valid? (all-network-interface-names))) diff --git a/guix/build/syscalls.scm b/guix/build/syscalls.scm index 749616ceb1..74428dbf56 100644 --- a/guix/build/syscalls.scm +++ b/guix/build/syscalls.scm @@ -104,6 +104,7 @@ network-interface-netmask network-interface-running? loopback-network-interface? + arp-network-interface? network-interface-address set-network-interface-netmask set-network-interface-up @@ -1160,6 +1161,7 @@ bytes." (define-as-needed IFF_BROADCAST #x2) ;Broadcast address valid. (define-as-needed IFF_LOOPBACK #x8) ;Is a loopback net. (define-as-needed IFF_RUNNING #x40) ;interface RFC2863 OPER_UP +(define-as-needed IFF_NOARP #x80) ;no ARP protocol (define IF_NAMESIZE 16) ;maximum interface name size @@ -1341,6 +1343,13 @@ interface NAME." (close-port sock) (not (zero? (logand flags IFF_RUNNING))))) +(define (arp-network-interface? name) + "Return true if NAME supports the ARP protocol." + (let* ((sock (socket SOCK_STREAM AF_INET 0)) + (flags (network-interface-flags sock name))) + (close-port sock) + (zero? (logand flags IFF_NOARP)))) + (define-as-needed (set-network-interface-flags socket name flags) "Set the flag of network interface NAME to FLAGS." (let ((req (make-bytevector ifreq-struct-size))) -- 2.21.0