1 /* Kernel module to match NFMARK values. */
3 /* (C) 1999-2001 Marc Boucher <marc@mbsi.ca>
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License version 2 as
7 * published by the Free Software Foundation.
10 #include <linux/module.h>
11 #include <linux/skbuff.h>
13 #include <linux/netfilter/xt_mark.h>
14 #include <linux/netfilter/x_tables.h>
16 MODULE_LICENSE("GPL");
17 MODULE_AUTHOR("Marc Boucher <marc@mbsi.ca>");
18 MODULE_DESCRIPTION("iptables mark matching module");
19 MODULE_ALIAS("ipt_mark");
20 MODULE_ALIAS("ip6t_mark");
23 match(const struct sk_buff *skb,
24 const struct net_device *in,
25 const struct net_device *out,
26 const void *matchinfo,
31 const struct xt_mark_info *info = matchinfo;
33 return ((skb->nfmark & info->mask) == info->mark) ^ info->invert;
37 checkentry(const char *tablename,
40 unsigned int matchsize,
41 unsigned int hook_mask)
43 struct xt_mark_info *minfo = (struct xt_mark_info *) matchinfo;
45 if (minfo->mark > 0xffffffff || minfo->mask > 0xffffffff) {
46 printk(KERN_WARNING "mark: only supports 32bit mark\n");
52 static struct xt_match mark_match = {
55 .matchsize = sizeof(struct xt_mark_info),
56 .checkentry = checkentry,
60 static struct xt_match mark6_match = {
63 .matchsize = sizeof(struct xt_mark_info),
64 .checkentry = checkentry,
68 static int __init init(void)
71 ret = xt_register_match(AF_INET, &mark_match);
75 ret = xt_register_match(AF_INET6, &mark6_match);
77 xt_unregister_match(AF_INET, &mark_match);
82 static void __exit fini(void)
84 xt_unregister_match(AF_INET, &mark_match);
85 xt_unregister_match(AF_INET6, &mark6_match);