Commit 76c72d4f authored by Denis V. Lunev's avatar Denis V. Lunev Committed by David S. Miller

[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: default avatarDenis V. Lunev <den@openvz.org>
Acked-by: default avatarAlexey Kuznetsov <kuznet@ms2.inr.ac.ru>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 056925ab
...@@ -65,7 +65,7 @@ struct fib_rules_ops ...@@ -65,7 +65,7 @@ struct fib_rules_ops
int nlgroup; int nlgroup;
const struct nla_policy *policy; const struct nla_policy *policy;
struct list_head *rules_list; struct list_head rules_list;
struct module *owner; struct module *owner;
}; };
......
...@@ -84,7 +84,7 @@ static void cleanup_ops(struct fib_rules_ops *ops) ...@@ -84,7 +84,7 @@ static void cleanup_ops(struct fib_rules_ops *ops)
{ {
struct fib_rule *rule, *tmp; 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); list_del_rcu(&rule->list);
fib_rule_put(rule); fib_rule_put(rule);
} }
...@@ -139,7 +139,7 @@ int fib_rules_lookup(struct fib_rules_ops *ops, struct flowi *fl, ...@@ -139,7 +139,7 @@ int fib_rules_lookup(struct fib_rules_ops *ops, struct flowi *fl,
rcu_read_lock(); rcu_read_lock();
list_for_each_entry_rcu(rule, ops->rules_list, list) { list_for_each_entry_rcu(rule, &ops->rules_list, list) {
jumped: jumped:
if (!fib_rule_match(rule, ops, fl, flags)) if (!fib_rule_match(rule, ops, fl, flags))
continue; continue;
...@@ -271,7 +271,7 @@ static int fib_nl_newrule(struct sk_buff *skb, struct nlmsghdr* nlh, void *arg) ...@@ -271,7 +271,7 @@ static int fib_nl_newrule(struct sk_buff *skb, struct nlmsghdr* nlh, void *arg)
if (rule->target <= rule->pref) if (rule->target <= rule->pref)
goto errout_free; 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) { if (r->pref == rule->target) {
rule->ctarget = r; rule->ctarget = r;
break; break;
...@@ -287,7 +287,7 @@ static int fib_nl_newrule(struct sk_buff *skb, struct nlmsghdr* nlh, void *arg) ...@@ -287,7 +287,7 @@ static int fib_nl_newrule(struct sk_buff *skb, struct nlmsghdr* nlh, void *arg)
if (err < 0) if (err < 0)
goto errout_free; 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) if (r->pref > rule->pref)
break; break;
last = r; last = r;
...@@ -300,7 +300,7 @@ static int fib_nl_newrule(struct sk_buff *skb, struct nlmsghdr* nlh, void *arg) ...@@ -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 * There are unresolved goto rules in the list, check if
* any of them are pointing to this new rule. * 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 && if (r->action == FR_ACT_GOTO &&
r->target == rule->pref) { r->target == rule->pref) {
BUG_ON(r->ctarget != NULL); BUG_ON(r->ctarget != NULL);
...@@ -320,7 +320,7 @@ static int fib_nl_newrule(struct sk_buff *skb, struct nlmsghdr* nlh, void *arg) ...@@ -320,7 +320,7 @@ static int fib_nl_newrule(struct sk_buff *skb, struct nlmsghdr* nlh, void *arg)
if (last) if (last)
list_add_rcu(&rule->list, &last->list); list_add_rcu(&rule->list, &last->list);
else 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); notify_rule_change(RTM_NEWRULE, rule, ops, nlh, NETLINK_CB(skb).pid);
flush_route_cache(ops); flush_route_cache(ops);
...@@ -359,7 +359,7 @@ static int fib_nl_delrule(struct sk_buff *skb, struct nlmsghdr* nlh, void *arg) ...@@ -359,7 +359,7 @@ static int fib_nl_delrule(struct sk_buff *skb, struct nlmsghdr* nlh, void *arg)
if (err < 0) if (err < 0)
goto errout; 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)) if (frh->action && (frh->action != rule->action))
continue; continue;
...@@ -402,7 +402,7 @@ static int fib_nl_delrule(struct sk_buff *skb, struct nlmsghdr* nlh, void *arg) ...@@ -402,7 +402,7 @@ static int fib_nl_delrule(struct sk_buff *skb, struct nlmsghdr* nlh, void *arg)
* actually been added. * actually been added.
*/ */
if (ops->nr_goto_rules > 0) { 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) { if (tmp->ctarget == rule) {
rcu_assign_pointer(tmp->ctarget, NULL); rcu_assign_pointer(tmp->ctarget, NULL);
ops->unresolved_rules++; ops->unresolved_rules++;
...@@ -498,7 +498,7 @@ static int dump_rules(struct sk_buff *skb, struct netlink_callback *cb, ...@@ -498,7 +498,7 @@ static int dump_rules(struct sk_buff *skb, struct netlink_callback *cb,
int idx = 0; int idx = 0;
struct fib_rule *rule; 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]) if (idx < cb->args[1])
goto skip; goto skip;
...@@ -608,12 +608,12 @@ static int fib_rules_event(struct notifier_block *this, unsigned long event, ...@@ -608,12 +608,12 @@ static int fib_rules_event(struct notifier_block *this, unsigned long event,
switch (event) { switch (event) {
case NETDEV_REGISTER: case NETDEV_REGISTER:
list_for_each_entry(ops, &rules_ops, list) list_for_each_entry(ops, &rules_ops, list)
attach_rules(ops->rules_list, dev); attach_rules(&ops->rules_list, dev);
break; break;
case NETDEV_UNREGISTER: case NETDEV_UNREGISTER:
list_for_each_entry(ops, &rules_ops, list) list_for_each_entry(ops, &rules_ops, list)
detach_rules(ops->rules_list, dev); detach_rules(&ops->rules_list, dev);
break; break;
} }
......
...@@ -57,8 +57,6 @@ static struct dn_fib_rule default_rule = { ...@@ -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) int dn_fib_lookup(struct flowi *flp, struct dn_fib_res *res)
{ {
...@@ -228,9 +226,9 @@ static u32 dn_fib_rule_default_pref(void) ...@@ -228,9 +226,9 @@ static u32 dn_fib_rule_default_pref(void)
struct list_head *pos; struct list_head *pos;
struct fib_rule *rule; struct fib_rule *rule;
if (!list_empty(&dn_fib_rules)) { if (!list_empty(&dn_fib_rules_ops.rules_list)) {
pos = dn_fib_rules.next; pos = dn_fib_rules_ops.rules_list.next;
if (pos->next != &dn_fib_rules) { if (pos->next != &dn_fib_rules_ops.rules_list) {
rule = list_entry(pos->next, struct fib_rule, list); rule = list_entry(pos->next, struct fib_rule, list);
if (rule->pref) if (rule->pref)
return rule->pref - 1; return rule->pref - 1;
...@@ -258,13 +256,14 @@ static struct fib_rules_ops dn_fib_rules_ops = { ...@@ -258,13 +256,14 @@ static struct fib_rules_ops dn_fib_rules_ops = {
.flush_cache = dn_fib_rule_flush_cache, .flush_cache = dn_fib_rule_flush_cache,
.nlgroup = RTNLGRP_DECnet_RULE, .nlgroup = RTNLGRP_DECnet_RULE,
.policy = dn_fib_rule_policy, .policy = dn_fib_rule_policy,
.rules_list = &dn_fib_rules, .rules_list = LIST_HEAD_INIT(dn_fib_rules_ops.rules_list),
.owner = THIS_MODULE, .owner = THIS_MODULE,
}; };
void __init dn_fib_rules_init(void) 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); fib_rules_register(&dn_fib_rules_ops);
} }
......
...@@ -76,8 +76,6 @@ static struct fib4_rule local_rule = { ...@@ -76,8 +76,6 @@ static struct fib4_rule local_rule = {
}, },
}; };
static LIST_HEAD(fib4_rules);
#ifdef CONFIG_NET_CLS_ROUTE #ifdef CONFIG_NET_CLS_ROUTE
u32 fib_rules_tclass(struct fib_result *res) u32 fib_rules_tclass(struct fib_result *res)
{ {
...@@ -279,9 +277,9 @@ static u32 fib4_rule_default_pref(void) ...@@ -279,9 +277,9 @@ static u32 fib4_rule_default_pref(void)
struct list_head *pos; struct list_head *pos;
struct fib_rule *rule; struct fib_rule *rule;
if (!list_empty(&fib4_rules)) { if (!list_empty(&fib4_rules_ops.rules_list)) {
pos = fib4_rules.next; pos = fib4_rules_ops.rules_list.next;
if (pos->next != &fib4_rules) { if (pos->next != &fib4_rules_ops.rules_list) {
rule = list_entry(pos->next, struct fib_rule, list); rule = list_entry(pos->next, struct fib_rule, list);
if (rule->pref) if (rule->pref)
return rule->pref - 1; return rule->pref - 1;
...@@ -317,15 +315,15 @@ static struct fib_rules_ops fib4_rules_ops = { ...@@ -317,15 +315,15 @@ static struct fib_rules_ops fib4_rules_ops = {
.flush_cache = fib4_rule_flush_cache, .flush_cache = fib4_rule_flush_cache,
.nlgroup = RTNLGRP_IPV4_RULE, .nlgroup = RTNLGRP_IPV4_RULE,
.policy = fib4_rule_policy, .policy = fib4_rule_policy,
.rules_list = &fib4_rules, .rules_list = LIST_HEAD_INIT(fib4_rules_ops.rules_list),
.owner = THIS_MODULE, .owner = THIS_MODULE,
}; };
void __init fib4_rules_init(void) void __init fib4_rules_init(void)
{ {
list_add_tail(&local_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); list_add_tail(&main_rule.common.list, &fib4_rules_ops.rules_list);
list_add_tail(&default_rule.common.list, &fib4_rules); list_add_tail(&default_rule.common.list, &fib4_rules_ops.rules_list);
fib_rules_register(&fib4_rules_ops); fib_rules_register(&fib4_rules_ops);
} }
...@@ -50,8 +50,6 @@ static struct fib6_rule local_rule = { ...@@ -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, struct dst_entry *fib6_rule_lookup(struct flowi *fl, int flags,
pol_lookup_t lookup) pol_lookup_t lookup)
{ {
...@@ -268,14 +266,14 @@ static struct fib_rules_ops fib6_rules_ops = { ...@@ -268,14 +266,14 @@ static struct fib_rules_ops fib6_rules_ops = {
.nlmsg_payload = fib6_rule_nlmsg_payload, .nlmsg_payload = fib6_rule_nlmsg_payload,
.nlgroup = RTNLGRP_IPV6_RULE, .nlgroup = RTNLGRP_IPV6_RULE,
.policy = fib6_rule_policy, .policy = fib6_rule_policy,
.rules_list = &fib6_rules, .rules_list = LIST_HEAD_INIT(fib6_rules_ops.rules_list),
.owner = THIS_MODULE, .owner = THIS_MODULE,
}; };
void __init fib6_rules_init(void) void __init fib6_rules_init(void)
{ {
list_add_tail(&local_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); list_add_tail(&main_rule.common.list, &fib6_rules_ops.rules_list);
fib_rules_register(&fib6_rules_ops); fib_rules_register(&fib6_rules_ops);
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment