aboutsummaryrefslogtreecommitdiffstats
path: root/net/ipv4/route.c
diff options
context:
space:
mode:
authorDavid S. Miller <davem@davemloft.net>2011-04-14 17:49:37 -0400
committerDavid S. Miller <davem@davemloft.net>2011-04-14 18:05:22 -0400
commit21d8c49e01a0c1c6eb6c750cd04110db4a539284 (patch)
tree03e19c4f6f24fd67da407463508c0ee27f6f9785 /net/ipv4/route.c
parent8849b720e9632acef139a349f9ec62e63ce7e497 (diff)
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/route.c')
-rw-r--r--net/ipv4/route.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/net/ipv4/route.c b/net/ipv4/route.c
index 0e7430c327a7..e9aee81de3e3 100644
--- a/net/ipv4/route.c
+++ b/net/ipv4/route.c
@@ -2615,7 +2615,9 @@ static struct rtable *ip_route_output_slow(struct net *net,
2615 fib_select_multipath(&res); 2615 fib_select_multipath(&res);
2616 else 2616 else
2617#endif 2617#endif
2618 if (!res.prefixlen && res.type == RTN_UNICAST && !fl4.flowi4_oif) 2618 if (!res.prefixlen &&
2619 res.table->tb_num_default > 1 &&
2620 res.type == RTN_UNICAST && !fl4.flowi4_oif)
2619 fib_select_default(&res); 2621 fib_select_default(&res);
2620 2622
2621 if (!fl4.saddr) 2623 if (!fl4.saddr)