diff options
author | Denis V. Lunev <den@openvz.org> | 2007-09-16 18:44:27 -0400 |
---|---|---|
committer | David S. Miller <davem@sunset.davemloft.net> | 2007-10-10 19:51:22 -0400 |
commit | 76c72d4f44ec5fb7f88eda8a0d3aa30922c891d1 (patch) | |
tree | 0c773487ff11d098a70fddbc631f153260614bdb | |
parent | 056925ab3145713e5e83cf8e05ae6fb2f4ace41e (diff) |
[IPV4/IPV6/DECNET]: Small cleanup for fib rules.
This patch slightly cleanups FIB rules framework. rules_list as a pointer
on struct fib_rules_ops is useless. It is always assigned with a static
per/subsystem list in IPv4, IPv6 and DecNet.
Signed-off-by: Denis V. Lunev <den@openvz.org>
Acked-by: Alexey Kuznetsov <kuznet@ms2.inr.ac.ru>
Signed-off-by: David S. Miller <davem@davemloft.net>
-rw-r--r-- | include/net/fib_rules.h | 2 | ||||
-rw-r--r-- | net/core/fib_rules.c | 22 | ||||
-rw-r--r-- | net/decnet/dn_rules.c | 13 | ||||
-rw-r--r-- | net/ipv4/fib_rules.c | 16 | ||||
-rw-r--r-- | net/ipv6/fib6_rules.c | 8 |
5 files changed, 28 insertions, 33 deletions
diff --git a/include/net/fib_rules.h b/include/net/fib_rules.h index 83e41dd15ccd..017aebd90683 100644 --- a/include/net/fib_rules.h +++ b/include/net/fib_rules.h | |||
@@ -65,7 +65,7 @@ struct fib_rules_ops | |||
65 | 65 | ||
66 | int nlgroup; | 66 | int nlgroup; |
67 | const struct nla_policy *policy; | 67 | const struct nla_policy *policy; |
68 | struct list_head *rules_list; | 68 | struct list_head rules_list; |
69 | struct module *owner; | 69 | struct module *owner; |
70 | }; | 70 | }; |
71 | 71 | ||
diff --git a/net/core/fib_rules.c b/net/core/fib_rules.c index 1ba71baf87ef..13de6f53f098 100644 --- a/net/core/fib_rules.c +++ b/net/core/fib_rules.c | |||
@@ -84,7 +84,7 @@ static void cleanup_ops(struct fib_rules_ops *ops) | |||
84 | { | 84 | { |
85 | struct fib_rule *rule, *tmp; | 85 | struct fib_rule *rule, *tmp; |
86 | 86 | ||
87 | list_for_each_entry_safe(rule, tmp, ops->rules_list, list) { | 87 | list_for_each_entry_safe(rule, tmp, &ops->rules_list, list) { |
88 | list_del_rcu(&rule->list); | 88 | list_del_rcu(&rule->list); |
89 | fib_rule_put(rule); | 89 | fib_rule_put(rule); |
90 | } | 90 | } |
@@ -139,7 +139,7 @@ int fib_rules_lookup(struct fib_rules_ops *ops, struct flowi *fl, | |||
139 | 139 | ||
140 | rcu_read_lock(); | 140 | rcu_read_lock(); |
141 | 141 | ||
142 | list_for_each_entry_rcu(rule, ops->rules_list, list) { | 142 | list_for_each_entry_rcu(rule, &ops->rules_list, list) { |
143 | jumped: | 143 | jumped: |
144 | if (!fib_rule_match(rule, ops, fl, flags)) | 144 | if (!fib_rule_match(rule, ops, fl, flags)) |
145 | continue; | 145 | continue; |
@@ -271,7 +271,7 @@ static int fib_nl_newrule(struct sk_buff *skb, struct nlmsghdr* nlh, void *arg) | |||
271 | if (rule->target <= rule->pref) | 271 | if (rule->target <= rule->pref) |
272 | goto errout_free; | 272 | goto errout_free; |
273 | 273 | ||
274 | list_for_each_entry(r, ops->rules_list, list) { | 274 | list_for_each_entry(r, &ops->rules_list, list) { |
275 | if (r->pref == rule->target) { | 275 | if (r->pref == rule->target) { |
276 | rule->ctarget = r; | 276 | rule->ctarget = r; |
277 | break; | 277 | break; |
@@ -287,7 +287,7 @@ static int fib_nl_newrule(struct sk_buff *skb, struct nlmsghdr* nlh, void *arg) | |||
287 | if (err < 0) | 287 | if (err < 0) |
288 | goto errout_free; | 288 | goto errout_free; |
289 | 289 | ||
290 | list_for_each_entry(r, ops->rules_list, list) { | 290 | list_for_each_entry(r, &ops->rules_list, list) { |
291 | if (r->pref > rule->pref) | 291 | if (r->pref > rule->pref) |
292 | break; | 292 | break; |
293 | last = r; | 293 | last = r; |
@@ -300,7 +300,7 @@ static int fib_nl_newrule(struct sk_buff *skb, struct nlmsghdr* nlh, void *arg) | |||
300 | * There are unresolved goto rules in the list, check if | 300 | * There are unresolved goto rules in the list, check if |
301 | * any of them are pointing to this new rule. | 301 | * any of them are pointing to this new rule. |
302 | */ | 302 | */ |
303 | list_for_each_entry(r, ops->rules_list, list) { | 303 | list_for_each_entry(r, &ops->rules_list, list) { |
304 | if (r->action == FR_ACT_GOTO && | 304 | if (r->action == FR_ACT_GOTO && |
305 | r->target == rule->pref) { | 305 | r->target == rule->pref) { |
306 | BUG_ON(r->ctarget != NULL); | 306 | BUG_ON(r->ctarget != NULL); |
@@ -320,7 +320,7 @@ static int fib_nl_newrule(struct sk_buff *skb, struct nlmsghdr* nlh, void *arg) | |||
320 | if (last) | 320 | if (last) |
321 | list_add_rcu(&rule->list, &last->list); | 321 | list_add_rcu(&rule->list, &last->list); |
322 | else | 322 | else |
323 | list_add_rcu(&rule->list, ops->rules_list); | 323 | list_add_rcu(&rule->list, &ops->rules_list); |
324 | 324 | ||
325 | notify_rule_change(RTM_NEWRULE, rule, ops, nlh, NETLINK_CB(skb).pid); | 325 | notify_rule_change(RTM_NEWRULE, rule, ops, nlh, NETLINK_CB(skb).pid); |
326 | flush_route_cache(ops); | 326 | flush_route_cache(ops); |
@@ -359,7 +359,7 @@ static int fib_nl_delrule(struct sk_buff *skb, struct nlmsghdr* nlh, void *arg) | |||
359 | if (err < 0) | 359 | if (err < 0) |
360 | goto errout; | 360 | goto errout; |
361 | 361 | ||
362 | list_for_each_entry(rule, ops->rules_list, list) { | 362 | list_for_each_entry(rule, &ops->rules_list, list) { |
363 | if (frh->action && (frh->action != rule->action)) | 363 | if (frh->action && (frh->action != rule->action)) |
364 | continue; | 364 | continue; |
365 | 365 | ||
@@ -402,7 +402,7 @@ static int fib_nl_delrule(struct sk_buff *skb, struct nlmsghdr* nlh, void *arg) | |||
402 | * actually been added. | 402 | * actually been added. |
403 | */ | 403 | */ |
404 | if (ops->nr_goto_rules > 0) { | 404 | if (ops->nr_goto_rules > 0) { |
405 | list_for_each_entry(tmp, ops->rules_list, list) { | 405 | list_for_each_entry(tmp, &ops->rules_list, list) { |
406 | if (tmp->ctarget == rule) { | 406 | if (tmp->ctarget == rule) { |
407 | rcu_assign_pointer(tmp->ctarget, NULL); | 407 | rcu_assign_pointer(tmp->ctarget, NULL); |
408 | ops->unresolved_rules++; | 408 | ops->unresolved_rules++; |
@@ -498,7 +498,7 @@ static int dump_rules(struct sk_buff *skb, struct netlink_callback *cb, | |||
498 | int idx = 0; | 498 | int idx = 0; |
499 | struct fib_rule *rule; | 499 | struct fib_rule *rule; |
500 | 500 | ||
501 | list_for_each_entry(rule, ops->rules_list, list) { | 501 | list_for_each_entry(rule, &ops->rules_list, list) { |
502 | if (idx < cb->args[1]) | 502 | if (idx < cb->args[1]) |
503 | goto skip; | 503 | goto skip; |
504 | 504 | ||
@@ -608,12 +608,12 @@ static int fib_rules_event(struct notifier_block *this, unsigned long event, | |||
608 | switch (event) { | 608 | switch (event) { |
609 | case NETDEV_REGISTER: | 609 | case NETDEV_REGISTER: |
610 | list_for_each_entry(ops, &rules_ops, list) | 610 | list_for_each_entry(ops, &rules_ops, list) |
611 | attach_rules(ops->rules_list, dev); | 611 | attach_rules(&ops->rules_list, dev); |
612 | break; | 612 | break; |
613 | 613 | ||
614 | case NETDEV_UNREGISTER: | 614 | case NETDEV_UNREGISTER: |
615 | list_for_each_entry(ops, &rules_ops, list) | 615 | list_for_each_entry(ops, &rules_ops, list) |
616 | detach_rules(ops->rules_list, dev); | 616 | detach_rules(&ops->rules_list, dev); |
617 | break; | 617 | break; |
618 | } | 618 | } |
619 | 619 | ||
diff --git a/net/decnet/dn_rules.c b/net/decnet/dn_rules.c index 84ff3dd37070..ddd3f04f0919 100644 --- a/net/decnet/dn_rules.c +++ b/net/decnet/dn_rules.c | |||
@@ -57,8 +57,6 @@ static struct dn_fib_rule default_rule = { | |||
57 | }, | 57 | }, |
58 | }; | 58 | }; |
59 | 59 | ||
60 | static LIST_HEAD(dn_fib_rules); | ||
61 | |||
62 | 60 | ||
63 | int dn_fib_lookup(struct flowi *flp, struct dn_fib_res *res) | 61 | int dn_fib_lookup(struct flowi *flp, struct dn_fib_res *res) |
64 | { | 62 | { |
@@ -228,9 +226,9 @@ static u32 dn_fib_rule_default_pref(void) | |||
228 | struct list_head *pos; | 226 | struct list_head *pos; |
229 | struct fib_rule *rule; | 227 | struct fib_rule *rule; |
230 | 228 | ||
231 | if (!list_empty(&dn_fib_rules)) { | 229 | if (!list_empty(&dn_fib_rules_ops.rules_list)) { |
232 | pos = dn_fib_rules.next; | 230 | pos = dn_fib_rules_ops.rules_list.next; |
233 | if (pos->next != &dn_fib_rules) { | 231 | if (pos->next != &dn_fib_rules_ops.rules_list) { |
234 | rule = list_entry(pos->next, struct fib_rule, list); | 232 | rule = list_entry(pos->next, struct fib_rule, list); |
235 | if (rule->pref) | 233 | if (rule->pref) |
236 | return rule->pref - 1; | 234 | return rule->pref - 1; |
@@ -258,13 +256,14 @@ static struct fib_rules_ops dn_fib_rules_ops = { | |||
258 | .flush_cache = dn_fib_rule_flush_cache, | 256 | .flush_cache = dn_fib_rule_flush_cache, |
259 | .nlgroup = RTNLGRP_DECnet_RULE, | 257 | .nlgroup = RTNLGRP_DECnet_RULE, |
260 | .policy = dn_fib_rule_policy, | 258 | .policy = dn_fib_rule_policy, |
261 | .rules_list = &dn_fib_rules, | 259 | .rules_list = LIST_HEAD_INIT(dn_fib_rules_ops.rules_list), |
262 | .owner = THIS_MODULE, | 260 | .owner = THIS_MODULE, |
263 | }; | 261 | }; |
264 | 262 | ||
265 | void __init dn_fib_rules_init(void) | 263 | void __init dn_fib_rules_init(void) |
266 | { | 264 | { |
267 | list_add_tail(&default_rule.common.list, &dn_fib_rules); | 265 | list_add_tail(&default_rule.common.list, |
266 | &dn_fib_rules_ops.rules_list); | ||
268 | fib_rules_register(&dn_fib_rules_ops); | 267 | fib_rules_register(&dn_fib_rules_ops); |
269 | } | 268 | } |
270 | 269 | ||
diff --git a/net/ipv4/fib_rules.c b/net/ipv4/fib_rules.c index 2a947840210e..f16839c6a721 100644 --- a/net/ipv4/fib_rules.c +++ b/net/ipv4/fib_rules.c | |||
@@ -76,8 +76,6 @@ static struct fib4_rule local_rule = { | |||
76 | }, | 76 | }, |
77 | }; | 77 | }; |
78 | 78 | ||
79 | static LIST_HEAD(fib4_rules); | ||
80 | |||
81 | #ifdef CONFIG_NET_CLS_ROUTE | 79 | #ifdef CONFIG_NET_CLS_ROUTE |
82 | u32 fib_rules_tclass(struct fib_result *res) | 80 | u32 fib_rules_tclass(struct fib_result *res) |
83 | { | 81 | { |
@@ -279,9 +277,9 @@ static u32 fib4_rule_default_pref(void) | |||
279 | struct list_head *pos; | 277 | struct list_head *pos; |
280 | struct fib_rule *rule; | 278 | struct fib_rule *rule; |
281 | 279 | ||
282 | if (!list_empty(&fib4_rules)) { | 280 | if (!list_empty(&fib4_rules_ops.rules_list)) { |
283 | pos = fib4_rules.next; | 281 | pos = fib4_rules_ops.rules_list.next; |
284 | if (pos->next != &fib4_rules) { | 282 | if (pos->next != &fib4_rules_ops.rules_list) { |
285 | rule = list_entry(pos->next, struct fib_rule, list); | 283 | rule = list_entry(pos->next, struct fib_rule, list); |
286 | if (rule->pref) | 284 | if (rule->pref) |
287 | return rule->pref - 1; | 285 | return rule->pref - 1; |
@@ -317,15 +315,15 @@ static struct fib_rules_ops fib4_rules_ops = { | |||
317 | .flush_cache = fib4_rule_flush_cache, | 315 | .flush_cache = fib4_rule_flush_cache, |
318 | .nlgroup = RTNLGRP_IPV4_RULE, | 316 | .nlgroup = RTNLGRP_IPV4_RULE, |
319 | .policy = fib4_rule_policy, | 317 | .policy = fib4_rule_policy, |
320 | .rules_list = &fib4_rules, | 318 | .rules_list = LIST_HEAD_INIT(fib4_rules_ops.rules_list), |
321 | .owner = THIS_MODULE, | 319 | .owner = THIS_MODULE, |
322 | }; | 320 | }; |
323 | 321 | ||
324 | void __init fib4_rules_init(void) | 322 | void __init fib4_rules_init(void) |
325 | { | 323 | { |
326 | list_add_tail(&local_rule.common.list, &fib4_rules); | 324 | list_add_tail(&local_rule.common.list, &fib4_rules_ops.rules_list); |
327 | list_add_tail(&main_rule.common.list, &fib4_rules); | 325 | list_add_tail(&main_rule.common.list, &fib4_rules_ops.rules_list); |
328 | list_add_tail(&default_rule.common.list, &fib4_rules); | 326 | list_add_tail(&default_rule.common.list, &fib4_rules_ops.rules_list); |
329 | 327 | ||
330 | fib_rules_register(&fib4_rules_ops); | 328 | fib_rules_register(&fib4_rules_ops); |
331 | } | 329 | } |
diff --git a/net/ipv6/fib6_rules.c b/net/ipv6/fib6_rules.c index 53b3998a486c..706622af206f 100644 --- a/net/ipv6/fib6_rules.c +++ b/net/ipv6/fib6_rules.c | |||
@@ -50,8 +50,6 @@ static struct fib6_rule local_rule = { | |||
50 | }, | 50 | }, |
51 | }; | 51 | }; |
52 | 52 | ||
53 | static LIST_HEAD(fib6_rules); | ||
54 | |||
55 | struct dst_entry *fib6_rule_lookup(struct flowi *fl, int flags, | 53 | struct dst_entry *fib6_rule_lookup(struct flowi *fl, int flags, |
56 | pol_lookup_t lookup) | 54 | pol_lookup_t lookup) |
57 | { | 55 | { |
@@ -268,14 +266,14 @@ static struct fib_rules_ops fib6_rules_ops = { | |||
268 | .nlmsg_payload = fib6_rule_nlmsg_payload, | 266 | .nlmsg_payload = fib6_rule_nlmsg_payload, |
269 | .nlgroup = RTNLGRP_IPV6_RULE, | 267 | .nlgroup = RTNLGRP_IPV6_RULE, |
270 | .policy = fib6_rule_policy, | 268 | .policy = fib6_rule_policy, |
271 | .rules_list = &fib6_rules, | 269 | .rules_list = LIST_HEAD_INIT(fib6_rules_ops.rules_list), |
272 | .owner = THIS_MODULE, | 270 | .owner = THIS_MODULE, |
273 | }; | 271 | }; |
274 | 272 | ||
275 | void __init fib6_rules_init(void) | 273 | void __init fib6_rules_init(void) |
276 | { | 274 | { |
277 | list_add_tail(&local_rule.common.list, &fib6_rules); | 275 | list_add_tail(&local_rule.common.list, &fib6_rules_ops.rules_list); |
278 | list_add_tail(&main_rule.common.list, &fib6_rules); | 276 | list_add_tail(&main_rule.common.list, &fib6_rules_ops.rules_list); |
279 | 277 | ||
280 | fib_rules_register(&fib6_rules_ops); | 278 | fib_rules_register(&fib6_rules_ops); |
281 | } | 279 | } |