pkt_sched: Add ->peek() methods for fifo, prio and SFQ qdiscs.
From: Patrick McHardy <kaber@trash.net> Just as a demonstration how easy adding a peek operation to the work-conserving qdiscs actually is. It doesn't need to keep or change any internal state in many cases thanks to the guarantee that the packet will either be dequeued or, if another packet arrives, the upper qdisc will immediately ->peek again to reevaluate the state. (This is only slightly modified Patrick's patch.) Signed-off-by: Jarek Poplawski <jarkao2@gmail.com> Signed-off-by: David S. Miller <davem@davemloft.net>
This commit is contained in:

committed by
David S. Miller

parent
90d841fd0a
commit
48a8f519e0
@@ -120,6 +120,19 @@ prio_requeue(struct sk_buff *skb, struct Qdisc* sch)
|
||||
return ret;
|
||||
}
|
||||
|
||||
static struct sk_buff *prio_peek(struct Qdisc *sch)
|
||||
{
|
||||
struct prio_sched_data *q = qdisc_priv(sch);
|
||||
int prio;
|
||||
|
||||
for (prio = 0; prio < q->bands; prio++) {
|
||||
struct Qdisc *qdisc = q->queues[prio];
|
||||
struct sk_buff *skb = qdisc->ops->peek(qdisc);
|
||||
if (skb)
|
||||
return skb;
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static struct sk_buff *prio_dequeue(struct Qdisc* sch)
|
||||
{
|
||||
@@ -421,6 +434,7 @@ static struct Qdisc_ops prio_qdisc_ops __read_mostly = {
|
||||
.priv_size = sizeof(struct prio_sched_data),
|
||||
.enqueue = prio_enqueue,
|
||||
.dequeue = prio_dequeue,
|
||||
.peek = prio_peek,
|
||||
.requeue = prio_requeue,
|
||||
.drop = prio_drop,
|
||||
.init = prio_init,
|
||||
|
Reference in New Issue
Block a user