]> err.no Git - linux-2.6/commitdiff
[IPV4/IPV6/DECNET]: Small cleanup for fib rules.
authorDenis V. Lunev <den@openvz.org>
Sun, 16 Sep 2007 22:44:27 +0000 (15:44 -0700)
committerDavid S. Miller <davem@sunset.davemloft.net>
Wed, 10 Oct 2007 23:51:22 +0000 (16:51 -0700)
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>
include/net/fib_rules.h
net/core/fib_rules.c
net/decnet/dn_rules.c
net/ipv4/fib_rules.c
net/ipv6/fib6_rules.c

index 83e41dd15ccde6e88b304687dac539462815d7dd..017aebd9068317f387df8f62de160cc7bad36a08 100644 (file)
@@ -65,7 +65,7 @@ struct fib_rules_ops
 
        int                     nlgroup;
        const struct nla_policy *policy;
-       struct list_head        *rules_list;
+       struct list_head        rules_list;
        struct module           *owner;
 };
 
index 1ba71baf87ef1a96754cd26e02f978d8e3378cb1..13de6f53f0981f19bb16e7aef2d542f2d5f8167a 100644 (file)
@@ -84,7 +84,7 @@ static void cleanup_ops(struct fib_rules_ops *ops)
 {
        struct fib_rule *rule, *tmp;
 
-       list_for_each_entry_safe(rule, tmp, ops->rules_list, list) {
+       list_for_each_entry_safe(rule, tmp, &ops->rules_list, list) {
                list_del_rcu(&rule->list);
                fib_rule_put(rule);
        }
@@ -139,7 +139,7 @@ int fib_rules_lookup(struct fib_rules_ops *ops, struct flowi *fl,
 
        rcu_read_lock();
 
-       list_for_each_entry_rcu(rule, ops->rules_list, list) {
+       list_for_each_entry_rcu(rule, &ops->rules_list, list) {
 jumped:
                if (!fib_rule_match(rule, ops, fl, flags))
                        continue;
@@ -271,7 +271,7 @@ static int fib_nl_newrule(struct sk_buff *skb, struct nlmsghdr* nlh, void *arg)
                if (rule->target <= rule->pref)
                        goto errout_free;
 
-               list_for_each_entry(r, ops->rules_list, list) {
+               list_for_each_entry(r, &ops->rules_list, list) {
                        if (r->pref == rule->target) {
                                rule->ctarget = r;
                                break;
@@ -287,7 +287,7 @@ static int fib_nl_newrule(struct sk_buff *skb, struct nlmsghdr* nlh, void *arg)
        if (err < 0)
                goto errout_free;
 
-       list_for_each_entry(r, ops->rules_list, list) {
+       list_for_each_entry(r, &ops->rules_list, list) {
                if (r->pref > rule->pref)
                        break;
                last = r;
@@ -300,7 +300,7 @@ static int fib_nl_newrule(struct sk_buff *skb, struct nlmsghdr* nlh, void *arg)
                 * There are unresolved goto rules in the list, check if
                 * any of them are pointing to this new rule.
                 */
-               list_for_each_entry(r, ops->rules_list, list) {
+               list_for_each_entry(r, &ops->rules_list, list) {
                        if (r->action == FR_ACT_GOTO &&
                            r->target == rule->pref) {
                                BUG_ON(r->ctarget != NULL);
@@ -320,7 +320,7 @@ static int fib_nl_newrule(struct sk_buff *skb, struct nlmsghdr* nlh, void *arg)
        if (last)
                list_add_rcu(&rule->list, &last->list);
        else
-               list_add_rcu(&rule->list, ops->rules_list);
+               list_add_rcu(&rule->list, &ops->rules_list);
 
        notify_rule_change(RTM_NEWRULE, rule, ops, nlh, NETLINK_CB(skb).pid);
        flush_route_cache(ops);
@@ -359,7 +359,7 @@ static int fib_nl_delrule(struct sk_buff *skb, struct nlmsghdr* nlh, void *arg)
        if (err < 0)
                goto errout;
 
-       list_for_each_entry(rule, ops->rules_list, list) {
+       list_for_each_entry(rule, &ops->rules_list, list) {
                if (frh->action && (frh->action != rule->action))
                        continue;
 
@@ -402,7 +402,7 @@ static int fib_nl_delrule(struct sk_buff *skb, struct nlmsghdr* nlh, void *arg)
                 * actually been added.
                 */
                if (ops->nr_goto_rules > 0) {
-                       list_for_each_entry(tmp, ops->rules_list, list) {
+                       list_for_each_entry(tmp, &ops->rules_list, list) {
                                if (tmp->ctarget == rule) {
                                        rcu_assign_pointer(tmp->ctarget, NULL);
                                        ops->unresolved_rules++;
@@ -498,7 +498,7 @@ static int dump_rules(struct sk_buff *skb, struct netlink_callback *cb,
        int idx = 0;
        struct fib_rule *rule;
 
-       list_for_each_entry(rule, ops->rules_list, list) {
+       list_for_each_entry(rule, &ops->rules_list, list) {
                if (idx < cb->args[1])
                        goto skip;
 
@@ -608,12 +608,12 @@ static int fib_rules_event(struct notifier_block *this, unsigned long event,
        switch (event) {
        case NETDEV_REGISTER:
                list_for_each_entry(ops, &rules_ops, list)
-                       attach_rules(ops->rules_list, dev);
+                       attach_rules(&ops->rules_list, dev);
                break;
 
        case NETDEV_UNREGISTER:
                list_for_each_entry(ops, &rules_ops, list)
-                       detach_rules(ops->rules_list, dev);
+                       detach_rules(&ops->rules_list, dev);
                break;
        }
 
index 84ff3dd370709fc8c8c7f2927d1e6f9861019ea5..ddd3f04f0919ee880dba236ee1516df96d3a6bee 100644 (file)
@@ -57,8 +57,6 @@ static struct dn_fib_rule default_rule = {
        },
 };
 
-static LIST_HEAD(dn_fib_rules);
-
 
 int dn_fib_lookup(struct flowi *flp, struct dn_fib_res *res)
 {
@@ -228,9 +226,9 @@ static u32 dn_fib_rule_default_pref(void)
        struct list_head *pos;
        struct fib_rule *rule;
 
-       if (!list_empty(&dn_fib_rules)) {
-               pos = dn_fib_rules.next;
-               if (pos->next != &dn_fib_rules) {
+       if (!list_empty(&dn_fib_rules_ops.rules_list)) {
+               pos = dn_fib_rules_ops.rules_list.next;
+               if (pos->next != &dn_fib_rules_ops.rules_list) {
                        rule = list_entry(pos->next, struct fib_rule, list);
                        if (rule->pref)
                                return rule->pref - 1;
@@ -258,13 +256,14 @@ static struct fib_rules_ops dn_fib_rules_ops = {
        .flush_cache    = dn_fib_rule_flush_cache,
        .nlgroup        = RTNLGRP_DECnet_RULE,
        .policy         = dn_fib_rule_policy,
-       .rules_list     = &dn_fib_rules,
+       .rules_list     = LIST_HEAD_INIT(dn_fib_rules_ops.rules_list),
        .owner          = THIS_MODULE,
 };
 
 void __init dn_fib_rules_init(void)
 {
-       list_add_tail(&default_rule.common.list, &dn_fib_rules);
+       list_add_tail(&default_rule.common.list,
+                       &dn_fib_rules_ops.rules_list);
        fib_rules_register(&dn_fib_rules_ops);
 }
 
index 2a947840210ece1a1e218972725e5bda5b21ea6f..f16839c6a721ab98d2402e16a9aa51087954afad 100644 (file)
@@ -76,8 +76,6 @@ static struct fib4_rule local_rule = {
        },
 };
 
-static LIST_HEAD(fib4_rules);
-
 #ifdef CONFIG_NET_CLS_ROUTE
 u32 fib_rules_tclass(struct fib_result *res)
 {
@@ -279,9 +277,9 @@ static u32 fib4_rule_default_pref(void)
        struct list_head *pos;
        struct fib_rule *rule;
 
-       if (!list_empty(&fib4_rules)) {
-               pos = fib4_rules.next;
-               if (pos->next != &fib4_rules) {
+       if (!list_empty(&fib4_rules_ops.rules_list)) {
+               pos = fib4_rules_ops.rules_list.next;
+               if (pos->next != &fib4_rules_ops.rules_list) {
                        rule = list_entry(pos->next, struct fib_rule, list);
                        if (rule->pref)
                                return rule->pref - 1;
@@ -317,15 +315,15 @@ static struct fib_rules_ops fib4_rules_ops = {
        .flush_cache    = fib4_rule_flush_cache,
        .nlgroup        = RTNLGRP_IPV4_RULE,
        .policy         = fib4_rule_policy,
-       .rules_list     = &fib4_rules,
+       .rules_list     = LIST_HEAD_INIT(fib4_rules_ops.rules_list),
        .owner          = THIS_MODULE,
 };
 
 void __init fib4_rules_init(void)
 {
-       list_add_tail(&local_rule.common.list, &fib4_rules);
-       list_add_tail(&main_rule.common.list, &fib4_rules);
-       list_add_tail(&default_rule.common.list, &fib4_rules);
+       list_add_tail(&local_rule.common.list, &fib4_rules_ops.rules_list);
+       list_add_tail(&main_rule.common.list, &fib4_rules_ops.rules_list);
+       list_add_tail(&default_rule.common.list, &fib4_rules_ops.rules_list);
 
        fib_rules_register(&fib4_rules_ops);
 }
index 53b3998a486ced67d9eae000cff6c9a1269ecf66..706622af206f1f7f5a04479223a1c4aa84334238 100644 (file)
@@ -50,8 +50,6 @@ static struct fib6_rule local_rule = {
        },
 };
 
-static LIST_HEAD(fib6_rules);
-
 struct dst_entry *fib6_rule_lookup(struct flowi *fl, int flags,
                                   pol_lookup_t lookup)
 {
@@ -268,14 +266,14 @@ static struct fib_rules_ops fib6_rules_ops = {
        .nlmsg_payload          = fib6_rule_nlmsg_payload,
        .nlgroup                = RTNLGRP_IPV6_RULE,
        .policy                 = fib6_rule_policy,
-       .rules_list             = &fib6_rules,
+       .rules_list             = LIST_HEAD_INIT(fib6_rules_ops.rules_list),
        .owner                  = THIS_MODULE,
 };
 
 void __init fib6_rules_init(void)
 {
-       list_add_tail(&local_rule.common.list, &fib6_rules);
-       list_add_tail(&main_rule.common.list, &fib6_rules);
+       list_add_tail(&local_rule.common.list, &fib6_rules_ops.rules_list);
+       list_add_tail(&main_rule.common.list, &fib6_rules_ops.rules_list);
 
        fib_rules_register(&fib6_rules_ops);
 }