]> git.proxmox.com Git - mirror_ubuntu-artful-kernel.git/blobdiff - net/ipv6/netfilter/ip6_tables.c
netfilter: x_tables: pass xt_counters struct to counter allocator
[mirror_ubuntu-artful-kernel.git] / net / ipv6 / netfilter / ip6_tables.c
index 55aacea24396dc17d429896c5ff77e5e8162a52e..a5a92083fd626f821fdd6d9315d47e739eebc168 100644 (file)
@@ -291,11 +291,7 @@ ip6t_do_table(struct sk_buff *skb,
         * rule is also a fragment-specific rule, non-fragments won't
         * match it. */
        acpar.hotdrop = false;
-       acpar.net     = state->net;
-       acpar.in      = state->in;
-       acpar.out     = state->out;
-       acpar.family  = NFPROTO_IPV6;
-       acpar.hooknum = hook;
+       acpar.state   = state;
 
        IP_NF_ASSERT(table->valid_hooks & (1 << hook));
 
@@ -574,12 +570,9 @@ find_check_entry(struct ip6t_entry *e, struct net *net, const char *name,
        unsigned int j;
        struct xt_mtchk_param mtpar;
        struct xt_entry_match *ematch;
-       unsigned long pcnt;
 
-       pcnt = xt_percpu_counter_alloc();
-       if (IS_ERR_VALUE(pcnt))
+       if (!xt_percpu_counter_alloc(&e->counters))
                return -ENOMEM;
-       e->counters.pcnt = pcnt;
 
        j = 0;
        mtpar.net       = net;
@@ -616,7 +609,7 @@ find_check_entry(struct ip6t_entry *e, struct net *net, const char *name,
                cleanup_match(ematch, net);
        }
 
-       xt_percpu_counter_free(e->counters.pcnt);
+       xt_percpu_counter_free(&e->counters);
 
        return ret;
 }
@@ -703,8 +696,7 @@ static void cleanup_entry(struct ip6t_entry *e, struct net *net)
        if (par.target->destroy != NULL)
                par.target->destroy(&par);
        module_put(par.target->me);
-
-       xt_percpu_counter_free(e->counters.pcnt);
+       xt_percpu_counter_free(&e->counters);
 }
 
 /* Checks and translates the user-supplied table segment (held in
@@ -1007,7 +999,7 @@ static int get_info(struct net *net, void __user *user,
 #endif
        t = try_then_request_module(xt_find_table_lock(net, AF_INET6, name),
                                    "ip6table_%s", name);
-       if (!IS_ERR_OR_NULL(t)) {
+       if (t) {
                struct ip6t_getinfo info;
                const struct xt_table_info *private = t->private;
 #ifdef CONFIG_COMPAT
@@ -1037,7 +1029,7 @@ static int get_info(struct net *net, void __user *user,
                xt_table_unlock(t);
                module_put(t->me);
        } else
-               ret = t ? PTR_ERR(t) : -ENOENT;
+               ret = -ENOENT;
 #ifdef CONFIG_COMPAT
        if (compat)
                xt_compat_unlock(AF_INET6);
@@ -1063,7 +1055,7 @@ get_entries(struct net *net, struct ip6t_get_entries __user *uptr,
        get.name[sizeof(get.name) - 1] = '\0';
 
        t = xt_find_table_lock(net, AF_INET6, get.name);
-       if (!IS_ERR_OR_NULL(t)) {
+       if (t) {
                struct xt_table_info *private = t->private;
                if (get.size == private->size)
                        ret = copy_entries_to_user(private->size,
@@ -1074,7 +1066,7 @@ get_entries(struct net *net, struct ip6t_get_entries __user *uptr,
                module_put(t->me);
                xt_table_unlock(t);
        } else
-               ret = t ? PTR_ERR(t) : -ENOENT;
+               ret = -ENOENT;
 
        return ret;
 }
@@ -1099,8 +1091,8 @@ __do_replace(struct net *net, const char *name, unsigned int valid_hooks,
 
        t = try_then_request_module(xt_find_table_lock(net, AF_INET6, name),
                                    "ip6table_%s", name);
-       if (IS_ERR_OR_NULL(t)) {
-               ret = t ? PTR_ERR(t) : -ENOENT;
+       if (!t) {
+               ret = -ENOENT;
                goto free_newinfo_counters_untrans;
        }
 
@@ -1214,8 +1206,8 @@ do_add_counters(struct net *net, const void __user *user, unsigned int len,
        if (IS_ERR(paddc))
                return PTR_ERR(paddc);
        t = xt_find_table_lock(net, AF_INET6, tmp.name);
-       if (IS_ERR_OR_NULL(t)) {
-               ret = t ? PTR_ERR(t) : -ENOENT;
+       if (!t) {
+               ret = -ENOENT;
                goto free;
        }
 
@@ -1651,7 +1643,7 @@ compat_get_entries(struct net *net, struct compat_ip6t_get_entries __user *uptr,
 
        xt_compat_lock(AF_INET6);
        t = xt_find_table_lock(net, AF_INET6, get.name);
-       if (!IS_ERR_OR_NULL(t)) {
+       if (t) {
                const struct xt_table_info *private = t->private;
                struct xt_table_info info;
                ret = compat_table_info(private, &info);
@@ -1665,7 +1657,7 @@ compat_get_entries(struct net *net, struct compat_ip6t_get_entries __user *uptr,
                module_put(t->me);
                xt_table_unlock(t);
        } else
-               ret = t ? PTR_ERR(t) : -ENOENT;
+               ret = -ENOENT;
 
        xt_compat_unlock(AF_INET6);
        return ret;