aboutsummaryrefslogtreecommitdiffstats
path: root/net/ipv4/fib_rules.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_rules.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_rules.c')
-rw-r--r--net/ipv4/fib_rules.c12
1 files changed, 8 insertions, 4 deletions
diff --git a/net/ipv4/fib_rules.c b/net/ipv4/fib_rules.c
index b23fd952c84f..c06da93b0b70 100644
--- a/net/ipv4/fib_rules.c
+++ b/net/ipv4/fib_rules.c
@@ -54,7 +54,7 @@ u32 fib_rules_tclass(const struct fib_result *res)
54} 54}
55#endif 55#endif
56 56
57int fib_lookup(struct net *net, struct flowi4 *flp, struct fib_result *res) 57int __fib_lookup(struct net *net, struct flowi4 *flp, struct fib_result *res)
58{ 58{
59 struct fib_lookup_arg arg = { 59 struct fib_lookup_arg arg = {
60 .result = res, 60 .result = res,
@@ -67,7 +67,7 @@ int fib_lookup(struct net *net, struct flowi4 *flp, struct fib_result *res)
67 67
68 return err; 68 return err;
69} 69}
70EXPORT_SYMBOL_GPL(fib_lookup); 70EXPORT_SYMBOL_GPL(__fib_lookup);
71 71
72static int fib4_rule_action(struct fib_rule *rule, struct flowi *flp, 72static int fib4_rule_action(struct fib_rule *rule, struct flowi *flp,
73 int flags, struct fib_lookup_arg *arg) 73 int flags, struct fib_lookup_arg *arg)
@@ -172,7 +172,7 @@ static int fib4_rule_configure(struct fib_rule *rule, struct sk_buff *skb,
172 if (tb[FRA_FLOW]) { 172 if (tb[FRA_FLOW]) {
173 rule4->tclassid = nla_get_u32(tb[FRA_FLOW]); 173 rule4->tclassid = nla_get_u32(tb[FRA_FLOW]);
174 if (rule4->tclassid) 174 if (rule4->tclassid)
175 fib_num_tclassid_users++; 175 net->ipv4.fib_num_tclassid_users++;
176 } 176 }
177#endif 177#endif
178 178
@@ -182,6 +182,7 @@ static int fib4_rule_configure(struct fib_rule *rule, struct sk_buff *skb,
182 rule4->dstmask = inet_make_mask(rule4->dst_len); 182 rule4->dstmask = inet_make_mask(rule4->dst_len);
183 rule4->tos = frh->tos; 183 rule4->tos = frh->tos;
184 184
185 net->ipv4.fib_has_custom_rules = true;
185 err = 0; 186 err = 0;
186errout: 187errout:
187 return err; 188 return err;
@@ -189,12 +190,14 @@ errout:
189 190
190static void fib4_rule_delete(struct fib_rule *rule) 191static void fib4_rule_delete(struct fib_rule *rule)
191{ 192{
193 struct net *net = rule->fr_net;
192#ifdef CONFIG_IP_ROUTE_CLASSID 194#ifdef CONFIG_IP_ROUTE_CLASSID
193 struct fib4_rule *rule4 = (struct fib4_rule *) rule; 195 struct fib4_rule *rule4 = (struct fib4_rule *) rule;
194 196
195 if (rule4->tclassid) 197 if (rule4->tclassid)
196 fib_num_tclassid_users--; 198 net->ipv4.fib_num_tclassid_users--;
197#endif 199#endif
200 net->ipv4.fib_has_custom_rules = true;
198} 201}
199 202
200static int fib4_rule_compare(struct fib_rule *rule, struct fib_rule_hdr *frh, 203static int fib4_rule_compare(struct fib_rule *rule, struct fib_rule_hdr *frh,
@@ -309,6 +312,7 @@ int __net_init fib4_rules_init(struct net *net)
309 if (err < 0) 312 if (err < 0)
310 goto fail; 313 goto fail;
311 net->ipv4.rules_ops = ops; 314 net->ipv4.rules_ops = ops;
315 net->ipv4.fib_has_custom_rules = false;
312 return 0; 316 return 0;
313 317
314fail: 318fail: