diff --git a/debian/changelog b/debian/changelog index 1ec68e1d..8910e0c5 100644 --- a/debian/changelog +++ b/debian/changelog @@ -11,9 +11,12 @@ byobu (4.23) unreleased; urgency=low * usr/lib/byobu/logo: - revert whitespace required by statusd * usr/lib/byobu/ip_address, usr/lib/byobu/.shutil: - - add a get_default_interface function + - add a get_network_interface function - something seems to have changed around the linux 3.0 kernel, in the order of /proc/net/dev; now test for 0.0.0.0 mask + * usr/lib/byobu/ip_address, usr/lib/byobu/network, + usr/lib/byobu/.shutil: + - reuse the get_network_interface function across network operations -- Dustin Kirkland Sun, 24 Jul 2011 14:23:38 -0500 diff --git a/usr/lib/byobu/.shutil b/usr/lib/byobu/.shutil index 124d682a..d37be6a0 100755 --- a/usr/lib/byobu/.shutil +++ b/usr/lib/byobu/.shutil @@ -270,12 +270,16 @@ get_now() { fi } -get_default_interface() { - local Iface Destination Gateway Flags RefCnt Use Metric Mask MTU Window IRTT - while read Iface Destination Gateway Flags RefCnt Use Metric Mask MTU Window IRTT; do - [ "$Mask" = "00000000" ] && break - done < /proc/net/route - _RET="$Iface" +get_network_interface() { + if [ -n "$MONITORED_NETWORK" ]; then + _RET="$MONITORED_NETWORK" + else + local Iface Destination Gateway Flags RefCnt Use Metric Mask MTU Window IRTT + while read Iface Destination Gateway Flags RefCnt Use Metric Mask MTU Window IRTT; do + [ "$Mask" = "00000000" ] && break + done < /proc/net/route + _RET="$Iface" + fi } # vi: syntax=sh ts=4 noexpandtab diff --git a/usr/lib/byobu/ip_address b/usr/lib/byobu/ip_address index beeda627..64308cb7 100755 --- a/usr/lib/byobu/ip_address +++ b/usr/lib/byobu/ip_address @@ -33,7 +33,7 @@ __ip_address() { else case "$IPV6" in 1|true|yes) interface=$(awk '$10 != "lo" { iface=$10 ; }; END { print iface; }' /proc/net/ipv6_route);; - *) get_default_interface; interface="$_RET";; + *) get_network_interface; interface="$_RET";; esac fi case "$IPV6" in diff --git a/usr/lib/byobu/network b/usr/lib/byobu/network index 2cd4f349..6caba275 100755 --- a/usr/lib/byobu/network +++ b/usr/lib/byobu/network @@ -19,24 +19,13 @@ # You should have received a copy of the GNU General Public License # along with this program. If not, see . -get_interface() { - _RET= - # Allow interface overrides in $BYOBU_CONFIG_DIR/status - if [ -n "$MONITORED_NETWORK" ]; then - _RET="$MONITORED_NETWORK" - else - # get the last interface listed in /proc/net/route - while read cn other; do _RET=$cn; done < /proc/net/route - fi -} - __network_detail() { - get_interface; local interface="$_RET" + get_network_interface; local interface="$_RET" LC_ALL=C /sbin/ifconfig "$interface" | $SED 's/\s*$//' } __network() { - get_interface; local interface="$_RET" + get_network_interface; local interface="$_RET" local t1=0 t2=0 x1=0 x2=0 # By default, we won't bug the user with the display of network traffic # below NETWORK_THRESHOLD in kbps; override in $BYOBU_CONFIG_DIR/status