summaryrefslogtreecommitdiff
path: root/scripts
diff options
context:
space:
mode:
authorStephen Hemminger <stephen.hemminger@vyatta.com>2008-07-11 17:16:55 -0700
committerStephen Hemminger <stephen.hemminger@vyatta.com>2008-07-11 17:16:55 -0700
commit9a25dee29ff200647e6b0f6b6dc58b0aade39a52 (patch)
treed2d5a11bc084a581200ebb31263afca0925cb2e9 /scripts
parent7f78fa942890465cace2e478c7f0795991722074 (diff)
downloadvyatta-cfg-qos-9a25dee29ff200647e6b0f6b6dc58b0aade39a52.tar.gz
vyatta-cfg-qos-9a25dee29ff200647e6b0f6b6dc58b0aade39a52.zip
Retry to find interface speed
Bugfix 3450 If device is offline, can't find speed. So use a sensible default and try a few times.
Diffstat (limited to 'scripts')
-rw-r--r--scripts/VyattaQosUtil.pm15
1 files changed, 13 insertions, 2 deletions
diff --git a/scripts/VyattaQosUtil.pm b/scripts/VyattaQosUtil.pm
index f847116..eca0ca3 100644
--- a/scripts/VyattaQosUtil.pm
+++ b/scripts/VyattaQosUtil.pm
@@ -220,17 +220,28 @@ sub getIfIndex {
# return result in bits per second
sub interfaceRate {
my ($interface) = @_;
+ my $speed;
my $config = new VyattaConfig;
$config->setLevel("interfaces ethernet");
if ($config->exists("$interface")) {
- my $speed = $config->returnValue("$interface speed");
+ $speed = $config->returnValue("$interface speed");
if (defined($speed) && $speed ne "auto") {
return $speed * 1000000;
}
}
- return ethtoolRate($interface);
+ # During boot it may take time for auto-negotiation
+ for (my $retries = 0; $retries < 5; $retries++) {
+ $speed = ethtoolRate($interface);
+ if (defined $speed) {
+ return $speed;
+ }
+ sleep 1;
+ }
+
+ warn "Could not determine speed for $interface, assuming 100mbit\n";
+ return 100 * 1000000;
}
## ethtoolRate("eth0")