aboutsummaryrefslogtreecommitdiffstats
path: root/net/netfilter
diff options
context:
space:
mode:
authorJan Engelhardt <jengelh@medozas.de>2008-10-08 05:35:18 -0400
committerPatrick McHardy <kaber@trash.net>2008-10-08 05:35:18 -0400
commit9b4fce7a3508a9776534188b6065b206a9608ccf (patch)
tree7df90f099a72738900deb93124ad86724a2df207 /net/netfilter
parentf7108a20dee44e5bb037f9e48f6a207b42e6ae1c (diff)
netfilter: xtables: move extension arguments into compound structure (2/6)
This patch does this for match extensions' checkentry functions. Signed-off-by: Jan Engelhardt <jengelh@medozas.de> Signed-off-by: Patrick McHardy <kaber@trash.net>
Diffstat (limited to 'net/netfilter')
-rw-r--r--net/netfilter/x_tables.c32
-rw-r--r--net/netfilter/xt_connbytes.c14
-rw-r--r--net/netfilter/xt_connlimit.c13
-rw-r--r--net/netfilter/xt_connmark.c20
-rw-r--r--net/netfilter/xt_conntrack.c9
-rw-r--r--net/netfilter/xt_dccp.c7
-rw-r--r--net/netfilter/xt_dscp.c11
-rw-r--r--net/netfilter/xt_esp.c8
-rw-r--r--net/netfilter/xt_hashlimit.c24
-rw-r--r--net/netfilter/xt_helper.c11
-rw-r--r--net/netfilter/xt_limit.c7
-rw-r--r--net/netfilter/xt_mark.c7
-rw-r--r--net/netfilter/xt_multiport.c37
-rw-r--r--net/netfilter/xt_owner.c14
-rw-r--r--net/netfilter/xt_physdev.c13
-rw-r--r--net/netfilter/xt_policy.c15
-rw-r--r--net/netfilter/xt_quota.c7
-rw-r--r--net/netfilter/xt_rateest.c8
-rw-r--r--net/netfilter/xt_recent.c7
-rw-r--r--net/netfilter/xt_sctp.c7
-rw-r--r--net/netfilter/xt_state.c9
-rw-r--r--net/netfilter/xt_statistic.c7
-rw-r--r--net/netfilter/xt_string.c9
-rw-r--r--net/netfilter/xt_tcpudp.c16
-rw-r--r--net/netfilter/xt_time.c7
25 files changed, 110 insertions, 209 deletions
diff --git a/net/netfilter/x_tables.c b/net/netfilter/x_tables.c
index d1f2fb3e8f2d..817ab14f7cd6 100644
--- a/net/netfilter/x_tables.c
+++ b/net/netfilter/x_tables.c
@@ -321,39 +321,39 @@ int xt_find_revision(u8 af, const char *name, u8 revision, int target,
321} 321}
322EXPORT_SYMBOL_GPL(xt_find_revision); 322EXPORT_SYMBOL_GPL(xt_find_revision);
323 323
324int xt_check_match(const struct xt_match *match, unsigned short family, 324int xt_check_match(struct xt_mtchk_param *par, u_int8_t family,
325 unsigned int size, const char *table, unsigned int hook_mask, 325 unsigned int size, u_int8_t proto, bool inv_proto)
326 unsigned short proto, int inv_proto, const void *entry,
327 void *matchinfo)
328{ 326{
329 if (XT_ALIGN(match->matchsize) != size && 327 if (XT_ALIGN(par->match->matchsize) != size &&
330 match->matchsize != -1) { 328 par->match->matchsize != -1) {
331 /* 329 /*
332 * ebt_among is exempt from centralized matchsize checking 330 * ebt_among is exempt from centralized matchsize checking
333 * because it uses a dynamic-size data set. 331 * because it uses a dynamic-size data set.
334 */ 332 */
335 printk("%s_tables: %s match: invalid size %Zu != %u\n", 333 printk("%s_tables: %s match: invalid size %Zu != %u\n",
336 xt_prefix[family], match->name, 334 xt_prefix[family], par->match->name,
337 XT_ALIGN(match->matchsize), size); 335 XT_ALIGN(par->match->matchsize), size);
338 return -EINVAL; 336 return -EINVAL;
339 } 337 }
340 if (match->table && strcmp(match->table, table)) { 338 if (par->match->table != NULL &&
339 strcmp(par->match->table, par->table) != 0) {
341 printk("%s_tables: %s match: only valid in %s table, not %s\n", 340 printk("%s_tables: %s match: only valid in %s table, not %s\n",
342 xt_prefix[family], match->name, match->table, table); 341 xt_prefix[family], par->match->name,
342 par->match->table, par->table);
343 return -EINVAL; 343 return -EINVAL;
344 } 344 }
345 if (match->hooks && (hook_mask & ~match->hooks) != 0) { 345 if (par->match->hooks && (par->hook_mask & ~par->match->hooks) != 0) {
346 printk("%s_tables: %s match: bad hook_mask %#x/%#x\n", 346 printk("%s_tables: %s match: bad hook_mask %#x/%#x\n",
347 xt_prefix[family], match->name, hook_mask, match->hooks); 347 xt_prefix[family], par->match->name,
348 par->hook_mask, par->match->hooks);
348 return -EINVAL; 349 return -EINVAL;
349 } 350 }
350 if (match->proto && (match->proto != proto || inv_proto)) { 351 if (par->match->proto && (par->match->proto != proto || inv_proto)) {
351 printk("%s_tables: %s match: only valid for protocol %u\n", 352 printk("%s_tables: %s match: only valid for protocol %u\n",
352 xt_prefix[family], match->name, match->proto); 353 xt_prefix[family], par->match->name, par->match->proto);
353 return -EINVAL; 354 return -EINVAL;
354 } 355 }
355 if (match->checkentry != NULL && 356 if (par->match->checkentry != NULL && !par->match->checkentry(par))
356 !match->checkentry(table, entry, match, matchinfo, hook_mask))
357 return -EINVAL; 357 return -EINVAL;
358 return 0; 358 return 0;
359} 359}
diff --git a/net/netfilter/xt_connbytes.c b/net/netfilter/xt_connbytes.c
index 30c19b5fe908..43a36c728e56 100644
--- a/net/netfilter/xt_connbytes.c
+++ b/net/netfilter/xt_connbytes.c
@@ -92,12 +92,9 @@ connbytes_mt(const struct sk_buff *skb, const struct xt_match_param *par)
92 return what >= sinfo->count.from; 92 return what >= sinfo->count.from;
93} 93}
94 94
95static bool 95static bool connbytes_mt_check(const struct xt_mtchk_param *par)
96connbytes_mt_check(const char *tablename, const void *ip,
97 const struct xt_match *match, void *matchinfo,
98 unsigned int hook_mask)
99{ 96{
100 const struct xt_connbytes_info *sinfo = matchinfo; 97 const struct xt_connbytes_info *sinfo = par->matchinfo;
101 98
102 if (sinfo->what != XT_CONNBYTES_PKTS && 99 if (sinfo->what != XT_CONNBYTES_PKTS &&
103 sinfo->what != XT_CONNBYTES_BYTES && 100 sinfo->what != XT_CONNBYTES_BYTES &&
@@ -109,17 +106,16 @@ connbytes_mt_check(const char *tablename, const void *ip,
109 sinfo->direction != XT_CONNBYTES_DIR_BOTH) 106 sinfo->direction != XT_CONNBYTES_DIR_BOTH)
110 return false; 107 return false;
111 108
112 if (nf_ct_l3proto_try_module_get(match->family) < 0) { 109 if (nf_ct_l3proto_try_module_get(par->match->family) < 0) {
113 printk(KERN_WARNING "can't load conntrack support for " 110 printk(KERN_WARNING "can't load conntrack support for "
114 "proto=%u\n", match->family); 111 "proto=%u\n", par->match->family);
115 return false; 112 return false;
116 } 113 }
117 114
118 return true; 115 return true;
119} 116}
120 117
121static void 118static void connbytes_mt_destroy(const struct xt_match *match, void *matchinfo)
122connbytes_mt_destroy(const struct xt_match *match, void *matchinfo)
123{ 119{
124 nf_ct_l3proto_module_put(match->family); 120 nf_ct_l3proto_module_put(match->family);
125} 121}
diff --git a/net/netfilter/xt_connlimit.c b/net/netfilter/xt_connlimit.c
index 8b8f70e76646..1361e9919cf2 100644
--- a/net/netfilter/xt_connlimit.c
+++ b/net/netfilter/xt_connlimit.c
@@ -221,24 +221,21 @@ connlimit_mt(const struct sk_buff *skb, const struct xt_match_param *par)
221 return false; 221 return false;
222} 222}
223 223
224static bool 224static bool connlimit_mt_check(const struct xt_mtchk_param *par)
225connlimit_mt_check(const char *tablename, const void *ip,
226 const struct xt_match *match, void *matchinfo,
227 unsigned int hook_mask)
228{ 225{
229 struct xt_connlimit_info *info = matchinfo; 226 struct xt_connlimit_info *info = par->matchinfo;
230 unsigned int i; 227 unsigned int i;
231 228
232 if (nf_ct_l3proto_try_module_get(match->family) < 0) { 229 if (nf_ct_l3proto_try_module_get(par->match->family) < 0) {
233 printk(KERN_WARNING "cannot load conntrack support for " 230 printk(KERN_WARNING "cannot load conntrack support for "
234 "address family %u\n", match->family); 231 "address family %u\n", par->match->family);
235 return false; 232 return false;
236 } 233 }
237 234
238 /* init private data */ 235 /* init private data */
239 info->data = kmalloc(sizeof(struct xt_connlimit_data), GFP_KERNEL); 236 info->data = kmalloc(sizeof(struct xt_connlimit_data), GFP_KERNEL);
240 if (info->data == NULL) { 237 if (info->data == NULL) {
241 nf_ct_l3proto_module_put(match->family); 238 nf_ct_l3proto_module_put(par->match->family);
242 return false; 239 return false;
243 } 240 }
244 241
diff --git a/net/netfilter/xt_connmark.c b/net/netfilter/xt_connmark.c
index df4f4a865a5e..b935b7888a90 100644
--- a/net/netfilter/xt_connmark.c
+++ b/net/netfilter/xt_connmark.c
@@ -61,33 +61,27 @@ connmark_mt_v0(const struct sk_buff *skb, const struct xt_match_param *par)
61 return ((ct->mark & info->mask) == info->mark) ^ info->invert; 61 return ((ct->mark & info->mask) == info->mark) ^ info->invert;
62} 62}
63 63
64static bool 64static bool connmark_mt_check_v0(const struct xt_mtchk_param *par)
65connmark_mt_check_v0(const char *tablename, const void *ip,
66 const struct xt_match *match, void *matchinfo,
67 unsigned int hook_mask)
68{ 65{
69 const struct xt_connmark_info *cm = matchinfo; 66 const struct xt_connmark_info *cm = par->matchinfo;
70 67
71 if (cm->mark > 0xffffffff || cm->mask > 0xffffffff) { 68 if (cm->mark > 0xffffffff || cm->mask > 0xffffffff) {
72 printk(KERN_WARNING "connmark: only support 32bit mark\n"); 69 printk(KERN_WARNING "connmark: only support 32bit mark\n");
73 return false; 70 return false;
74 } 71 }
75 if (nf_ct_l3proto_try_module_get(match->family) < 0) { 72 if (nf_ct_l3proto_try_module_get(par->match->family) < 0) {
76 printk(KERN_WARNING "can't load conntrack support for " 73 printk(KERN_WARNING "can't load conntrack support for "
77 "proto=%u\n", match->family); 74 "proto=%u\n", par->match->family);
78 return false; 75 return false;
79 } 76 }
80 return true; 77 return true;
81} 78}
82 79
83static bool 80static bool connmark_mt_check(const struct xt_mtchk_param *par)
84connmark_mt_check(const char *tablename, const void *ip,
85 const struct xt_match *match, void *matchinfo,
86 unsigned int hook_mask)
87{ 81{
88 if (nf_ct_l3proto_try_module_get(match->family) < 0) { 82 if (nf_ct_l3proto_try_module_get(par->match->family) < 0) {
89 printk(KERN_WARNING "cannot load conntrack support for " 83 printk(KERN_WARNING "cannot load conntrack support for "
90 "proto=%u\n", match->family); 84 "proto=%u\n", par->match->family);
91 return false; 85 return false;
92 } 86 }
93 return true; 87 return true;
diff --git a/net/netfilter/xt_conntrack.c b/net/netfilter/xt_conntrack.c
index 13a7e4eacdfd..f04c46a02ce0 100644
--- a/net/netfilter/xt_conntrack.c
+++ b/net/netfilter/xt_conntrack.c
@@ -278,14 +278,11 @@ conntrack_mt(const struct sk_buff *skb, const struct xt_match_param *par)
278 return true; 278 return true;
279} 279}
280 280
281static bool 281static bool conntrack_mt_check(const struct xt_mtchk_param *par)
282conntrack_mt_check(const char *tablename, const void *ip,
283 const struct xt_match *match, void *matchinfo,
284 unsigned int hook_mask)
285{ 282{
286 if (nf_ct_l3proto_try_module_get(match->family) < 0) { 283 if (nf_ct_l3proto_try_module_get(par->match->family) < 0) {
287 printk(KERN_WARNING "can't load conntrack support for " 284 printk(KERN_WARNING "can't load conntrack support for "
288 "proto=%u\n", match->family); 285 "proto=%u\n", par->match->family);
289 return false; 286 return false;
290 } 287 }
291 return true; 288 return true;
diff --git a/net/netfilter/xt_dccp.c b/net/netfilter/xt_dccp.c
index 7aa30bb91050..e5d3e8673287 100644
--- a/net/netfilter/xt_dccp.c
+++ b/net/netfilter/xt_dccp.c
@@ -121,12 +121,9 @@ dccp_mt(const struct sk_buff *skb, const struct xt_match_param *par)
121 XT_DCCP_OPTION, info->flags, info->invflags); 121 XT_DCCP_OPTION, info->flags, info->invflags);
122} 122}
123 123
124static bool 124static bool dccp_mt_check(const struct xt_mtchk_param *par)
125dccp_mt_check(const char *tablename, const void *inf,
126 const struct xt_match *match, void *matchinfo,
127 unsigned int hook_mask)
128{ 125{
129 const struct xt_dccp_info *info = matchinfo; 126 const struct xt_dccp_info *info = par->matchinfo;
130 127
131 return !(info->flags & ~XT_DCCP_VALID_FLAGS) 128 return !(info->flags & ~XT_DCCP_VALID_FLAGS)
132 && !(info->invflags & ~XT_DCCP_VALID_FLAGS) 129 && !(info->invflags & ~XT_DCCP_VALID_FLAGS)
diff --git a/net/netfilter/xt_dscp.c b/net/netfilter/xt_dscp.c
index 57d612061358..c3f8085460d7 100644
--- a/net/netfilter/xt_dscp.c
+++ b/net/netfilter/xt_dscp.c
@@ -43,15 +43,12 @@ dscp_mt6(const struct sk_buff *skb, const struct xt_match_param *par)
43 return (dscp == info->dscp) ^ !!info->invert; 43 return (dscp == info->dscp) ^ !!info->invert;
44} 44}
45 45
46static bool 46static bool dscp_mt_check(const struct xt_mtchk_param *par)
47dscp_mt_check(const char *tablename, const void *info,
48 const struct xt_match *match, void *matchinfo,
49 unsigned int hook_mask)
50{ 47{
51 const u_int8_t dscp = ((struct xt_dscp_info *)matchinfo)->dscp; 48 const struct xt_dscp_info *info = par->matchinfo;
52 49
53 if (dscp > XT_DSCP_MAX) { 50 if (info->dscp > XT_DSCP_MAX) {
54 printk(KERN_ERR "xt_dscp: dscp %x out of range\n", dscp); 51 printk(KERN_ERR "xt_dscp: dscp %x out of range\n", info->dscp);
55 return false; 52 return false;
56 } 53 }
57 54
diff --git a/net/netfilter/xt_esp.c b/net/netfilter/xt_esp.c
index 6d59f2e7c1c1..609439967c2c 100644
--- a/net/netfilter/xt_esp.c
+++ b/net/netfilter/xt_esp.c
@@ -66,13 +66,9 @@ static bool esp_mt(const struct sk_buff *skb, const struct xt_match_param *par)
66 !!(espinfo->invflags & XT_ESP_INV_SPI)); 66 !!(espinfo->invflags & XT_ESP_INV_SPI));
67} 67}
68 68
69/* Called when user tries to insert an entry of this type. */ 69static bool esp_mt_check(const struct xt_mtchk_param *par)
70static bool
71esp_mt_check(const char *tablename, const void *ip_void,
72 const struct xt_match *match, void *matchinfo,
73 unsigned int hook_mask)
74{ 70{
75 const struct xt_esp *espinfo = matchinfo; 71 const struct xt_esp *espinfo = par->matchinfo;
76 72
77 if (espinfo->invflags & ~XT_ESP_INV_MASK) { 73 if (espinfo->invflags & ~XT_ESP_INV_MASK) {
78 duprintf("xt_esp: unknown flags %X\n", espinfo->invflags); 74 duprintf("xt_esp: unknown flags %X\n", espinfo->invflags);
diff --git a/net/netfilter/xt_hashlimit.c b/net/netfilter/xt_hashlimit.c
index 22a60a728cf1..2f73820e46d7 100644
--- a/net/netfilter/xt_hashlimit.c
+++ b/net/netfilter/xt_hashlimit.c
@@ -664,12 +664,9 @@ hashlimit_mt(const struct sk_buff *skb, const struct xt_match_param *par)
664 return false; 664 return false;
665} 665}
666 666
667static bool 667static bool hashlimit_mt_check_v0(const struct xt_mtchk_param *par)
668hashlimit_mt_check_v0(const char *tablename, const void *inf,
669 const struct xt_match *match, void *matchinfo,
670 unsigned int hook_mask)
671{ 668{
672 struct xt_hashlimit_info *r = matchinfo; 669 struct xt_hashlimit_info *r = par->matchinfo;
673 670
674 /* Check for overflow. */ 671 /* Check for overflow. */
675 if (r->cfg.burst == 0 || 672 if (r->cfg.burst == 0 ||
@@ -698,8 +695,8 @@ hashlimit_mt_check_v0(const char *tablename, const void *inf,
698 * the list of htable's in htable_create(), since then we would 695 * the list of htable's in htable_create(), since then we would
699 * create duplicate proc files. -HW */ 696 * create duplicate proc files. -HW */
700 mutex_lock(&hlimit_mutex); 697 mutex_lock(&hlimit_mutex);
701 r->hinfo = htable_find_get(r->name, match->family); 698 r->hinfo = htable_find_get(r->name, par->match->family);
702 if (!r->hinfo && htable_create_v0(r, match->family) != 0) { 699 if (!r->hinfo && htable_create_v0(r, par->match->family) != 0) {
703 mutex_unlock(&hlimit_mutex); 700 mutex_unlock(&hlimit_mutex);
704 return false; 701 return false;
705 } 702 }
@@ -710,12 +707,9 @@ hashlimit_mt_check_v0(const char *tablename, const void *inf,
710 return true; 707 return true;
711} 708}
712 709
713static bool 710static bool hashlimit_mt_check(const struct xt_mtchk_param *par)
714hashlimit_mt_check(const char *tablename, const void *inf,
715 const struct xt_match *match, void *matchinfo,
716 unsigned int hook_mask)
717{ 711{
718 struct xt_hashlimit_mtinfo1 *info = matchinfo; 712 struct xt_hashlimit_mtinfo1 *info = par->matchinfo;
719 713
720 /* Check for overflow. */ 714 /* Check for overflow. */
721 if (info->cfg.burst == 0 || 715 if (info->cfg.burst == 0 ||
@@ -729,7 +723,7 @@ hashlimit_mt_check(const char *tablename, const void *inf,
729 return false; 723 return false;
730 if (info->name[sizeof(info->name)-1] != '\0') 724 if (info->name[sizeof(info->name)-1] != '\0')
731 return false; 725 return false;
732 if (match->family == NFPROTO_IPV4) { 726 if (par->match->family == NFPROTO_IPV4) {
733 if (info->cfg.srcmask > 32 || info->cfg.dstmask > 32) 727 if (info->cfg.srcmask > 32 || info->cfg.dstmask > 32)
734 return false; 728 return false;
735 } else { 729 } else {
@@ -744,8 +738,8 @@ hashlimit_mt_check(const char *tablename, const void *inf,
744 * the list of htable's in htable_create(), since then we would 738 * the list of htable's in htable_create(), since then we would
745 * create duplicate proc files. -HW */ 739 * create duplicate proc files. -HW */
746 mutex_lock(&hlimit_mutex); 740 mutex_lock(&hlimit_mutex);
747 info->hinfo = htable_find_get(info->name, match->family); 741 info->hinfo = htable_find_get(info->name, par->match->family);
748 if (!info->hinfo && htable_create(info, match->family) != 0) { 742 if (!info->hinfo && htable_create(info, par->match->family) != 0) {
749 mutex_unlock(&hlimit_mutex); 743 mutex_unlock(&hlimit_mutex);
750 return false; 744 return false;
751 } 745 }
diff --git a/net/netfilter/xt_helper.c b/net/netfilter/xt_helper.c
index 73bdc3ba13fc..86d3c332fcb8 100644
--- a/net/netfilter/xt_helper.c
+++ b/net/netfilter/xt_helper.c
@@ -54,16 +54,13 @@ helper_mt(const struct sk_buff *skb, const struct xt_match_param *par)
54 return ret; 54 return ret;
55} 55}
56 56
57static bool 57static bool helper_mt_check(const struct xt_mtchk_param *par)
58helper_mt_check(const char *tablename, const void *inf,
59 const struct xt_match *match, void *matchinfo,
60 unsigned int hook_mask)
61{ 58{
62 struct xt_helper_info *info = matchinfo; 59 struct xt_helper_info *info = par->matchinfo;
63 60
64 if (nf_ct_l3proto_try_module_get(match->family) < 0) { 61 if (nf_ct_l3proto_try_module_get(par->match->family) < 0) {
65 printk(KERN_WARNING "can't load conntrack support for " 62 printk(KERN_WARNING "can't load conntrack support for "
66 "proto=%u\n", match->family); 63 "proto=%u\n", par->match->family);
67 return false; 64 return false;
68 } 65 }
69 info->name[29] = '\0'; 66 info->name[29] = '\0';
diff --git a/net/netfilter/xt_limit.c b/net/netfilter/xt_limit.c
index c475eac5dbec..c908d69a5595 100644
--- a/net/netfilter/xt_limit.c
+++ b/net/netfilter/xt_limit.c
@@ -92,12 +92,9 @@ user2credits(u_int32_t user)
92 return (user * HZ * CREDITS_PER_JIFFY) / XT_LIMIT_SCALE; 92 return (user * HZ * CREDITS_PER_JIFFY) / XT_LIMIT_SCALE;
93} 93}
94 94
95static bool 95static bool limit_mt_check(const struct xt_mtchk_param *par)
96limit_mt_check(const char *tablename, const void *inf,
97 const struct xt_match *match, void *matchinfo,
98 unsigned int hook_mask)
99{ 96{
100 struct xt_rateinfo *r = matchinfo; 97 struct xt_rateinfo *r = par->matchinfo;
101 98
102 /* Check for overflow. */ 99 /* Check for overflow. */
103 if (r->burst == 0 100 if (r->burst == 0
diff --git a/net/netfilter/xt_mark.c b/net/netfilter/xt_mark.c
index 885476146531..10b9e34bbc5b 100644
--- a/net/netfilter/xt_mark.c
+++ b/net/netfilter/xt_mark.c
@@ -38,12 +38,9 @@ mark_mt(const struct sk_buff *skb, const struct xt_match_param *par)
38 return ((skb->mark & info->mask) == info->mark) ^ info->invert; 38 return ((skb->mark & info->mask) == info->mark) ^ info->invert;
39} 39}
40 40
41static bool 41static bool mark_mt_check_v0(const struct xt_mtchk_param *par)
42mark_mt_check_v0(const char *tablename, const void *entry,
43 const struct xt_match *match, void *matchinfo,
44 unsigned int hook_mask)
45{ 42{
46 const struct xt_mark_info *minfo = matchinfo; 43 const struct xt_mark_info *minfo = par->matchinfo;
47 44
48 if (minfo->mark > 0xffffffff || minfo->mask > 0xffffffff) { 45 if (minfo->mark > 0xffffffff || minfo->mask > 0xffffffff) {
49 printk(KERN_WARNING "mark: only supports 32bit mark\n"); 46 printk(KERN_WARNING "mark: only supports 32bit mark\n");
diff --git a/net/netfilter/xt_multiport.c b/net/netfilter/xt_multiport.c
index 7087e291528d..d06bb2dd3900 100644
--- a/net/netfilter/xt_multiport.c
+++ b/net/netfilter/xt_multiport.c
@@ -158,50 +158,37 @@ check(u_int16_t proto,
158 && count <= XT_MULTI_PORTS; 158 && count <= XT_MULTI_PORTS;
159} 159}
160 160
161/* Called when user tries to insert an entry of this type. */ 161static bool multiport_mt_check_v0(const struct xt_mtchk_param *par)
162static bool
163multiport_mt_check_v0(const char *tablename, const void *info,
164 const struct xt_match *match, void *matchinfo,
165 unsigned int hook_mask)
166{ 162{
167 const struct ipt_ip *ip = info; 163 const struct ipt_ip *ip = par->entryinfo;
168 const struct xt_multiport *multiinfo = matchinfo; 164 const struct xt_multiport *multiinfo = par->matchinfo;
169 165
170 return check(ip->proto, ip->invflags, multiinfo->flags, 166 return check(ip->proto, ip->invflags, multiinfo->flags,
171 multiinfo->count); 167 multiinfo->count);
172} 168}
173 169
174static bool 170static bool multiport_mt_check(const struct xt_mtchk_param *par)
175multiport_mt_check(const char *tablename, const void *info,
176 const struct xt_match *match, void *matchinfo,
177 unsigned int hook_mask)
178{ 171{
179 const struct ipt_ip *ip = info; 172 const struct ipt_ip *ip = par->entryinfo;
180 const struct xt_multiport_v1 *multiinfo = matchinfo; 173 const struct xt_multiport_v1 *multiinfo = par->matchinfo;
181 174
182 return check(ip->proto, ip->invflags, multiinfo->flags, 175 return check(ip->proto, ip->invflags, multiinfo->flags,
183 multiinfo->count); 176 multiinfo->count);
184} 177}
185 178
186static bool 179static bool multiport_mt6_check_v0(const struct xt_mtchk_param *par)
187multiport_mt6_check_v0(const char *tablename, const void *info,
188 const struct xt_match *match, void *matchinfo,
189 unsigned int hook_mask)
190{ 180{
191 const struct ip6t_ip6 *ip = info; 181 const struct ip6t_ip6 *ip = par->entryinfo;
192 const struct xt_multiport *multiinfo = matchinfo; 182 const struct xt_multiport *multiinfo = par->matchinfo;
193 183
194 return check(ip->proto, ip->invflags, multiinfo->flags, 184 return check(ip->proto, ip->invflags, multiinfo->flags,
195 multiinfo->count); 185 multiinfo->count);
196} 186}
197 187
198static bool 188static bool multiport_mt6_check(const struct xt_mtchk_param *par)
199multiport_mt6_check(const char *tablename, const void *info,
200 const struct xt_match *match, void *matchinfo,
201 unsigned int hook_mask)
202{ 189{
203 const struct ip6t_ip6 *ip = info; 190 const struct ip6t_ip6 *ip = par->entryinfo;
204 const struct xt_multiport_v1 *multiinfo = matchinfo; 191 const struct xt_multiport_v1 *multiinfo = par->matchinfo;
205 192
206 return check(ip->proto, ip->invflags, multiinfo->flags, 193 return check(ip->proto, ip->invflags, multiinfo->flags,
207 multiinfo->count); 194 multiinfo->count);
diff --git a/net/netfilter/xt_owner.c b/net/netfilter/xt_owner.c
index 493b5eb8d148..32f84e84d9e6 100644
--- a/net/netfilter/xt_owner.c
+++ b/net/netfilter/xt_owner.c
@@ -107,12 +107,9 @@ owner_mt(const struct sk_buff *skb, const struct xt_match_param *par)
107 return true; 107 return true;
108} 108}
109 109
110static bool 110static bool owner_mt_check_v0(const struct xt_mtchk_param *par)
111owner_mt_check_v0(const char *tablename, const void *ip,
112 const struct xt_match *match, void *matchinfo,
113 unsigned int hook_mask)
114{ 111{
115 const struct ipt_owner_info *info = matchinfo; 112 const struct ipt_owner_info *info = par->matchinfo;
116 113
117 if (info->match & (IPT_OWNER_PID | IPT_OWNER_SID | IPT_OWNER_COMM)) { 114 if (info->match & (IPT_OWNER_PID | IPT_OWNER_SID | IPT_OWNER_COMM)) {
118 printk(KERN_WARNING KBUILD_MODNAME 115 printk(KERN_WARNING KBUILD_MODNAME
@@ -124,12 +121,9 @@ owner_mt_check_v0(const char *tablename, const void *ip,
124 return true; 121 return true;
125} 122}
126 123
127static bool 124static bool owner_mt6_check_v0(const struct xt_mtchk_param *par)
128owner_mt6_check_v0(const char *tablename, const void *ip,
129 const struct xt_match *match, void *matchinfo,
130 unsigned int hook_mask)
131{ 125{
132 const struct ip6t_owner_info *info = matchinfo; 126 const struct ip6t_owner_info *info = par->matchinfo;
133 127
134 if (info->match & (IP6T_OWNER_PID | IP6T_OWNER_SID)) { 128 if (info->match & (IP6T_OWNER_PID | IP6T_OWNER_SID)) {
135 printk(KERN_WARNING KBUILD_MODNAME 129 printk(KERN_WARNING KBUILD_MODNAME
diff --git a/net/netfilter/xt_physdev.c b/net/netfilter/xt_physdev.c
index e980e179d4f1..b01786d2dd91 100644
--- a/net/netfilter/xt_physdev.c
+++ b/net/netfilter/xt_physdev.c
@@ -91,12 +91,9 @@ match_outdev:
91 return ret ^ !(info->invert & XT_PHYSDEV_OP_OUT); 91 return ret ^ !(info->invert & XT_PHYSDEV_OP_OUT);
92} 92}
93 93
94static bool 94static bool physdev_mt_check(const struct xt_mtchk_param *par)
95physdev_mt_check(const char *tablename, const void *ip,
96 const struct xt_match *match, void *matchinfo,
97 unsigned int hook_mask)
98{ 95{
99 const struct xt_physdev_info *info = matchinfo; 96 const struct xt_physdev_info *info = par->matchinfo;
100 97
101 if (!(info->bitmask & XT_PHYSDEV_OP_MASK) || 98 if (!(info->bitmask & XT_PHYSDEV_OP_MASK) ||
102 info->bitmask & ~XT_PHYSDEV_OP_MASK) 99 info->bitmask & ~XT_PHYSDEV_OP_MASK)
@@ -104,12 +101,12 @@ physdev_mt_check(const char *tablename, const void *ip,
104 if (info->bitmask & XT_PHYSDEV_OP_OUT && 101 if (info->bitmask & XT_PHYSDEV_OP_OUT &&
105 (!(info->bitmask & XT_PHYSDEV_OP_BRIDGED) || 102 (!(info->bitmask & XT_PHYSDEV_OP_BRIDGED) ||
106 info->invert & XT_PHYSDEV_OP_BRIDGED) && 103 info->invert & XT_PHYSDEV_OP_BRIDGED) &&
107 hook_mask & ((1 << NF_INET_LOCAL_OUT) | (1 << NF_INET_FORWARD) | 104 par->hook_mask & ((1 << NF_INET_LOCAL_OUT) |
108 (1 << NF_INET_POST_ROUTING))) { 105 (1 << NF_INET_FORWARD) | (1 << NF_INET_POST_ROUTING))) {
109 printk(KERN_WARNING "physdev match: using --physdev-out in the " 106 printk(KERN_WARNING "physdev match: using --physdev-out in the "
110 "OUTPUT, FORWARD and POSTROUTING chains for non-bridged " 107 "OUTPUT, FORWARD and POSTROUTING chains for non-bridged "
111 "traffic is not supported anymore.\n"); 108 "traffic is not supported anymore.\n");
112 if (hook_mask & (1 << NF_INET_LOCAL_OUT)) 109 if (par->hook_mask & (1 << NF_INET_LOCAL_OUT))
113 return false; 110 return false;
114 } 111 }
115 return true; 112 return true;
diff --git a/net/netfilter/xt_policy.c b/net/netfilter/xt_policy.c
index b0a00fb0511b..328bd20ddd25 100644
--- a/net/netfilter/xt_policy.c
+++ b/net/netfilter/xt_policy.c
@@ -128,26 +128,23 @@ policy_mt(const struct sk_buff *skb, const struct xt_match_param *par)
128 return ret; 128 return ret;
129} 129}
130 130
131static bool 131static bool policy_mt_check(const struct xt_mtchk_param *par)
132policy_mt_check(const char *tablename, const void *ip_void,
133 const struct xt_match *match, void *matchinfo,
134 unsigned int hook_mask)
135{ 132{
136 const struct xt_policy_info *info = matchinfo; 133 const struct xt_policy_info *info = par->matchinfo;
137 134
138 if (!(info->flags & (XT_POLICY_MATCH_IN|XT_POLICY_MATCH_OUT))) { 135 if (!(info->flags & (XT_POLICY_MATCH_IN|XT_POLICY_MATCH_OUT))) {
139 printk(KERN_ERR "xt_policy: neither incoming nor " 136 printk(KERN_ERR "xt_policy: neither incoming nor "
140 "outgoing policy selected\n"); 137 "outgoing policy selected\n");
141 return false; 138 return false;
142 } 139 }
143 if (hook_mask & (1 << NF_INET_PRE_ROUTING | 1 << NF_INET_LOCAL_IN) 140 if (par->hook_mask & ((1 << NF_INET_PRE_ROUTING) |
144 && info->flags & XT_POLICY_MATCH_OUT) { 141 (1 << NF_INET_LOCAL_IN)) && info->flags & XT_POLICY_MATCH_OUT) {
145 printk(KERN_ERR "xt_policy: output policy not valid in " 142 printk(KERN_ERR "xt_policy: output policy not valid in "
146 "PRE_ROUTING and INPUT\n"); 143 "PRE_ROUTING and INPUT\n");
147 return false; 144 return false;
148 } 145 }
149 if (hook_mask & (1 << NF_INET_POST_ROUTING | 1 << NF_INET_LOCAL_OUT) 146 if (par->hook_mask & ((1 << NF_INET_POST_ROUTING) |
150 && info->flags & XT_POLICY_MATCH_IN) { 147 (1 << NF_INET_LOCAL_OUT)) && info->flags & XT_POLICY_MATCH_IN) {
151 printk(KERN_ERR "xt_policy: input policy not valid in " 148 printk(KERN_ERR "xt_policy: input policy not valid in "
152 "POST_ROUTING and OUTPUT\n"); 149 "POST_ROUTING and OUTPUT\n");
153 return false; 150 return false;
diff --git a/net/netfilter/xt_quota.c b/net/netfilter/xt_quota.c
index 3ab92666c149..c84fce5e0f3e 100644
--- a/net/netfilter/xt_quota.c
+++ b/net/netfilter/xt_quota.c
@@ -37,12 +37,9 @@ quota_mt(const struct sk_buff *skb, const struct xt_match_param *par)
37 return ret; 37 return ret;
38} 38}
39 39
40static bool 40static bool quota_mt_check(const struct xt_mtchk_param *par)
41quota_mt_check(const char *tablename, const void *entry,
42 const struct xt_match *match, void *matchinfo,
43 unsigned int hook_mask)
44{ 41{
45 struct xt_quota_info *q = matchinfo; 42 struct xt_quota_info *q = par->matchinfo;
46 43
47 if (q->flags & ~XT_QUOTA_MASK) 44 if (q->flags & ~XT_QUOTA_MASK)
48 return false; 45 return false;
diff --git a/net/netfilter/xt_rateest.c b/net/netfilter/xt_rateest.c
index e9f64ef45655..4b05ce168a78 100644
--- a/net/netfilter/xt_rateest.c
+++ b/net/netfilter/xt_rateest.c
@@ -74,13 +74,9 @@ xt_rateest_mt(const struct sk_buff *skb, const struct xt_match_param *par)
74 return ret; 74 return ret;
75} 75}
76 76
77static bool xt_rateest_mt_checkentry(const char *tablename, 77static bool xt_rateest_mt_checkentry(const struct xt_mtchk_param *par)
78 const void *ip,
79 const struct xt_match *match,
80 void *matchinfo,
81 unsigned int hook_mask)
82{ 78{
83 struct xt_rateest_match_info *info = matchinfo; 79 struct xt_rateest_match_info *info = par->matchinfo;
84 struct xt_rateest *est1, *est2; 80 struct xt_rateest *est1, *est2;
85 81
86 if (hweight32(info->flags & (XT_RATEEST_MATCH_ABS | 82 if (hweight32(info->flags & (XT_RATEEST_MATCH_ABS |
diff --git a/net/netfilter/xt_recent.c b/net/netfilter/xt_recent.c
index baeb90a56231..a512b49f3fe4 100644
--- a/net/netfilter/xt_recent.c
+++ b/net/netfilter/xt_recent.c
@@ -280,12 +280,9 @@ out:
280 return ret; 280 return ret;
281} 281}
282 282
283static bool 283static bool recent_mt_check(const struct xt_mtchk_param *par)
284recent_mt_check(const char *tablename, const void *ip,
285 const struct xt_match *match, void *matchinfo,
286 unsigned int hook_mask)
287{ 284{
288 const struct xt_recent_mtinfo *info = matchinfo; 285 const struct xt_recent_mtinfo *info = par->matchinfo;
289 struct recent_table *t; 286 struct recent_table *t;
290 unsigned i; 287 unsigned i;
291 bool ret = false; 288 bool ret = false;
diff --git a/net/netfilter/xt_sctp.c b/net/netfilter/xt_sctp.c
index b0014ab65da7..e223cb43ae8e 100644
--- a/net/netfilter/xt_sctp.c
+++ b/net/netfilter/xt_sctp.c
@@ -147,12 +147,9 @@ sctp_mt(const struct sk_buff *skb, const struct xt_match_param *par)
147 XT_SCTP_CHUNK_TYPES, info->flags, info->invflags); 147 XT_SCTP_CHUNK_TYPES, info->flags, info->invflags);
148} 148}
149 149
150static bool 150static bool sctp_mt_check(const struct xt_mtchk_param *par)
151sctp_mt_check(const char *tablename, const void *inf,
152 const struct xt_match *match, void *matchinfo,
153 unsigned int hook_mask)
154{ 151{
155 const struct xt_sctp_info *info = matchinfo; 152 const struct xt_sctp_info *info = par->matchinfo;
156 153
157 return !(info->flags & ~XT_SCTP_VALID_FLAGS) 154 return !(info->flags & ~XT_SCTP_VALID_FLAGS)
158 && !(info->invflags & ~XT_SCTP_VALID_FLAGS) 155 && !(info->invflags & ~XT_SCTP_VALID_FLAGS)
diff --git a/net/netfilter/xt_state.c b/net/netfilter/xt_state.c
index 29f5a8a1b024..88b1235519d7 100644
--- a/net/netfilter/xt_state.c
+++ b/net/netfilter/xt_state.c
@@ -37,14 +37,11 @@ state_mt(const struct sk_buff *skb, const struct xt_match_param *par)
37 return (sinfo->statemask & statebit); 37 return (sinfo->statemask & statebit);
38} 38}
39 39
40static bool 40static bool state_mt_check(const struct xt_mtchk_param *par)
41state_mt_check(const char *tablename, const void *inf,
42 const struct xt_match *match, void *matchinfo,
43 unsigned int hook_mask)
44{ 41{
45 if (nf_ct_l3proto_try_module_get(match->family) < 0) { 42 if (nf_ct_l3proto_try_module_get(par->match->family) < 0) {
46 printk(KERN_WARNING "can't load conntrack support for " 43 printk(KERN_WARNING "can't load conntrack support for "
47 "proto=%u\n", match->family); 44 "proto=%u\n", par->match->family);
48 return false; 45 return false;
49 } 46 }
50 return true; 47 return true;
diff --git a/net/netfilter/xt_statistic.c b/net/netfilter/xt_statistic.c
index dcadc491db21..0d75141139d5 100644
--- a/net/netfilter/xt_statistic.c
+++ b/net/netfilter/xt_statistic.c
@@ -49,12 +49,9 @@ statistic_mt(const struct sk_buff *skb, const struct xt_match_param *par)
49 return ret; 49 return ret;
50} 50}
51 51
52static bool 52static bool statistic_mt_check(const struct xt_mtchk_param *par)
53statistic_mt_check(const char *tablename, const void *entry,
54 const struct xt_match *match, void *matchinfo,
55 unsigned int hook_mask)
56{ 53{
57 struct xt_statistic_info *info = matchinfo; 54 struct xt_statistic_info *info = par->matchinfo;
58 55
59 if (info->mode > XT_STATISTIC_MODE_MAX || 56 if (info->mode > XT_STATISTIC_MODE_MAX ||
60 info->flags & ~XT_STATISTIC_MASK) 57 info->flags & ~XT_STATISTIC_MASK)
diff --git a/net/netfilter/xt_string.c b/net/netfilter/xt_string.c
index 33f2d29ca4f7..c9407aa78f73 100644
--- a/net/netfilter/xt_string.c
+++ b/net/netfilter/xt_string.c
@@ -40,12 +40,9 @@ string_mt(const struct sk_buff *skb, const struct xt_match_param *par)
40 40
41#define STRING_TEXT_PRIV(m) ((struct xt_string_info *)(m)) 41#define STRING_TEXT_PRIV(m) ((struct xt_string_info *)(m))
42 42
43static bool 43static bool string_mt_check(const struct xt_mtchk_param *par)
44string_mt_check(const char *tablename, const void *ip,
45 const struct xt_match *match, void *matchinfo,
46 unsigned int hook_mask)
47{ 44{
48 struct xt_string_info *conf = matchinfo; 45 struct xt_string_info *conf = par->matchinfo;
49 struct ts_config *ts_conf; 46 struct ts_config *ts_conf;
50 int flags = TS_AUTOLOAD; 47 int flags = TS_AUTOLOAD;
51 48
@@ -56,7 +53,7 @@ string_mt_check(const char *tablename, const void *ip,
56 return false; 53 return false;
57 if (conf->patlen > XT_STRING_MAX_PATTERN_SIZE) 54 if (conf->patlen > XT_STRING_MAX_PATTERN_SIZE)
58 return false; 55 return false;
59 if (match->revision == 1) { 56 if (par->match->revision == 1) {
60 if (conf->u.v1.flags & 57 if (conf->u.v1.flags &
61 ~(XT_STRING_FLAG_IGNORECASE | XT_STRING_FLAG_INVERT)) 58 ~(XT_STRING_FLAG_IGNORECASE | XT_STRING_FLAG_INVERT))
62 return false; 59 return false;
diff --git a/net/netfilter/xt_tcpudp.c b/net/netfilter/xt_tcpudp.c
index 66cf71b1d59c..1ebdc4934eed 100644
--- a/net/netfilter/xt_tcpudp.c
+++ b/net/netfilter/xt_tcpudp.c
@@ -126,13 +126,9 @@ static bool tcp_mt(const struct sk_buff *skb, const struct xt_match_param *par)
126 return true; 126 return true;
127} 127}
128 128
129/* Called when user tries to insert an entry of this type. */ 129static bool tcp_mt_check(const struct xt_mtchk_param *par)
130static bool
131tcp_mt_check(const char *tablename, const void *info,
132 const struct xt_match *match, void *matchinfo,
133 unsigned int hook_mask)
134{ 130{
135 const struct xt_tcp *tcpinfo = matchinfo; 131 const struct xt_tcp *tcpinfo = par->matchinfo;
136 132
137 /* Must specify no unknown invflags */ 133 /* Must specify no unknown invflags */
138 return !(tcpinfo->invflags & ~XT_TCP_INV_MASK); 134 return !(tcpinfo->invflags & ~XT_TCP_INV_MASK);
@@ -165,13 +161,9 @@ static bool udp_mt(const struct sk_buff *skb, const struct xt_match_param *par)
165 !!(udpinfo->invflags & XT_UDP_INV_DSTPT)); 161 !!(udpinfo->invflags & XT_UDP_INV_DSTPT));
166} 162}
167 163
168/* Called when user tries to insert an entry of this type. */ 164static bool udp_mt_check(const struct xt_mtchk_param *par)
169static bool
170udp_mt_check(const char *tablename, const void *info,
171 const struct xt_match *match, void *matchinfo,
172 unsigned int hook_mask)
173{ 165{
174 const struct xt_udp *udpinfo = matchinfo; 166 const struct xt_udp *udpinfo = par->matchinfo;
175 167
176 /* Must specify no unknown invflags */ 168 /* Must specify no unknown invflags */
177 return !(udpinfo->invflags & ~XT_UDP_INV_MASK); 169 return !(udpinfo->invflags & ~XT_UDP_INV_MASK);
diff --git a/net/netfilter/xt_time.c b/net/netfilter/xt_time.c
index 28599d3979c4..29375ba8db73 100644
--- a/net/netfilter/xt_time.c
+++ b/net/netfilter/xt_time.c
@@ -218,12 +218,9 @@ time_mt(const struct sk_buff *skb, const struct xt_match_param *par)
218 return true; 218 return true;
219} 219}
220 220
221static bool 221static bool time_mt_check(const struct xt_mtchk_param *par)
222time_mt_check(const char *tablename, const void *ip,
223 const struct xt_match *match, void *matchinfo,
224 unsigned int hook_mask)
225{ 222{
226 const struct xt_time_info *info = matchinfo; 223 const struct xt_time_info *info = par->matchinfo;
227 224
228 if (info->daytime_start > XT_TIME_MAX_DAYTIME || 225 if (info->daytime_start > XT_TIME_MAX_DAYTIME ||
229 info->daytime_stop > XT_TIME_MAX_DAYTIME) { 226 info->daytime_stop > XT_TIME_MAX_DAYTIME) {