Commit d2a7b6ba authored by Jan Engelhardt's avatar Jan Engelhardt

netfilter: xtables: make use of xt_request_find_target

Signed-off-by: default avatarJan Engelhardt <jengelh@medozas.de>
parent ff67e4e4
...@@ -395,13 +395,9 @@ ebt_check_watcher(struct ebt_entry_watcher *w, struct xt_tgchk_param *par, ...@@ -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) left - sizeof(struct ebt_entry_watcher) < w->watcher_size)
return -EINVAL; return -EINVAL;
watcher = try_then_request_module( watcher = xt_request_find_target(NFPROTO_BRIDGE, w->u.name, 0);
xt_find_target(NFPROTO_BRIDGE, w->u.name, 0),
"ebt_%s", w->u.name);
if (IS_ERR(watcher)) if (IS_ERR(watcher))
return PTR_ERR(watcher); return PTR_ERR(watcher);
if (watcher == NULL)
return -ENOENT;
w->u.watcher = watcher; w->u.watcher = watcher;
par->target = watcher; par->target = watcher;
...@@ -714,15 +710,10 @@ ebt_check_entry(struct ebt_entry *e, struct net *net, ...@@ -714,15 +710,10 @@ ebt_check_entry(struct ebt_entry *e, struct net *net,
t = (struct ebt_entry_target *)(((char *)e) + e->target_offset); t = (struct ebt_entry_target *)(((char *)e) + e->target_offset);
gap = e->next_offset - e->target_offset; gap = e->next_offset - e->target_offset;
target = try_then_request_module( target = xt_request_find_target(NFPROTO_BRIDGE, t->u.name, 0);
xt_find_target(NFPROTO_BRIDGE, t->u.name, 0),
"ebt_%s", t->u.name);
if (IS_ERR(target)) { if (IS_ERR(target)) {
ret = PTR_ERR(target); ret = PTR_ERR(target);
goto cleanup_watchers; goto cleanup_watchers;
} else if (target == NULL) {
ret = -ENOENT;
goto cleanup_watchers;
} }
t->u.target = target; t->u.target = target;
......
...@@ -523,13 +523,11 @@ find_check_entry(struct arpt_entry *e, const char *name, unsigned int size) ...@@ -523,13 +523,11 @@ find_check_entry(struct arpt_entry *e, const char *name, unsigned int size)
return ret; return ret;
t = arpt_get_target(e); t = arpt_get_target(e);
target = try_then_request_module(xt_find_target(NFPROTO_ARP, target = xt_request_find_target(NFPROTO_ARP, t->u.user.name,
t->u.user.name, t->u.user.revision);
t->u.user.revision), if (IS_ERR(target)) {
"arpt_%s", t->u.user.name);
if (IS_ERR(target) || !target) {
duprintf("find_check_entry: `%s' not found\n", t->u.user.name); duprintf("find_check_entry: `%s' not found\n", t->u.user.name);
ret = target ? PTR_ERR(target) : -ENOENT; ret = PTR_ERR(target);
goto out; goto out;
} }
t->u.kernel.target = target; t->u.kernel.target = target;
...@@ -1252,14 +1250,12 @@ check_compat_entry_size_and_hooks(struct compat_arpt_entry *e, ...@@ -1252,14 +1250,12 @@ check_compat_entry_size_and_hooks(struct compat_arpt_entry *e,
entry_offset = (void *)e - (void *)base; entry_offset = (void *)e - (void *)base;
t = compat_arpt_get_target(e); t = compat_arpt_get_target(e);
target = try_then_request_module(xt_find_target(NFPROTO_ARP, target = xt_request_find_target(NFPROTO_ARP, t->u.user.name,
t->u.user.name, t->u.user.revision);
t->u.user.revision), if (IS_ERR(target)) {
"arpt_%s", t->u.user.name);
if (IS_ERR(target) || !target) {
duprintf("check_compat_entry_size_and_hooks: `%s' not found\n", duprintf("check_compat_entry_size_and_hooks: `%s' not found\n",
t->u.user.name); t->u.user.name);
ret = target ? PTR_ERR(target) : -ENOENT; ret = PTR_ERR(target);
goto out; goto out;
} }
t->u.kernel.target = target; t->u.kernel.target = target;
......
...@@ -701,13 +701,11 @@ find_check_entry(struct ipt_entry *e, struct net *net, const char *name, ...@@ -701,13 +701,11 @@ find_check_entry(struct ipt_entry *e, struct net *net, const char *name,
} }
t = ipt_get_target(e); t = ipt_get_target(e);
target = try_then_request_module(xt_find_target(AF_INET, target = xt_request_find_target(NFPROTO_IPV4, t->u.user.name,
t->u.user.name, t->u.user.revision);
t->u.user.revision), if (IS_ERR(target)) {
"ipt_%s", t->u.user.name);
if (IS_ERR(target) || !target) {
duprintf("find_check_entry: `%s' not found\n", t->u.user.name); 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; goto cleanup_matches;
} }
t->u.kernel.target = target; t->u.kernel.target = target;
...@@ -1547,14 +1545,12 @@ check_compat_entry_size_and_hooks(struct compat_ipt_entry *e, ...@@ -1547,14 +1545,12 @@ check_compat_entry_size_and_hooks(struct compat_ipt_entry *e,
} }
t = compat_ipt_get_target(e); t = compat_ipt_get_target(e);
target = try_then_request_module(xt_find_target(AF_INET, target = xt_request_find_target(NFPROTO_IPV4, t->u.user.name,
t->u.user.name, t->u.user.revision);
t->u.user.revision), if (IS_ERR(target)) {
"ipt_%s", t->u.user.name);
if (IS_ERR(target) || !target) {
duprintf("check_compat_entry_size_and_hooks: `%s' not found\n", duprintf("check_compat_entry_size_and_hooks: `%s' not found\n",
t->u.user.name); t->u.user.name);
ret = target ? PTR_ERR(target) : -ENOENT; ret = PTR_ERR(target);
goto release_matches; goto release_matches;
} }
t->u.kernel.target = target; t->u.kernel.target = target;
......
...@@ -733,13 +733,11 @@ find_check_entry(struct ip6t_entry *e, struct net *net, const char *name, ...@@ -733,13 +733,11 @@ find_check_entry(struct ip6t_entry *e, struct net *net, const char *name,
} }
t = ip6t_get_target(e); t = ip6t_get_target(e);
target = try_then_request_module(xt_find_target(AF_INET6, target = xt_request_find_target(NFPROTO_IPV6, t->u.user.name,
t->u.user.name, t->u.user.revision);
t->u.user.revision), if (IS_ERR(target)) {
"ip6t_%s", t->u.user.name);
if (IS_ERR(target) || !target) {
duprintf("find_check_entry: `%s' not found\n", t->u.user.name); 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; goto cleanup_matches;
} }
t->u.kernel.target = target; t->u.kernel.target = target;
...@@ -1581,14 +1579,12 @@ check_compat_entry_size_and_hooks(struct compat_ip6t_entry *e, ...@@ -1581,14 +1579,12 @@ check_compat_entry_size_and_hooks(struct compat_ip6t_entry *e,
} }
t = compat_ip6t_get_target(e); t = compat_ip6t_get_target(e);
target = try_then_request_module(xt_find_target(AF_INET6, target = xt_request_find_target(NFPROTO_IPV6, t->u.user.name,
t->u.user.name, t->u.user.revision);
t->u.user.revision), if (IS_ERR(target)) {
"ip6t_%s", t->u.user.name);
if (IS_ERR(target) || !target) {
duprintf("check_compat_entry_size_and_hooks: `%s' not found\n", duprintf("check_compat_entry_size_and_hooks: `%s' not found\n",
t->u.user.name); t->u.user.name);
ret = target ? PTR_ERR(target) : -ENOENT; ret = PTR_ERR(target);
goto release_matches; goto release_matches;
} }
t->u.kernel.target = target; t->u.kernel.target = target;
......
...@@ -250,9 +250,7 @@ struct xt_target *xt_request_find_target(u8 af, const char *name, u8 revision) ...@@ -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), target = try_then_request_module(xt_find_target(af, name, revision),
"%st_%s", xt_prefix[af], name); "%st_%s", xt_prefix[af], name);
if (IS_ERR(target) || !target) return (target != NULL) ? target : ERR_PTR(-ENOENT);
return NULL;
return target;
} }
EXPORT_SYMBOL_GPL(xt_request_find_target); EXPORT_SYMBOL_GPL(xt_request_find_target);
......
...@@ -46,8 +46,8 @@ static int ipt_init_target(struct ipt_entry_target *t, char *table, unsigned int ...@@ -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, target = xt_request_find_target(AF_INET, t->u.user.name,
t->u.user.revision); t->u.user.revision);
if (!target) if (IS_ERR(target))
return -ENOENT; return PTR_ERR(target);
t->u.kernel.target = target; t->u.kernel.target = target;
par.table = table; par.table = table;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment