Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 25 Jul 2018 17:20:55 +0000 (UTC)
From:      Navdeep Parhar <np@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r336719 - head/usr.sbin/cxgbetool
Message-ID:  <201807251720.w6PHKtj0098797@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: np
Date: Wed Jul 25 17:20:54 2018
New Revision: 336719
URL: https://svnweb.freebsd.org/changeset/base/336719

Log:
  cxgbetool(8): Require and validate only those inputs that are applicable
  to the type of rate limiter being configured.  For example, the class
  WRR scheduler doesn't need any kbps limits (it just needs the weights
  for each class), the channel scheduler doesn't need anything except the
  aggregate kbps to limit the channel to, and so on.
  
  MFC after:	3 days
  Sponsored by:	Chelsio Communications

Modified:
  head/usr.sbin/cxgbetool/cxgbetool.c

Modified: head/usr.sbin/cxgbetool/cxgbetool.c
==============================================================================
--- head/usr.sbin/cxgbetool/cxgbetool.c	Wed Jul 25 17:20:06 2018	(r336718)
+++ head/usr.sbin/cxgbetool/cxgbetool.c	Wed Jul 25 17:20:54 2018	(r336719)
@@ -2862,15 +2862,20 @@ sched_class(int argc, const char *argv[])
 			warnx("sched params \"level\" parameter missing");
 			errs++;
 		}
-		if (op.u.params.mode < 0) {
+		if (op.u.params.mode < 0 &&
+		    op.u.params.level == SCHED_CLASS_LEVEL_CL_RL) {
 			warnx("sched params \"mode\" parameter missing");
 			errs++;
 		}
-		if (op.u.params.rateunit < 0) {
+		if (op.u.params.rateunit < 0 &&
+		    (op.u.params.level == SCHED_CLASS_LEVEL_CL_RL ||
+		    op.u.params.level == SCHED_CLASS_LEVEL_CH_RL)) {
 			warnx("sched params \"rate-unit\" parameter missing");
 			errs++;
 		}
-		if (op.u.params.ratemode < 0) {
+		if (op.u.params.ratemode < 0 &&
+		    (op.u.params.level == SCHED_CLASS_LEVEL_CL_RL ||
+		    op.u.params.level == SCHED_CLASS_LEVEL_CH_RL)) {
 			warnx("sched params \"rate-mode\" parameter missing");
 			errs++;
 		}
@@ -2878,7 +2883,9 @@ sched_class(int argc, const char *argv[])
 			warnx("sched params \"channel\" missing");
 			errs++;
 		}
-		if (op.u.params.cl < 0) {
+		if (op.u.params.cl < 0 &&
+		    (op.u.params.level == SCHED_CLASS_LEVEL_CL_RL ||
+		    op.u.params.level == SCHED_CLASS_LEVEL_CL_WRR)) {
 			warnx("sched params \"class\" missing");
 			errs++;
 		}
@@ -2889,15 +2896,14 @@ sched_class(int argc, const char *argv[])
 			    "rate-limit level");
 			errs++;
 		}
-		if (op.u.params.weight < 0 &&
-		    op.u.params.level == SCHED_CLASS_LEVEL_CL_WRR) {
-			warnx("sched params \"weight\" missing for "
-			    "weighted-round-robin level");
+		if (op.u.params.level == SCHED_CLASS_LEVEL_CL_WRR &&
+		    (op.u.params.weight < 1 || op.u.params.weight > 99)) {
+			warnx("sched params \"weight\" missing or invalid "
+			    "(not 1-99) for weighted-round-robin level");
 			errs++;
 		}
 		if (op.u.params.pktsize < 0 &&
-		    (op.u.params.level == SCHED_CLASS_LEVEL_CL_RL ||
-		    op.u.params.level == SCHED_CLASS_LEVEL_CH_RL)) {
+		    op.u.params.level == SCHED_CLASS_LEVEL_CL_RL) {
 			warnx("sched params \"pkt-size\" missing for "
 			    "rate-limit level");
 			errs++;



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201807251720.w6PHKtj0098797>