summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--scripts/VyattaQosTrafficShaper.pm9
-rw-r--r--scripts/VyattaQosUtil.pm11
2 files changed, 11 insertions, 9 deletions
diff --git a/scripts/VyattaQosTrafficShaper.pm b/scripts/VyattaQosTrafficShaper.pm
index e282533..ce4ea3f 100644
--- a/scripts/VyattaQosTrafficShaper.pm
+++ b/scripts/VyattaQosTrafficShaper.pm
@@ -106,7 +106,7 @@
my $rate = _getPercentRate($self->{_rate}, $limit);
if ($rate > $limit) {
- print "Configuration error in: $level\n";
+ print STDERR "Configuration error in: $level\n";
printf STDERR
"The bandwidth reserved for this class (%dKbps) must be less than\n",
$rate / 1000;
@@ -117,7 +117,7 @@
my $ceil = _getPercentRate($self->{_ceiling}, $limit);
if (defined $ceil && $ceil < $rate) {
- print "Configuration error in: $level\n";
+ print STDERR "Configuration error in: $level\n";
printf STDERR
"The bandwidth ceiling for this class (%dKbps) must be greater or equal to\n",
$ceil / 1000;
@@ -281,8 +281,9 @@ sub _getAutoRate {
if ( $rate eq "auto" ) {
$rate = VyattaQosUtil::interfaceRate($dev);
- if ( ! defined $rate ) {
- die "Interface $dev speed cannot be determined; use explicit bandwidth value\n";
+ if (! defined $rate ) {
+ print STDERR "Interface $dev speed cannot be determined (assuming 10mbit)\n";
+ $rate = 10000000;
}
} else {
$rate = VyattaQosUtil::getRate($rate);
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;
}
}