[NETFILTER]: x_tables: switch xt_match->match to bool
[cascardo/linux.git] / net / netfilter / xt_policy.c
index a3aa62f..0aa487b 100644 (file)
@@ -8,7 +8,6 @@
  */
 
 #include <linux/kernel.h>
-#include <linux/config.h>
 #include <linux/module.h>
 #include <linux/skbuff.h>
 #include <linux/init.h>
@@ -21,7 +20,7 @@ MODULE_AUTHOR("Patrick McHardy <kaber@trash.net>");
 MODULE_DESCRIPTION("Xtables IPsec policy matching module");
 MODULE_LICENSE("GPL");
 
-static inline int
+static inline bool
 xt_addr_cmp(const union xt_policy_addr *a1, const union xt_policy_addr *m,
            const union xt_policy_addr *a2, unsigned short family)
 {
@@ -31,10 +30,10 @@ xt_addr_cmp(const union xt_policy_addr *a1, const union xt_policy_addr *m,
        case AF_INET6:
                return !ipv6_masked_addr_cmp(&a1->a6, &m->a6, &a2->a6);
        }
-       return 0;
+       return false;
 }
 
-static inline int
+static inline bool
 match_xfrm_state(struct xfrm_state *x, const struct xt_policy_elem *e,
                 unsigned short family)
 {
@@ -109,14 +108,14 @@ match_policy_out(const struct sk_buff *skb, const struct xt_policy_info *info,
        return strict ? i == info->len : 0;
 }
 
-static int match(const struct sk_buff *skb,
-                 const struct net_device *in,
-                 const struct net_device *out,
-                 const struct xt_match *match,
-                 const void *matchinfo,
-                 int offset,
-                 unsigned int protoff,
-                 int *hotdrop)
+static bool match(const struct sk_buff *skb,
+                 const struct net_device *in,
+                 const struct net_device *out,
+                 const struct xt_match *match,
+                 const void *matchinfo,
+                 int offset,
+                 unsigned int protoff,
+                 bool *hotdrop)
 {
        const struct xt_policy_info *info = matchinfo;
        int ret;
@@ -127,36 +126,35 @@ static int match(const struct sk_buff *skb,
                ret = match_policy_out(skb, info, match->family);
 
        if (ret < 0)
-               ret = info->flags & XT_POLICY_MATCH_NONE ? 1 : 0;
+               ret = info->flags & XT_POLICY_MATCH_NONE ? true : false;
        else if (info->flags & XT_POLICY_MATCH_NONE)
-               ret = 0;
+               ret = false;
 
        return ret;
 }
 
 static int checkentry(const char *tablename, const void *ip_void,
-                      const struct xt_match *match,
-                      void *matchinfo, unsigned int matchsize,
-                      unsigned int hook_mask)
+                     const struct xt_match *match,
+                     void *matchinfo, unsigned int hook_mask)
 {
        struct xt_policy_info *info = matchinfo;
 
        if (!(info->flags & (XT_POLICY_MATCH_IN|XT_POLICY_MATCH_OUT))) {
                printk(KERN_ERR "xt_policy: neither incoming nor "
-                               "outgoing policy selected\n");
+                               "outgoing policy selected\n");
                return 0;
        }
        /* hook values are equal for IPv4 and IPv6 */
        if (hook_mask & (1 << NF_IP_PRE_ROUTING | 1 << NF_IP_LOCAL_IN)
            && info->flags & XT_POLICY_MATCH_OUT) {
                printk(KERN_ERR "xt_policy: output policy not valid in "
-                               "PRE_ROUTING and INPUT\n");
+                               "PRE_ROUTING and INPUT\n");
                return 0;
        }
        if (hook_mask & (1 << NF_IP_POST_ROUTING | 1 << NF_IP_LOCAL_OUT)
            && info->flags & XT_POLICY_MATCH_IN) {
                printk(KERN_ERR "xt_policy: input policy not valid in "
-                               "POST_ROUTING and OUTPUT\n");
+                               "POST_ROUTING and OUTPUT\n");
                return 0;
        }
        if (info->len > XT_POLICY_MAX_ELEM) {
@@ -166,43 +164,34 @@ static int checkentry(const char *tablename, const void *ip_void,
        return 1;
 }
 
-static struct xt_match policy_match = {
-       .name           = "policy",
-       .family         = AF_INET,
-       .match          = match,
-       .matchsize      = sizeof(struct xt_policy_info),
-       .checkentry     = checkentry,
-       .family         = AF_INET,
-       .me             = THIS_MODULE,
-};
-
-static struct xt_match policy6_match = {
-       .name           = "policy",
-       .family         = AF_INET6,
-       .match          = match,
-       .matchsize      = sizeof(struct xt_policy_info),
-       .checkentry     = checkentry,
-       .family         = AF_INET6,
-       .me             = THIS_MODULE,
+static struct xt_match xt_policy_match[] = {
+       {
+               .name           = "policy",
+               .family         = AF_INET,
+               .checkentry     = checkentry,
+               .match          = match,
+               .matchsize      = sizeof(struct xt_policy_info),
+               .me             = THIS_MODULE,
+       },
+       {
+               .name           = "policy",
+               .family         = AF_INET6,
+               .checkentry     = checkentry,
+               .match          = match,
+               .matchsize      = sizeof(struct xt_policy_info),
+               .me             = THIS_MODULE,
+       },
 };
 
 static int __init init(void)
 {
-       int ret;
-
-       ret = xt_register_match(&policy_match);
-       if (ret)
-               return ret;
-       ret = xt_register_match(&policy6_match);
-       if (ret)
-               xt_unregister_match(&policy_match);
-       return ret;
+       return xt_register_matches(xt_policy_match,
+                                  ARRAY_SIZE(xt_policy_match));
 }
 
 static void __exit fini(void)
 {
-       xt_unregister_match(&policy6_match);
-       xt_unregister_match(&policy_match);
+       xt_unregister_matches(xt_policy_match, ARRAY_SIZE(xt_policy_match));
 }
 
 module_init(init);