Merge branch 'master' of /repos/git/net-next-2.6
[pandora-kernel.git] / net / ipv6 / netfilter / ip6t_hbh.c
index e606775..e424e7c 100644 (file)
@@ -6,7 +6,7 @@
  * it under the terms of the GNU General Public License version 2 as
  * published by the Free Software Foundation.
  */
  * it under the terms of the GNU General Public License version 2 as
  * published by the Free Software Foundation.
  */
-
+#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
 #include <linux/module.h>
 #include <linux/skbuff.h>
 #include <linux/ipv6.h>
 #include <linux/module.h>
 #include <linux/skbuff.h>
 #include <linux/ipv6.h>
@@ -41,6 +41,8 @@ MODULE_ALIAS("ip6t_dst");
  *     5       -> RTALERT 2 x x
  */
 
  *     5       -> RTALERT 2 x x
  */
 
+static struct xt_match hbh_mt6_reg[] __read_mostly;
+
 static bool
 hbh_mt6(const struct sk_buff *skb, const struct xt_match_param *par)
 {
 static bool
 hbh_mt6(const struct sk_buff *skb, const struct xt_match_param *par)
 {
@@ -58,7 +60,9 @@ hbh_mt6(const struct sk_buff *skb, const struct xt_match_param *par)
        unsigned int optlen;
        int err;
 
        unsigned int optlen;
        int err;
 
-       err = ipv6_find_hdr(skb, &ptr, par->match->data, NULL);
+       err = ipv6_find_hdr(skb, &ptr,
+                           (par->match == &hbh_mt6_reg[0]) ?
+                           NEXTHDR_HOP : NEXTHDR_DEST, NULL);
        if (err < 0) {
                if (err != -ENOENT)
                        *par->hotdrop = true;
        if (err < 0) {
                if (err != -ENOENT)
                        *par->hotdrop = true;
@@ -160,32 +164,32 @@ hbh_mt6(const struct sk_buff *skb, const struct xt_match_param *par)
        return false;
 }
 
        return false;
 }
 
-static bool hbh_mt6_check(const struct xt_mtchk_param *par)
+static int hbh_mt6_check(const struct xt_mtchk_param *par)
 {
        const struct ip6t_opts *optsinfo = par->matchinfo;
 
        if (optsinfo->invflags & ~IP6T_OPTS_INV_MASK) {
 {
        const struct ip6t_opts *optsinfo = par->matchinfo;
 
        if (optsinfo->invflags & ~IP6T_OPTS_INV_MASK) {
-               pr_debug("ip6t_opts: unknown flags %X\n", optsinfo->invflags);
-               return false;
+               pr_debug("unknown flags %X\n", optsinfo->invflags);
+               return -EINVAL;
        }
 
        if (optsinfo->flags & IP6T_OPTS_NSTRICT) {
        }
 
        if (optsinfo->flags & IP6T_OPTS_NSTRICT) {
-               pr_debug("ip6t_opts: Not strict - not implemented");
-               return false;
+               pr_debug("Not strict - not implemented");
+               return -EINVAL;
        }
 
        }
 
-       return true;
+       return 0;
 }
 
 static struct xt_match hbh_mt6_reg[] __read_mostly = {
        {
 }
 
 static struct xt_match hbh_mt6_reg[] __read_mostly = {
        {
+               /* Note, hbh_mt6 relies on the order of hbh_mt6_reg */
                .name           = "hbh",
                .family         = NFPROTO_IPV6,
                .match          = hbh_mt6,
                .matchsize      = sizeof(struct ip6t_opts),
                .checkentry     = hbh_mt6_check,
                .me             = THIS_MODULE,
                .name           = "hbh",
                .family         = NFPROTO_IPV6,
                .match          = hbh_mt6,
                .matchsize      = sizeof(struct ip6t_opts),
                .checkentry     = hbh_mt6_check,
                .me             = THIS_MODULE,
-               .data           = NEXTHDR_HOP,
        },
        {
                .name           = "dst",
        },
        {
                .name           = "dst",
@@ -194,7 +198,6 @@ static struct xt_match hbh_mt6_reg[] __read_mostly = {
                .matchsize      = sizeof(struct ip6t_opts),
                .checkentry     = hbh_mt6_check,
                .me             = THIS_MODULE,
                .matchsize      = sizeof(struct ip6t_opts),
                .checkentry     = hbh_mt6_check,
                .me             = THIS_MODULE,
-               .data           = NEXTHDR_DEST,
        },
 };
 
        },
 };