Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

at v2.6.16-rc3 91 lines 2.0 kB view raw
1/* Kernel module to match NFMARK values. */ 2 3/* (C) 1999-2001 Marc Boucher <marc@mbsi.ca> 4 * 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. 8 */ 9 10#include <linux/module.h> 11#include <linux/skbuff.h> 12 13#include <linux/netfilter/xt_mark.h> 14#include <linux/netfilter/x_tables.h> 15 16MODULE_LICENSE("GPL"); 17MODULE_AUTHOR("Marc Boucher <marc@mbsi.ca>"); 18MODULE_DESCRIPTION("iptables mark matching module"); 19MODULE_ALIAS("ipt_mark"); 20MODULE_ALIAS("ip6t_mark"); 21 22static int 23match(const struct sk_buff *skb, 24 const struct net_device *in, 25 const struct net_device *out, 26 const void *matchinfo, 27 int offset, 28 unsigned int protoff, 29 int *hotdrop) 30{ 31 const struct xt_mark_info *info = matchinfo; 32 33 return ((skb->nfmark & info->mask) == info->mark) ^ info->invert; 34} 35 36static int 37checkentry(const char *tablename, 38 const void *entry, 39 void *matchinfo, 40 unsigned int matchsize, 41 unsigned int hook_mask) 42{ 43 struct xt_mark_info *minfo = (struct xt_mark_info *) matchinfo; 44 45 if (matchsize != XT_ALIGN(sizeof(struct xt_mark_info))) 46 return 0; 47 48 if (minfo->mark > 0xffffffff || minfo->mask > 0xffffffff) { 49 printk(KERN_WARNING "mark: only supports 32bit mark\n"); 50 return 0; 51 } 52 53 return 1; 54} 55 56static struct xt_match mark_match = { 57 .name = "mark", 58 .match = &match, 59 .checkentry = &checkentry, 60 .me = THIS_MODULE, 61}; 62 63static struct xt_match mark6_match = { 64 .name = "mark", 65 .match = &match, 66 .checkentry = &checkentry, 67 .me = THIS_MODULE, 68}; 69 70static int __init init(void) 71{ 72 int ret; 73 ret = xt_register_match(AF_INET, &mark_match); 74 if (ret) 75 return ret; 76 77 ret = xt_register_match(AF_INET6, &mark6_match); 78 if (ret) 79 xt_unregister_match(AF_INET, &mark_match); 80 81 return ret; 82} 83 84static void __exit fini(void) 85{ 86 xt_unregister_match(AF_INET, &mark_match); 87 xt_unregister_match(AF_INET6, &mark6_match); 88} 89 90module_init(init); 91module_exit(fini);