]> git.proxmox.com Git - mirror_ubuntu-artful-kernel.git/commitdiff
netfilter: ipt_CLUSTERIP: switch to nf_register_net_hook
authorFlorian Westphal <fw@strlen.de>
Wed, 17 May 2017 09:25:31 +0000 (11:25 +0200)
committerPablo Neira Ayuso <pablo@netfilter.org>
Mon, 29 May 2017 09:32:35 +0000 (11:32 +0200)
one of the last remaining users of the old api, hopefully followup commit
can remove it soon.

Signed-off-by: Florian Westphal <fw@strlen.de>
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
net/ipv4/netfilter/ipt_CLUSTERIP.c

index 038f293c23766de6cd77f361269743498c2dd18e..f30bee8e407b5a0c46f8430dc6a89ad24d69ad1a 100644 (file)
@@ -743,14 +743,20 @@ static const struct file_operations clusterip_proc_fops = {
 static int clusterip_net_init(struct net *net)
 {
        struct clusterip_net *cn = net_generic(net, clusterip_net_id);
+       int ret;
 
        INIT_LIST_HEAD(&cn->configs);
 
        spin_lock_init(&cn->lock);
 
+       ret = nf_register_net_hook(net, &cip_arp_ops);
+       if (ret < 0)
+               return ret;
+
 #ifdef CONFIG_PROC_FS
        cn->procdir = proc_mkdir("ipt_CLUSTERIP", net->proc_net);
        if (!cn->procdir) {
+               nf_unregister_net_hook(net, &cip_arp_ops);
                pr_err("Unable to proc dir entry\n");
                return -ENOMEM;
        }
@@ -765,6 +771,7 @@ static void clusterip_net_exit(struct net *net)
        struct clusterip_net *cn = net_generic(net, clusterip_net_id);
        proc_remove(cn->procdir);
 #endif
+       nf_unregister_net_hook(net, &cip_arp_ops);
 }
 
 static struct pernet_operations clusterip_net_ops = {
@@ -786,17 +793,11 @@ static int __init clusterip_tg_init(void)
        if (ret < 0)
                goto cleanup_subsys;
 
-       ret = nf_register_hook(&cip_arp_ops);
-       if (ret < 0)
-               goto cleanup_target;
-
        pr_info("ClusterIP Version %s loaded successfully\n",
                CLUSTERIP_VERSION);
 
        return 0;
 
-cleanup_target:
-       xt_unregister_target(&clusterip_tg_reg);
 cleanup_subsys:
        unregister_pernet_subsys(&clusterip_net_ops);
        return ret;
@@ -806,7 +807,6 @@ static void __exit clusterip_tg_exit(void)
 {
        pr_info("ClusterIP Version %s unloading\n", CLUSTERIP_VERSION);
 
-       nf_unregister_hook(&cip_arp_ops);
        xt_unregister_target(&clusterip_tg_reg);
        unregister_pernet_subsys(&clusterip_net_ops);