netfilter: xtables: shorten up return clause
[linux-2.6-microblaze.git] / net / ipv4 / netfilter / ipt_CLUSTERIP.c
index 40ca2d2..5d70c43 100644 (file)
@@ -9,6 +9,7 @@
  * published by the Free Software Foundation.
  *
  */
+#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
 #include <linux/module.h>
 #include <linux/proc_fs.h>
 #include <linux/jhash.h>
@@ -238,8 +239,7 @@ clusterip_hashfn(const struct sk_buff *skb,
                break;
        default:
                if (net_ratelimit())
-                       printk(KERN_NOTICE "CLUSTERIP: unknown protocol `%u'\n",
-                               iph->protocol);
+                       pr_info("unknown protocol %u\n", iph->protocol);
                sport = dport = 0;
        }
 
@@ -261,7 +261,7 @@ clusterip_hashfn(const struct sk_buff *skb,
                hashval = 0;
                /* This cannot happen, unless the check function wasn't called
                 * at rule load time */
-               printk("CLUSTERIP: unknown mode `%u'\n", config->hash_mode);
+               pr_info("unknown mode %u\n", config->hash_mode);
                BUG();
                break;
        }
@@ -294,7 +294,7 @@ clusterip_tg(struct sk_buff *skb, const struct xt_target_param *par)
 
        ct = nf_ct_get(skb, &ctinfo);
        if (ct == NULL) {
-               printk(KERN_ERR "CLUSTERIP: no conntrack!\n");
+               pr_info("no conntrack!\n");
                        /* FIXME: need to drop invalid ones, since replies
                         * to outgoing connections of other nodes will be
                         * marked as INVALID */
@@ -347,25 +347,24 @@ clusterip_tg(struct sk_buff *skb, const struct xt_target_param *par)
        return XT_CONTINUE;
 }
 
-static bool clusterip_tg_check(const struct xt_tgchk_param *par)
+static int clusterip_tg_check(const struct xt_tgchk_param *par)
 {
        struct ipt_clusterip_tgt_info *cipinfo = par->targinfo;
        const struct ipt_entry *e = par->entryinfo;
-
        struct clusterip_config *config;
+       int ret;
 
        if (cipinfo->hash_mode != CLUSTERIP_HASHMODE_SIP &&
            cipinfo->hash_mode != CLUSTERIP_HASHMODE_SIP_SPT &&
            cipinfo->hash_mode != CLUSTERIP_HASHMODE_SIP_SPT_DPT) {
-               printk(KERN_WARNING "CLUSTERIP: unknown mode `%u'\n",
-                       cipinfo->hash_mode);
-               return false;
+               pr_info("unknown mode %u\n", cipinfo->hash_mode);
+               return -EINVAL;
 
        }
        if (e->ip.dmsk.s_addr != htonl(0xffffffff) ||
            e->ip.dst.s_addr == 0) {
-               printk(KERN_ERR "CLUSTERIP: Please specify destination IP\n");
-               return false;
+               pr_info("Please specify destination IP\n");
+               return -EINVAL;
        }
 
        /* FIXME: further sanity checks */
@@ -373,41 +372,41 @@ static bool clusterip_tg_check(const struct xt_tgchk_param *par)
        config = clusterip_config_find_get(e->ip.dst.s_addr, 1);
        if (!config) {
                if (!(cipinfo->flags & CLUSTERIP_FLAG_NEW)) {
-                       printk(KERN_WARNING "CLUSTERIP: no config found for %pI4, need 'new'\n", &e->ip.dst.s_addr);
-                       return false;
+                       pr_info("no config found for %pI4, need 'new'\n",
+                               &e->ip.dst.s_addr);
+                       return -EINVAL;
                } else {
                        struct net_device *dev;
 
                        if (e->ip.iniface[0] == '\0') {
-                               printk(KERN_WARNING "CLUSTERIP: Please specify an interface name\n");
-                               return false;
+                               pr_info("Please specify an interface name\n");
+                               return -EINVAL;
                        }
 
                        dev = dev_get_by_name(&init_net, e->ip.iniface);
                        if (!dev) {
-                               printk(KERN_WARNING "CLUSTERIP: no such interface %s\n", e->ip.iniface);
-                               return false;
+                               pr_info("no such interface %s\n",
+                                       e->ip.iniface);
+                               return -ENOENT;
                        }
 
                        config = clusterip_config_init(cipinfo,
                                                        e->ip.dst.s_addr, dev);
                        if (!config) {
-                               printk(KERN_WARNING "CLUSTERIP: cannot allocate config\n");
+                               pr_info("cannot allocate config\n");
                                dev_put(dev);
-                               return false;
+                               return -ENOMEM;
                        }
                        dev_mc_add(config->dev,config->clustermac, ETH_ALEN, 0);
                }
        }
        cipinfo->config = config;
 
-       if (nf_ct_l3proto_try_module_get(par->target->family) < 0) {
-               printk(KERN_WARNING "can't load conntrack support for "
-                                   "proto=%u\n", par->target->family);
-               return false;
-       }
-
-       return true;
+       ret = nf_ct_l3proto_try_module_get(par->family);
+       if (ret < 0)
+               pr_info("cannot load conntrack support for proto=%u\n",
+                       par->family);
+       return ret;
 }
 
 /* drop reference count of cluster config when rule is deleted */
@@ -421,7 +420,7 @@ static void clusterip_tg_destroy(const struct xt_tgdtor_param *par)
 
        clusterip_config_put(cipinfo->config);
 
-       nf_ct_l3proto_module_put(par->target->family);
+       nf_ct_l3proto_module_put(par->family);
 }
 
 #ifdef CONFIG_COMPAT
@@ -478,8 +477,8 @@ static void arp_print(struct arp_payload *payload)
        }
        hbuffer[--k]='\0';
 
-       printk("src %pI4@%s, dst %pI4\n",
-               &payload->src_ip, hbuffer, &payload->dst_ip);
+       pr_debug("src %pI4@%s, dst %pI4\n",
+                &payload->src_ip, hbuffer, &payload->dst_ip);
 }
 #endif
 
@@ -518,7 +517,7 @@ arp_mangle(unsigned int hook,
         * this wouldn't work, since we didn't subscribe the mcast group on
         * other interfaces */
        if (c->dev != out) {
-               pr_debug("CLUSTERIP: not mangling arp reply on different "
+               pr_debug("not mangling arp reply on different "
                         "interface: cip'%s'-skb'%s'\n",
                         c->dev->name, out->name);
                clusterip_config_put(c);
@@ -529,7 +528,7 @@ arp_mangle(unsigned int hook,
        memcpy(payload->src_hw, c->clustermac, arp->ar_hln);
 
 #ifdef DEBUG
-       pr_debug(KERN_DEBUG "CLUSTERIP mangled arp reply: ");
+       pr_debug("mangled arp reply: ");
        arp_print(payload);
 #endif
 
@@ -560,8 +559,7 @@ struct clusterip_seq_position {
 
 static void *clusterip_seq_start(struct seq_file *s, loff_t *pos)
 {
-       const struct proc_dir_entry *pde = s->private;
-       struct clusterip_config *c = pde->data;
+       struct clusterip_config *c = s->private;
        unsigned int weight;
        u_int32_t local_nodes;
        struct clusterip_seq_position *idx;
@@ -632,10 +630,9 @@ static int clusterip_proc_open(struct inode *inode, struct file *file)
 
        if (!ret) {
                struct seq_file *sf = file->private_data;
-               struct proc_dir_entry *pde = PDE(inode);
-               struct clusterip_config *c = pde->data;
+               struct clusterip_config *c = PDE(inode)->data;
 
-               sf->private = pde;
+               sf->private = c;
 
                clusterip_config_get(c);
        }
@@ -645,8 +642,7 @@ static int clusterip_proc_open(struct inode *inode, struct file *file)
 
 static int clusterip_proc_release(struct inode *inode, struct file *file)
 {
-       struct proc_dir_entry *pde = PDE(inode);
-       struct clusterip_config *c = pde->data;
+       struct clusterip_config *c = PDE(inode)->data;
        int ret;
 
        ret = seq_release(inode, file);
@@ -660,10 +656,9 @@ static int clusterip_proc_release(struct inode *inode, struct file *file)
 static ssize_t clusterip_proc_write(struct file *file, const char __user *input,
                                size_t size, loff_t *ofs)
 {
+       struct clusterip_config *c = PDE(file->f_path.dentry->d_inode)->data;
 #define PROC_WRITELEN  10
        char buffer[PROC_WRITELEN+1];
-       const struct proc_dir_entry *pde = PDE(file->f_path.dentry->d_inode);
-       struct clusterip_config *c = pde->data;
        unsigned long nodenum;
 
        if (copy_from_user(buffer, input, PROC_WRITELEN))
@@ -709,13 +704,13 @@ static int __init clusterip_tg_init(void)
 #ifdef CONFIG_PROC_FS
        clusterip_procdir = proc_mkdir("ipt_CLUSTERIP", init_net.proc_net);
        if (!clusterip_procdir) {
-               printk(KERN_ERR "CLUSTERIP: Unable to proc dir entry\n");
+               pr_err("Unable to proc dir entry\n");
                ret = -ENOMEM;
                goto cleanup_hook;
        }
 #endif /* CONFIG_PROC_FS */
 
-       printk(KERN_NOTICE "ClusterIP Version %s loaded successfully\n",
+       pr_info("ClusterIP Version %s loaded successfully\n",
                CLUSTERIP_VERSION);
        return 0;
 
@@ -730,8 +725,7 @@ cleanup_target:
 
 static void __exit clusterip_tg_exit(void)
 {
-       printk(KERN_NOTICE "ClusterIP Version %s unloading\n",
-               CLUSTERIP_VERSION);
+       pr_info("ClusterIP Version %s unloading\n", CLUSTERIP_VERSION);
 #ifdef CONFIG_PROC_FS
        remove_proc_entry(clusterip_procdir->name, clusterip_procdir->parent);
 #endif