]> git.proxmox.com Git - mirror_ubuntu-bionic-kernel.git/blobdiff - net/ipv6/netfilter/ip6t_hbh.c
[NETFILTER]: x_tables: consistent and unique symbol names
[mirror_ubuntu-bionic-kernel.git] / net / ipv6 / netfilter / ip6t_hbh.c
index 3f25babe044068625a95ea3886b05b7b7365482f..b76e27dc73d2b039055e14aba1be45cfc81092b2 100644 (file)
@@ -16,6 +16,7 @@
 
 #include <asm/byteorder.h>
 
+#include <linux/netfilter/x_tables.h>
 #include <linux/netfilter_ipv6/ip6_tables.h>
 #include <linux/netfilter_ipv6/ip6t_opts.h>
 
@@ -24,12 +25,6 @@ MODULE_DESCRIPTION("IPv6 opts 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
@@ -46,53 +41,52 @@ MODULE_ALIAS("ip6t_dst");
  *     5       -> RTALERT 2 x x
  */
 
-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
+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, *oh;
+       struct ipv6_opt_hdr _optsh;
+       const struct ipv6_opt_hdr *oh;
        const struct ip6t_opts *optinfo = matchinfo;
        unsigned int temp;
        unsigned int ptr;
        unsigned int hdrlen = 0;
-       unsigned int ret = 0;
-       u8 _opttype, *tp = NULL;
-       u8 _optlen, *lp = NULL;
+       bool ret = false;
+       u8 _opttype;
+       u8 _optlen;
+       const u_int8_t *tp = NULL;
+       const u_int8_t *lp = NULL;
        unsigned int optlen;
        int err;
 
        err = ipv6_find_hdr(skb, &ptr, match->data, NULL);
        if (err < 0) {
                if (err != -ENOENT)
-                       *hotdrop = 1;
-               return 0;
+                       *hotdrop = true;
+               return false;
        }
 
        oh = skb_header_pointer(skb, ptr, sizeof(_optsh), &_optsh);
        if (oh == NULL) {
-               *hotdrop = 1;
-               return 0;
+               *hotdrop = true;
+               return false;
        }
 
        hdrlen = ipv6_optlen(oh);
        if (skb->len - ptr < hdrlen) {
                /* Packet smaller than it's length field */
-               return 0;
+               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) ||
@@ -104,10 +98,10 @@ match(const struct sk_buff *skb,
        if (!(optinfo->flags & IP6T_OPTS_OPTS)) {
                return ret;
        } else if (optinfo->flags & IP6T_OPTS_NSTRICT) {
-               DEBUGP("Not strict - not implemented");
+               pr_debug("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)
@@ -119,12 +113,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);
-                               return 0;
+                               pr_debug("Tbad %02X %02X\n", *tp,
+                                        (optinfo->opts[temp] & 0xFF00) >> 8);
+                               return false;
                        } else {
-                               DEBUGP("Tok ");
+                               pr_debug("Tok ");
                        }
                        /* Length check */
                        if (*tp) {
@@ -141,23 +134,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);
-                                       return 0;
+                                       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");
+                           temp < optinfo->optsnr - 1) {
+                               pr_debug("new pointer is too large! \n");
                                break;
                        }
                        ptr += optlen;
@@ -166,59 +159,57 @@ match(const struct sk_buff *skb,
                if (temp == optinfo->optsnr)
                        return ret;
                else
-                       return 0;
+                       return false;
        }
 
-       return 0;
+       return false;
 }
 
 /* Called when user tries to insert an entry of this type. */
-static int
-checkentry(const char *tablename,
-          const void *entry,
-          const struct xt_match *match,
-          void *matchinfo,
-          unsigned int hook_mask)
+static bool
+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);
-               return 0;
+               pr_debug("ip6t_opts: unknown flags %X\n", optsinfo->invflags);
+               return false;
        }
-       return 1;
+       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);