netfilter: xtables: move extension arguments into compound structure (4/6)
[linux-2.6-block.git] / net / ipv4 / netfilter / arp_tables.c
index 03e83a65aec5eca5dab1b1c99401c3ac40985ed2..5b631ad74b5fd03db9b2f25fff0515cd434e51dd 100644 (file)
@@ -200,15 +200,12 @@ static inline int arp_checkentry(const struct arpt_arp *arp)
        return 1;
 }
 
-static unsigned int arpt_error(struct sk_buff *skb,
-                              const struct net_device *in,
-                              const struct net_device *out,
-                              unsigned int hooknum,
-                              const struct xt_target *target,
-                              const void *targinfo)
+static unsigned int
+arpt_error(struct sk_buff *skb, const struct xt_target_param *par)
 {
        if (net_ratelimit())
-               printk("arp_tables: error: '%s'\n", (char *)targinfo);
+               printk("arp_tables: error: '%s'\n",
+                      (const char *)par->targinfo);
 
        return NF_DROP;
 }
@@ -232,6 +229,7 @@ unsigned int arpt_do_table(struct sk_buff *skb,
        const char *indev, *outdev;
        void *table_base;
        const struct xt_table_info *private;
+       struct xt_target_param tgpar;
 
        if (!pskb_may_pull(skb, arp_hdr_len(skb->dev)))
                return NF_DROP;
@@ -245,6 +243,10 @@ unsigned int arpt_do_table(struct sk_buff *skb,
        e = get_entry(table_base, private->hook_entry[hook]);
        back = get_entry(table_base, private->underflow[hook]);
 
+       tgpar.in      = in;
+       tgpar.out     = out;
+       tgpar.hooknum = hook;
+
        arp = arp_hdr(skb);
        do {
                if (arp_packet_match(arp, skb->dev, indev, outdev, &e->arp)) {
@@ -290,11 +292,10 @@ unsigned int arpt_do_table(struct sk_buff *skb,
                                /* Targets which reenter must return
                                 * abs. verdicts
                                 */
+                               tgpar.target   = t->u.kernel.target;
+                               tgpar.targinfo = t->data;
                                verdict = t->u.kernel.target->target(skb,
-                                                                    in, out,
-                                                                    hook,
-                                                                    t->u.kernel.target,
-                                                                    t->data);
+                                                                    &tgpar);
 
                                /* Target might have changed stuff. */
                                arp = arp_hdr(skb);
@@ -463,16 +464,15 @@ static inline int check_target(struct arpt_entry *e, const char *name)
        t = arpt_get_target(e);
        target = t->u.kernel.target;
 
-       ret = xt_check_target(target, NF_ARP, t->u.target_size - sizeof(*t),
-                             name, e->comefrom, 0, 0);
-       if (!ret && t->u.kernel.target->checkentry
-           && !t->u.kernel.target->checkentry(name, e, target, t->data,
-                                              e->comefrom)) {
+       ret = xt_check_target(target, NFPROTO_ARP,
+                             t->u.target_size - sizeof(*t),
+                             name, e->comefrom, 0, 0, e, t->data);
+       if (ret < 0) {
                duprintf("arp_tables: check failed for `%s'.\n",
                         t->u.kernel.target->name);
-               ret = -EINVAL;
+               return ret;
        }
-       return ret;
+       return 0;
 }
 
 static inline int
@@ -488,7 +488,8 @@ find_check_entry(struct arpt_entry *e, const char *name, unsigned int size,
                return ret;
 
        t = arpt_get_target(e);
-       target = try_then_request_module(xt_find_target(NF_ARP, t->u.user.name,
+       target = try_then_request_module(xt_find_target(NFPROTO_ARP,
+                                                       t->u.user.name,
                                                        t->u.user.revision),
                                         "arpt_%s", t->u.user.name);
        if (IS_ERR(target) || !target) {
@@ -788,7 +789,7 @@ static void compat_standard_from_user(void *dst, void *src)
        int v = *(compat_int_t *)src;
 
        if (v > 0)
-               v += xt_compat_calc_jump(NF_ARP, v);
+               v += xt_compat_calc_jump(NFPROTO_ARP, v);
        memcpy(dst, &v, sizeof(v));
 }
 
@@ -797,7 +798,7 @@ static int compat_standard_to_user(void __user *dst, void *src)
        compat_int_t cv = *(int *)src;
 
        if (cv > 0)
-               cv -= xt_compat_calc_jump(NF_ARP, cv);
+               cv -= xt_compat_calc_jump(NFPROTO_ARP, cv);
        return copy_to_user(dst, &cv, sizeof(cv)) ? -EFAULT : 0;
 }
 
@@ -815,7 +816,7 @@ static int compat_calc_entry(struct arpt_entry *e,
        t = arpt_get_target(e);
        off += xt_compat_target_offset(t->u.kernel.target);
        newinfo->size -= off;
-       ret = xt_compat_add_offset(NF_ARP, entry_offset, off);
+       ret = xt_compat_add_offset(NFPROTO_ARP, entry_offset, off);
        if (ret)
                return ret;
 
@@ -866,9 +867,9 @@ static int get_info(struct net *net, void __user *user, int *len, int compat)
        name[ARPT_TABLE_MAXNAMELEN-1] = '\0';
 #ifdef CONFIG_COMPAT
        if (compat)
-               xt_compat_lock(NF_ARP);
+               xt_compat_lock(NFPROTO_ARP);
 #endif
-       t = try_then_request_module(xt_find_table_lock(net, NF_ARP, name),
+       t = try_then_request_module(xt_find_table_lock(net, NFPROTO_ARP, name),
                                    "arptable_%s", name);
        if (t && !IS_ERR(t)) {
                struct arpt_getinfo info;
@@ -878,7 +879,7 @@ static int get_info(struct net *net, void __user *user, int *len, int compat)
                if (compat) {
                        struct xt_table_info tmp;
                        ret = compat_table_info(private, &tmp);
-                       xt_compat_flush_offsets(NF_ARP);
+                       xt_compat_flush_offsets(NFPROTO_ARP);
                        private = &tmp;
                }
 #endif
@@ -901,7 +902,7 @@ static int get_info(struct net *net, void __user *user, int *len, int compat)
                ret = t ? PTR_ERR(t) : -ENOENT;
 #ifdef CONFIG_COMPAT
        if (compat)
-               xt_compat_unlock(NF_ARP);
+               xt_compat_unlock(NFPROTO_ARP);
 #endif
        return ret;
 }
@@ -925,7 +926,7 @@ static int get_entries(struct net *net, struct arpt_get_entries __user *uptr,
                return -EINVAL;
        }
 
-       t = xt_find_table_lock(net, NF_ARP, get.name);
+       t = xt_find_table_lock(net, NFPROTO_ARP, get.name);
        if (t && !IS_ERR(t)) {
                const struct xt_table_info *private = t->private;
 
@@ -967,7 +968,7 @@ static int __do_replace(struct net *net, const char *name,
                goto out;
        }
 
-       t = try_then_request_module(xt_find_table_lock(net, NF_ARP, name),
+       t = try_then_request_module(xt_find_table_lock(net, NFPROTO_ARP, name),
                                    "arptable_%s", name);
        if (!t || IS_ERR(t)) {
                ret = t ? PTR_ERR(t) : -ENOENT;
@@ -1134,7 +1135,7 @@ static int do_add_counters(struct net *net, void __user *user, unsigned int len,
                goto free;
        }
 
-       t = xt_find_table_lock(net, NF_ARP, name);
+       t = xt_find_table_lock(net, NFPROTO_ARP, name);
        if (!t || IS_ERR(t)) {
                ret = t ? PTR_ERR(t) : -ENOENT;
                goto free;
@@ -1218,7 +1219,7 @@ check_compat_entry_size_and_hooks(struct compat_arpt_entry *e,
        entry_offset = (void *)e - (void *)base;
 
        t = compat_arpt_get_target(e);
-       target = try_then_request_module(xt_find_target(NF_ARP,
+       target = try_then_request_module(xt_find_target(NFPROTO_ARP,
                                                        t->u.user.name,
                                                        t->u.user.revision),
                                         "arpt_%s", t->u.user.name);
@@ -1232,7 +1233,7 @@ check_compat_entry_size_and_hooks(struct compat_arpt_entry *e,
 
        off += xt_compat_target_offset(target);
        *size += off;
-       ret = xt_compat_add_offset(NF_ARP, entry_offset, off);
+       ret = xt_compat_add_offset(NFPROTO_ARP, entry_offset, off);
        if (ret)
                goto release_target;
 
@@ -1333,7 +1334,7 @@ static int translate_compat_table(const char *name,
 
        duprintf("translate_compat_table: size %u\n", info->size);
        j = 0;
-       xt_compat_lock(NF_ARP);
+       xt_compat_lock(NFPROTO_ARP);
        /* Walk through entries, checking offsets. */
        ret = COMPAT_ARPT_ENTRY_ITERATE(entry0, total_size,
                                        check_compat_entry_size_and_hooks,
@@ -1383,8 +1384,8 @@ static int translate_compat_table(const char *name,
        ret = COMPAT_ARPT_ENTRY_ITERATE(entry0, total_size,
                                        compat_copy_entry_from_user,
                                        &pos, &size, name, newinfo, entry1);
-       xt_compat_flush_offsets(NF_ARP);
-       xt_compat_unlock(NF_ARP);
+       xt_compat_flush_offsets(NFPROTO_ARP);
+       xt_compat_unlock(NFPROTO_ARP);
        if (ret)
                goto free_newinfo;
 
@@ -1420,8 +1421,8 @@ out:
        COMPAT_ARPT_ENTRY_ITERATE(entry0, total_size, compat_release_entry, &j);
        return ret;
 out_unlock:
-       xt_compat_flush_offsets(NF_ARP);
-       xt_compat_unlock(NF_ARP);
+       xt_compat_flush_offsets(NFPROTO_ARP);
+       xt_compat_unlock(NFPROTO_ARP);
        goto out;
 }
 
@@ -1607,8 +1608,8 @@ static int compat_get_entries(struct net *net,
                return -EINVAL;
        }
 
-       xt_compat_lock(NF_ARP);
-       t = xt_find_table_lock(net, NF_ARP, get.name);
+       xt_compat_lock(NFPROTO_ARP);
+       t = xt_find_table_lock(net, NFPROTO_ARP, get.name);
        if (t && !IS_ERR(t)) {
                const struct xt_table_info *private = t->private;
                struct xt_table_info info;
@@ -1623,13 +1624,13 @@ static int compat_get_entries(struct net *net,
                                 private->size, get.size);
                        ret = -EAGAIN;
                }
-               xt_compat_flush_offsets(NF_ARP);
+               xt_compat_flush_offsets(NFPROTO_ARP);
                module_put(t->me);
                xt_table_unlock(t);
        } else
                ret = t ? PTR_ERR(t) : -ENOENT;
 
-       xt_compat_unlock(NF_ARP);
+       xt_compat_unlock(NFPROTO_ARP);
        return ret;
 }
 
@@ -1709,7 +1710,7 @@ static int do_arpt_get_ctl(struct sock *sk, int cmd, void __user *user, int *len
                        break;
                }
 
-               try_then_request_module(xt_find_revision(NF_ARP, rev.name,
+               try_then_request_module(xt_find_revision(NFPROTO_ARP, rev.name,
                                                         rev.revision, 1, &ret),
                                        "arpt_%s", rev.name);
                break;
@@ -1787,7 +1788,7 @@ void arpt_unregister_table(struct xt_table *table)
 static struct xt_target arpt_standard_target __read_mostly = {
        .name           = ARPT_STANDARD_TARGET,
        .targetsize     = sizeof(int),
-       .family         = NF_ARP,
+       .family         = NFPROTO_ARP,
 #ifdef CONFIG_COMPAT
        .compatsize     = sizeof(compat_int_t),
        .compat_from_user = compat_standard_from_user,
@@ -1799,7 +1800,7 @@ static struct xt_target arpt_error_target __read_mostly = {
        .name           = ARPT_ERROR_TARGET,
        .target         = arpt_error,
        .targetsize     = ARPT_FUNCTION_MAXNAMELEN,
-       .family         = NF_ARP,
+       .family         = NFPROTO_ARP,
 };
 
 static struct nf_sockopt_ops arpt_sockopts = {
@@ -1821,12 +1822,12 @@ static struct nf_sockopt_ops arpt_sockopts = {
 
 static int __net_init arp_tables_net_init(struct net *net)
 {
-       return xt_proto_init(net, NF_ARP);
+       return xt_proto_init(net, NFPROTO_ARP);
 }
 
 static void __net_exit arp_tables_net_exit(struct net *net)
 {
-       xt_proto_fini(net, NF_ARP);
+       xt_proto_fini(net, NFPROTO_ARP);
 }
 
 static struct pernet_operations arp_tables_net_ops = {