* [PATCH] netem packet scheduler class support
@ 2004-07-12 17:15 Stephen Hemminger
2004-07-12 17:28 ` [PATCH] netem missing qdisc destroy Stephen Hemminger
2004-07-13 22:19 ` [PATCH] netem -- Stephen Hemminger
0 siblings, 2 replies; 4+ messages in thread
From: Stephen Hemminger @ 2004-07-12 17:15 UTC (permalink / raw)
To: David S. Miller; +Cc: netdev
Simple enhancement to netem packet scheduler that makes it classful so
that the underlying pfifo default discipline can be substituted with something
else (tbf, red, ...)
Signed-off-by: Stephen Hemminger <shemminger@osdl.org>
--- linux-2.6/net/sched/sch_netem.c 2004-07-12 08:05:35.439533776 -0700
+++ tcp-2.6/net/sched/sch_netem.c 2004-07-12 09:00:23.251710352 -0700
@@ -829,8 +829,95 @@ rtattr_failure:
return -1;
}
+static int netem_dump_class(struct Qdisc *sch, unsigned long cl,
+ struct sk_buff *skb, struct tcmsg *tcm)
+{
+ struct netem_sched_data *q = (struct netem_sched_data*)sch->data;
+
+ if (cl != 1) /* only one class */
+ return -ENOENT;
+
+ tcm->tcm_handle |= TC_H_MIN(1);
+ tcm->tcm_info = q->qdisc->handle;
+
+ return 0;
+}
+
+static int netem_graft(struct Qdisc *sch, unsigned long arg, struct Qdisc *new,
+ struct Qdisc **old)
+{
+ struct netem_sched_data *q = (struct netem_sched_data *)sch->data;
+
+ if (new == NULL)
+ new = &noop_qdisc;
+
+ sch_tree_lock(sch);
+ *old = xchg(&q->qdisc, new);
+ qdisc_reset(*old);
+ sch->q.qlen = 0;
+ sch_tree_unlock(sch);
+
+ return 0;
+}
+
+static struct Qdisc *netem_leaf(struct Qdisc *sch, unsigned long arg)
+{
+ struct netem_sched_data *q = (struct netem_sched_data *)sch->data;
+ return q->qdisc;
+}
+
+static unsigned long netem_get(struct Qdisc *sch, u32 classid)
+{
+ return 1;
+}
+
+static void netem_put(struct Qdisc *sch, unsigned long arg)
+{
+}
+
+static int netem_change_class(struct Qdisc *sch, u32 classid, u32 parentid,
+ struct rtattr **tca, unsigned long *arg)
+{
+ return -ENOSYS;
+}
+
+static int netem_delete(struct Qdisc *sch, unsigned long arg)
+{
+ return -ENOSYS;
+}
+
+static void netem_walk(struct Qdisc *sch, struct qdisc_walker *walker)
+{
+ if (!walker->stop) {
+ if (walker->count >= walker->skip)
+ if (walker->fn(sch, 1, walker) < 0) {
+ walker->stop = 1;
+ return;
+ }
+ walker->count++;
+ }
+}
+
+static struct tcf_proto **netem_find_tcf(struct Qdisc *sch, unsigned long cl)
+{
+ return NULL;
+}
+
+static struct Qdisc_class_ops netem_class_ops = {
+ .graft = netem_graft,
+ .leaf = netem_leaf,
+ .get = netem_get,
+ .put = netem_put,
+ .change = netem_change_class,
+ .delete = netem_delete,
+ .walk = netem_walk,
+ .tcf_chain = netem_find_tcf,
+ .dump = netem_dump_class,
+};
+
static struct Qdisc_ops netem_qdisc_ops = {
.id = "netem",
+ .cl_ops = &netem_class_ops,
.priv_size = sizeof(struct netem_sched_data),
.enqueue = netem_enqueue,
.dequeue = netem_dequeue,
^ permalink raw reply [flat|nested] 4+ messages in thread
* [PATCH] netem missing qdisc destroy
2004-07-12 17:15 [PATCH] netem packet scheduler class support Stephen Hemminger
@ 2004-07-12 17:28 ` Stephen Hemminger
2004-07-13 22:19 ` [PATCH] netem -- Stephen Hemminger
1 sibling, 0 replies; 4+ messages in thread
From: Stephen Hemminger @ 2004-07-12 17:28 UTC (permalink / raw)
To: David S. Miller; +Cc: netdev
The underlying qdisc was not being properly destroyed, shows up as
assertion failure on device removal.
Signed-off-by: Stephen Hemminger <shemminger@osdl.org>
diff -Nru a/net/sched/sch_netem.c b/net/sched/sch_netem.c
--- a/net/sched/sch_netem.c 2004-07-12 10:27:10 -07:00
+++ b/net/sched/sch_netem.c 2004-07-12 10:27:10 -07:00
@@ -806,6 +806,9 @@
struct netem_sched_data *q = (struct netem_sched_data *)sch->data;
del_timer_sync(&q->timer);
+
+ qdisc_destroy(q->qdisc);
+ q->qdisc = &noop_qdisc;
}
static int netem_dump(struct Qdisc *sch, struct sk_buff *skb)
^ permalink raw reply [flat|nested] 4+ messages in thread
* [PATCH] netem --
2004-07-12 17:15 [PATCH] netem packet scheduler class support Stephen Hemminger
2004-07-12 17:28 ` [PATCH] netem missing qdisc destroy Stephen Hemminger
@ 2004-07-13 22:19 ` Stephen Hemminger
2004-07-21 20:45 ` David S. Miller
1 sibling, 1 reply; 4+ messages in thread
From: Stephen Hemminger @ 2004-07-13 22:19 UTC (permalink / raw)
To: David S. Miller; +Cc: netdev
The netem scheduler needs to limit its delayed packet queue to prevent
a application burst from chewing up too much memory.
Signed-off-by: Stephen Hemminger <shemminger@osdl.org>
diff -Nru a/net/sched/sch_netem.c b/net/sched/sch_netem.c
--- a/net/sched/sch_netem.c 2004-07-13 13:02:58 -07:00
+++ b/net/sched/sch_netem.c 2004-07-13 13:02:58 -07:00
@@ -643,11 +643,17 @@
PSCHED_TADD2(now, delay, cb->time_to_send);
/* Always queue at tail to keep packets in order */
- __skb_queue_tail(&q->delayed, skb);
- sch->q.qlen++;
- sch->stats.bytes += skb->len;
- sch->stats.packets++;
- return 0;
+ if (likely(q->delayed.qlen < q->limit)) {
+ __skb_queue_tail(&q->delayed, skb);
+ sch->q.qlen++;
+ sch->stats.bytes += skb->len;
+ sch->stats.packets++;
+ return 0;
+ }
+
+ sch->stats.drops++;
+ kfree_skb(skb);
+ return NET_XMIT_DROP;
}
/* Requeue packets but don't change time stamp */
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] netem --
2004-07-13 22:19 ` [PATCH] netem -- Stephen Hemminger
@ 2004-07-21 20:45 ` David S. Miller
0 siblings, 0 replies; 4+ messages in thread
From: David S. Miller @ 2004-07-21 20:45 UTC (permalink / raw)
To: Stephen Hemminger; +Cc: netdev
All 3 netem patches applied to 2.6.x, thanks Stephen.
The 2.4.x copy of this thing is falling behind the 2.6.x
code. By diffing the two you can see what is missing,
the randomization jitter feature is the biggest part.
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2004-07-21 20:45 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2004-07-12 17:15 [PATCH] netem packet scheduler class support Stephen Hemminger
2004-07-12 17:28 ` [PATCH] netem missing qdisc destroy Stephen Hemminger
2004-07-13 22:19 ` [PATCH] netem -- Stephen Hemminger
2004-07-21 20:45 ` David S. Miller
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).