diff options
author | Stephen Hemminger <stephen.hemminger@vyatta.com> | 2008-07-23 15:02:38 -0700 |
---|---|---|
committer | Stephen Hemminger <stephen.hemminger@vyatta.com> | 2008-07-23 15:02:38 -0700 |
commit | f7e9c8ff3f02586d290f4618986dcac0b2a102d1 (patch) | |
tree | 3fdf1551cd6feff3a307b5fc53091922f77be26d | |
parent | 699404b2b18ae03da9fcf6fe45eee33471c5624e (diff) | |
download | vyatta-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
-rw-r--r-- | scripts/VyattaQosTrafficShaper.pm | 9 | ||||
-rw-r--r-- | scripts/VyattaQosUtil.pm | 11 |
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; } } |