From owner-svn-src-head@freebsd.org Wed Jul 25 17:20:55 2018 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id A9BA210502B2; Wed, 25 Jul 2018 17:20:55 +0000 (UTC) (envelope-from np@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 600718607D; Wed, 25 Jul 2018 17:20:55 +0000 (UTC) (envelope-from np@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 27B251D1A0; Wed, 25 Jul 2018 17:20:55 +0000 (UTC) (envelope-from np@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id w6PHKtUv098798; Wed, 25 Jul 2018 17:20:55 GMT (envelope-from np@FreeBSD.org) Received: (from np@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w6PHKtj0098797; Wed, 25 Jul 2018 17:20:55 GMT (envelope-from np@FreeBSD.org) Message-Id: <201807251720.w6PHKtj0098797@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: np set sender to np@FreeBSD.org using -f From: Navdeep Parhar Date: Wed, 25 Jul 2018 17:20:55 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r336719 - head/usr.sbin/cxgbetool X-SVN-Group: head X-SVN-Commit-Author: np X-SVN-Commit-Paths: head/usr.sbin/cxgbetool X-SVN-Commit-Revision: 336719 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.27 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 25 Jul 2018 17:20:55 -0000 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++;