From 410e94afe308549e097137f4ef3241ebcf1d4ed5 Mon Sep 17 00:00:00 2001
From: Stephen Hemminger <stephen.hemminger@vyatta.com>
Date: Mon, 19 Jul 2010 16:13:28 -0700
Subject: Add check for random-detect on slow speed class

The calculation of random-detect queue parameters is based on recommended
values from RFC. If allowed bandwidth is too small, the queue will be
too small to be useable. In that case just fail.
---
 lib/Vyatta/Qos/ShaperClass.pm | 17 ++++++++++++++---
 1 file changed, 14 insertions(+), 3 deletions(-)

(limited to 'lib')

diff --git a/lib/Vyatta/Qos/ShaperClass.pm b/lib/Vyatta/Qos/ShaperClass.pm
index 439e404..6b474e6 100644
--- a/lib/Vyatta/Qos/ShaperClass.pm
+++ b/lib/Vyatta/Qos/ShaperClass.pm
@@ -117,17 +117,28 @@ sub rateCheck {
         exit 1;
     }
 
-    my $qlimit = $self->{_limit};
-    if (defined($qlimit) && $self->{_qdisc} eq 'random-detect') {
+    if ($self->{_qdisc} eq 'random-detect') {
 	my $avg = 1024;
 	my $qmax = ( $rate * 100 ) / 8000;
-	if ($qlimit * $avg < $qmax) {
+	my $qlimit = $self->{_limit};
+	if (defined($qlimit) && $qlimit * $avg < $qmax) {
 	    print STDERR "Configuration error in: $level\n";
 	    printf STDERR
 "The queue limit (%d) is too small, must be greater than %d when using random-detect\n",
 		$level, $qmax / $avg;
 	    exit 1;
 	}
+
+	# The assumptions about average packet size and allowable latency
+	# result in limit on available bandwidth
+	#
+	# 2 * Avg pkt = (BW * Latency) / 8 bit/byte
+	# 16K bits = BW * .1 sec
+	if ($qmax < $avg) {
+	    print STDERR "Configuration error in: $level\n";
+	    die 
+"Random-detect queue type requires effective bandwidth of 160 Kbit/sec or greater\n";
+	}
     }
 }
 
-- 
cgit v1.2.3