summaryrefslogtreecommitdiff
path: root/include/net
diff options
context:
space:
mode:
authorNogah Frankel <nogahf@mellanox.com>2017-12-04 13:31:11 +0200
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2018-02-25 11:05:48 +0100
commita0514c0ba76a5a941ed3b8efa7a952273c1ca421 (patch)
tree93cad8c05c587fca9fe4e94aedbef0bebe0428f0 /include/net
parent1c03903e973c276f9e75d6f7f3727b51b97c803b (diff)
net_sched: red: Avoid illegal values
[ Upstream commit 8afa10cbe281b10371fee5a87ab266e48d71a7f9 ] 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> Signed-off-by: Sasha Levin <alexander.levin@microsoft.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'include/net')
-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 ba5039418a93..3618cdfec884 100644
--- a/include/net/red.h
+++ b/include/net/red.h
@@ -167,6 +167,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)