]> git.karo-electronics.de Git - linux-beck.git/blobdiff - net/netfilter/xt_mark.c
[NETFILTER] x_tables: Abstraction layer for {ip,ip6,arp}_tables
[linux-beck.git] / net / netfilter / xt_mark.c
similarity index 60%
rename from net/ipv4/netfilter/ipt_mark.c
rename to net/netfilter/xt_mark.c
index 00bef6cdd3f8e3c6b164bea7142b8dba81448be9..2a0ac62b72c8cfe097403228abaff594310e79b4 100644 (file)
 #include <linux/module.h>
 #include <linux/skbuff.h>
 
-#include <linux/netfilter_ipv4/ipt_mark.h>
-#include <linux/netfilter_ipv4/ip_tables.h>
+#include <linux/netfilter/xt_mark.h>
+#include <linux/netfilter/x_tables.h>
 
 MODULE_LICENSE("GPL");
 MODULE_AUTHOR("Marc Boucher <marc@mbsi.ca>");
 MODULE_DESCRIPTION("iptables mark matching module");
+MODULE_ALIAS("ipt_mark");
+MODULE_ALIAS("ip6t_mark");
 
 static int
 match(const struct sk_buff *skb,
@@ -23,23 +25,24 @@ match(const struct sk_buff *skb,
       const struct net_device *out,
       const void *matchinfo,
       int offset,
+      unsigned int protoff,
       int *hotdrop)
 {
-       const struct ipt_mark_info *info = matchinfo;
+       const struct xt_mark_info *info = matchinfo;
 
        return ((skb->nfmark & info->mask) == info->mark) ^ info->invert;
 }
 
 static int
 checkentry(const char *tablename,
-           const struct ipt_ip *ip,
+           const void *entry,
            void *matchinfo,
            unsigned int matchsize,
            unsigned int hook_mask)
 {
-       struct ipt_mark_info *minfo = (struct ipt_mark_info *) matchinfo;
+       struct xt_mark_info *minfo = (struct xt_mark_info *) matchinfo;
 
-       if (matchsize != IPT_ALIGN(sizeof(struct ipt_mark_info)))
+       if (matchsize != XT_ALIGN(sizeof(struct xt_mark_info)))
                return 0;
 
        if (minfo->mark > 0xffffffff || minfo->mask > 0xffffffff) {
@@ -50,7 +53,14 @@ checkentry(const char *tablename,
        return 1;
 }
 
-static struct ipt_match mark_match = {
+static struct xt_match mark_match = {
+       .name           = "mark",
+       .match          = &match,
+       .checkentry     = &checkentry,
+       .me             = THIS_MODULE,
+};
+
+static struct xt_match mark6_match = {
        .name           = "mark",
        .match          = &match,
        .checkentry     = &checkentry,
@@ -59,12 +69,22 @@ static struct ipt_match mark_match = {
 
 static int __init init(void)
 {
-       return ipt_register_match(&mark_match);
+       int ret;
+       ret = xt_register_match(AF_INET, &mark_match);
+       if (ret)
+               return ret;
+
+       ret = xt_register_match(AF_INET6, &mark6_match);
+       if (ret)
+               xt_unregister_match(AF_INET, &mark_match);
+
+       return ret;
 }
 
 static void __exit fini(void)
 {
-       ipt_unregister_match(&mark_match);
+       xt_unregister_match(AF_INET, &mark_match);
+       xt_unregister_match(AF_INET6, &mark6_match);
 }
 
 module_init(init);