Subject: Re: [PATCH][NET_SCHED] sch_api: fix qdisc_tree_decrease_qlen() loop

From: Jarek Poplawski <[email-masked]>
Date: Tue, 15 Apr 2008 20:25:41 +0200

On Tue, Apr 15, 2008 at 07:41:44PM +0200, Jarek Poplawski wrote:
> On Tue, Apr 15, 2008 at 03:09:53PM +0200, Patrick McHardy wrote:
> ...
> > On second thought I agree with you, the behaviour is inconsistent
> > and FFFF: shouldn't be used as major, otherwise the major doesn't
> > uniquely identify a qdisc anymore.
> 
> Like ingress vs. root handle? I think it's more about additional
> checks (and good memory).

...That's why better discourage...

> 
> > diff --git a/net/sched/sch_api.c b/net/sched/sch_api.c
> > index fc8708a..c486e9d 100644
> > --- a/net/sched/sch_api.c
> > +++ b/net/sched/sch_api.c
> > @@ -386,7 +386,7 @@ void qdisc_tree_decrease_qlen(struct Qdisc *sch, unsigned int n)
> >  	if (n == 0)
> >  		return;
> >  	while ((parentid = sch->parent)) {
> > -		if (TC_H_MAJ(parentid) == TC_H_MAJ(TC_H_INGRESS))
> > +		if (parentid == TC_H_INGRESS)
> 
> Maybe like this?:
>  +		if (parentid == TC_H_ROOT || parentid == TC_H_INGRESS)

Still wrong! Rather this:

  	while ((parentid = sch->parent)) {
  		if (parentid == TC_H_ROOT)
  			return;

  		sch = qdisc_lookup(sch->dev, TC_H_MAJ(parentid));
		if (!sch || sch->parentid == TC_H_INGRESS) {
			...

Jarek P.