Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 41949
b: refs/heads/master
c: 43effa1
h: refs/heads/master
i:
  41947: 2923516
v: v3
  • Loading branch information
Patrick McHardy authored and David S. Miller committed Dec 3, 2006
1 parent 138fd1d commit 692c9a0
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 7 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 9f9afec48221fe4a19f84a9341f5b304bf7d7783
refs/heads/master: 43effa1e57fc4635e0301b27d78f9d83afe78974
2 changes: 2 additions & 0 deletions trunk/include/net/sch_generic.h
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ struct Qdisc_class_ops
int (*graft)(struct Qdisc *, unsigned long cl,
struct Qdisc *, struct Qdisc **);
struct Qdisc * (*leaf)(struct Qdisc *, unsigned long cl);
void (*qlen_notify)(struct Qdisc *, unsigned long);

/* Class manipulation routines */
unsigned long (*get)(struct Qdisc *, u32 classid);
Expand Down Expand Up @@ -172,6 +173,7 @@ extern void dev_activate(struct net_device *dev);
extern void dev_deactivate(struct net_device *dev);
extern void qdisc_reset(struct Qdisc *qdisc);
extern void qdisc_destroy(struct Qdisc *qdisc);
extern void qdisc_tree_decrease_qlen(struct Qdisc *qdisc, unsigned int n);
extern struct Qdisc *qdisc_alloc(struct net_device *dev, struct Qdisc_ops *ops);
extern struct Qdisc *qdisc_create_dflt(struct net_device *dev,
struct Qdisc_ops *ops, u32 parentid);
Expand Down
38 changes: 32 additions & 6 deletions trunk/net/sched/sch_api.c
Original file line number Diff line number Diff line change
Expand Up @@ -191,21 +191,27 @@ int unregister_qdisc(struct Qdisc_ops *qops)
(root qdisc, all its children, children of children etc.)
*/

struct Qdisc *qdisc_lookup(struct net_device *dev, u32 handle)
static struct Qdisc *__qdisc_lookup(struct net_device *dev, u32 handle)
{
struct Qdisc *q;

read_lock(&qdisc_tree_lock);
list_for_each_entry(q, &dev->qdisc_list, list) {
if (q->handle == handle) {
read_unlock(&qdisc_tree_lock);
if (q->handle == handle)
return q;
}
}
read_unlock(&qdisc_tree_lock);
return NULL;
}

struct Qdisc *qdisc_lookup(struct net_device *dev, u32 handle)
{
struct Qdisc *q;

read_lock(&qdisc_tree_lock);
q = __qdisc_lookup(dev, handle);
read_unlock(&qdisc_tree_lock);
return q;
}

static struct Qdisc *qdisc_leaf(struct Qdisc *p, u32 classid)
{
unsigned long cl;
Expand Down Expand Up @@ -348,6 +354,26 @@ dev_graft_qdisc(struct net_device *dev, struct Qdisc *qdisc)
return oqdisc;
}

void qdisc_tree_decrease_qlen(struct Qdisc *sch, unsigned int n)
{
struct Qdisc_class_ops *cops;
unsigned long cl;
u32 parentid;

if (n == 0)
return;
while ((parentid = sch->parent)) {
sch = __qdisc_lookup(sch->dev, TC_H_MAJ(parentid));
cops = sch->ops->cl_ops;
if (cops->qlen_notify) {
cl = cops->get(sch, parentid);
cops->qlen_notify(sch, cl);
cops->put(sch, cl);
}
sch->q.qlen -= n;
}
}
EXPORT_SYMBOL(qdisc_tree_decrease_qlen);

/* Graft qdisc "new" to class "classid" of qdisc "parent" or
to device "dev".
Expand Down

0 comments on commit 692c9a0

Please sign in to comment.