]> pilppa.org Git - linux-2.6-omap-h63xx.git/blobdiff - net/ipv6/netfilter/ip6t_hbh.c
Merge branches 'sched/devel', 'sched/cpu-hotplug', 'sched/cpusets' and 'sched/urgent...
[linux-2.6-omap-h63xx.git] / net / ipv6 / netfilter / ip6t_hbh.c
index 8eecac14ddaa9da7107ab05ada358c534b77ccfd..26654b26d7fafd3f2d20103484498b2098d30461 100644 (file)
 #include <linux/netfilter_ipv6/ip6t_opts.h>
 
 MODULE_LICENSE("GPL");
-MODULE_DESCRIPTION("IPv6 opts match");
+MODULE_DESCRIPTION("Xtables: IPv6 Hop-By-Hop and Destination Header match");
 MODULE_AUTHOR("Andras Kis-Szabo <kisza@sch.bme.hu>");
 MODULE_ALIAS("ip6t_dst");
 
-#if 0
-#define DEBUGP printk
-#else
-#define DEBUGP(format, args...)
-#endif
-
 /*
  *  (Type & 0xC0) >> 6
  *     0       -> ignorable
@@ -48,14 +42,10 @@ MODULE_ALIAS("ip6t_dst");
  */
 
 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)
+hbh_mt6(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)
 {
        struct ipv6_opt_hdr _optsh;
        const struct ipv6_opt_hdr *oh;
@@ -90,13 +80,13 @@ match(const struct sk_buff *skb,
                return false;
        }
 
-       DEBUGP("IPv6 OPTS LEN %u %u ", hdrlen, oh->hdrlen);
+       pr_debug("IPv6 OPTS LEN %u %u ", hdrlen, oh->hdrlen);
 
-       DEBUGP("len %02X %04X %02X ",
-              optinfo->hdrlen, hdrlen,
-              (!(optinfo->flags & IP6T_OPTS_LEN) ||
-               ((optinfo->hdrlen == hdrlen) ^
-                !!(optinfo->invflags & IP6T_OPTS_INV_LEN))));
+       pr_debug("len %02X %04X %02X ",
+                optinfo->hdrlen, hdrlen,
+                (!(optinfo->flags & IP6T_OPTS_LEN) ||
+                 ((optinfo->hdrlen == hdrlen) ^
+                  !!(optinfo->invflags & IP6T_OPTS_INV_LEN))));
 
        ret = (oh != NULL) &&
              (!(optinfo->flags & IP6T_OPTS_LEN) ||
@@ -107,11 +97,9 @@ match(const struct sk_buff *skb,
        hdrlen -= 2;
        if (!(optinfo->flags & IP6T_OPTS_OPTS)) {
                return ret;
-       } else if (optinfo->flags & IP6T_OPTS_NSTRICT) {
-               DEBUGP("Not strict - not implemented");
        } else {
-               DEBUGP("Strict ");
-               DEBUGP("#%d ", optinfo->optsnr);
+               pr_debug("Strict ");
+               pr_debug("#%d ", optinfo->optsnr);
                for (temp = 0; temp < optinfo->optsnr; temp++) {
                        /* type field exists ? */
                        if (hdrlen < 1)
@@ -123,12 +111,11 @@ match(const struct sk_buff *skb,
 
                        /* Type check */
                        if (*tp != (optinfo->opts[temp] & 0xFF00) >> 8) {
-                               DEBUGP("Tbad %02X %02X\n",
-                                      *tp,
-                                      (optinfo->opts[temp] & 0xFF00) >> 8);
+                               pr_debug("Tbad %02X %02X\n", *tp,
+                                        (optinfo->opts[temp] & 0xFF00) >> 8);
                                return false;
                        } else {
-                               DEBUGP("Tok ");
+                               pr_debug("Tok ");
                        }
                        /* Length check */
                        if (*tp) {
@@ -145,23 +132,23 @@ match(const struct sk_buff *skb,
                                spec_len = optinfo->opts[temp] & 0x00FF;
 
                                if (spec_len != 0x00FF && spec_len != *lp) {
-                                       DEBUGP("Lbad %02X %04X\n", *lp,
-                                              spec_len);
+                                       pr_debug("Lbad %02X %04X\n", *lp,
+                                                spec_len);
                                        return false;
                                }
-                               DEBUGP("Lok ");
+                               pr_debug("Lok ");
                                optlen = *lp + 2;
                        } else {
-                               DEBUGP("Pad1\n");
+                               pr_debug("Pad1\n");
                                optlen = 1;
                        }
 
                        /* Step to the next */
-                       DEBUGP("len%04X \n", optlen);
+                       pr_debug("len%04X \n", optlen);
 
                        if ((ptr > skb->len - optlen || hdrlen < optlen) &&
                            temp < optinfo->optsnr - 1) {
-                               DEBUGP("new pointer is too large! \n");
+                               pr_debug("new pointer is too large! \n");
                                break;
                        }
                        ptr += optlen;
@@ -178,51 +165,55 @@ match(const struct sk_buff *skb,
 
 /* Called when user tries to insert an entry of this type. */
 static bool
-checkentry(const char *tablename,
-          const void *entry,
-          const struct xt_match *match,
-          void *matchinfo,
-          unsigned int hook_mask)
+hbh_mt6_check(const char *tablename, const void *entry,
+              const struct xt_match *match, void *matchinfo,
+              unsigned int hook_mask)
 {
        const struct ip6t_opts *optsinfo = matchinfo;
 
        if (optsinfo->invflags & ~IP6T_OPTS_INV_MASK) {
-               DEBUGP("ip6t_opts: unknown flags %X\n", optsinfo->invflags);
+               pr_debug("ip6t_opts: unknown flags %X\n", optsinfo->invflags);
                return false;
        }
+
+       if (optsinfo->flags & IP6T_OPTS_NSTRICT) {
+               pr_debug("ip6t_opts: Not strict - not implemented");
+               return false;
+       }
+
        return true;
 }
 
-static struct xt_match opts_match[] = {
+static struct xt_match hbh_mt6_reg[] __read_mostly = {
        {
                .name           = "hbh",
                .family         = AF_INET6,
-               .match          = match,
+               .match          = hbh_mt6,
                .matchsize      = sizeof(struct ip6t_opts),
-               .checkentry     = checkentry,
+               .checkentry     = hbh_mt6_check,
                .me             = THIS_MODULE,
                .data           = NEXTHDR_HOP,
        },
        {
                .name           = "dst",
                .family         = AF_INET6,
-               .match          = match,
+               .match          = hbh_mt6,
                .matchsize      = sizeof(struct ip6t_opts),
-               .checkentry     = checkentry,
+               .checkentry     = hbh_mt6_check,
                .me             = THIS_MODULE,
                .data           = NEXTHDR_DEST,
        },
 };
 
-static int __init ip6t_hbh_init(void)
+static int __init hbh_mt6_init(void)
 {
-       return xt_register_matches(opts_match, ARRAY_SIZE(opts_match));
+       return xt_register_matches(hbh_mt6_reg, ARRAY_SIZE(hbh_mt6_reg));
 }
 
-static void __exit ip6t_hbh_fini(void)
+static void __exit hbh_mt6_exit(void)
 {
-       xt_unregister_matches(opts_match, ARRAY_SIZE(opts_match));
+       xt_unregister_matches(hbh_mt6_reg, ARRAY_SIZE(hbh_mt6_reg));
 }
 
-module_init(ip6t_hbh_init);
-module_exit(ip6t_hbh_fini);
+module_init(hbh_mt6_init);
+module_exit(hbh_mt6_exit);