Commit d2a7b6bad2c38e41eddb0b24d03627d9e7aa3f7b
1 parent
ff67e4e42b
Exists in
master
and in
39 other branches
netfilter: xtables: make use of xt_request_find_target
Signed-off-by: Jan Engelhardt <jengelh@medozas.de>
Showing 6 changed files with 29 additions and 52 deletions Side-by-side Diff
net/bridge/netfilter/ebtables.c
... | ... | @@ -395,13 +395,9 @@ |
395 | 395 | left - sizeof(struct ebt_entry_watcher) < w->watcher_size) |
396 | 396 | return -EINVAL; |
397 | 397 | |
398 | - watcher = try_then_request_module( | |
399 | - xt_find_target(NFPROTO_BRIDGE, w->u.name, 0), | |
400 | - "ebt_%s", w->u.name); | |
398 | + watcher = xt_request_find_target(NFPROTO_BRIDGE, w->u.name, 0); | |
401 | 399 | if (IS_ERR(watcher)) |
402 | 400 | return PTR_ERR(watcher); |
403 | - if (watcher == NULL) | |
404 | - return -ENOENT; | |
405 | 401 | w->u.watcher = watcher; |
406 | 402 | |
407 | 403 | par->target = watcher; |
408 | 404 | |
... | ... | @@ -714,14 +710,9 @@ |
714 | 710 | t = (struct ebt_entry_target *)(((char *)e) + e->target_offset); |
715 | 711 | gap = e->next_offset - e->target_offset; |
716 | 712 | |
717 | - target = try_then_request_module( | |
718 | - xt_find_target(NFPROTO_BRIDGE, t->u.name, 0), | |
719 | - "ebt_%s", t->u.name); | |
713 | + target = xt_request_find_target(NFPROTO_BRIDGE, t->u.name, 0); | |
720 | 714 | if (IS_ERR(target)) { |
721 | 715 | ret = PTR_ERR(target); |
722 | - goto cleanup_watchers; | |
723 | - } else if (target == NULL) { | |
724 | - ret = -ENOENT; | |
725 | 716 | goto cleanup_watchers; |
726 | 717 | } |
727 | 718 |
net/ipv4/netfilter/arp_tables.c
... | ... | @@ -523,13 +523,11 @@ |
523 | 523 | return ret; |
524 | 524 | |
525 | 525 | t = arpt_get_target(e); |
526 | - target = try_then_request_module(xt_find_target(NFPROTO_ARP, | |
527 | - t->u.user.name, | |
528 | - t->u.user.revision), | |
529 | - "arpt_%s", t->u.user.name); | |
530 | - if (IS_ERR(target) || !target) { | |
526 | + target = xt_request_find_target(NFPROTO_ARP, t->u.user.name, | |
527 | + t->u.user.revision); | |
528 | + if (IS_ERR(target)) { | |
531 | 529 | duprintf("find_check_entry: `%s' not found\n", t->u.user.name); |
532 | - ret = target ? PTR_ERR(target) : -ENOENT; | |
530 | + ret = PTR_ERR(target); | |
533 | 531 | goto out; |
534 | 532 | } |
535 | 533 | t->u.kernel.target = target; |
536 | 534 | |
... | ... | @@ -1252,14 +1250,12 @@ |
1252 | 1250 | entry_offset = (void *)e - (void *)base; |
1253 | 1251 | |
1254 | 1252 | t = compat_arpt_get_target(e); |
1255 | - target = try_then_request_module(xt_find_target(NFPROTO_ARP, | |
1256 | - t->u.user.name, | |
1257 | - t->u.user.revision), | |
1258 | - "arpt_%s", t->u.user.name); | |
1259 | - if (IS_ERR(target) || !target) { | |
1253 | + target = xt_request_find_target(NFPROTO_ARP, t->u.user.name, | |
1254 | + t->u.user.revision); | |
1255 | + if (IS_ERR(target)) { | |
1260 | 1256 | duprintf("check_compat_entry_size_and_hooks: `%s' not found\n", |
1261 | 1257 | t->u.user.name); |
1262 | - ret = target ? PTR_ERR(target) : -ENOENT; | |
1258 | + ret = PTR_ERR(target); | |
1263 | 1259 | goto out; |
1264 | 1260 | } |
1265 | 1261 | t->u.kernel.target = target; |
net/ipv4/netfilter/ip_tables.c
... | ... | @@ -701,13 +701,11 @@ |
701 | 701 | } |
702 | 702 | |
703 | 703 | t = ipt_get_target(e); |
704 | - target = try_then_request_module(xt_find_target(AF_INET, | |
705 | - t->u.user.name, | |
706 | - t->u.user.revision), | |
707 | - "ipt_%s", t->u.user.name); | |
708 | - if (IS_ERR(target) || !target) { | |
704 | + target = xt_request_find_target(NFPROTO_IPV4, t->u.user.name, | |
705 | + t->u.user.revision); | |
706 | + if (IS_ERR(target)) { | |
709 | 707 | duprintf("find_check_entry: `%s' not found\n", t->u.user.name); |
710 | - ret = target ? PTR_ERR(target) : -ENOENT; | |
708 | + ret = PTR_ERR(target); | |
711 | 709 | goto cleanup_matches; |
712 | 710 | } |
713 | 711 | t->u.kernel.target = target; |
714 | 712 | |
... | ... | @@ -1547,14 +1545,12 @@ |
1547 | 1545 | } |
1548 | 1546 | |
1549 | 1547 | t = compat_ipt_get_target(e); |
1550 | - target = try_then_request_module(xt_find_target(AF_INET, | |
1551 | - t->u.user.name, | |
1552 | - t->u.user.revision), | |
1553 | - "ipt_%s", t->u.user.name); | |
1554 | - if (IS_ERR(target) || !target) { | |
1548 | + target = xt_request_find_target(NFPROTO_IPV4, t->u.user.name, | |
1549 | + t->u.user.revision); | |
1550 | + if (IS_ERR(target)) { | |
1555 | 1551 | duprintf("check_compat_entry_size_and_hooks: `%s' not found\n", |
1556 | 1552 | t->u.user.name); |
1557 | - ret = target ? PTR_ERR(target) : -ENOENT; | |
1553 | + ret = PTR_ERR(target); | |
1558 | 1554 | goto release_matches; |
1559 | 1555 | } |
1560 | 1556 | t->u.kernel.target = target; |
net/ipv6/netfilter/ip6_tables.c
... | ... | @@ -733,13 +733,11 @@ |
733 | 733 | } |
734 | 734 | |
735 | 735 | t = ip6t_get_target(e); |
736 | - target = try_then_request_module(xt_find_target(AF_INET6, | |
737 | - t->u.user.name, | |
738 | - t->u.user.revision), | |
739 | - "ip6t_%s", t->u.user.name); | |
740 | - if (IS_ERR(target) || !target) { | |
736 | + target = xt_request_find_target(NFPROTO_IPV6, t->u.user.name, | |
737 | + t->u.user.revision); | |
738 | + if (IS_ERR(target)) { | |
741 | 739 | duprintf("find_check_entry: `%s' not found\n", t->u.user.name); |
742 | - ret = target ? PTR_ERR(target) : -ENOENT; | |
740 | + ret = PTR_ERR(target); | |
743 | 741 | goto cleanup_matches; |
744 | 742 | } |
745 | 743 | t->u.kernel.target = target; |
746 | 744 | |
... | ... | @@ -1581,14 +1579,12 @@ |
1581 | 1579 | } |
1582 | 1580 | |
1583 | 1581 | t = compat_ip6t_get_target(e); |
1584 | - target = try_then_request_module(xt_find_target(AF_INET6, | |
1585 | - t->u.user.name, | |
1586 | - t->u.user.revision), | |
1587 | - "ip6t_%s", t->u.user.name); | |
1588 | - if (IS_ERR(target) || !target) { | |
1582 | + target = xt_request_find_target(NFPROTO_IPV6, t->u.user.name, | |
1583 | + t->u.user.revision); | |
1584 | + if (IS_ERR(target)) { | |
1589 | 1585 | duprintf("check_compat_entry_size_and_hooks: `%s' not found\n", |
1590 | 1586 | t->u.user.name); |
1591 | - ret = target ? PTR_ERR(target) : -ENOENT; | |
1587 | + ret = PTR_ERR(target); | |
1592 | 1588 | goto release_matches; |
1593 | 1589 | } |
1594 | 1590 | t->u.kernel.target = target; |
net/netfilter/x_tables.c
... | ... | @@ -250,9 +250,7 @@ |
250 | 250 | |
251 | 251 | target = try_then_request_module(xt_find_target(af, name, revision), |
252 | 252 | "%st_%s", xt_prefix[af], name); |
253 | - if (IS_ERR(target) || !target) | |
254 | - return NULL; | |
255 | - return target; | |
253 | + return (target != NULL) ? target : ERR_PTR(-ENOENT); | |
256 | 254 | } |
257 | 255 | EXPORT_SYMBOL_GPL(xt_request_find_target); |
258 | 256 |
net/sched/act_ipt.c