]> git.proxmox.com Git - mirror_ubuntu-artful-kernel.git/blobdiff - net/core/fib_rules.c
net: Kill hold_net release_net
[mirror_ubuntu-artful-kernel.git] / net / core / fib_rules.c
index 44706e81b2e03df3e9d39c1cd76879a4ede48d1e..68ea6950cad1f646906cf45ba78819447a8618eb 100644 (file)
@@ -31,7 +31,7 @@ int fib_default_rule_add(struct fib_rules_ops *ops,
        r->pref = pref;
        r->table = table;
        r->flags = flags;
-       r->fr_net = hold_net(ops->fro_net);
+       r->fr_net = ops->fro_net;
 
        r->suppress_prefixlen = -1;
        r->suppress_ifgroup = -1;
@@ -116,7 +116,6 @@ static int __fib_rules_register(struct fib_rules_ops *ops)
                if (ops->family == o->family)
                        goto errout;
 
-       hold_net(net);
        list_add_tail_rcu(&ops->list, &net->rules_ops);
        err = 0;
 errout:
@@ -160,15 +159,6 @@ static void fib_rules_cleanup_ops(struct fib_rules_ops *ops)
        }
 }
 
-static void fib_rules_put_rcu(struct rcu_head *head)
-{
-       struct fib_rules_ops *ops = container_of(head, struct fib_rules_ops, rcu);
-       struct net *net = ops->fro_net;
-
-       release_net(net);
-       kfree(ops);
-}
-
 void fib_rules_unregister(struct fib_rules_ops *ops)
 {
        struct net *net = ops->fro_net;
@@ -178,7 +168,7 @@ void fib_rules_unregister(struct fib_rules_ops *ops)
        fib_rules_cleanup_ops(ops);
        spin_unlock(&net->rules_mod_lock);
 
-       call_rcu(&ops->rcu, fib_rules_put_rcu);
+       kfree_rcu(ops, rcu);
 }
 EXPORT_SYMBOL_GPL(fib_rules_unregister);
 
@@ -303,7 +293,7 @@ static int fib_nl_newrule(struct sk_buff *skb, struct nlmsghdr* nlh)
                err = -ENOMEM;
                goto errout;
        }
-       rule->fr_net = hold_net(net);
+       rule->fr_net = net;
 
        if (tb[FRA_PRIORITY])
                rule->pref = nla_get_u32(tb[FRA_PRIORITY]);
@@ -423,7 +413,6 @@ static int fib_nl_newrule(struct sk_buff *skb, struct nlmsghdr* nlh)
        return 0;
 
 errout_free:
-       release_net(rule->fr_net);
        kfree(rule);
 errout:
        rules_ops_put(ops);
@@ -492,6 +481,12 @@ static int fib_nl_delrule(struct sk_buff *skb, struct nlmsghdr* nlh)
                        goto errout;
                }
 
+               if (ops->delete) {
+                       err = ops->delete(rule);
+                       if (err)
+                               goto errout;
+               }
+
                list_del_rcu(&rule->list);
 
                if (rule->action == FR_ACT_GOTO) {
@@ -517,8 +512,6 @@ static int fib_nl_delrule(struct sk_buff *skb, struct nlmsghdr* nlh)
 
                notify_rule_change(RTM_DELRULE, rule, ops, nlh,
                                   NETLINK_CB(skb).portid);
-               if (ops->delete)
-                       ops->delete(rule);
                fib_rule_put(rule);
                flush_route_cache(ops);
                rules_ops_put(ops);