From owner-svn-src-all@freebsd.org Tue Jan 26 22:46:59 2016 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id EBA88A6E6B1; Tue, 26 Jan 2016 22:46:59 +0000 (UTC) (envelope-from luigi@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 mx1.freebsd.org (Postfix) with ESMTPS id A1B4A19FB; Tue, 26 Jan 2016 22:46:59 +0000 (UTC) (envelope-from luigi@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u0QMkwgF096058; Tue, 26 Jan 2016 22:46:58 GMT (envelope-from luigi@FreeBSD.org) Received: (from luigi@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u0QMkwTM096057; Tue, 26 Jan 2016 22:46:58 GMT (envelope-from luigi@FreeBSD.org) Message-Id: <201601262246.u0QMkwTM096057@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: luigi set sender to luigi@FreeBSD.org using -f From: Luigi Rizzo Date: Tue, 26 Jan 2016 22:46:58 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r294857 - head/sys/netpfil/ipfw X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 26 Jan 2016 22:47:00 -0000 Author: luigi Date: Tue Jan 26 22:46:58 2016 New Revision: 294857 URL: https://svnweb.freebsd.org/changeset/base/294857 Log: prevent warnings for signed/unsigned comparisons and unused arguments. Add checks for parameters overflowing 32 bit. Modified: head/sys/netpfil/ipfw/dn_sched_rr.c Modified: head/sys/netpfil/ipfw/dn_sched_rr.c ============================================================================== --- head/sys/netpfil/ipfw/dn_sched_rr.c Tue Jan 26 22:45:45 2016 (r294856) +++ head/sys/netpfil/ipfw/dn_sched_rr.c Tue Jan 26 22:46:58 2016 (r294857) @@ -52,8 +52,8 @@ struct rr_queue { struct dn_queue q; /* Standard queue */ int status; /* 1: queue is in the list */ - int credit; /* Number of bytes to transmit */ - int quantum; /* quantum * C */ + uint32_t credit; /* max bytes we can transmit */ + uint32_t quantum; /* quantum * weight */ struct rr_queue *qnext; /* */ }; @@ -61,9 +61,9 @@ struct rr_queue { * and is right after dn_schk */ struct rr_schk { - int min_q; /* Min quantum */ - int max_q; /* Max quantum */ - int q_bytes; /* Bytes per quantum */ + uint32_t min_q; /* Min quantum */ + uint32_t max_q; /* Max quantum */ + uint32_t q_bytes; /* default quantum in bytes */ }; /* per-instance round robin list, right after dn_sch_inst */ @@ -227,6 +227,7 @@ rr_new_sched(struct dn_sch_inst *_si) static int rr_free_sched(struct dn_sch_inst *_si) { + (void)_si; ND("called"); /* Nothing to do? */ return 0; @@ -237,6 +238,7 @@ rr_new_fsk(struct dn_fsk *fs) { struct rr_schk *schk = (struct rr_schk *)(fs->sched + 1); /* par[0] is the weight, par[1] is the quantum step */ + /* make sure the product fits an uint32_t */ ipdn_bound_var(&fs->fs.par[0], 1, 1, 65536, "RR weight"); ipdn_bound_var(&fs->fs.par[1], schk->q_bytes, @@ -248,10 +250,16 @@ static int rr_new_queue(struct dn_queue *_q) { struct rr_queue *q = (struct rr_queue *)_q; + uint64_t quantum; _q->ni.oid.subtype = DN_SCHED_RR; - q->quantum = _q->fs->fs.par[0] * _q->fs->fs.par[1]; + quantum = (uint64_t)_q->fs->fs.par[0] * _q->fs->fs.par[1]; + if (quantum >= (1ULL<< 32)) { + D("quantum too large, truncating to 4G - 1"); + quantum = (1ULL<< 32) - 1; + } + q->quantum = quantum; ND("called, q->quantum %d", q->quantum); q->credit = q->quantum; q->status = 0;