summaryrefslogtreecommitdiff
path: root/include/net/red.h
diff options
context:
space:
mode:
authorNogah Frankel <nogahf@mellanox.com>2017-12-04 13:31:11 +0200
committerDavid S. Miller <davem@davemloft.net>2017-12-05 14:37:13 -0500
commit8afa10cbe281b10371fee5a87ab266e48d71a7f9 (patch)
treef821390027974ff7b78d22df3862e181bea9d2ca /include/net/red.h
parent5c472203421ab4f928aa1ae9e1dbcfdd80324148 (diff)
net_sched: red: Avoid illegal values
Check the qmin & qmax values doesn't overflow for the given Wlog value. Check that qmin <= qmax. Fixes: a783474591f2 ("[PKT_SCHED]: Generic RED layer") Signed-off-by: Nogah Frankel <nogahf@mellanox.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'include/net/red.h')
-rw-r--r--include/net/red.h11
1 files changed, 11 insertions, 0 deletions
diff --git a/include/net/red.h b/include/net/red.h
index 5918f78d36a0..9665582c4687 100644
--- a/include/net/red.h
+++ b/include/net/red.h
@@ -168,6 +168,17 @@ static inline void red_set_vars(struct red_vars *v)
v->qcount = -1;
}
+static inline bool red_check_params(u32 qth_min, u32 qth_max, u8 Wlog)
+{
+ if (fls(qth_min) + Wlog > 32)
+ return false;
+ if (fls(qth_max) + Wlog > 32)
+ return false;
+ if (qth_max < qth_min)
+ return false;
+ return true;
+}
+
static inline void red_set_parms(struct red_parms *p,
u32 qth_min, u32 qth_max, u8 Wlog, u8 Plog,
u8 Scell_log, u8 *stab, u32 max_P)