linux 2.4 routing algorithm?

2 messages, 2 authors, 2003-09-19 · open the first message on its own page

linux 2.4 routing algorithm?

From: Kristen Carlson <hidden>
Date: 2003-09-17 23:47:53

Hello,
I'm trying to understand the routing algorithm for linux 2.4.  I thought
it would use a longest prefix match due to some documentation I had googled,
but the code in route.c looks like a hash.  I probably just don't understand
how lpm would be coded in practice.  Am I looking in the right place?  Can
someone give me a clue about how this works?

Thanks,
Kristen

-- 
WWXD (What Would Xena Do?) 

Re: linux 2.4 routing algorithm?

From: David S. Miller <hidden>
Date: 2003-09-19 02:57:53

On Wed, 17 Sep 2003 16:47:53 -0700
Kristen Carlson [off-list ref] wrote:
I'm trying to understand the routing algorithm for linux 2.4.  I thought
it would use a longest prefix match due to some documentation I had googled,
but the code in route.c looks like a hash.  I probably just don't understand
how lpm would be coded in practice.  Am I looking in the right place?  Can
someone give me a clue about how this works?
route.c is the routing cache, it caches prefix based lookup results
so that a direct hash based lookup can be used for subsequent lookups
on the same exact key.

The prefix based lookup occurs in fib_hash.c, it uses 32+1 hash tables
to implement the prefix based lookup, one for each bit in the IPV4 address
plus an extra for "default" routes requiring matching of no bits.  The
hash tables are lookup up from most specific to least specific so that
we truly get a longest matching prefix lookup.

Any time the routing tables are changed, the routing cache in route.c
is flushed completely.
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help