Subject: [PATCH net-next 3/6] netem: define NETEM_DIST_MAX

From: Stephen Hemminger <[email-masked]>
Date: Wed, 23 Feb 2011 15:04:19 -0800

Rather than magic constant in code, expose the maximum size of
packet distribution table in API. In iproute2, q_netem defines
MAX_DIST as 16K already.

Signed-off-by: Stephen Hemminger <[email-masked]>

---
 include/linux/pkt_sched.h |    1 +
 net/sched/sch_netem.c     |    2 +-
 2 files changed, 2 insertions(+), 1 deletion(-)

--- a/include/linux/pkt_sched.h	2011-02-23 14:43:08.838297372 -0800
+++ b/include/linux/pkt_sched.h	2011-02-23 14:50:10.329760558 -0800
@@ -495,6 +495,7 @@ struct tc_netem_corrupt {
 };
 
 #define NETEM_DIST_SCALE	8192
+#define NETEM_DIST_MAX		16384
 
 /* DRR */
 
--- a/net/sched/sch_netem.c	2011-02-23 14:50:09.445745344 -0800
+++ b/net/sched/sch_netem.c	2011-02-23 14:50:10.329760558 -0800
@@ -332,7 +332,7 @@ static int get_dist_table(struct Qdisc *
 	int i;
 	size_t s;
 
-	if (n > 65536)
+	if (n > NETEM_DIST_MAX)
 		return -EINVAL;
 
 	s = sizeof(struct disttable) + n * sizeof(s16);