services: static-networking: Avoid use of net-tools.
* gnu/services/networking.scm (<static-networking>)[net-tools]: Remove. (static-networking-service-type): Use 'add-network-route/gateway' and 'delete-network-route' instead of NET-TOOLS. (static-networking-service): Adjust accordingly.
This commit is contained in:
parent
9e38e3cf52
commit
e48fcd7b8d
|
@ -62,6 +62,7 @@
|
||||||
bitlbee-service
|
bitlbee-service
|
||||||
bitlbee-service-type
|
bitlbee-service-type
|
||||||
|
|
||||||
|
wicd-service-type
|
||||||
wicd-service
|
wicd-service
|
||||||
network-manager-service
|
network-manager-service
|
||||||
connman-service
|
connman-service
|
||||||
|
@ -116,15 +117,14 @@ fe80::1%lo0 apps.facebook.com\n")
|
||||||
(default #f))
|
(default #f))
|
||||||
(gateway static-networking-gateway)
|
(gateway static-networking-gateway)
|
||||||
(provision static-networking-provision)
|
(provision static-networking-provision)
|
||||||
(name-servers static-networking-name-servers)
|
(name-servers static-networking-name-servers))
|
||||||
(net-tools static-networking-net-tools))
|
|
||||||
|
|
||||||
(define static-networking-service-type
|
(define static-networking-service-type
|
||||||
(shepherd-service-type
|
(shepherd-service-type
|
||||||
'static-networking
|
'static-networking
|
||||||
(match-lambda
|
(match-lambda
|
||||||
(($ <static-networking> interface ip netmask gateway provision
|
(($ <static-networking> interface ip netmask gateway provision
|
||||||
name-servers net-tools)
|
name-servers)
|
||||||
(let ((loopback? (memq 'loopback provision)))
|
(let ((loopback? (memq 'loopback provision)))
|
||||||
|
|
||||||
;; TODO: Eventually replace 'route' with bindings for the appropriate
|
;; TODO: Eventually replace 'route' with bindings for the appropriate
|
||||||
|
@ -146,19 +146,23 @@ fe80::1%lo0 apps.facebook.com\n")
|
||||||
(inet-pton AF_INET #$netmask)))
|
(inet-pton AF_INET #$netmask)))
|
||||||
(maskaddr (and mask
|
(maskaddr (and mask
|
||||||
(make-socket-address AF_INET
|
(make-socket-address AF_INET
|
||||||
mask 0))))
|
mask 0)))
|
||||||
|
(gateway (and #$gateway
|
||||||
|
(inet-pton AF_INET #$gateway)))
|
||||||
|
(gatewayaddr (and gateway
|
||||||
|
(make-socket-address AF_INET
|
||||||
|
gateway 0))))
|
||||||
(configure-network-interface #$interface sockaddr
|
(configure-network-interface #$interface sockaddr
|
||||||
(logior IFF_UP
|
(logior IFF_UP
|
||||||
#$(if loopback?
|
#$(if loopback?
|
||||||
#~IFF_LOOPBACK
|
#~IFF_LOOPBACK
|
||||||
0))
|
0))
|
||||||
#:netmask maskaddr))
|
#:netmask maskaddr)
|
||||||
#$(if gateway
|
(when gateway
|
||||||
#~(zero? (system* (string-append #$net-tools
|
(let ((sock (socket AF_INET SOCK_DGRAM 0)))
|
||||||
"/sbin/route")
|
(add-network-route/gateway sock gatewayaddr)
|
||||||
"add" "-net" "default"
|
(close-port sock))))
|
||||||
"gw" #$gateway))
|
|
||||||
#t)
|
|
||||||
#$(if (pair? name-servers)
|
#$(if (pair? name-servers)
|
||||||
#~(call-with-output-file "/etc/resolv.conf"
|
#~(call-with-output-file "/etc/resolv.conf"
|
||||||
(lambda (port)
|
(lambda (port)
|
||||||
|
@ -168,18 +172,19 @@ fe80::1%lo0 apps.facebook.com\n")
|
||||||
(for-each (lambda (server)
|
(for-each (lambda (server)
|
||||||
(format port "nameserver ~a~%"
|
(format port "nameserver ~a~%"
|
||||||
server))
|
server))
|
||||||
'#$name-servers)))
|
'#$name-servers)
|
||||||
|
#t))
|
||||||
#t)))
|
#t)))
|
||||||
(stop #~(lambda _
|
(stop #~(lambda _
|
||||||
;; Return #f is successfully stopped.
|
;; Return #f is successfully stopped.
|
||||||
(let ((sock (socket AF_INET SOCK_STREAM 0)))
|
(let ((sock (socket AF_INET SOCK_STREAM 0)))
|
||||||
|
(when #$gateway
|
||||||
|
(delete-network-route sock
|
||||||
|
(make-socket-address
|
||||||
|
AF_INET INADDR_ANY 0)))
|
||||||
(set-network-interface-flags sock #$interface 0)
|
(set-network-interface-flags sock #$interface 0)
|
||||||
(close-port sock))
|
(close-port sock)
|
||||||
(not #$(if gateway
|
#f)))
|
||||||
#~(system* (string-append #$net-tools
|
|
||||||
"/sbin/route")
|
|
||||||
"del" "-net" "default")
|
|
||||||
#t))))
|
|
||||||
(respawn? #f)))))))
|
(respawn? #f)))))))
|
||||||
|
|
||||||
(define* (static-networking-service interface ip
|
(define* (static-networking-service interface ip
|
||||||
|
@ -195,8 +200,7 @@ it must be a string specifying the default network gateway."
|
||||||
(static-networking (interface interface) (ip ip)
|
(static-networking (interface interface) (ip ip)
|
||||||
(netmask netmask) (gateway gateway)
|
(netmask netmask) (gateway gateway)
|
||||||
(provision provision)
|
(provision provision)
|
||||||
(name-servers name-servers)
|
(name-servers name-servers))))
|
||||||
(net-tools net-tools))))
|
|
||||||
|
|
||||||
(define dhcp-client-service-type
|
(define dhcp-client-service-type
|
||||||
(shepherd-service-type
|
(shepherd-service-type
|
||||||
|
|
Loading…
Reference in New Issue