aboutsummaryrefslogtreecommitdiffstats
path: root/net/ipv4/fib_frontend.c
diff options
context:
space:
mode:
authorDavid S. Miller <davem@davemloft.net>2012-07-06 01:13:13 -0400
committerDavid S. Miller <davem@davemloft.net>2012-07-06 01:13:13 -0400
commitf4530fa574df4d833506c53697ed1daa0d390bf4 (patch)
tree2a19ff4c8410d5aee18a78cddaeb765ed9aa95d6 /net/ipv4/fib_frontend.c
parent700db99d0140e9da2a31e08ebd3e1b121691aa26 (diff)
ipv4: Avoid overhead when no custom FIB rules are installed.
If the user hasn't actually installed any custom rules, or fiddled with the default ones, don't go through the whole FIB rules layer. It's just pure overhead. Instead do what we do with CONFIG_IP_MULTIPLE_TABLES disabled, check the individual tables by hand, one by one. Also, move fib_num_tclassid_users into the ipv4 network namespace. Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/ipv4/fib_frontend.c')
-rw-r--r--net/ipv4/fib_frontend.c27
1 files changed, 22 insertions, 5 deletions
diff --git a/net/ipv4/fib_frontend.c b/net/ipv4/fib_frontend.c
index 3e11ea225dad..81f85716a894 100644
--- a/net/ipv4/fib_frontend.c
+++ b/net/ipv4/fib_frontend.c
@@ -86,6 +86,24 @@ struct fib_table *fib_new_table(struct net *net, u32 id)
86 tb = fib_trie_table(id); 86 tb = fib_trie_table(id);
87 if (!tb) 87 if (!tb)
88 return NULL; 88 return NULL;
89
90 switch (id) {
91 case RT_TABLE_LOCAL:
92 net->ipv4.fib_local = tb;
93 break;
94
95 case RT_TABLE_MAIN:
96 net->ipv4.fib_main = tb;
97 break;
98
99 case RT_TABLE_DEFAULT:
100 net->ipv4.fib_default = tb;
101 break;
102
103 default:
104 break;
105 }
106
89 h = id & (FIB_TABLE_HASHSZ - 1); 107 h = id & (FIB_TABLE_HASHSZ - 1);
90 hlist_add_head_rcu(&tb->tb_hlist, &net->ipv4.fib_table_hash[h]); 108 hlist_add_head_rcu(&tb->tb_hlist, &net->ipv4.fib_table_hash[h]);
91 return tb; 109 return tb;
@@ -218,10 +236,6 @@ __be32 fib_compute_spec_dst(struct sk_buff *skb)
218 return inet_select_addr(dev, ip_hdr(skb)->saddr, scope); 236 return inet_select_addr(dev, ip_hdr(skb)->saddr, scope);
219} 237}
220 238
221#ifdef CONFIG_IP_ROUTE_CLASSID
222int fib_num_tclassid_users __read_mostly;
223#endif
224
225/* Given (packet source, input interface) and optional (dst, oif, tos): 239/* Given (packet source, input interface) and optional (dst, oif, tos):
226 * - (main) check, that source is valid i.e. not broadcast or our local 240 * - (main) check, that source is valid i.e. not broadcast or our local
227 * address. 241 * address.
@@ -312,7 +326,7 @@ int fib_validate_source(struct sk_buff *skb, __be32 src, __be32 dst,
312{ 326{
313 int r = secpath_exists(skb) ? 0 : IN_DEV_RPFILTER(idev); 327 int r = secpath_exists(skb) ? 0 : IN_DEV_RPFILTER(idev);
314 328
315 if (!r && !fib_num_tclassid_users) { 329 if (!r && !fib_num_tclassid_users(dev_net(dev))) {
316 *itag = 0; 330 *itag = 0;
317 return 0; 331 return 0;
318 } 332 }
@@ -1134,6 +1148,9 @@ static int __net_init fib_net_init(struct net *net)
1134{ 1148{
1135 int error; 1149 int error;
1136 1150
1151#ifdef CONFIG_IP_ROUTE_CLASSID
1152 net->ipv4.fib_num_tclassid_users = 0;
1153#endif
1137 error = ip_fib_net_init(net); 1154 error = ip_fib_net_init(net);
1138 if (error < 0) 1155 if (error < 0)
1139 goto out; 1156 goto out;