[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <Pine.LNX.4.44.0611301530590.4036-100000@dhcp09282.ntc.nokia.com>
Date: Thu, 30 Nov 2006 15:51:04 +0200 (EET)
From: "Nordlund Kim (Nokia-NET/Helsinki)" <Kim.Nordlund@...ia.com>
To: ext Patrick McHardy <kaber@...sh.net>
cc: "Nordlund Kim (Nokia-NET/Helsinki)" <Kim.Nordlund@...ia.com>,
<davem@...emloft.net>, <netdev@...r.kernel.org>
Subject: Re: [PKT_SCHED] act_gact: division by zero
On Thu, 30 Nov 2006, ext Patrick McHardy wrote:
> I think it should reject an invalid configuration or handle
> the zero case correctly by not dividing.
You are correct. 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@...ia.com>
diff -rub linux-2.6.19-orig/net/sched/act_gact.c linux/net/sched/act_gact.c
--- linux-2.6.19-orig/net/sched/act_gact.c 2006-11-29 23:57:37.000000000 +0200
+++ linux/net/sched/act_gact.c 2006-11-30 15:33:12.000000000 +0200
@@ -48,14 +48,14 @@
#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;
}
-
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Powered by blists - more mailing lists