diff options
author | Jan Engelhardt <jengelh@medozas.de> | 2009-07-10 13:27:47 -0400 |
---|---|---|
committer | Jan Engelhardt <jengelh@medozas.de> | 2010-03-25 10:02:19 -0400 |
commit | fd0ec0e6216baea854465bbdb177f2d1b2ccaf22 (patch) | |
tree | 47a935d96deae38aa0a030039e303b071a7803e0 /net | |
parent | d2a7b6bad2c38e41eddb0b24d03627d9e7aa3f7b (diff) |
netfilter: xtables: consolidate code into xt_request_find_match
Signed-off-by: Jan Engelhardt <jengelh@medozas.de>
Diffstat (limited to 'net')
-rw-r--r-- | net/bridge/netfilter/ebtables.c | 5 | ||||
-rw-r--r-- | net/ipv4/netfilter/ip_tables.c | 18 | ||||
-rw-r--r-- | net/ipv6/netfilter/ip6_tables.c | 18 | ||||
-rw-r--r-- | net/netfilter/x_tables.c | 11 |
4 files changed, 28 insertions, 24 deletions
diff --git a/net/bridge/netfilter/ebtables.c b/net/bridge/netfilter/ebtables.c index 6d3b256d2f61..c41f3fad0587 100644 --- a/net/bridge/netfilter/ebtables.c +++ b/net/bridge/netfilter/ebtables.c | |||
@@ -361,12 +361,9 @@ ebt_check_match(struct ebt_entry_match *m, struct xt_mtchk_param *par, | |||
361 | left - sizeof(struct ebt_entry_match) < m->match_size) | 361 | left - sizeof(struct ebt_entry_match) < m->match_size) |
362 | return -EINVAL; | 362 | return -EINVAL; |
363 | 363 | ||
364 | match = try_then_request_module(xt_find_match(NFPROTO_BRIDGE, | 364 | match = xt_request_find_match(NFPROTO_BRIDGE, m->u.name, 0); |
365 | m->u.name, 0), "ebt_%s", m->u.name); | ||
366 | if (IS_ERR(match)) | 365 | if (IS_ERR(match)) |
367 | return PTR_ERR(match); | 366 | return PTR_ERR(match); |
368 | if (match == NULL) | ||
369 | return -ENOENT; | ||
370 | m->u.match = match; | 367 | m->u.match = match; |
371 | 368 | ||
372 | par->match = match; | 369 | par->match = match; |
diff --git a/net/ipv4/netfilter/ip_tables.c b/net/ipv4/netfilter/ip_tables.c index e24ec48ee8cd..09f6567a85b7 100644 --- a/net/ipv4/netfilter/ip_tables.c +++ b/net/ipv4/netfilter/ip_tables.c | |||
@@ -629,12 +629,11 @@ find_check_match(struct ipt_entry_match *m, struct xt_mtchk_param *par) | |||
629 | struct xt_match *match; | 629 | struct xt_match *match; |
630 | int ret; | 630 | int ret; |
631 | 631 | ||
632 | match = try_then_request_module(xt_find_match(AF_INET, m->u.user.name, | 632 | match = xt_request_find_match(NFPROTO_IPV4, m->u.user.name, |
633 | m->u.user.revision), | 633 | m->u.user.revision); |
634 | "ipt_%s", m->u.user.name); | 634 | if (IS_ERR(match)) { |
635 | if (IS_ERR(match) || !match) { | ||
636 | duprintf("find_check_match: `%s' not found\n", m->u.user.name); | 635 | duprintf("find_check_match: `%s' not found\n", m->u.user.name); |
637 | return match ? PTR_ERR(match) : -ENOENT; | 636 | return PTR_ERR(match); |
638 | } | 637 | } |
639 | m->u.kernel.match = match; | 638 | m->u.kernel.match = match; |
640 | 639 | ||
@@ -1472,13 +1471,12 @@ compat_find_calc_match(struct ipt_entry_match *m, | |||
1472 | { | 1471 | { |
1473 | struct xt_match *match; | 1472 | struct xt_match *match; |
1474 | 1473 | ||
1475 | match = try_then_request_module(xt_find_match(AF_INET, m->u.user.name, | 1474 | match = xt_request_find_match(NFPROTO_IPV4, m->u.user.name, |
1476 | m->u.user.revision), | 1475 | m->u.user.revision); |
1477 | "ipt_%s", m->u.user.name); | 1476 | if (IS_ERR(match)) { |
1478 | if (IS_ERR(match) || !match) { | ||
1479 | duprintf("compat_check_calc_match: `%s' not found\n", | 1477 | duprintf("compat_check_calc_match: `%s' not found\n", |
1480 | m->u.user.name); | 1478 | m->u.user.name); |
1481 | return match ? PTR_ERR(match) : -ENOENT; | 1479 | return PTR_ERR(match); |
1482 | } | 1480 | } |
1483 | m->u.kernel.match = match; | 1481 | m->u.kernel.match = match; |
1484 | *size += xt_compat_match_offset(match); | 1482 | *size += xt_compat_match_offset(match); |
diff --git a/net/ipv6/netfilter/ip6_tables.c b/net/ipv6/netfilter/ip6_tables.c index 842bef374dcc..41e2429c0163 100644 --- a/net/ipv6/netfilter/ip6_tables.c +++ b/net/ipv6/netfilter/ip6_tables.c | |||
@@ -660,12 +660,11 @@ find_check_match(struct ip6t_entry_match *m, struct xt_mtchk_param *par) | |||
660 | struct xt_match *match; | 660 | struct xt_match *match; |
661 | int ret; | 661 | int ret; |
662 | 662 | ||
663 | match = try_then_request_module(xt_find_match(AF_INET6, m->u.user.name, | 663 | match = xt_request_find_match(NFPROTO_IPV6, m->u.user.name, |
664 | m->u.user.revision), | 664 | m->u.user.revision); |
665 | "ip6t_%s", m->u.user.name); | 665 | if (IS_ERR(match)) { |
666 | if (IS_ERR(match) || !match) { | ||
667 | duprintf("find_check_match: `%s' not found\n", m->u.user.name); | 666 | duprintf("find_check_match: `%s' not found\n", m->u.user.name); |
668 | return match ? PTR_ERR(match) : -ENOENT; | 667 | return PTR_ERR(match); |
669 | } | 668 | } |
670 | m->u.kernel.match = match; | 669 | m->u.kernel.match = match; |
671 | 670 | ||
@@ -1506,13 +1505,12 @@ compat_find_calc_match(struct ip6t_entry_match *m, | |||
1506 | { | 1505 | { |
1507 | struct xt_match *match; | 1506 | struct xt_match *match; |
1508 | 1507 | ||
1509 | match = try_then_request_module(xt_find_match(AF_INET6, m->u.user.name, | 1508 | match = xt_request_find_match(NFPROTO_IPV6, m->u.user.name, |
1510 | m->u.user.revision), | 1509 | m->u.user.revision); |
1511 | "ip6t_%s", m->u.user.name); | 1510 | if (IS_ERR(match)) { |
1512 | if (IS_ERR(match) || !match) { | ||
1513 | duprintf("compat_check_calc_match: `%s' not found\n", | 1511 | duprintf("compat_check_calc_match: `%s' not found\n", |
1514 | m->u.user.name); | 1512 | m->u.user.name); |
1515 | return match ? PTR_ERR(match) : -ENOENT; | 1513 | return PTR_ERR(match); |
1516 | } | 1514 | } |
1517 | m->u.kernel.match = match; | 1515 | m->u.kernel.match = match; |
1518 | *size += xt_compat_match_offset(match); | 1516 | *size += xt_compat_match_offset(match); |
diff --git a/net/netfilter/x_tables.c b/net/netfilter/x_tables.c index bf2806afd920..ee7fe215b3e1 100644 --- a/net/netfilter/x_tables.c +++ b/net/netfilter/x_tables.c | |||
@@ -214,6 +214,17 @@ struct xt_match *xt_find_match(u8 af, const char *name, u8 revision) | |||
214 | } | 214 | } |
215 | EXPORT_SYMBOL(xt_find_match); | 215 | EXPORT_SYMBOL(xt_find_match); |
216 | 216 | ||
217 | struct xt_match * | ||
218 | xt_request_find_match(uint8_t nfproto, const char *name, uint8_t revision) | ||
219 | { | ||
220 | struct xt_match *match; | ||
221 | |||
222 | match = try_then_request_module(xt_find_match(nfproto, name, revision), | ||
223 | "%st_%s", xt_prefix[nfproto], name); | ||
224 | return (match != NULL) ? match : ERR_PTR(-ENOENT); | ||
225 | } | ||
226 | EXPORT_SYMBOL_GPL(xt_request_find_match); | ||
227 | |||
217 | /* Find target, grabs ref. Returns ERR_PTR() on error. */ | 228 | /* Find target, grabs ref. Returns ERR_PTR() on error. */ |
218 | struct xt_target *xt_find_target(u8 af, const char *name, u8 revision) | 229 | struct xt_target *xt_find_target(u8 af, const char *name, u8 revision) |
219 | { | 230 | { |