netdev
[Top] [All Lists]

Re: [PATCH] Clean up fib_hash datastructures

To: "David S. Miller" <davem@xxxxxxxxxxxxx>
Subject: Re: [PATCH] Clean up fib_hash datastructures
From: jamal <hadi@xxxxxxxxxx>
Date: 20 Sep 2004 09:33:17 -0400
Cc: Herbert Xu <herbert@xxxxxxxxxxxxxxxxxxx>, netdev@xxxxxxxxxxx
In-reply-to: <20040919201735.3d9e1d6d.davem@xxxxxxxxxxxxx>
Organization: jamalopolous
References: <1095640781.1047.168.camel@xxxxxxxxxxxxxxxx> <E1C9Edi-00033O-00@xxxxxxxxxxxxxxxxxxxxxxxx> <20040919201735.3d9e1d6d.davem@xxxxxxxxxxxxx>
Reply-to: hadi@xxxxxxxxxx
Sender: netdev-bounce@xxxxxxxxxxx
On Sun, 2004-09-19 at 23:17, David S. Miller wrote:
> On Mon, 20 Sep 2004 13:14:54 +1000
> Herbert Xu <herbert@xxxxxxxxxxxxxxxxxxx> wrote:
> 
> > jamal <hadi@xxxxxxxxxx> wrote:
> > > 
> > > --- a/net/ipv4/fib_hash.c       2004/09/20 00:35:16     1.1
> > > +++ b/net/ipv4/fib_hash.c       2004/09/20 00:36:16
> > > @@ -915,7 +915,7 @@
> > >             iter->zone = iter->zone->fz_next) {
> > >                int maxslot;
> > > 
> > > -               if (!iter->zone->fz_next)
> > > +               if (!iter->zone->fz_nent)
> > >                        continue;
> > 
> > Good catch.  There seems to be another problem with the seq_file
> > conversion.  Why is this check only in fib_get_first(), but not
> > in fib_get_next()?
> > 
> > Either it's needed in fib_get_next() as well, or it can be removed here.
> 
> It's an optimization, the hash list traversal will find no entries
> even if we don't do this test.
> 
> It does belong in fib_get_next(), so I'll happily add it there.
> Thanks.

Seems like get_first just populates the fib_iter_state with the first
valid entry and fib_get_next gets the next valid one - Sorry never paid
attention when patches for these were going in. 
In which case the check for zero entries is missing from fib_get_next
making it ineeficient (but not buggy).
A more complete patch (untested, uncompiled) attached.

cheers,
jamal

Attachment: fibhash_p_2
Description: Text document

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