struct xt_table *xt_find_table_lock(struct net *net, u_int8_t af,
                                    const char *name);
+struct xt_table *xt_request_find_table_lock(struct net *net, u_int8_t af,
+                                           const char *name);
 void xt_table_unlock(struct xt_table *t);
 
 int xt_proto_init(struct net *net, u_int8_t af);
 
        if (compat)
                xt_compat_lock(NFPROTO_ARP);
 #endif
-       t = try_then_request_module(xt_find_table_lock(net, NFPROTO_ARP, name),
-                                   "arptable_%s", name);
-       if (t) {
+       t = xt_request_find_table_lock(net, NFPROTO_ARP, name);
+       if (!IS_ERR(t)) {
                struct arpt_getinfo info;
                const struct xt_table_info *private = t->private;
 #ifdef CONFIG_COMPAT
                xt_table_unlock(t);
                module_put(t->me);
        } else
-               ret = -ENOENT;
+               ret = PTR_ERR(t);
 #ifdef CONFIG_COMPAT
        if (compat)
                xt_compat_unlock(NFPROTO_ARP);
        get.name[sizeof(get.name) - 1] = '\0';
 
        t = xt_find_table_lock(net, NFPROTO_ARP, get.name);
-       if (t) {
+       if (!IS_ERR(t)) {
                const struct xt_table_info *private = t->private;
 
                if (get.size == private->size)
                module_put(t->me);
                xt_table_unlock(t);
        } else
-               ret = -ENOENT;
+               ret = PTR_ERR(t);
 
        return ret;
 }
                goto out;
        }
 
-       t = try_then_request_module(xt_find_table_lock(net, NFPROTO_ARP, name),
-                                   "arptable_%s", name);
-       if (!t) {
-               ret = -ENOENT;
+       t = xt_request_find_table_lock(net, NFPROTO_ARP, name);
+       if (IS_ERR(t)) {
+               ret = PTR_ERR(t);
                goto free_newinfo_counters_untrans;
        }
 
                return PTR_ERR(paddc);
 
        t = xt_find_table_lock(net, NFPROTO_ARP, tmp.name);
-       if (!t) {
-               ret = -ENOENT;
+       if (IS_ERR(t)) {
+               ret = PTR_ERR(t);
                goto free;
        }
 
 
        xt_compat_lock(NFPROTO_ARP);
        t = xt_find_table_lock(net, NFPROTO_ARP, get.name);
-       if (t) {
+       if (!IS_ERR(t)) {
                const struct xt_table_info *private = t->private;
                struct xt_table_info info;
 
                module_put(t->me);
                xt_table_unlock(t);
        } else
-               ret = -ENOENT;
+               ret = PTR_ERR(t);
 
        xt_compat_unlock(NFPROTO_ARP);
        return ret;
 
        if (compat)
                xt_compat_lock(AF_INET);
 #endif
-       t = try_then_request_module(xt_find_table_lock(net, AF_INET, name),
-                                   "iptable_%s", name);
-       if (t) {
+       t = xt_request_find_table_lock(net, AF_INET, name);
+       if (!IS_ERR(t)) {
                struct ipt_getinfo info;
                const struct xt_table_info *private = t->private;
 #ifdef CONFIG_COMPAT
                xt_table_unlock(t);
                module_put(t->me);
        } else
-               ret = -ENOENT;
+               ret = PTR_ERR(t);
 #ifdef CONFIG_COMPAT
        if (compat)
                xt_compat_unlock(AF_INET);
        get.name[sizeof(get.name) - 1] = '\0';
 
        t = xt_find_table_lock(net, AF_INET, get.name);
-       if (t) {
+       if (!IS_ERR(t)) {
                const struct xt_table_info *private = t->private;
                if (get.size == private->size)
                        ret = copy_entries_to_user(private->size,
                module_put(t->me);
                xt_table_unlock(t);
        } else
-               ret = -ENOENT;
+               ret = PTR_ERR(t);
 
        return ret;
 }
                goto out;
        }
 
-       t = try_then_request_module(xt_find_table_lock(net, AF_INET, name),
-                                   "iptable_%s", name);
-       if (!t) {
-               ret = -ENOENT;
+       t = xt_request_find_table_lock(net, AF_INET, name);
+       if (IS_ERR(t)) {
+               ret = PTR_ERR(t);
                goto free_newinfo_counters_untrans;
        }
 
                return PTR_ERR(paddc);
 
        t = xt_find_table_lock(net, AF_INET, tmp.name);
-       if (!t) {
-               ret = -ENOENT;
+       if (IS_ERR(t)) {
+               ret = PTR_ERR(t);
                goto free;
        }
 
 
        xt_compat_lock(AF_INET);
        t = xt_find_table_lock(net, AF_INET, get.name);
-       if (t) {
+       if (!IS_ERR(t)) {
                const struct xt_table_info *private = t->private;
                struct xt_table_info info;
                ret = compat_table_info(private, &info);
                module_put(t->me);
                xt_table_unlock(t);
        } else
-               ret = -ENOENT;
+               ret = PTR_ERR(t);
 
        xt_compat_unlock(AF_INET);
        return ret;
 
        if (compat)
                xt_compat_lock(AF_INET6);
 #endif
-       t = try_then_request_module(xt_find_table_lock(net, AF_INET6, name),
-                                   "ip6table_%s", name);
-       if (t) {
+       t = xt_request_find_table_lock(net, AF_INET6, name);
+       if (!IS_ERR(t)) {
                struct ip6t_getinfo info;
                const struct xt_table_info *private = t->private;
 #ifdef CONFIG_COMPAT
                xt_table_unlock(t);
                module_put(t->me);
        } else
-               ret = -ENOENT;
+               ret = PTR_ERR(t);
 #ifdef CONFIG_COMPAT
        if (compat)
                xt_compat_unlock(AF_INET6);
        get.name[sizeof(get.name) - 1] = '\0';
 
        t = xt_find_table_lock(net, AF_INET6, get.name);
-       if (t) {
+       if (!IS_ERR(t)) {
                struct xt_table_info *private = t->private;
                if (get.size == private->size)
                        ret = copy_entries_to_user(private->size,
                module_put(t->me);
                xt_table_unlock(t);
        } else
-               ret = -ENOENT;
+               ret = PTR_ERR(t);
 
        return ret;
 }
                goto out;
        }
 
-       t = try_then_request_module(xt_find_table_lock(net, AF_INET6, name),
-                                   "ip6table_%s", name);
-       if (!t) {
-               ret = -ENOENT;
+       t = xt_request_find_table_lock(net, AF_INET6, name);
+       if (IS_ERR(t)) {
+               ret = PTR_ERR(t);
                goto free_newinfo_counters_untrans;
        }
 
        if (IS_ERR(paddc))
                return PTR_ERR(paddc);
        t = xt_find_table_lock(net, AF_INET6, tmp.name);
-       if (!t) {
-               ret = -ENOENT;
+       if (IS_ERR(t)) {
+               ret = PTR_ERR(t);
                goto free;
        }
 
 
        xt_compat_lock(AF_INET6);
        t = xt_find_table_lock(net, AF_INET6, get.name);
-       if (t) {
+       if (!IS_ERR(t)) {
                const struct xt_table_info *private = t->private;
                struct xt_table_info info;
                ret = compat_table_info(private, &info);
                module_put(t->me);
                xt_table_unlock(t);
        } else
-               ret = -ENOENT;
+               ret = PTR_ERR(t);
 
        xt_compat_unlock(AF_INET6);
        return ret;
 
 }
 EXPORT_SYMBOL(xt_free_table_info);
 
-/* Find table by name, grabs mutex & ref.  Returns NULL on error. */
+/* Find table by name, grabs mutex & ref.  Returns ERR_PTR on error. */
 struct xt_table *xt_find_table_lock(struct net *net, u_int8_t af,
                                    const char *name)
 {
 
        /* Table doesn't exist in this netns, re-try init */
        list_for_each_entry(t, &init_net.xt.tables[af], list) {
+               int err;
+
                if (strcmp(t->name, name))
                        continue;
-               if (!try_module_get(t->me)) {
-                       mutex_unlock(&xt[af].mutex);
-                       return NULL;
-               }
-
+               if (!try_module_get(t->me))
+                       goto out;
                mutex_unlock(&xt[af].mutex);
-               if (t->table_init(net) != 0) {
+               err = t->table_init(net);
+               if (err < 0) {
                        module_put(t->me);
-                       return NULL;
+                       return ERR_PTR(err);
                }
 
                found = t;
        module_put(found->me);
  out:
        mutex_unlock(&xt[af].mutex);
-       return NULL;
+       return ERR_PTR(-ENOENT);
 }
 EXPORT_SYMBOL_GPL(xt_find_table_lock);
 
+struct xt_table *xt_request_find_table_lock(struct net *net, u_int8_t af,
+                                           const char *name)
+{
+       struct xt_table *t = xt_find_table_lock(net, af, name);
+
+#ifdef CONFIG_MODULE
+       if (IS_ERR(t)) {
+               int err = request_module("%stable_%s", xt_prefix[af], name);
+               if (err)
+                       return ERR_PTR(err);
+               t = xt_find_table_lock(net, af, name);
+       }
+#endif
+
+       return t;
+}
+EXPORT_SYMBOL_GPL(xt_request_find_table_lock);
+
 void xt_table_unlock(struct xt_table *table)
 {
        mutex_unlock(&xt[table->af].mutex);