]> bbs.cooldavid.org Git - net-next-2.6.git/blobdiff - net/ipv6/netfilter/ip6table_filter.c
netfilter: xtables: use xt_table for hook instantiation
[net-next-2.6.git] / net / ipv6 / netfilter / ip6table_filter.c
index ad378efd0eb8c2d35f2c1e8e10eeb6c2746bc5a4..6e95d0614ca9cb9aa16ae6e03758ef9514de8028 100644 (file)
@@ -56,64 +56,21 @@ static const struct xt_table packet_filter = {
        .valid_hooks    = FILTER_VALID_HOOKS,
        .me             = THIS_MODULE,
        .af             = NFPROTO_IPV6,
+       .priority       = NF_IP6_PRI_FILTER,
 };
 
 /* The work comes in here from netfilter.c. */
 static unsigned int
-ip6t_in_hook(unsigned int hook,
-                  struct sk_buff *skb,
-                  const struct net_device *in,
-                  const struct net_device *out,
-                  int (*okfn)(struct sk_buff *))
+ip6table_filter_hook(unsigned int hook, struct sk_buff *skb,
+                    const struct net_device *in, const struct net_device *out,
+                    int (*okfn)(struct sk_buff *))
 {
-       return ip6t_do_table(skb, hook, in, out,
-                            dev_net(in)->ipv6.ip6table_filter);
-}
-
-static unsigned int
-ip6t_local_out_hook(unsigned int hook,
-                  struct sk_buff *skb,
-                  const struct net_device *in,
-                  const struct net_device *out,
-                  int (*okfn)(struct sk_buff *))
-{
-#if 0
-       /* root is playing with raw sockets. */
-       if (skb->len < sizeof(struct iphdr) ||
-           ip_hdrlen(skb) < sizeof(struct iphdr)) {
-               if (net_ratelimit())
-                       printk("ip6t_hook: happy cracking.\n");
-               return NF_ACCEPT;
-       }
-#endif
+       const struct net *net = dev_net((in != NULL) ? in : out);
 
-       return ip6t_do_table(skb, hook, in, out,
-                            dev_net(out)->ipv6.ip6table_filter);
+       return ip6t_do_table(skb, hook, in, out, net->ipv6.ip6table_filter);
 }
 
-static struct nf_hook_ops ip6t_ops[] __read_mostly = {
-       {
-               .hook           = ip6t_in_hook,
-               .owner          = THIS_MODULE,
-               .pf             = NFPROTO_IPV6,
-               .hooknum        = NF_INET_LOCAL_IN,
-               .priority       = NF_IP6_PRI_FILTER,
-       },
-       {
-               .hook           = ip6t_in_hook,
-               .owner          = THIS_MODULE,
-               .pf             = NFPROTO_IPV6,
-               .hooknum        = NF_INET_FORWARD,
-               .priority       = NF_IP6_PRI_FILTER,
-       },
-       {
-               .hook           = ip6t_local_out_hook,
-               .owner          = THIS_MODULE,
-               .pf             = NFPROTO_IPV6,
-               .hooknum        = NF_INET_LOCAL_OUT,
-               .priority       = NF_IP6_PRI_FILTER,
-       },
-};
+static struct nf_hook_ops *filter_ops __read_mostly;
 
 /* Default to forward because I got too much mail already. */
 static int forward = NF_ACCEPT;
@@ -131,7 +88,7 @@ static int __net_init ip6table_filter_net_init(struct net *net)
 
 static void __net_exit ip6table_filter_net_exit(struct net *net)
 {
-       ip6t_unregister_table(net->ipv6.ip6table_filter);
+       ip6t_unregister_table(net, net->ipv6.ip6table_filter);
 }
 
 static struct pernet_operations ip6table_filter_net_ops = {
@@ -156,9 +113,11 @@ static int __init ip6table_filter_init(void)
                return ret;
 
        /* Register hooks */
-       ret = nf_register_hooks(ip6t_ops, ARRAY_SIZE(ip6t_ops));
-       if (ret < 0)
+       filter_ops = xt_hook_link(&packet_filter, ip6table_filter_hook);
+       if (IS_ERR(filter_ops)) {
+               ret = PTR_ERR(filter_ops);
                goto cleanup_table;
+       }
 
        return ret;
 
@@ -169,7 +128,7 @@ static int __init ip6table_filter_init(void)
 
 static void __exit ip6table_filter_fini(void)
 {
-       nf_unregister_hooks(ip6t_ops, ARRAY_SIZE(ip6t_ops));
+       xt_hook_unlink(&packet_filter, filter_ops);
        unregister_pernet_subsys(&ip6table_filter_net_ops);
 }