aboutsummaryrefslogtreecommitdiffstats
path: root/net
diff options
context:
space:
mode:
authorJan Engelhardt <jengelh@computergmbh.de>2008-01-15 02:41:11 -0500
committerDavid S. Miller <davem@davemloft.net>2008-01-28 18:02:23 -0500
commit17b0d7ef658583842da75eebf8001dc617f0b52e (patch)
tree079a3f24b1adb92026b3f8cc659efbf8cc948ac0 /net
parent64eb12f9972d45f3b9b0f0a33a966e311c3d5275 (diff)
[NETFILTER]: xt_mark match, revision 1
Introduces the xt_mark match revision 1. It uses fixed types, eventually obsoleting revision 0 some day (uses nonfixed types). Signed-off-by: Jan Engelhardt <jengelh@computergmbh.de> Signed-off-by: Patrick McHardy <kaber@trash.net> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net')
-rw-r--r--net/netfilter/xt_mark.c72
1 files changed, 52 insertions, 20 deletions
diff --git a/net/netfilter/xt_mark.c b/net/netfilter/xt_mark.c
index ce8735e97627..5cc8cc57c722 100644
--- a/net/netfilter/xt_mark.c
+++ b/net/netfilter/xt_mark.c
@@ -1,10 +1,13 @@
1/* Kernel module to match NFMARK values. */ 1/*
2 2 * xt_mark - Netfilter module to match NFMARK value
3/* (C) 1999-2001 Marc Boucher <marc@mbsi.ca> 3 *
4 * (C) 1999-2001 Marc Boucher <marc@mbsi.ca>
5 * Copyright © CC Computer Consultants GmbH, 2007 - 2008
6 * Jan Engelhardt <jengelh@computergmbh.de>
4 * 7 *
5 * This program is free software; you can redistribute it and/or modify 8 * 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 9 * it under the terms of the GNU General Public License version 2 as
7 * published by the Free Software Foundation. 10 * published by the Free Software Foundation.
8 */ 11 */
9 12
10#include <linux/module.h> 13#include <linux/module.h>
@@ -20,19 +23,30 @@ MODULE_ALIAS("ipt_mark");
20MODULE_ALIAS("ip6t_mark"); 23MODULE_ALIAS("ip6t_mark");
21 24
22static bool 25static bool
26mark_mt_v0(const struct sk_buff *skb, const struct net_device *in,
27 const struct net_device *out, const struct xt_match *match,
28 const void *matchinfo, int offset, unsigned int protoff,
29 bool *hotdrop)
30{
31 const struct xt_mark_info *info = matchinfo;
32
33 return ((skb->mark & info->mask) == info->mark) ^ info->invert;
34}
35
36static bool
23mark_mt(const struct sk_buff *skb, const struct net_device *in, 37mark_mt(const struct sk_buff *skb, const struct net_device *in,
24 const struct net_device *out, const struct xt_match *match, 38 const struct net_device *out, const struct xt_match *match,
25 const void *matchinfo, int offset, unsigned int protoff, bool *hotdrop) 39 const void *matchinfo, int offset, unsigned int protoff, bool *hotdrop)
26{ 40{
27 const struct xt_mark_info *info = matchinfo; 41 const struct xt_mark_mtinfo1 *info = matchinfo;
28 42
29 return ((skb->mark & info->mask) == info->mark) ^ info->invert; 43 return ((skb->mark & info->mask) == info->mark) ^ info->invert;
30} 44}
31 45
32static bool 46static bool
33mark_mt_check(const char *tablename, const void *entry, 47mark_mt_check_v0(const char *tablename, const void *entry,
34 const struct xt_match *match, void *matchinfo, 48 const struct xt_match *match, void *matchinfo,
35 unsigned int hook_mask) 49 unsigned int hook_mask)
36{ 50{
37 const struct xt_mark_info *minfo = matchinfo; 51 const struct xt_mark_info *minfo = matchinfo;
38 52
@@ -51,7 +65,7 @@ struct compat_xt_mark_info {
51 u_int16_t __pad2; 65 u_int16_t __pad2;
52}; 66};
53 67
54static void mark_mt_compat_from_user(void *dst, void *src) 68static void mark_mt_compat_from_user_v0(void *dst, void *src)
55{ 69{
56 const struct compat_xt_mark_info *cm = src; 70 const struct compat_xt_mark_info *cm = src;
57 struct xt_mark_info m = { 71 struct xt_mark_info m = {
@@ -62,7 +76,7 @@ static void mark_mt_compat_from_user(void *dst, void *src)
62 memcpy(dst, &m, sizeof(m)); 76 memcpy(dst, &m, sizeof(m));
63} 77}
64 78
65static int mark_mt_compat_to_user(void __user *dst, void *src) 79static int mark_mt_compat_to_user_v0(void __user *dst, void *src)
66{ 80{
67 const struct xt_mark_info *m = src; 81 const struct xt_mark_info *m = src;
68 struct compat_xt_mark_info cm = { 82 struct compat_xt_mark_info cm = {
@@ -77,30 +91,48 @@ static int mark_mt_compat_to_user(void __user *dst, void *src)
77static struct xt_match mark_mt_reg[] __read_mostly = { 91static struct xt_match mark_mt_reg[] __read_mostly = {
78 { 92 {
79 .name = "mark", 93 .name = "mark",
94 .revision = 0,
80 .family = AF_INET, 95 .family = AF_INET,
81 .checkentry = mark_mt_check, 96 .checkentry = mark_mt_check_v0,
82 .match = mark_mt, 97 .match = mark_mt_v0,
83 .matchsize = sizeof(struct xt_mark_info), 98 .matchsize = sizeof(struct xt_mark_info),
84#ifdef CONFIG_COMPAT 99#ifdef CONFIG_COMPAT
85 .compatsize = sizeof(struct compat_xt_mark_info), 100 .compatsize = sizeof(struct compat_xt_mark_info),
86 .compat_from_user = mark_mt_compat_from_user, 101 .compat_from_user = mark_mt_compat_from_user_v0,
87 .compat_to_user = mark_mt_compat_to_user, 102 .compat_to_user = mark_mt_compat_to_user_v0,
88#endif 103#endif
89 .me = THIS_MODULE, 104 .me = THIS_MODULE,
90 }, 105 },
91 { 106 {
92 .name = "mark", 107 .name = "mark",
108 .revision = 0,
93 .family = AF_INET6, 109 .family = AF_INET6,
94 .checkentry = mark_mt_check, 110 .checkentry = mark_mt_check_v0,
95 .match = mark_mt, 111 .match = mark_mt_v0,
96 .matchsize = sizeof(struct xt_mark_info), 112 .matchsize = sizeof(struct xt_mark_info),
97#ifdef CONFIG_COMPAT 113#ifdef CONFIG_COMPAT
98 .compatsize = sizeof(struct compat_xt_mark_info), 114 .compatsize = sizeof(struct compat_xt_mark_info),
99 .compat_from_user = mark_mt_compat_from_user, 115 .compat_from_user = mark_mt_compat_from_user_v0,
100 .compat_to_user = mark_mt_compat_to_user, 116 .compat_to_user = mark_mt_compat_to_user_v0,
101#endif 117#endif
102 .me = THIS_MODULE, 118 .me = THIS_MODULE,
103 }, 119 },
120 {
121 .name = "mark",
122 .revision = 1,
123 .family = AF_INET,
124 .match = mark_mt,
125 .matchsize = sizeof(struct xt_mark_mtinfo1),
126 .me = THIS_MODULE,
127 },
128 {
129 .name = "mark",
130 .revision = 1,
131 .family = AF_INET6,
132 .match = mark_mt,
133 .matchsize = sizeof(struct xt_mark_mtinfo1),
134 .me = THIS_MODULE,
135 },
104}; 136};
105 137
106static int __init mark_mt_init(void) 138static int __init mark_mt_init(void)