提交 a163148c 编写于 作者: K Kim Nordlund 提交者: David S. Miller

[PKT_SCHED] act_gact: division by zero

Not returning -EINVAL, because someone might want to use the value
zero in some future gact_prob algorithm?
Signed-off-by: NKim Nordlund <kim.nordlund@nokia.com>
Signed-off-by: NDavid S. Miller <davem@davemloft.net>
上级 0b251df1
......@@ -48,14 +48,14 @@ static struct tcf_hashinfo gact_hash_info = {
#ifdef CONFIG_GACT_PROB
static int gact_net_rand(struct tcf_gact *gact)
{
if (net_random() % gact->tcfg_pval)
if (!gact->tcfg_pval || net_random() % gact->tcfg_pval)
return gact->tcf_action;
return gact->tcfg_paction;
}
static int gact_determ(struct tcf_gact *gact)
{
if (gact->tcf_bstats.packets % gact->tcfg_pval)
if (!gact->tcfg_pval || gact->tcf_bstats.packets % gact->tcfg_pval)
return gact->tcf_action;
return gact->tcfg_paction;
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册