netfilter: xtables: move extension arguments into compound structure (2/6)
[linux-3.10.git] / net / netfilter / x_tables.c
index aece6c2..817ab14 100644 (file)
@@ -30,7 +30,7 @@
 
 MODULE_LICENSE("GPL");
 MODULE_AUTHOR("Harald Welte <laforge@netfilter.org>");
-MODULE_DESCRIPTION("[ip,ip6,arp]_tables backend module");
+MODULE_DESCRIPTION("{ip,ip6,arp,eb}_tables backend module");
 
 #define SMP_ALIGN(x) (((x) + SMP_CACHE_BYTES-1) & ~(SMP_CACHE_BYTES-1))
 
@@ -321,31 +321,40 @@ int xt_find_revision(u8 af, const char *name, u8 revision, int target,
 }
 EXPORT_SYMBOL_GPL(xt_find_revision);
 
-int xt_check_match(const struct xt_match *match, unsigned short family,
-                  unsigned int size, const char *table, unsigned int hook_mask,
-                  unsigned short proto, int inv_proto)
+int xt_check_match(struct xt_mtchk_param *par, u_int8_t family,
+                  unsigned int size, u_int8_t proto, bool inv_proto)
 {
-       if (XT_ALIGN(match->matchsize) != size) {
+       if (XT_ALIGN(par->match->matchsize) != size &&
+           par->match->matchsize != -1) {
+               /*
+                * ebt_among is exempt from centralized matchsize checking
+                * because it uses a dynamic-size data set.
+                */
                printk("%s_tables: %s match: invalid size %Zu != %u\n",
-                      xt_prefix[family], match->name,
-                      XT_ALIGN(match->matchsize), size);
+                      xt_prefix[family], par->match->name,
+                      XT_ALIGN(par->match->matchsize), size);
                return -EINVAL;
        }
-       if (match->table && strcmp(match->table, table)) {
+       if (par->match->table != NULL &&
+           strcmp(par->match->table, par->table) != 0) {
                printk("%s_tables: %s match: only valid in %s table, not %s\n",
-                      xt_prefix[family], match->name, match->table, table);
+                      xt_prefix[family], par->match->name,
+                      par->match->table, par->table);
                return -EINVAL;
        }
-       if (match->hooks && (hook_mask & ~match->hooks) != 0) {
-               printk("%s_tables: %s match: bad hook_mask %u/%u\n",
-                      xt_prefix[family], match->name, hook_mask, match->hooks);
+       if (par->match->hooks && (par->hook_mask & ~par->match->hooks) != 0) {
+               printk("%s_tables: %s match: bad hook_mask %#x/%#x\n",
+                      xt_prefix[family], par->match->name,
+                      par->hook_mask, par->match->hooks);
                return -EINVAL;
        }
-       if (match->proto && (match->proto != proto || inv_proto)) {
+       if (par->match->proto && (par->match->proto != proto || inv_proto)) {
                printk("%s_tables: %s match: only valid for protocol %u\n",
-                      xt_prefix[family], match->name, match->proto);
+                      xt_prefix[family], par->match->name, par->match->proto);
                return -EINVAL;
        }
+       if (par->match->checkentry != NULL && !par->match->checkentry(par))
+               return -EINVAL;
        return 0;
 }
 EXPORT_SYMBOL_GPL(xt_check_match);
@@ -464,7 +473,8 @@ EXPORT_SYMBOL_GPL(xt_compat_match_to_user);
 
 int xt_check_target(const struct xt_target *target, unsigned short family,
                    unsigned int size, const char *table, unsigned int hook_mask,
-                   unsigned short proto, int inv_proto)
+                   unsigned short proto, int inv_proto, const void *entry,
+                   void *targinfo)
 {
        if (XT_ALIGN(target->targetsize) != size) {
                printk("%s_tables: %s target: invalid size %Zu != %u\n",
@@ -478,7 +488,7 @@ int xt_check_target(const struct xt_target *target, unsigned short family,
                return -EINVAL;
        }
        if (target->hooks && (hook_mask & ~target->hooks) != 0) {
-               printk("%s_tables: %s target: bad hook_mask %u/%u\n",
+               printk("%s_tables: %s target: bad hook_mask %#x/%#x\n",
                       xt_prefix[family], target->name, hook_mask,
                       target->hooks);
                return -EINVAL;
@@ -488,6 +498,9 @@ int xt_check_target(const struct xt_target *target, unsigned short family,
                       xt_prefix[family], target->name, target->proto);
                return -EINVAL;
        }
+       if (target->checkentry != NULL &&
+           !target->checkentry(table, entry, target, targinfo, hook_mask))
+               return -EINVAL;
        return 0;
 }
 EXPORT_SYMBOL_GPL(xt_check_target);