[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

ifupdown: Add support for GNU/Hurd (for review)



Source: ifupdown
Version: 0.7~rc2+experimental
Severity: important

(First set of patches, not claimed to be final)

Attached are three patches to enable support of ifupdown for GNU/Hurd.
The first patch adds a build dependency of inetutils-ifconfig, the
second adds (faked) tests for GNU/Hurd, while the third contains the
patches to the noweb source ifupdown.nw. Comments/corrections/fixes
please!

Note: ifupdown is written in noweb, which build-depends on iconc, icont,
iconx and other packages. there fore the importance of a successful
build of icon.

One immediate comment: The test case for IPv6 is not consistent with the
actual code. Probably pfinet is needed, as inetutils-ifconfig does not
seem to support IPv6?

Testing of the actual commands is not so easy when working remotely, the
risk of destroying the network connection is large... Will do some more
testing when the commands needed have settled. 

One issue with inetutils-ifconfig is already found:

inetutils-ifconfig --interface lo --up
inetutils-ifconfig: SIOCSIFFLAGS failed: Computer bought the farm

inetutils-ifconfig --interface lo --down
inetutils-ifconfig: SIOCSIFFLAGS failed: Computer bought the farm

The lo interface is brought up/down properly even if the pfinet?
translator died. Cannot see any translator on the lo interface, only on
eth0.
--- a/debian/rules	2012-04-25 00:37:27.000000000 +0200
+++ b/debian/rules	2012-05-09 15:42:47.000000000 +0200
@@ -77,6 +77,8 @@
 override_dh_gencontrol:
 ifeq ($(DEB_HOST_ARCH_OS),linux)
 	dh_gencontrol -- -V'net:Depends=iproute (>= 20071016-1)' -V'net:Suggests=net-tools'
-else
+else ifeq ($(DEB_HOST_ARCH_OS),kfreebsd)
 	dh_gencontrol -- -V'net:Depends=net-tools' -V'net:Suggests='
-endif
+else ifeq ($(DEB_HOST_ARCH_OS),hurd)
+	dh_gencontrol -- -V'net:Depends=inetutils-tools' -V'net:Suggests='
+endif

--- /dev/null	2012-04-02 18:20:02.000000000 +0200
+++ ifupdown-0.7~rc2+experimental/debian/testbuild-hurd	2012-05-12 19:26:49.000000000 +0200
@@ -0,0 +1,281 @@
+#!/bin/sh -e
+
+rm -rf tests/
+mkdir tests
+cat >tests/testcase.1 <<EOF
+# RUN: -a
+auto eth0
+iface eth0 inet static
+  address 1.2.3.4
+  netmask 255.255.255.0
+  up echo hi
+  post-up echo hello
+EOF
+cat >tests/up.1 <<EOF
+====stdout====
+====stderr====
+run-parts --exit-on-error --verbose /etc/network/if-pre-up.d
+Configuring interface eth0=eth0 (inet)
+run-parts --exit-on-error --verbose /etc/network/if-pre-up.d
+
+inetutils-ifconfig --interface eth0 --address 1.2.3.4 --netmask 255.255.255.0           --up
+
+echo hi
+echo hello
+run-parts --exit-on-error --verbose /etc/network/if-up.d
+run-parts --exit-on-error --verbose /etc/network/if-up.d
+EOF
+
+cat >tests/testcase.2 <<EOF
+# RUN: -a
+auto eth0 eth1 eth2
+auto eth3 eth4 eth5
+allow-hotplug eth6
+iface eth0 inet static
+  address 1.2.3.4
+  netmask 255.255.255.0
+iface eth1 inet static
+  address 1.3.4.5
+  netmask 255.255.255.0
+iface eth2 inet static
+  address 1.4.5.6
+  netmask 255.255.255.0
+iface eth3 inet static
+  address 1.5.6.7
+  netmask 255.255.255.0
+iface eth4 inet static
+  address 1.7.8.9
+  netmask 255.255.255.0
+iface eth5 inet static
+  address 1.8.9.10
+  netmask 255.255.255.0
+iface eth6 inet static
+  address 1.11.12.13
+  netmask 255.255.255.0
+iface eth7 inet static
+  address 1.14.15.16
+  netmask 255.255.255.0
+EOF
+cat >tests/up.2 <<EOF
+====stdout====
+====stderr====
+run-parts --exit-on-error --verbose /etc/network/if-pre-up.d
+Configuring interface eth0=eth0 (inet)
+run-parts --exit-on-error --verbose /etc/network/if-pre-up.d
+
+inetutils-ifconfig --interface eth0 --address 1.2.3.4 --netmask 255.255.255.0           --up
+
+run-parts --exit-on-error --verbose /etc/network/if-up.d
+Configuring interface eth1=eth1 (inet)
+run-parts --exit-on-error --verbose /etc/network/if-pre-up.d
+
+inetutils-ifconfig --interface eth1 --address 1.3.4.5 --netmask 255.255.255.0           --up
+
+run-parts --exit-on-error --verbose /etc/network/if-up.d
+Configuring interface eth2=eth2 (inet)
+run-parts --exit-on-error --verbose /etc/network/if-pre-up.d
+
+inetutils-ifconfig --interface eth2 --address 1.4.5.6 --netmask 255.255.255.0           --up
+
+run-parts --exit-on-error --verbose /etc/network/if-up.d
+Configuring interface eth3=eth3 (inet)
+run-parts --exit-on-error --verbose /etc/network/if-pre-up.d
+
+inetutils-ifconfig --interface eth3 --address 1.5.6.7 --netmask 255.255.255.0           --up
+
+run-parts --exit-on-error --verbose /etc/network/if-up.d
+Configuring interface eth4=eth4 (inet)
+run-parts --exit-on-error --verbose /etc/network/if-pre-up.d
+
+inetutils-ifconfig --interface eth4 --address 1.7.8.9 --netmask 255.255.255.0           --up
+
+run-parts --exit-on-error --verbose /etc/network/if-up.d
+Configuring interface eth5=eth5 (inet)
+run-parts --exit-on-error --verbose /etc/network/if-pre-up.d
+
+inetutils-ifconfig --interface eth5 --address 1.8.9.10 --netmask 255.255.255.0           --up
+
+run-parts --exit-on-error --verbose /etc/network/if-up.d
+run-parts --exit-on-error --verbose /etc/network/if-up.d
+EOF
+
+cat >tests/testcase.3 <<EOF
+# RUN: -a
+auto eth0
+iface eth0 inet static
+  address 1.2.3.4
+  netmask 255.255.255.0
+iface eth0 inet static
+  address 3ffe:ffff:100:f101::1
+  netmask 64
+EOF
+cat >tests/up.3 <<EOF
+====stdout====
+====stderr====
+run-parts --exit-on-error --verbose /etc/network/if-pre-up.d
+Configuring interface eth0=eth0 (inet)
+run-parts --exit-on-error --verbose /etc/network/if-pre-up.d
+
+inetutils-ifconfig --interface eth0 --address 1.2.3.4 --netmask 255.255.255.0           --up
+
+run-parts --exit-on-error --verbose /etc/network/if-up.d
+Configuring interface eth0=eth0 (inet)
+run-parts --exit-on-error --verbose /etc/network/if-pre-up.d
+
+inetutils-ifconfig --interface eth0 --address 3ffe:ffff:100:f101::1 --netmask 64       --up
+
+run-parts --exit-on-error --verbose /etc/network/if-up.d
+run-parts --exit-on-error --verbose /etc/network/if-up.d
+EOF
+
+cat >tests/testcase.4 <<EOF
+# RUN: eth0=work
+mapping eth0
+  script tests/map.eth0.work
+iface work inet static
+  address 1.2.3.4
+  netmask 255.255.255.0
+  up echo hi
+  post-up echo hello
+EOF
+cat >tests/up.4 <<EOF
+====stdout====
+====stderr====
+Configuring interface eth0=work (inet)
+run-parts --exit-on-error --verbose /etc/network/if-pre-up.d
+
+inetutils-ifconfig --interface eth0 --address 1.2.3.4 --netmask 255.255.255.0           --up
+
+echo hi
+echo hello
+run-parts --exit-on-error --verbose /etc/network/if-up.d
+EOF
+
+cat >tests/testcase.5 <<EOF
+# RUN: -a
+auto eth0
+iface eth0 inet static
+  address 1.2.3.4
+  netmask 255.255.255.0
+  hwaddress ether 00:DE:AD:00:BE:AF
+EOF
+cat >tests/up.5 <<EOF
+====stdout====
+====stderr====
+run-parts --exit-on-error --verbose /etc/network/if-pre-up.d
+Configuring interface eth0=eth0 (inet)
+run-parts --exit-on-error --verbose /etc/network/if-pre-up.d
+Warning: Option hwaddress: 00:DE:AD:00:BE:AF not yet supported
+inetutils-ifconfig --interface eth0 --address 1.2.3.4 --netmask 255.255.255.0           --up
+
+run-parts --exit-on-error --verbose /etc/network/if-up.d
+run-parts --exit-on-error --verbose /etc/network/if-up.d
+EOF
+
+cat >tests/testcase.6 <<EOF
+# RUN: -a
+auto eth0
+iface eth0 inet static
+  address 1.2.3.4
+  netmask 255.255.255.0
+  hwaddress 00:DE:AD:00:BE:AF
+EOF
+cat >tests/up.6 <<EOF
+====stdout====
+====stderr====
+run-parts --exit-on-error --verbose /etc/network/if-pre-up.d
+Configuring interface eth0=eth0 (inet)
+run-parts --exit-on-error --verbose /etc/network/if-pre-up.d
+Warning: Option hwaddress: 00:DE:AD:00:BE:AF not yet supported
+inetutils-ifconfig --interface eth0 --address 1.2.3.4 --netmask 255.255.255.0           --up
+
+run-parts --exit-on-error --verbose /etc/network/if-up.d
+run-parts --exit-on-error --verbose /etc/network/if-up.d
+EOF
+
+cat >tests/testcase.7 <<EOF
+# RUN: -a
+auto eth0 eth0.1 tunnel
+iface eth0 inet static
+  address 1.2.3.4
+  netmask 255.255.255.0
+iface eth0 inet6 static
+  address 3ffe:ffff:100:f101::1
+  netmask 64
+  privext 2
+  accept_ra 0
+iface eth0.1 inet6 static
+  address 3ffe:ffff:120:f101::1
+  netmask 64
+iface tunnel inet6 6to4
+  local 1.2.3.4
+EOF
+cat >tests/up.7 <<EOF
+====stdout====
+====stderr====
+Configuring interface eth0=eth0 (inet)
+run-parts --verbose /etc/network/if-pre-up.d
+ip addr add 1.2.3.4/255.255.255.0  	 dev eth0
+ip link set dev eth0   up
+
+run-parts --verbose /etc/network/if-up.d
+Configuring interface eth0=eth0 (inet6)
+run-parts --verbose /etc/network/if-pre-up.d
+modprobe -q net-pf-10 > /dev/null 2>&1 || true # ignore failure.
+sysctl net.ipv6.conf.eth0.use_tempaddr=2 
+sysctl net.ipv6.conf.eth0.accept_ra=0
+sysctl net.ipv6.conf.eth0.autoconf=0
+
+ip link set dev eth0	up
+ip -6 addr add 3ffe:ffff:100:f101::1/64 dev eth0
+
+run-parts --verbose /etc/network/if-up.d
+Configuring interface eth0.1=eth0.1 (inet6)
+run-parts --verbose /etc/network/if-pre-up.d
+modprobe -q net-pf-10 > /dev/null 2>&1 || true # ignore failure.
+
+
+sysctl net.ipv6.conf.eth0/1.autoconf=0
+
+ip link set dev eth0.1   up
+ip -6 addr add 3ffe:ffff:120:f101::1/64 dev eth0.1
+
+run-parts --verbose /etc/network/if-up.d
+Configuring interface tunnel=tunnel (inet6)
+run-parts --verbose /etc/network/if-pre-up.d
+modprobe -q net-pf-10 > /dev/null 2>&1 || true # ignore failure.
+ip tunnel add tunnel mode sit remote any local 1.2.3.4        
+ip link set tunnel up 
+ip addr add 2002:0102:0304::1/16 dev tunnel
+ip route add 2000::/3 via ::192.88.99.1 dev tunnel
+run-parts --verbose /etc/network/if-up.d
+EOF
+
+# Note: Testcase 7 is not run on GNU/Hurd, tunnel is not yet implemented.
+result=true
+for test in 1 2 3 4 5 6; do
+        args="$(cat tests/testcase.$test | sed -n 's/^# RUN: //p')"
+        ./ifup -nv --force -i tests/testcase.$test $args \
+                >tests/up-res-out.$test 2>tests/up-res-err.$test || 
+                true
+        (echo "====stdout===="; cat tests/up-res-out.$test
+         echo "====stderr===="; cat tests/up-res-err.$test) > tests/up-res.$test
+
+        echo "Testcase $test: $args"
+        
+        if diff -ub tests/up.$test tests/up-res.$test; then
+                echo "(okay)"
+        else
+                echo "(failed)"
+                result=false
+        fi
+        echo "=========="
+done
+
+if $result; then
+        echo "(okay overall)"
+        exit 0
+else
+        echo "(failed overall)"
+        exit 1
+fi
--- a/ifupdown.nw	2012-04-25 00:37:27.000000000 +0200
+++ b/ifupdown.nw	2012-05-21 19:38:30.000000000 +0200
@@ -551,7 +551,7 @@
 
 use strict;
 
-<<determine the target architecrure>>
+<<determine the target architecture>>
 
 # declarations
 <<defn2c variables>>
@@ -566,7 +566,7 @@
 @ 
 
 First of all, we determine the target architecture by calling [[dpkg-architecture]] and stripping the trailing newline:
-<<determine the target architecrure>>=
+<<determine the target architecture>>=
 my $DEB_HOST_ARCH_OS = `dpkg-architecture -qDEB_HOST_ARCH_OS`;
 
 $DEB_HOST_ARCH_OS =~ s/\n//;
@@ -965,7 +965,7 @@
 
 use strict;
 
-<<determine the target architecrure>>
+<<determine the target architecture>>
 
 # declarations
 <<defn2man variables>>
@@ -1016,7 +1016,7 @@
 
 Which only leaves extracting the description and options for each
 method. And, of course, this imposes less restrictions of the
-[[.defn]] file than [[defn2c.pl]] did. It's a crazy old world.
+[.defn]] file than [[defn2c.pl]] did. It's a crazy old world.
 
 <<defn2man subroutines>>=
 sub get_method {
@@ -4575,6 +4575,26 @@
 <<common functions implementations>>
 @ 
 
+\subsection{Hurd-specific functions}
+
+<<archhurd.h>>=
+/* no OS-specific functions yet */
+<<common functions declarations>>
+@
+
+<<archhurd.c>>=
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <unistd.h>
+#include <sys/utsname.h>
+#include <sys/stat.h>
+
+#include "archhurd.h"
+
+<<common functions implementations>>
+@ 
+
 \section{Linux Address Families}
 \subsection{IPv4 Address Family}
 
@@ -5272,6 +5292,194 @@
 
 @ 
 
+\section{Hurd Address Families}
+\subsection{IPv4 Address Family}
+
+<<inet.defn>>=
+architecture hurd
+
+<<Hurd inet methods>>
+@ 
+
+<<Hurd inet methods>>=
+<<Hurd inet methods: loopback>>
+
+<<Hurd inet methods: static>>
+
+<<inet methods: manual>>
+
+<<Hurd inet methods: dhcp>>
+
+<<inet methods: bootp>>
+
+<<inet methods: ppp>>
+
+<<inet methods: wvdial>>
+
+<<inet methods: ipv4ll>>
+@ 
+
+<<Hurd inet methods: loopback>>=
+method loopback
+  description
+    This method may be used to define the IPv4 loopback interface.
+
+  up
+    inetutils-ifconfig --interface %iface% 127.0.0.1 --up
+
+  down
+    inetutils-ifconfig --interface %iface% --down
+@ 
+
+<<Hurd inet methods: static>>=
+method static
+  description
+    This method may be used to define Ethernet interfaces with statically
+    allocated IPv4 addresses.
+      
+  options
+    address address             -- Address (dotted quad/netmask) *required*
+    netmask mask                -- Netmask (dotted quad or CIDR)
+    broadcast broadcast_address -- Broadcast address (dotted quad)
+    metric metric               -- Routing metric for default gateway (integer)
+    gateway address             -- Default gateway (dotted quad)
+    pointopoint address         -- Address of other end point (dotted quad). \
+                                   Note the spelling of "point-to".
+    hwaddress address           -- Link local address (Not yet supported)
+    mtu size                    -- MTU size
+
+  conversion
+    hwaddress cleanup_hwaddress
+
+  up
+    [[Warning: Option hwaddress: %hwaddress% not yet supported]]
+    inetutils-ifconfig --interface %iface% --address %address% [[--netmask %netmask%]] \
+    [[--broadcast %broadcast%]] [[--mtu %mtu%]] --up
+    [[fsysopts /servers/socket/2 $(showtrans /servers/socket/2) --gateway %gateway% ]]
+
+  down
+    inetutils-ifconfig --interface %iface% --down
+@
+
+<<Hurd inet methods: dhcp>>=
+method dhcp
+  description
+    This method may be used to obtain an address via DHCP with any of
+    the tools: dhclient, udhcpc, dhcpcd.
+    (They have been listed in their order of precedence.)
+    If you have a complicated DHCP setup you should
+    note that some of these clients use their own configuration files
+    and do not obtain their configuration information via *ifup*.
+
+  options
+    hostname hostname       -- Hostname to be requested (dhcpcd, udhcpc)
+    leasetime leasetime     -- Preferred lease time in seconds (dhcpcd)
+    vendor vendor           -- Vendor class identifier (dhcpcd)
+    client client           -- Client identifier (dhcpcd, udhcpc)
+    hwaddress address       -- Hardware Address (Not yet supported)
+
+  conversion
+    hwaddress cleanup_hwaddress  (Not yet supported)
+
+  up
+    [[Warning: Option hwaddress: %hwaddress% not yet supported]]
+    dhclient -1 -v -pf /run/dhclient.%iface%.pid -lf /var/lib/dhcp/dhclient.%iface%.leases %iface% \
+        if (execable("/sbin/dhclient"))
+    udhcpc -n -p /run/udhcpc.%iface%.pid -i %iface% [[-H %hostname%]] \
+           [[-c %client%]] \
+        elsif (execable("/sbin/udhcpc"))
+    dhcpcd [[-h %hostname%]] [[-i %vendor%]] [[-I %client%]] \
+           [[-l %leasetime%]] %iface% \
+        elsif (execable("/sbin/dhcpcd"))
+
+  down
+    dhclient -v -r -pf /run/dhclient.%iface%.pid -lf /var/lib/dhcp/dhclient.%iface%.leases %iface% \
+        if (execable("/sbin/dhclient"))
+    kill -USR2 $(cat /run/udhcpc.%iface%.pid); kill -TERM $(cat /run/udhcpc.%iface%.pid) \
+        elsif (execable("/sbin/udhcpc"))
+    dhcpcd -k %iface% \
+        elsif (execable("/sbin/dhcpcd"))
+
+    ifconfig %iface% down
+@ 
+
+\subsection{IPv6 Address Family}
+
+<<inet6.defn>>=
+architecture Hurd
+
+method loopback
+  description
+    This method may be used to define the IPv6 loopback interface.
+  up
+    [[FIXME: Add proper commands here for ipv6]]
+    settrans -afg /servers/socket/26 /hurd/pfinet --interface %iface% --ipv6 ::1
+    inetutils-ifconfig --interface %iface% inet6 ::1
+  down
+    [[FIXME: Add proper commands here for ipv6]]
+    inetutils-ifconfig --interface %iface% --down
+
+method static
+  description
+    This method may be used to define interfaces with statically assigned
+    IPv6 addresses.
+
+  options
+    address address        -- Address (colon delimited) *required*
+    netmask mask           -- Netmask (number of bits, eg 64) *required*
+    gateway address        -- Default gateway (colon delimited)
+    media type             -- Medium type, driver dependent
+    hwaddress address      -- Hardware address  (Not yet supported)
+    mtu size               -- MTU size
+
+  conversion
+    hwaddress cleanup_hwaddress
+
+  up
+    [[FIXME: Add proper commands here for ipv6]]
+    [[Warning: Option media: %media% not yet supported]]
+    [[Warning: Option hwaddress: %hwaddress% not yet supported]]
+    settrans -afg /servers/socket/26 /hurd/pfinet --interface %iface% --address6 %address% --mtu %mtu% --netmask %netmask --gateway6 %gateway%
+
+  down
+    [[FIXME: Add proper commands here for ipv6]]
+    inetutils-ifconfig --interface %iface% --down
+
+method manual
+  description
+    This method may be used to define interfaces for which no configuration
+    is done by default.  Such interfaces can be configured manually by
+    means of *up* and *down* commands or /etc/network/if-*.d scripts.
+
+  up
+
+  down
+
+method dhcp
+  description
+    This method may be used to obtain network interface configuration via
+    stateful DHCPv6 with dhclient.  In stateful DHCPv6, the DHCP server is
+    responsible for assigning addresses to clients.
+
+  options
+    hwaddress address      -- Hardware address (Not yet supported)
+
+  conversion
+    hwaddress cleanup_hwaddress
+
+  up
+    [[Warning: Option hwaddress: %hwaddress% not yet supported]]
+    inetutils-ifconfig --interface %iface% --up
+    dhclient -6 -1 -pf /run/dhclient6.%iface%.pid -lf /var/lib/dhcp/dhclient6.%iface%.leases %iface% \
+        if (execable("/sbin/dhclient"))
+
+  down
+    dhclient -6 -r -pf /run/dhclient6.%iface%.pid -lf /var/lib/dhcp/dhclient6.%iface%.leases %iface% \
+        if (execable("/sbin/dhclient"))
+    inetutils-ifconfig --interface %iface% --down
+
+@ 
+
 \section{Internal address metafamily}
 
 <<address family declarations>>=

Reply to: