Skip to contentSkip to conversation

Move fib_alias out of fib_hash.c

DISCUSSION David S. Miller 5 participants 11 messages Sep 29, 2004 – Sep 30, 2004

Subsystems (2)
lore
Share & tools
lore

David S. Miller

author maintainer
#0 lore raw

Ok, this begins the movement of fib_alias object handling out of fib_hash.c The idea is to make fib_hash.c purely a longest-matching-prefix lookup implementation.

Look at fn_hash_lookup() after these changes, and you'll get an idea of how I want the whole fib_hash.c file to look in the end.

I'll work on insert/delete tomorrow.

#1 lore raw
Quoted 8 lines · David S. Miller

Ok, this begins the movement of fib_alias object handling out of fib_hash.c The idea is to make fib_hash.c purely a longest-matching-prefix lookup implementation.

Look at fn_hash_lookup() after these changes, and you'll get an idea of how I want the whole fib_hash.c file to look in the end.

Exactly,
we can interface new lookups cleanly. For a trie something like:

static int
fn_trie_lookup(struct fib_table *tb, const struct flowi *flp, struct fib_result *res)

{
	struct trie *t = (struct trie *) tb->tb_data;
	struct list_head *fah=NULL;
	int err=1, plen, r;

	r = trie_pfx_get(t, flp->fl4_dst, &fah, &plen);

	if (r && fah) 
		err = fib_semantic_match(fah,
					 flp, res,
					 plen);
	return err;
}

Cheers.

						--ro
author maintainer
#2 lore raw
Quoted 1 line · On Wed, 29 Sep 2004 17:20:45 +0200 Robert Olsson <[email protected]>…

we can interface new lookups cleanly. For a trie something like:

You are already making a critical logic error.

You cannot find the longest matching prefix and just use that.

Rather, you must iterate through all matching prefixes in the table from longest to shortest, trying fib_semantic_match() on each one until it says OK.

If you don't do that, then you're not providing the same behavior of the current code. If next hops go down, you have to try the next longest matching prefix and so on and so forth. It can also be the case that the longest matching prefix entry has no matching TOS key, whereas a shorter prefix does.

This makes using a new algorithm very non-trivial.

Probably what you should do is keep an array on the function stack, recording shorter prefix entries you see on your walk down to the longest matching prefix. Then you process the array one entry at a time back to the root, trying fib_semantic_match() on each one.

#3 lore raw
Quoted 9 lines · David S. Miller
Quoted 1 line · On Wed, 29 Sep 2004 17:20:45 +0200 Robert Olsson <[email protected]>…

we can interface new lookups cleanly. For a trie something like:

You are already making a critical logic error.

You cannot find the longest matching prefix and just use that.

Quoted 7 lines

Rather, you must iterate through all matching prefixes in the table from longest to shortest, trying fib_semantic_match() on each one until it says OK.

If you don't do that, then you're not providing the same behavior of the current code. If next hops go down, you have to try the next longest matching prefix and so on and so forth.

I'm not criticizing the current design, but it is very typical of routers to put the burden of fixing up the FIB in the event of a next-hop state change on the routing daemon, and not the dataplane. Which is one reason why having a FIB datastructure that can be updated very efficiently is important.

Quoted 3 lines

It can also
be the case that the longest matching prefix entry has no matching TOS key, whereas a shorter prefix does.

No routing protocols are distributing TOS-specific routes, and there is no prospect of that feature ever coming back. Why pay the cost of matching TOS on every packet forwarded?

Regards,

// Steve

author maintainer
#4 lore raw
Quoted 7 lines · On Wed, 29 Sep 2004 17:20:43 -0400 Steven Blake <[email protected]> wrote:
Quoted 3 lines

It can also
be the case that the longest matching prefix entry has no matching TOS key, whereas a shorter prefix does.

No routing protocols are distributing TOS-specific routes, and there is no prospect of that feature ever coming back. Why pay the cost of matching TOS on every packet forwarded?

Because once we add functionality to the kernel we can't simply rip it out. People do use TOS routing, via static routes or similar.

#5 lore raw
Quoted 7 lines · David S. Miller
Quoted 4 lines · On Wed, 29 Sep 2004 17:20:43 -0400 Steven Blake <[email protected]> wrote:
Quoted 3 lines

It can also
be the case that the longest matching prefix entry has no matching TOS key, whereas a shorter prefix does.

Quoted 7 lines
Quoted 3 lines

No routing protocols are distributing TOS-specific routes, and there is no prospect of that feature ever coming back. Why pay the cost of matching TOS on every packet forwarded?

Because once we add functionality to the kernel we can't simply rip it out. People do use TOS routing, via static routes or similar.

I'm not so sure anybody uses it really. How about adding a printk for it and seeing if anybody complains?

-Andi

#6 lore raw
Quoted 8 lines · Andi Kleen
Quoted 3 lines · David S. Miller

Because once we add functionality to the kernel we can't simply rip it out. People do use TOS routing, via static routes or similar.

I'm not so sure anybody uses it really. How about adding a printk for it and seeing if anybody complains?

I don't think you should remove existing features in the middle of a stable release cycle. If you want to have a compile option, that defaults to off, allows some new algorithm, then that sounds more reasonable...

And I don't think the majority of people would see the printk untill way too late.

Ben

Signature · 2 lines
Ben Greear <[email protected]>
Candela Technologies Inc  http://www.candelatech.com
#7 lore raw
Quoted 8 lines · Ben Greear
Quoted 7 lines · Andi Kleen
Quoted 3 lines · David S. Miller

Because once we add functionality to the kernel we can't simply rip it out. People do use TOS routing, via static routes or similar.

Quoted 5 lines
Quoted 2 lines

I'm not so sure anybody uses it really. How about adding a printk for it and seeing if anybody complains?

I don't think you should remove existing features in the middle of a stable release cycle. If you want to have a compile option, that defaults to off,

There is no stable release cycle anymore. Linus has abolished that.

Maybe we will get it back at some point if the current way doesn't work out, but currently it's unlimited hacking time.

Quoted 2 lines

And I don't think the majority of people would see the printk untill way too late.

That was always the case, nothing new.

-Andi

#8 lore raw
Quoted 4 lines · Andi Kleen

There is no stable release cycle anymore. Linus has abolished that.

Maybe we will get it back at some point if the current way doesn't work out, but currently it's unlimited hacking time.

Sounds fun for the programmers and a pain in the ass for everyone else. But, maybe I can shove some of my patches into the tree with less friction!

Ben

Signature · 2 lines
Ben Greear <[email protected]>
Candela Technologies Inc  http://www.candelatech.com
#9 lore raw
In reply to Steven Blake
Quoted 3 lines · Steven Blake

No routing protocols are distributing TOS-specific routes, and there is no prospect of that feature ever coming back. Why pay the cost of matching TOS on every packet forwarded?

Well you may be right but with a pluggable lookup algo we could choose between TOS-capable/complex and more lightweight and speedy things.

Cheers.

						--ro
#10 lore raw
In reply to David S. Miller
Quoted 5 lines · David S. Miller

You cannot find the longest matching prefix and just use that.

Rather, you must iterate through all matching prefixes in the table from longest to shortest, trying fib_semantic_match() on each one until it says OK.

You're right we have to match semantics then first after that return longest prefix to comply w. current matching.

Quoted 1 line

This makes using a new algorithm very non-trivial.

Yes and will take resources compared to simple longest prefix.

Quoted 5 lines

Probably what you should do is keep an array on the function stack, recording shorter prefix entries you see on your walk down to the longest matching prefix. Then you process the array one entry at a time back to the root, trying fib_semantic_match() on each one.

We have backtracking as we search to leaves and as leaves does not always has a matching prefix. So we have to look into how semantics match can be done here instead and backtrack until we got a semantics match. Was about to test w. ipv6 to start with due to ipv4 complexity. Anyway ipv4 fib-code is cleaner now.

Cheers.

						--ro