summaryrefslogtreecommitdiffstats
path: root/sys/netpfil
diff options
context:
space:
mode:
authorluigi <luigi@FreeBSD.org>2016-01-26 22:46:58 +0000
committerluigi <luigi@FreeBSD.org>2016-01-26 22:46:58 +0000
commit17af12dfee178c781ceb88ace4ccddb8595478bb (patch)
tree72fae5e768e95ec65f22c08ac908196c5208f9a1 /sys/netpfil
parent3043ee5984d99c40baf7dd38bf39ffdf2495bf47 (diff)
downloadFreeBSD-src-17af12dfee178c781ceb88ace4ccddb8595478bb.zip
FreeBSD-src-17af12dfee178c781ceb88ace4ccddb8595478bb.tar.gz
prevent warnings for signed/unsigned comparisons and unused arguments.
Add checks for parameters overflowing 32 bit.
Diffstat (limited to 'sys/netpfil')
-rw-r--r--sys/netpfil/ipfw/dn_sched_rr.c20
1 files changed, 14 insertions, 6 deletions
diff --git a/sys/netpfil/ipfw/dn_sched_rr.c b/sys/netpfil/ipfw/dn_sched_rr.c
index dd608d7..63e525a 100644
--- a/sys/netpfil/ipfw/dn_sched_rr.c
+++ b/sys/netpfil/ipfw/dn_sched_rr.c
@@ -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;
OpenPOWER on IntegriCloud