diff options
author | David S. Miller <davem@davemloft.net> | 2011-04-14 14:49:37 -0700 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2011-04-14 15:05:22 -0700 |
commit | 21d8c49e01a0c1c6eb6c750cd04110db4a539284 (patch) | |
tree | 03e19c4f6f24fd67da407463508c0ee27f6f9785 /net/ipv4/fib_trie.c | |
parent | 8849b720e9632acef139a349f9ec62e63ce7e497 (diff) | |
download | blackbird-op-linux-21d8c49e01a0c1c6eb6c750cd04110db4a539284.tar.gz blackbird-op-linux-21d8c49e01a0c1c6eb6c750cd04110db4a539284.zip |
ipv4: Call fib_select_default() only when actually necessary.
fib_select_default() is a complete NOP, and completely pointless
to invoke, when we have no more than 1 default route installed.
And this is far and away the common case.
So remember how many prefixlen==0 routes we have in the routing
table, and elide the call when we have no more than one of those.
This cuts output route creation time by 157 cycles on Niagara2+.
In order to add the new int to fib_table, we have to correct the type
of ->tb_data[] to unsigned long, otherwise the private area will be
unaligned on 64-bit systems.
Signed-off-by: David S. Miller <davem@davemloft.net>
Reviewed-by: Eric Dumazet <eric.dumazet@gmail.com>
Diffstat (limited to 'net/ipv4/fib_trie.c')
-rw-r--r-- | net/ipv4/fib_trie.c | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/net/ipv4/fib_trie.c b/net/ipv4/fib_trie.c index bde80c450b52..9ac481a10d37 100644 --- a/net/ipv4/fib_trie.c +++ b/net/ipv4/fib_trie.c @@ -1332,6 +1332,9 @@ int fib_table_insert(struct fib_table *tb, struct fib_config *cfg) } } + if (!plen) + tb->tb_num_default++; + list_add_tail_rcu(&new_fa->fa_list, (fa ? &fa->fa_list : fa_head)); @@ -1697,6 +1700,9 @@ int fib_table_delete(struct fib_table *tb, struct fib_config *cfg) list_del_rcu(&fa->fa_list); + if (!plen) + tb->tb_num_default--; + if (list_empty(fa_head)) { hlist_del_rcu(&li->hlist); free_leaf_info(li); @@ -1987,6 +1993,7 @@ struct fib_table *fib_trie_table(u32 id) tb->tb_id = id; tb->tb_default = -1; + tb->tb_num_default = 0; t = (struct trie *) tb->tb_data; memset(t, 0, sizeof(*t)); |