Skip to content

Commit

Permalink
[PKT_SCHED] act_gact: division by zero
Browse files Browse the repository at this point in the history
Not returning -EINVAL, because someone might want to use the value
zero in some future gact_prob algorithm?

Signed-off-by: Kim Nordlund <kim.nordlund@nokia.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
  • Loading branch information
Kim Nordlund authored and David S. Miller committed Dec 3, 2006
1 parent 0b251df commit a163148
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions net/sched/act_gact.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down

0 comments on commit a163148

Please sign in to comment.