netfilter: xtables: make use of xt_request_find_target
authorJan Engelhardt <jengelh@medozas.de>
Fri, 10 Jul 2009 16:55:11 +0000 (18:55 +0200)
committerJan Engelhardt <jengelh@medozas.de>
Thu, 25 Mar 2010 14:02:19 +0000 (15:02 +0100)
Signed-off-by: Jan Engelhardt <jengelh@medozas.de>
net/bridge/netfilter/ebtables.c
net/ipv4/netfilter/arp_tables.c
net/ipv4/netfilter/ip_tables.c
net/ipv6/netfilter/ip6_tables.c
net/netfilter/x_tables.c
net/sched/act_ipt.c

index 989d72cc81482a9dfa3a77e72ed417188e826beb..6d3b256d2f6152c88c7a712b894d71f82456f5b4 100644 (file)
@@ -395,13 +395,9 @@ ebt_check_watcher(struct ebt_entry_watcher *w, struct xt_tgchk_param *par,
           left - sizeof(struct ebt_entry_watcher) < w->watcher_size)
                return -EINVAL;
 
-       watcher = try_then_request_module(
-                 xt_find_target(NFPROTO_BRIDGE, w->u.name, 0),
-                 "ebt_%s", w->u.name);
+       watcher = xt_request_find_target(NFPROTO_BRIDGE, w->u.name, 0);
        if (IS_ERR(watcher))
                return PTR_ERR(watcher);
-       if (watcher == NULL)
-               return -ENOENT;
        w->u.watcher = watcher;
 
        par->target   = watcher;
@@ -714,15 +710,10 @@ ebt_check_entry(struct ebt_entry *e, struct net *net,
        t = (struct ebt_entry_target *)(((char *)e) + e->target_offset);
        gap = e->next_offset - e->target_offset;
 
-       target = try_then_request_module(
-                xt_find_target(NFPROTO_BRIDGE, t->u.name, 0),
-                "ebt_%s", t->u.name);
+       target = xt_request_find_target(NFPROTO_BRIDGE, t->u.name, 0);
        if (IS_ERR(target)) {
                ret = PTR_ERR(target);
                goto cleanup_watchers;
-       } else if (target == NULL) {
-               ret = -ENOENT;
-               goto cleanup_watchers;
        }
 
        t->u.target = target;
index f07d77f6575144e68eb79819a851021db84ab647..e8e363d90365487fd54ca8c2130cef5aea526ea0 100644 (file)
@@ -523,13 +523,11 @@ 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(NFPROTO_ARP,
-                                                       t->u.user.name,
-                                                       t->u.user.revision),
-                                        "arpt_%s", t->u.user.name);
-       if (IS_ERR(target) || !target) {
+       target = xt_request_find_target(NFPROTO_ARP, t->u.user.name,
+                                       t->u.user.revision);
+       if (IS_ERR(target)) {
                duprintf("find_check_entry: `%s' not found\n", t->u.user.name);
-               ret = target ? PTR_ERR(target) : -ENOENT;
+               ret = PTR_ERR(target);
                goto out;
        }
        t->u.kernel.target = target;
@@ -1252,14 +1250,12 @@ 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(NFPROTO_ARP,
-                                                       t->u.user.name,
-                                                       t->u.user.revision),
-                                        "arpt_%s", t->u.user.name);
-       if (IS_ERR(target) || !target) {
+       target = xt_request_find_target(NFPROTO_ARP, t->u.user.name,
+                                       t->u.user.revision);
+       if (IS_ERR(target)) {
                duprintf("check_compat_entry_size_and_hooks: `%s' not found\n",
                         t->u.user.name);
-               ret = target ? PTR_ERR(target) : -ENOENT;
+               ret = PTR_ERR(target);
                goto out;
        }
        t->u.kernel.target = target;
index 73fdf20263ed402d17e593a4ce10e1c16290cd04..e24ec48ee8cd95b94527f7cde286dbf05123543c 100644 (file)
@@ -701,13 +701,11 @@ find_check_entry(struct ipt_entry *e, struct net *net, const char *name,
        }
 
        t = ipt_get_target(e);
-       target = try_then_request_module(xt_find_target(AF_INET,
-                                                       t->u.user.name,
-                                                       t->u.user.revision),
-                                        "ipt_%s", t->u.user.name);
-       if (IS_ERR(target) || !target) {
+       target = xt_request_find_target(NFPROTO_IPV4, t->u.user.name,
+                                       t->u.user.revision);
+       if (IS_ERR(target)) {
                duprintf("find_check_entry: `%s' not found\n", t->u.user.name);
-               ret = target ? PTR_ERR(target) : -ENOENT;
+               ret = PTR_ERR(target);
                goto cleanup_matches;
        }
        t->u.kernel.target = target;
@@ -1547,14 +1545,12 @@ check_compat_entry_size_and_hooks(struct compat_ipt_entry *e,
        }
 
        t = compat_ipt_get_target(e);
-       target = try_then_request_module(xt_find_target(AF_INET,
-                                                       t->u.user.name,
-                                                       t->u.user.revision),
-                                        "ipt_%s", t->u.user.name);
-       if (IS_ERR(target) || !target) {
+       target = xt_request_find_target(NFPROTO_IPV4, t->u.user.name,
+                                       t->u.user.revision);
+       if (IS_ERR(target)) {
                duprintf("check_compat_entry_size_and_hooks: `%s' not found\n",
                         t->u.user.name);
-               ret = target ? PTR_ERR(target) : -ENOENT;
+               ret = PTR_ERR(target);
                goto release_matches;
        }
        t->u.kernel.target = target;
index 1b2414e03a3477cb02a2bff046a37ec7320c2a20..842bef374dccb18e7bdca2539a9e20c2a1fa1246 100644 (file)
@@ -733,13 +733,11 @@ find_check_entry(struct ip6t_entry *e, struct net *net, const char *name,
        }
 
        t = ip6t_get_target(e);
-       target = try_then_request_module(xt_find_target(AF_INET6,
-                                                       t->u.user.name,
-                                                       t->u.user.revision),
-                                        "ip6t_%s", t->u.user.name);
-       if (IS_ERR(target) || !target) {
+       target = xt_request_find_target(NFPROTO_IPV6, t->u.user.name,
+                                       t->u.user.revision);
+       if (IS_ERR(target)) {
                duprintf("find_check_entry: `%s' not found\n", t->u.user.name);
-               ret = target ? PTR_ERR(target) : -ENOENT;
+               ret = PTR_ERR(target);
                goto cleanup_matches;
        }
        t->u.kernel.target = target;
@@ -1581,14 +1579,12 @@ check_compat_entry_size_and_hooks(struct compat_ip6t_entry *e,
        }
 
        t = compat_ip6t_get_target(e);
-       target = try_then_request_module(xt_find_target(AF_INET6,
-                                                       t->u.user.name,
-                                                       t->u.user.revision),
-                                        "ip6t_%s", t->u.user.name);
-       if (IS_ERR(target) || !target) {
+       target = xt_request_find_target(NFPROTO_IPV6, t->u.user.name,
+                                       t->u.user.revision);
+       if (IS_ERR(target)) {
                duprintf("check_compat_entry_size_and_hooks: `%s' not found\n",
                         t->u.user.name);
-               ret = target ? PTR_ERR(target) : -ENOENT;
+               ret = PTR_ERR(target);
                goto release_matches;
        }
        t->u.kernel.target = target;
index 9a248d4a877fd5fbe22f0917776a85e3ee0579d3..bf2806afd92053bdad34f2cd9d98c89951b6e57e 100644 (file)
@@ -250,9 +250,7 @@ struct xt_target *xt_request_find_target(u8 af, const char *name, u8 revision)
 
        target = try_then_request_module(xt_find_target(af, name, revision),
                                         "%st_%s", xt_prefix[af], name);
-       if (IS_ERR(target) || !target)
-               return NULL;
-       return target;
+       return (target != NULL) ? target : ERR_PTR(-ENOENT);
 }
 EXPORT_SYMBOL_GPL(xt_request_find_target);
 
index 082c520b0def5d85f8ca8dc830d3ec20250cd758..b9f79c251d752ce2c6fed4697683a22725fea758 100644 (file)
@@ -46,8 +46,8 @@ static int ipt_init_target(struct ipt_entry_target *t, char *table, unsigned int
 
        target = xt_request_find_target(AF_INET, t->u.user.name,
                                        t->u.user.revision);
-       if (!target)
-               return -ENOENT;
+       if (IS_ERR(target))
+               return PTR_ERR(target);
 
        t->u.kernel.target = target;
        par.table     = table;