netdev
[Top] [All Lists]

Re: [PATCH] (3/3) netem: adjust parent qlen when duplicating

To: Stephen Hemminger <shemminger@xxxxxxxx>
Subject: Re: [PATCH] (3/3) netem: adjust parent qlen when duplicating
From: Patrick McHardy <kaber@xxxxxxxxx>
Date: Wed, 04 May 2005 01:35:29 +0200
Cc: "David S. Miller" <davem@xxxxxxxxxxxxx>, netdev@xxxxxxxxxxx, netem@xxxxxxxx
In-reply-to: <20050503162550.30acf31a@dxpl.pdx.osdl.net>
References: <20050503162550.30acf31a@dxpl.pdx.osdl.net>
Sender: netdev-bounce@xxxxxxxxxxx
User-agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.7.7) Gecko/20050420 Debian/1.7.7-2
Stephen Hemminger wrote:
> Fix qlen underrun when doing duplication with netem. If netem is used as 
> leaf discipline, then the parent needs to be tweaked when packets  are 
> duplicated.

> +                     /* Since one packet can generate two packets in the
> +                      * queue, the parent's qlen accounting gets confused,
> +                      * so fix it.
> +                      */
> +                     qp = qdisc_lookup(sch->dev, TC_H_MAJ(sch->parent));
> +                     if (qp)
> +                             qp->q.qlen++;

This only works in a hierarchy with just one qdisc above netem, there
could be up to seven (check_loop_fn prevents more than that). It's also
not safe because it violates qdisc locking rules, when this code is
executed dev->queue_lock is already taken and qdisc_lookup() grabs
qdisc_tree_lock, but they can only be taken in the other order.

Regards
Patrick

<Prev in Thread] Current Thread [Next in Thread>