History

netfilter: xtables: consolidate code into xt_request_find_match

Jan Engelhardt committed 17 years ago

Commit fd0ec0e1 parent d2a7b6b5 files · +30 −24Browse files

Unified · Split

5 files
  1. include/linux/netfilter/x_tables.h +2 −0
  2. net/bridge/netfilter/ebtables.c +1 −4
  3. net/ipv4/netfilter/ip_tables.c +8 −10
  4. net/ipv6/netfilter/ip6_tables.c +8 −10
  5. net/netfilter/x_tables.c +11 −0
include/linux/netfilter/x_tables.h+2−0
@@ -436,6 +436,8 @@ extern struct xt_table_info *xt_replace_table(struct xt_table *table, · 435 unmodified lines
436436
437437 extern struct xt_match *xt_find_match(u8 af, const char *name, u8 revision);
438438 extern struct xt_target *xt_find_target(u8 af, const char *name, u8 revision);
439+extern struct xt_match *xt_request_find_match(u8 af, const char *name,
440+ u8 revision);
439441 extern struct xt_target *xt_request_find_target(u8 af, const char *name,
440442 u8 revision);
441443 extern int xt_find_revision(u8 af, const char *name, u8 revision,
net/bridge/netfilter/ebtables.c+1−4
@@ -361,12 +361,9 @@ ebt_check_match(struct ebt_entry_match *m, struct xt_mtchk_param *par, · 360 unmodified lines
361361 left - sizeof(struct ebt_entry_match) < m->match_size)
362362 return -EINVAL;
363363
364− match = try_then_request_module(xt_find_match(NFPROTO_BRIDGE,
365− m->u.name, 0), "ebt_%s", m->u.name);
364+ match = xt_request_find_match(NFPROTO_BRIDGE, m->u.name, 0);
366365 if (IS_ERR(match))
367366 return PTR_ERR(match);
368− if (match == NULL)
369− return -ENOENT;
370367 m->u.match = match;
371368
372369 par->match = match;
net/ipv4/netfilter/ip_tables.c+8−10
@@ -629,12 +629,11 @@ find_check_match(struct ipt_entry_match *m, struct xt_mtchk_param *par) · 628 unmodified lines
629629 struct xt_match *match;
630630 int ret;
631631
632− match = try_then_request_module(xt_find_match(AF_INET, m->u.user.name,
633− m->u.user.revision),
634− "ipt_%s", m->u.user.name);
635− if (IS_ERR(match) || !match) {
632+ match = xt_request_find_match(NFPROTO_IPV4, m->u.user.name,
633+ m->u.user.revision);
634+ if (IS_ERR(match)) {
636635 duprintf("find_check_match: `%s' not found\n", m->u.user.name);
637− return match ? PTR_ERR(match) : -ENOENT;
636+ return PTR_ERR(match);
638637 }
639638 m->u.kernel.match = match;
640639
@@ -1472,13 +1471,12 @@ compat_find_calc_match(struct ipt_entry_match *m, · 831 unmodified lines
14721471 {
14731472 struct xt_match *match;
14741473
1475− match = try_then_request_module(xt_find_match(AF_INET, m->u.user.name,
1476− m->u.user.revision),
1477− "ipt_%s", m->u.user.name);
1478− if (IS_ERR(match) || !match) {
1474+ match = xt_request_find_match(NFPROTO_IPV4, m->u.user.name,
1475+ m->u.user.revision);
1476+ if (IS_ERR(match)) {
14791477 duprintf("compat_check_calc_match: `%s' not found\n",
14801478 m->u.user.name);
1481− return match ? PTR_ERR(match) : -ENOENT;
1479+ return PTR_ERR(match);
14821480 }
14831481 m->u.kernel.match = match;
14841482 *size += xt_compat_match_offset(match);
net/ipv6/netfilter/ip6_tables.c+8−10
@@ -660,12 +660,11 @@ find_check_match(struct ip6t_entry_match *m, struct xt_mtchk_param *par) · 659 unmodified lines
660660 struct xt_match *match;
661661 int ret;
662662
663− match = try_then_request_module(xt_find_match(AF_INET6, m->u.user.name,
664− m->u.user.revision),
665− "ip6t_%s", m->u.user.name);
666− if (IS_ERR(match) || !match) {
663+ match = xt_request_find_match(NFPROTO_IPV6, m->u.user.name,
664+ m->u.user.revision);
665+ if (IS_ERR(match)) {
667666 duprintf("find_check_match: `%s' not found\n", m->u.user.name);
668− return match ? PTR_ERR(match) : -ENOENT;
667+ return PTR_ERR(match);
669668 }
670669 m->u.kernel.match = match;
671670
@@ -1506,13 +1505,12 @@ compat_find_calc_match(struct ip6t_entry_match *m, · 834 unmodified lines
15061505 {
15071506 struct xt_match *match;
15081507
1509− match = try_then_request_module(xt_find_match(AF_INET6, m->u.user.name,
1510− m->u.user.revision),
1511− "ip6t_%s", m->u.user.name);
1512− if (IS_ERR(match) || !match) {
1508+ match = xt_request_find_match(NFPROTO_IPV6, m->u.user.name,
1509+ m->u.user.revision);
1510+ if (IS_ERR(match)) {
15131511 duprintf("compat_check_calc_match: `%s' not found\n",
15141512 m->u.user.name);
1515− return match ? PTR_ERR(match) : -ENOENT;
1513+ return PTR_ERR(match);
15161514 }
15171515 m->u.kernel.match = match;
15181516 *size += xt_compat_match_offset(match);
net/netfilter/x_tables.c+11−0
@@ -214,6 +214,17 @@ struct xt_match *xt_find_match(u8 af, const char *name, u8 revision) · 213 unmodified lines
214214 }
215215 EXPORT_SYMBOL(xt_find_match);
216216
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+
217228 /* Find target, grabs ref. Returns ERR_PTR() on error. */
218229 struct xt_target *xt_find_target(u8 af, const char *name, u8 revision)
219230 {

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t