Hello again! Here's an additional patch on top of the previous in the series. It restores backwards compatability for the "hwaddress" option (and drops the new lladdress option that was invented for the new syntax).
(this leaves only the "media" option for full backwards compatability AFAIK, but I'm not going to care about that one since it was driver specific and probably not widely used.) More details in the top of the patch file. See attachment. Please note that this patch only updates the noweb file, the generated files needs to be updated after the patch is applied! -- Regards, Andreas Henriksson
commit d0d8fcd837a0ee817b2265bc9ba1c516d5c07190 Author: Andreas Henriksson <[EMAIL PROTECTED]> Date: Wed Dec 19 20:24:46 2007 +0100 Restore hwaddress compatability (and drop newly invented lladdress). The previous interfaces syntax was "hwaddress class address" since thats what ifconfig used. (class is one of ether, ax25, ARCnet or netrom. address is dependent on the above choice.) With iproute you only need to specify the address thus the new syntax "hwaddress address", so we need to strip off the class if we detect it has been specified to keep backwards compatability. This is implemented here, and we also supply two tests for new and old style hwaddress syntax. diff --git a/debian/remaketests.sh b/debian/remaketests.sh index 8d27291..e54ad99 100755 --- a/debian/remaketests.sh +++ b/debian/remaketests.sh @@ -24,7 +24,7 @@ done cat <<EOF result=true -for test in 1 2 3 4; do +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 || diff --git a/debian/testbuild b/debian/testbuild index 89910c7..b1f7ee4 100755 --- a/debian/testbuild +++ b/debian/testbuild @@ -145,8 +145,51 @@ echo hello run-parts --verbose /etc/network/if-up.d EOF +cat >tests/testcase.5 <<EOF +# RUN: -a +# old style hwaddress including <class> +auto eth0 +iface eth0 inet static + address 1.2.3.4 + netmask 24 + hwaddress ether 00:DE:AD:00:BE:AF +EOF +cat >tests/up.5 <<EOF +====stdout==== +====stderr==== +Configuring interface eth0=eth0 (inet) +run-parts --verbose /etc/network/if-pre-up.d +ip addr add 1.2.3.4/24 dev eth0 +ip link set dev eth0 address 00:DE:AD:00:BE:AF up + +run-parts --verbose /etc/network/if-up.d +EOF + +cat >tests/testcase.6 <<EOF +# RUN: -a +# new style hwaddress without <class> +auto eth0 +iface eth0 inet static + address 1.2.3.4 + netmask 24 + hwaddress 00:DE:AD:00:BE:AF +EOF + +cat >tests/up.6 <<EOF +====stdout==== +====stderr==== +Configuring interface eth0=eth0 (inet) +run-parts --verbose /etc/network/if-pre-up.d +ip addr add 1.2.3.4/24 dev eth0 +ip link set dev eth0 address 00:DE:AD:00:BE:AF up + +run-parts --verbose /etc/network/if-up.d +EOF + + + result=true -for test in 1 2 3 4; do +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 || diff --git a/ifupdown.nw b/ifupdown.nw index 96e69cc..048c10e 100644 --- a/ifupdown.nw +++ b/ifupdown.nw @@ -1846,6 +1846,7 @@ with. <<process iface option line>>= <<convert [[post-up]] and [[pre-down]] aliases to [[up]] and [[down]]>> <<check for duplicate options>> +<<fix old interfaces syntax for backwards compabitibility>> <<add option>> @ @@ -1878,6 +1879,31 @@ if (strcmp(firstword, "pre-down") == 0) { } } } +@ + +<<fix old interfaces syntax for backwards compabitibility>>= +{ + if (strcmp(firstword, "hwaddress") == 0) + { + char *space = strchr(rest, ' '); + + if (space != NULL) { + *space = '\0'; + if (strcasecmp(rest, "ether") == 0 || + strcasecmp(rest, "ax25") == 0 || + strcasecmp(rest, "ARCnet") == 0 || + strcasecmp(rest, "netrom") == 0) + { + /* found deprecated <class> attribute */ + memmove(rest, space+1, strlen(space+1)+1); + } + else + { + *space = ' '; + } + } + } +} @ Given the previous definition of [[add_variable()]] adding an option @@ -4008,13 +4034,13 @@ method static gateway address -- Default gateway (dotted quad) pointopoint address -- Address of other end point (dotted quad). \ Note the spelling of "point-to". - lladdress address -- Link local address. (Replaces hwaddress) + hwaddress address -- Hardware address. mtu size -- MTU size up ip addr add %address%[[/%netmask%]] [[broadcast %broadcast%]] \ [[peer %pointtopoint%]] dev %iface% - ip link set dev %iface% [[mtu %mtu%]] [[address %lladdress%]] up + ip link set dev %iface% [[mtu %mtu%]] [[address %hwaddress%]] up [[ ip route add default via %gateway% [[metric %metric%]] dev %iface% ]] @@ -4052,10 +4078,10 @@ method dhcp leasetime leasetime -- Preferred lease time in seconds (dhcpcd) vendor vendor -- Vendor class identifier (dhcpcd) client client -- Client identifier (dhcpcd, udhcpc) - lladdress address -- Link local address. (Replaces hwaddress) + hwaddress address -- Hardware address. up - [[ip link set dev %iface% address %lladdress%]] + [[ip link set dev %iface% address %hwaddress%]] dhclient3 -pf /var/run/dhclient.%iface%.pid -lf /var/lib/dhcp3/dhclient.%iface%.leases %iface% \ if (execable("/sbin/dhclient3")) dhclient -e -pf /var/run/dhclient.%iface%.pid -lf /var/lib/dhcp/dhclient.%iface%.leases %iface% \ @@ -4168,10 +4194,10 @@ method static address address -- Address (colon delimited) *required* netmask mask -- Netmask (number of bits, eg 64) *required* gateway address -- Default gateway (colon delimited) - lladdress address -- Link local address. (Replaces hwaddress) + hwaddress address -- Hardware address. mtu size -- MTU size up - ip link set dev %iface% [[mtu %mtu%]] [[address %lladdress%]] up + ip link set dev %iface% [[mtu %mtu%]] [[address %hwaddress%]] up ip -6 addr add %address%[[/%netmask%]] dev %iface% [[ ip -6 route add default via %gateway% dev %iface% ]]