[arch-projects] [PATCH 0/2] iproute2 migration
I'm resubmitting my work of migrating to iproute2 from net-tools at Tom's request. It's pretty much the same, but with the feedback from Dan, I've added some extremely simple deprecation logic to yell at the user when he or she is still using the net-tools variables. The new logic uses some fairly simple (and generic) declarations: interface, address, netmask, and gateway. If interface is undefined, we fire off the deprecation warning, as this is the _only_ variable required to establish a connection via iproute2. If address is undefined, we skip reading netmask and gateway, and assume usage of dhcp. If address _is_ defined, we assert the need for gateway and netmask. I've opted to make this warning fairly common, firing it both on bringing up, and bringing down interfaces, as I think this needs to be made very clear, given the severity of the change. Along with this change, we would need to do a little bit of juggling with coreutils and yp-tools in order to make net-tools truly optional: - coreutils is currently built without hostname. enable this, removing it from net-tools. - yp-tools is currently in extra. we would need to bring this into core in order to support setting a domainname, and remove the symlinks to hostname from the net-tools package. As always, comments, criticisms, and tomatoes are welcome. dave
--- network | 5 ----- rc.sysinit | 2 -- 2 files changed, 0 insertions(+), 7 deletions(-) diff --git a/network b/network index 5a261b4..9cd6109 100755 --- a/network +++ b/network @@ -210,11 +210,6 @@ case "$1" in fi ;; stop) - #if ck_daemon network; then - # echo "Network is not running. Try 'network start'" - # exit - #fi - if [[ $NETWORK_PERSIST =~ yes|YES && $RUNLEVEL == [06] ]]; then status "Skipping Network Shutdown" true exit 0 diff --git a/rc.sysinit b/rc.sysinit index fa1ba5f..5a21539 100755 --- a/rc.sysinit +++ b/rc.sysinit @@ -328,8 +328,6 @@ stat_busy "Removing Leftover Files" /bin/mkdir -m1777 /tmp/.{X11,ICE}-unix stat_done -#status "Updating Shared Library Links" /sbin/ldconfig - if [[ $HOSTNAME ]]; then status "Setting Hostname: $HOSTNAME" /bin/hostname "$HOSTNAME" fi -- 1.7.5.2
Applied. Thanks! -t On Sun, May 22, 2011 at 4:43 PM, Dave Reisner <d@falconindy.com> wrote:
--- network | 5 ----- rc.sysinit | 2 -- 2 files changed, 0 insertions(+), 7 deletions(-)
diff --git a/network b/network index 5a261b4..9cd6109 100755 --- a/network +++ b/network @@ -210,11 +210,6 @@ case "$1" in fi ;; stop) - #if ck_daemon network; then - # echo "Network is not running. Try 'network start'" - # exit - #fi - if [[ $NETWORK_PERSIST =~ yes|YES && $RUNLEVEL == [06] ]]; then status "Skipping Network Shutdown" true exit 0 diff --git a/rc.sysinit b/rc.sysinit index fa1ba5f..5a21539 100755 --- a/rc.sysinit +++ b/rc.sysinit @@ -328,8 +328,6 @@ stat_busy "Removing Leftover Files" /bin/mkdir -m1777 /tmp/.{X11,ICE}-unix stat_done
-#status "Updating Shared Library Links" /sbin/ldconfig - if [[ $HOSTNAME ]]; then status "Setting Hostname: $HOSTNAME" /bin/hostname "$HOSTNAME" fi -- 1.7.5.2
Provide large warnings when net-tools functionality is used. Add documentation in rc.conf for the new iproute2 based config. --- PKGBUILD | 7 ++-- network | 118 ++++++++++++++++++++++++++++++++++++++++++++---------------- rc.conf | 40 +++++--------------- rc.sysinit | 2 +- 4 files changed, 102 insertions(+), 65 deletions(-) diff --git a/PKGBUILD b/PKGBUILD index c5f2acd..5c9764c 100644 --- a/PKGBUILD +++ b/PKGBUILD @@ -9,9 +9,10 @@ groups=('base') conflicts=('initscripts') provides=('initscripts=9999') backup=(etc/inittab etc/rc.conf etc/rc.local etc/rc.local.shutdown) -depends=('glibc' 'bash' 'grep' 'coreutils' 'udev>=139-1' - 'net-tools' 'ncurses' 'kbd' 'findutils' 'sysvinit') -optdepends=('bridge-utils: Network bridging support' +depends=('glibc' 'bash' 'grep' 'coreutils' 'udev>=139-1' 'iproute2' + 'ncurses' 'kbd' 'findutils' 'sysvinit') +optdepends=('net-tools: legacy networking support' + 'bridge-utils: Network bridging support' 'dhcpcd: DHCP network configuration' 'wireless_tools: Wireless networking') source=() diff --git a/network b/network index 9cd6109..7350149 100755 --- a/network +++ b/network @@ -7,6 +7,49 @@ for s in wireless bonding bridges dhcpcd; do [[ -f /etc/conf.d/$s ]] && . "/etc/conf.d/$s" done +# helper function to determine if legacy network support is needed +need_legacy() { + if [[ -z $interface ]]; then + return 0 # need legacy + fi + + return 1 # enough present for iproute2 support +} + +deprecated() { + printf "${C_FAIL}Warning:${C_CLEAR} This functionality is deprecated.\n" + printf " Please refer to /etc/rc.conf on how to define a single wired\n" + printf " connection, or use a utility such as netcfg.\n" +} + +network_up() { + /usr/sbin/ip link set dev $interface up || return 1 + + if [[ $address ]]; then + for var in netmask gateway; do + if [[ -z ${!var} ]]; then + printf "${C_FAIL}Error: static address defined without $var!\n" + return 1 + fi + done + /usr/sbin/ip addr add $address/$netmask dev $interface || return 1 + /usr/sbin/ip route add default via $gateway || return 1 + else + /sbin/dhcpcd $DHCPCD_ARGS $interface || return 1 + fi +} + +network_down() { + if [[ -f /var/run/dhcpcd-$interface.pid ]]; then + /sbin/dhcpcd -k $interface || return 1 + else + /usr/sbin/ip route del default || return 1 + /usr/sbin/ip addr flush dev $interface || return 1 + fi + + /usr/sbin/ip link set dev $interface down || return 1 +} + ifup() { local ifcfg=${!1} @@ -179,29 +222,34 @@ bridge_down() { case "$1" in start) + # deprecation check + need_legacy && deprecated if ! ck_daemon network; then echo "Network is already running. Try 'network restart'" exit fi - stat_busy "Starting Network" error=0 - # bring up bridge interfaces - bridge_up - # bring up ethernet interfaces - for ifline in ${INTERFACES[@]}; do - if [[ $ifline = ${ifline#!} ]]; then - ifup $ifline || error=1 - fi - done - # bring up bond interfaces - bond_up - # bring up routes - for rtline in "${ROUTES[@]}"; do - if [ "$rtline" = "${rtline#!}" ]; then - rtup $rtline || error=1 - fi - done + if need_legacy; then + # bring up bridge interfaces + bridge_up + # bring up ethernet interfaces + for ifline in ${INTERFACES[@]}; do + if [[ $ifline = ${ifline#!} ]]; then + ifup $ifline || error=1 + fi + done + # bring up bond interfaces + bond_up + # bring up routes + for rtline in "${ROUTES[@]}"; do + if [ "$rtline" = "${rtline#!}" ]; then + rtup $rtline || error=1 + fi + done + else + network_up + fi if ((error == 0)); then add_daemon network stat_done @@ -210,6 +258,8 @@ case "$1" in fi ;; stop) + # deprecation check + need_legacy && deprecated if [[ $NETWORK_PERSIST =~ yes|YES && $RUNLEVEL == [06] ]]; then status "Skipping Network Shutdown" true exit 0 @@ -218,20 +268,24 @@ case "$1" in stat_busy "Stopping Network" rm_daemon network error=0 - for rtline in "${ROUTES[@]}"; do - if [[ $rtline = ${rtline#!} ]]; then - rtdown $rtline || error=1 - fi - done - # bring down bond interfaces - bond_down - for ifline in ${INTERFACES[@]}; do - if [[ $ifline = ${ifline#!} ]]; then - ifdown $ifline || error=1 - fi - done - # bring down bridge interfaces - bridge_down + if need_legacy; then + for rtline in "${ROUTES[@]}"; do + if [[ $rtline = ${rtline#!} ]]; then + rtdown $rtline || error=1 + fi + done + # bring down bond interfaces + bond_down + for ifline in ${INTERFACES[@]}; do + if [[ $ifline = ${ifline#!} ]]; then + ifdown $ifline || error=1 + fi + done + # bring down bridge interfaces + bridge_down + else + network_down + fi if ((error == 0)); then stat_done else @@ -244,6 +298,8 @@ case "$1" in $0 start ;; ifup|ifdown|iflist|rtup|rtdown|rtlist) + # deprecation check + need_legacy && deprecated $1 $2 ;; *) diff --git a/rc.conf b/rc.conf index 89ea27e..5ebcd35 100644 --- a/rc.conf +++ b/rc.conf @@ -59,44 +59,24 @@ USELVM="no" # HOSTNAME="myhost" -# Use 'ifconfig -a' or 'ls /sys/class/net/' to see all available interfaces. +# Use 'ip addr' or 'ls /sys/class/net/' to see all available interfaces. # -# Interfaces to start at boot-up (in this order) -# Declare each interface then list in INTERFACES -# - prefix an entry in INTERFACES with a ! to disable it -# - no hyphens in your interface names - Bash doesn't like it +# Wired network setup +# - interface: name of device (required) +# - address: IP address (leave blank for DHCP) +# - netmask: subnet mask (ignored for DHCP) +# - gateway: default route (ignored for DHCP) # -# DHCP: Set your interface to "dhcp" (eth0="dhcp") -# Wireless: See network profiles below -# - -#Static IP example -#eth0="eth0 192.168.0.2 netmask 255.255.255.0 broadcast 192.168.0.255" -eth0="dhcp" -INTERFACES=(eth0) -# Routes to start at boot-up (in this order) -# Declare each route then list in ROUTES -# - prefix an entry in ROUTES with a ! to disable it -# -gateway="default gw 192.168.0.1" -ROUTES=(!gateway) +interface= +address= +netmask= +gateway= # Setting this to "yes" will skip network shutdown. # This is required if your root device is on NFS. NETWORK_PERSIST="no" -# Enable these network profiles at boot-up. These are only useful -# if you happen to need multiple network configurations (ie, laptop users) -# - set to 'menu' to present a menu during boot-up (dialog package required) -# - prefix an entry with a ! to disable it -# -# Network profiles are found in /etc/network.d -# -# This now requires the netcfg package -# -#NETWORKS=(main) - # ----------------------------------------------------------------------- # DAEMONS # ----------------------------------------------------------------------- diff --git a/rc.sysinit b/rc.sysinit index 5a21539..9d30da2 100755 --- a/rc.sysinit +++ b/rc.sysinit @@ -115,7 +115,7 @@ run_hook sysinit_udevsettled # bring up the loopback interface [[ -d /sys/class/net/lo ]] && \ - status "Bringing up loopback interface" /sbin/ifconfig lo 127.0.0.1 up + status "Bringing up loopback interface" /usr/sbin/ip link set up dev lo # FakeRAID devices detection if [[ $USEDMRAID =~ yes|YES && -x /sbin/dmraid ]]; then -- 1.7.5.2
On Sun, May 22, 2011 at 4:43 PM, Dave Reisner <d@falconindy.com> wrote:
Provide large warnings when net-tools functionality is used. Add documentation in rc.conf for the new iproute2 based config.
Functionality looks great (though untested). Nitpicks below.
diff --git a/PKGBUILD b/PKGBUILD index c5f2acd..5c9764c 100644 --- a/PKGBUILD +++ b/PKGBUILD @@ -9,9 +9,10 @@ groups=('base') conflicts=('initscripts') provides=('initscripts=9999') backup=(etc/inittab etc/rc.conf etc/rc.local etc/rc.local.shutdown) -depends=('glibc' 'bash' 'grep' 'coreutils' 'udev>=139-1' - 'net-tools' 'ncurses' 'kbd' 'findutils' 'sysvinit') -optdepends=('bridge-utils: Network bridging support' +depends=('glibc' 'bash' 'grep' 'coreutils' 'udev>=139-1' 'iproute2' + 'ncurses' 'kbd' 'findutils' 'sysvinit') +optdepends=('net-tools: legacy networking support' + 'bridge-utils: Network bridging support' 'dhcpcd: DHCP network configuration' 'wireless_tools: Wireless networking')
Not important, but the above hunk could easily have been made +/- 4 rather than +/- 7 (to make it easier to review :) ).
diff --git a/network b/network index 9cd6109..7350149 100755 --- a/network +++ b/network @@ -7,6 +7,49 @@ for s in wireless bonding bridges dhcpcd; do [[ -f /etc/conf.d/$s ]] && . "/etc/conf.d/$s" done
+# helper function to determine if legacy network support is needed +need_legacy() { + if [[ -z $interface ]]; then + return 0 # need legacy + fi + + return 1 # enough present for iproute2 support +}
Isn't the logic here inverted: 1=false and 0=true? Maybe just the name needs to change?
+deprecated() { + printf "${C_FAIL}Warning:${C_CLEAR} This functionality is deprecated.\n" + printf " Please refer to /etc/rc.conf on how to define a single wired\n" + printf " connection, or use a utility such as netcfg.\n" +}
I guess the people who will see this are the ones who have not updated their rc.conf's and hence might not have the new comments either, so maybe it would be better to put a reference to the wiki, and add the explanation there too? Just a suggestion. Cheers, Tom
On Sun, May 22, 2011 at 05:50:18PM +0200, Tom Gundersen wrote:
On Sun, May 22, 2011 at 4:43 PM, Dave Reisner <d@falconindy.com> wrote:
Provide large warnings when net-tools functionality is used. Add documentation in rc.conf for the new iproute2 based config.
Functionality looks great (though untested). Nitpicks below.
diff --git a/PKGBUILD b/PKGBUILD index c5f2acd..5c9764c 100644 --- a/PKGBUILD +++ b/PKGBUILD @@ -9,9 +9,10 @@ groups=('base') conflicts=('initscripts') provides=('initscripts=9999') backup=(etc/inittab etc/rc.conf etc/rc.local etc/rc.local.shutdown) -depends=('glibc' 'bash' 'grep' 'coreutils' 'udev>=139-1' - 'net-tools' 'ncurses' 'kbd' 'findutils' 'sysvinit') -optdepends=('bridge-utils: Network bridging support' +depends=('glibc' 'bash' 'grep' 'coreutils' 'udev>=139-1' 'iproute2' + 'ncurses' 'kbd' 'findutils' 'sysvinit') +optdepends=('net-tools: legacy networking support' + 'bridge-utils: Network bridging support' 'dhcpcd: DHCP network configuration' 'wireless_tools: Wireless networking')
Not important, but the above hunk could easily have been made +/- 4 rather than +/- 7 (to make it easier to review :) ).
Yeah, carelessness on my part. and now optdepends isn't sorted anymore. /me panics
diff --git a/network b/network index 9cd6109..7350149 100755 --- a/network +++ b/network @@ -7,6 +7,49 @@ for s in wireless bonding bridges dhcpcd; do [[ -f /etc/conf.d/$s ]] && . "/etc/conf.d/$s" done
+# helper function to determine if legacy network support is needed +need_legacy() { + if [[ -z $interface ]]; then + return 0 # need legacy + fi + + return 1 # enough present for iproute2 support +}
Isn't the logic here inverted: 1=false and 0=true? Maybe just the name needs to change?
Looks fine to me. bash evaluates a command as "true" when it returns a 0 (no-error) status.
+deprecated() { + printf "${C_FAIL}Warning:${C_CLEAR} This functionality is deprecated.\n" + printf " Please refer to /etc/rc.conf on how to define a single wired\n" + printf " connection, or use a utility such as netcfg.\n" +}
I guess the people who will see this are the ones who have not updated their rc.conf's and hence might not have the new comments either, so maybe it would be better to put a reference to the wiki, and add the explanation there too? Just a suggestion.
Certainly, updating the wiki would be in order. That said, we need to assume that our users are following the upgrade paths we set forth and properly merging their pacnews. d
On Sun, May 22, 2011 at 6:02 PM, Dave Reisner <d@falconindy.com> wrote:
Isn't the logic here inverted: 1=false and 0=true? Maybe just the name needs to change?
Looks fine to me. bash evaluates a command as "true" when it returns a 0 (no-error) status.
I stand corrected. But, but, but that is insane of bash...
Certainly, updating the wiki would be in order. That said, we need to assume that our users are following the upgrade paths we set forth and properly merging their pacnews.
It doesn't matter I guess. If there are no other objections/comments (and if it doesn't break my boot ;-) ). I'll push it out sometime next week (I'll pull from your github). Thanks for your work on this! Cheers, Tom
On Sun, May 22, 2011 at 4:43 PM, Dave Reisner <d@falconindy.com> wrote:
I'm resubmitting my work of migrating to iproute2 from net-tools at Tom's request. It's pretty much the same, but with the feedback from Dan, I've added some extremely simple deprecation logic to yell at the user when he or she is still using the net-tools variables.
Thanks! This is very much appreciated!
- yp-tools is currently in extra. we would need to bring this into core in order to support setting a domainname, and remove the symlinks to hostname from the net-tools package.
Question: What is the use-case of setting the domainname in the absence of yp-tools? Is this common? Would it be acceptable to keep yp-tools in extra? (I wouldn't be opposed moving it to core, I'd just like to understand the reasons). Maybe you should get in touch wit the net-tools/yp-tools/coreutils maintainers (whoever they are) to get their sign-off's on this? Cheers, Tom
On Sun, May 22, 2011 at 05:06:20PM +0200, Tom Gundersen wrote:
On Sun, May 22, 2011 at 4:43 PM, Dave Reisner <d@falconindy.com> wrote:
I'm resubmitting my work of migrating to iproute2 from net-tools at Tom's request. It's pretty much the same, but with the feedback from Dan, I've added some extremely simple deprecation logic to yell at the user when he or she is still using the net-tools variables.
Thanks! This is very much appreciated!
- yp-tools is currently in extra. we would need to bring this into core in order to support setting a domainname, and remove the symlinks to hostname from the net-tools package.
Question: What is the use-case of setting the domainname in the absence of yp-tools? Is this common? Would it be acceptable to keep yp-tools in extra? (I wouldn't be opposed moving it to core, I'd just like to understand the reasons).
Maybe you should get in touch wit the net-tools/yp-tools/coreutils maintainers (whoever they are) to get their sign-off's on this?
Cheers,
Tom
I don't know of a use case for setting domainname without the need for the other facilities yp-tools provides. If you need a DNS search domain, you can set that in /etc/resolv.conf. I've CC'd Allan (coreutils) and Gaetan (yp-tools) on this email. I've linked in Patch 0/2 [1] in case they aren't subscribed to the list. d [1] http://mailman.archlinux.org/pipermail/arch-projects/2011-May/000863.html
[2011-05-22 10:43:17 -0400] Dave Reisner:
- yp-tools is currently in extra. we would need to bring this into core in order to support setting a domainname
I do not think yp-tools is really eligible to go to [core]: strictly- speaking, it is not required to either boot up the computer or connect to the Internet. However, it can perfectly well be made an optdepends of initscripts while staying in [extra]; this is probably the way to go since yp-tools is not of use to everybody. -- Gaetan
On Mon, May 23, 2011 at 12:05 AM, Gaetan Bisson <bisson@archlinux.org> wrote:
[2011-05-22 10:43:17 -0400] Dave Reisner:
- yp-tools is currently in extra. we would need to bring this into core in order to support setting a domainname
I do not think yp-tools is really eligible to go to [core]: strictly- speaking, it is not required to either boot up the computer or connect to the Internet.
However, it can perfectly well be made an optdepends of initscripts while staying in [extra]; this is probably the way to go since yp-tools is not of use to everybody.
I don't think it is even needed to make it an optdepend as initscripts actually doesn't use it. I guess the question boils down to if the "domainname" command needs to be in core, or if it is ok to move it to extra. To the best of my knowledge it should be ok. -t
On May 22, 2011 6:05 PM, "Gaetan Bisson" <bisson@archlinux.org> wrote:
[2011-05-22 10:43:17 -0400] Dave Reisner:
- yp-tools is currently in extra. we would need to bring this into core
to support setting a domainname
I do not think yp-tools is really eligible to go to [core]: strictly- speaking, it is not required to either boot up the computer or connect to the Internet.
However, it can perfectly well be made an optdepends of initscripts while staying in [extra]; this is probably the way to go since yp-tools is not of use to everybody.
-- Gaetan As long as its kosher to have an optdepend lower in the dep tree. I agree
in order that its certainly not the majority use case. Dave
On Sun, May 22, 2011 at 6:42 PM, dave reisner <d@falconindy.com> wrote:
On May 22, 2011 6:05 PM, "Gaetan Bisson" <bisson@archlinux.org> wrote:
[2011-05-22 10:43:17 -0400] Dave Reisner:
- yp-tools is currently in extra. we would need to bring this into core in order to support setting a domainname
I do not think yp-tools is really eligible to go to [core]: strictly- speaking, it is not required to either boot up the computer or connect to the Internet.
However, it can perfectly well be made an optdepends of initscripts while staying in [extra]; this is probably the way to go since yp-tools is not of use to everybody.
-- Gaetan
As long as its kosher to have an optdepend lower in the dep tree. I agree that its certainly not the majority use case.
Dave
A [core] package can have an optdepends on a package in [extra]. No-one objected when I did it for links. Other packages might do it too. Eric
On Sun, May 22, 2011 at 4:43 PM, Dave Reisner <d@falconindy.com> wrote:
I'm resubmitting my work of migrating to iproute2 from net-tools at Tom's request. It's pretty much the same, but with the feedback from Dan, I've added some extremely simple deprecation logic to yell at the user when he or she is still using the net-tools variables.
The new logic uses some fairly simple (and generic) declarations: interface, address, netmask, and gateway. If interface is undefined, we fire off the deprecation warning, as this is the _only_ variable required to establish a connection via iproute2. If address is undefined, we skip reading netmask and gateway, and assume usage of dhcp. If address _is_ defined, we assert the need for gateway and netmask.
I've opted to make this warning fairly common, firing it both on bringing up, and bringing down interfaces, as I think this needs to be made very clear, given the severity of the change.
Along with this change, we would need to do a little bit of juggling with coreutils and yp-tools in order to make net-tools truly optional:
- coreutils is currently built without hostname. enable this, removing it from net-tools. - yp-tools is currently in extra. we would need to bring this into core in order to support setting a domainname, and remove the symlinks to hostname from the net-tools package.
As always, comments, criticisms, and tomatoes are welcome.
I pushed these patches now. I probably will hold off on a release for some time, to give people a chance to test this a bit more as a bug in this code could be critical. Thanks again for your work! Cheers, Tom
On May 24, 2011 6:55 AM, "Tom Gundersen" <teg@jklm.no> wrote:
On Sun, May 22, 2011 at 4:43 PM, Dave Reisner <d@falconindy.com> wrote:
I'm resubmitting my work of migrating to iproute2 from net-tools at
request. It's pretty much the same, but with the feedback from Dan, I've added some extremely simple deprecation logic to yell at the user when he or she is still using the net-tools variables.
The new logic uses some fairly simple (and generic) declarations: interface, address, netmask, and gateway. If interface is undefined, we fire off
Tom's the
deprecation warning, as this is the _only_ variable required to establish a connection via iproute2. If address is undefined, we skip reading netmask and gateway, and assume usage of dhcp. If address _is_ defined, we assert the need for gateway and netmask.
I've opted to make this warning fairly common, firing it both on bringing up, and bringing down interfaces, as I think this needs to be made very clear, given the severity of the change.
Along with this change, we would need to do a little bit of juggling with coreutils and yp-tools in order to make net-tools truly optional:
- coreutils is currently built without hostname. enable this, removing it from net-tools. - yp-tools is currently in extra. we would need to bring this into core in order to support setting a domainname, and remove the symlinks to hostname from the net-tools package.
As always, comments, criticisms, and tomatoes are welcome.
I pushed these patches now. I probably will hold off on a release for some time, to give people a chance to test this a bit more as a bug in this code could be critical.
Thanks again for your work!
Cheers,
Tom Sounds good to me! Thanks for merging!
D
participants (5)
-
Dave Reisner
-
dave reisner
-
Eric Bélanger
-
Gaetan Bisson
-
Tom Gundersen