summaryrefslogtreecommitdiff
path: root/scripts/VyattaQosUtil.pm
diff options
context:
space:
mode:
authorStephen Hemminger <stephen.hemminger@vyatta.com>2008-07-23 15:02:38 -0700
committerStephen Hemminger <stephen.hemminger@vyatta.com>2008-07-23 15:02:38 -0700
commitf7e9c8ff3f02586d290f4618986dcac0b2a102d1 (patch)
tree3fdf1551cd6feff3a307b5fc53091922f77be26d /scripts/VyattaQosUtil.pm
parent699404b2b18ae03da9fcf6fe45eee33471c5624e (diff)
downloadvyatta-cfg-qos-f7e9c8ff3f02586d290f4618986dcac0b2a102d1.tar.gz
vyatta-cfg-qos-f7e9c8ff3f02586d290f4618986dcac0b2a102d1.zip
Handle auto bandwidth value better
Need to handle the case of devices that don't know their current speed. In this case, ethtool will print "Unknown!" which the old code wasn't handling right. Move the default speed stuff down into traffic shaper code as well, so any future policies using auto can make other choices as to what to do in this case. Bugfix: 3450
Diffstat (limited to 'scripts/VyattaQosUtil.pm')
-rw-r--r--scripts/VyattaQosUtil.pm11
1 files changed, 6 insertions, 5 deletions
diff --git a/scripts/VyattaQosUtil.pm b/scripts/VyattaQosUtil.pm
index eca0ca3..668f5c1 100644
--- a/scripts/VyattaQosUtil.pm
+++ b/scripts/VyattaQosUtil.pm
@@ -235,13 +235,12 @@ sub interfaceRate {
for (my $retries = 0; $retries < 5; $retries++) {
$speed = ethtoolRate($interface);
if (defined $speed) {
- return $speed;
+ last;
}
sleep 1;
}
- warn "Could not determine speed for $interface, assuming 100mbit\n";
- return 100 * 1000000;
+ return $speed;
}
## ethtoolRate("eth0")
@@ -265,8 +264,10 @@ sub ethtoolRate {
while (<$ethtool>) {
my @line = split;
if ($line[0] =~ /^Speed:/) {
- $rate = $line[1];
- $rate =~ s#Mb/s#000000#;
+ if ($line[1] =~ /[0-9]+Mb\/s/ ) {
+ $rate = $line[1];
+ $rate =~ s#Mb/s#000000#;
+ }
last;
}
}