diff options
author | Jan Engelhardt <jengelh@computergmbh.de> | 2008-01-15 02:38:52 -0500 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2008-01-28 18:02:21 -0500 |
commit | e0a812aea5cbf2085f7645bf2bfd9cba91c8a672 (patch) | |
tree | aff3da78b789dcdd9c4fa57cd3b49df266ea6621 /net | |
parent | 0dc8c76029f4675c2345eefd947f123e64de1aae (diff) |
[NETFILTER]: xt_MARK target, revision 2
Introduces the xt_MARK target revision 2. It uses fixed types, and
also uses the more expressive XOR logic.
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.c | 74 |
1 files changed, 52 insertions, 22 deletions
diff --git a/net/netfilter/xt_MARK.c b/net/netfilter/xt_MARK.c index 57c6d55e33d3..1c3fb75adfd1 100644 --- a/net/netfilter/xt_MARK.c +++ b/net/netfilter/xt_MARK.c | |||
@@ -1,10 +1,13 @@ | |||
1 | /* This is a module which is used for setting the NFMARK field of an skb. */ | 1 | /* |
2 | 2 | * xt_MARK - Netfilter module to modify the NFMARK field of an skb | |
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> |
@@ -33,9 +36,9 @@ mark_tg_v0(struct sk_buff *skb, const struct net_device *in, | |||
33 | } | 36 | } |
34 | 37 | ||
35 | static unsigned int | 38 | static unsigned int |
36 | mark_tg(struct sk_buff *skb, const struct net_device *in, | 39 | mark_tg_v1(struct sk_buff *skb, const struct net_device *in, |
37 | const struct net_device *out, unsigned int hooknum, | 40 | const struct net_device *out, unsigned int hooknum, |
38 | const struct xt_target *target, const void *targinfo) | 41 | const struct xt_target *target, const void *targinfo) |
39 | { | 42 | { |
40 | const struct xt_mark_target_info_v1 *markinfo = targinfo; | 43 | const struct xt_mark_target_info_v1 *markinfo = targinfo; |
41 | int mark = 0; | 44 | int mark = 0; |
@@ -58,6 +61,17 @@ mark_tg(struct sk_buff *skb, const struct net_device *in, | |||
58 | return XT_CONTINUE; | 61 | return XT_CONTINUE; |
59 | } | 62 | } |
60 | 63 | ||
64 | static unsigned int | ||
65 | mark_tg(struct sk_buff *skb, const struct net_device *in, | ||
66 | const struct net_device *out, unsigned int hooknum, | ||
67 | const struct xt_target *target, const void *targinfo) | ||
68 | { | ||
69 | const struct xt_mark_tginfo2 *info = targinfo; | ||
70 | |||
71 | skb->mark = (skb->mark & ~info->mask) ^ info->mark; | ||
72 | return XT_CONTINUE; | ||
73 | } | ||
74 | |||
61 | static bool | 75 | static bool |
62 | mark_tg_check_v0(const char *tablename, const void *entry, | 76 | mark_tg_check_v0(const char *tablename, const void *entry, |
63 | const struct xt_target *target, void *targinfo, | 77 | const struct xt_target *target, void *targinfo, |
@@ -73,9 +87,9 @@ mark_tg_check_v0(const char *tablename, const void *entry, | |||
73 | } | 87 | } |
74 | 88 | ||
75 | static bool | 89 | static bool |
76 | mark_tg_check(const char *tablename, const void *entry, | 90 | mark_tg_check_v1(const char *tablename, const void *entry, |
77 | const struct xt_target *target, void *targinfo, | 91 | const struct xt_target *target, void *targinfo, |
78 | unsigned int hook_mask) | 92 | unsigned int hook_mask) |
79 | { | 93 | { |
80 | const struct xt_mark_target_info_v1 *markinfo = targinfo; | 94 | const struct xt_mark_target_info_v1 *markinfo = targinfo; |
81 | 95 | ||
@@ -98,7 +112,7 @@ struct compat_xt_mark_target_info { | |||
98 | compat_ulong_t mark; | 112 | compat_ulong_t mark; |
99 | }; | 113 | }; |
100 | 114 | ||
101 | static void mark_tg_compat_from_user(void *dst, void *src) | 115 | static void mark_tg_compat_from_user_v0(void *dst, void *src) |
102 | { | 116 | { |
103 | const struct compat_xt_mark_target_info *cm = src; | 117 | const struct compat_xt_mark_target_info *cm = src; |
104 | struct xt_mark_target_info m = { | 118 | struct xt_mark_target_info m = { |
@@ -107,7 +121,7 @@ static void mark_tg_compat_from_user(void *dst, void *src) | |||
107 | memcpy(dst, &m, sizeof(m)); | 121 | memcpy(dst, &m, sizeof(m)); |
108 | } | 122 | } |
109 | 123 | ||
110 | static int mark_tg_compat_to_user(void __user *dst, void *src) | 124 | static int mark_tg_compat_to_user_v0(void __user *dst, void *src) |
111 | { | 125 | { |
112 | const struct xt_mark_target_info *m = src; | 126 | const struct xt_mark_target_info *m = src; |
113 | struct compat_xt_mark_target_info cm = { | 127 | struct compat_xt_mark_target_info cm = { |
@@ -154,8 +168,8 @@ static struct xt_target mark_tg_reg[] __read_mostly = { | |||
154 | .targetsize = sizeof(struct xt_mark_target_info), | 168 | .targetsize = sizeof(struct xt_mark_target_info), |
155 | #ifdef CONFIG_COMPAT | 169 | #ifdef CONFIG_COMPAT |
156 | .compatsize = sizeof(struct compat_xt_mark_target_info), | 170 | .compatsize = sizeof(struct compat_xt_mark_target_info), |
157 | .compat_from_user = mark_tg_compat_from_user, | 171 | .compat_from_user = mark_tg_compat_from_user_v0, |
158 | .compat_to_user = mark_tg_compat_to_user, | 172 | .compat_to_user = mark_tg_compat_to_user_v0, |
159 | #endif | 173 | #endif |
160 | .table = "mangle", | 174 | .table = "mangle", |
161 | .me = THIS_MODULE, | 175 | .me = THIS_MODULE, |
@@ -164,8 +178,8 @@ static struct xt_target mark_tg_reg[] __read_mostly = { | |||
164 | .name = "MARK", | 178 | .name = "MARK", |
165 | .family = AF_INET, | 179 | .family = AF_INET, |
166 | .revision = 1, | 180 | .revision = 1, |
167 | .checkentry = mark_tg_check, | 181 | .checkentry = mark_tg_check_v1, |
168 | .target = mark_tg, | 182 | .target = mark_tg_v1, |
169 | .targetsize = sizeof(struct xt_mark_target_info_v1), | 183 | .targetsize = sizeof(struct xt_mark_target_info_v1), |
170 | #ifdef CONFIG_COMPAT | 184 | #ifdef CONFIG_COMPAT |
171 | .compatsize = sizeof(struct compat_xt_mark_target_info_v1), | 185 | .compatsize = sizeof(struct compat_xt_mark_target_info_v1), |
@@ -184,8 +198,8 @@ static struct xt_target mark_tg_reg[] __read_mostly = { | |||
184 | .targetsize = sizeof(struct xt_mark_target_info), | 198 | .targetsize = sizeof(struct xt_mark_target_info), |
185 | #ifdef CONFIG_COMPAT | 199 | #ifdef CONFIG_COMPAT |
186 | .compatsize = sizeof(struct compat_xt_mark_target_info), | 200 | .compatsize = sizeof(struct compat_xt_mark_target_info), |
187 | .compat_from_user = mark_tg_compat_from_user, | 201 | .compat_from_user = mark_tg_compat_from_user_v0, |
188 | .compat_to_user = mark_tg_compat_to_user, | 202 | .compat_to_user = mark_tg_compat_to_user_v0, |
189 | #endif | 203 | #endif |
190 | .table = "mangle", | 204 | .table = "mangle", |
191 | .me = THIS_MODULE, | 205 | .me = THIS_MODULE, |
@@ -194,8 +208,8 @@ static struct xt_target mark_tg_reg[] __read_mostly = { | |||
194 | .name = "MARK", | 208 | .name = "MARK", |
195 | .family = AF_INET6, | 209 | .family = AF_INET6, |
196 | .revision = 1, | 210 | .revision = 1, |
197 | .checkentry = mark_tg_check, | 211 | .checkentry = mark_tg_check_v1, |
198 | .target = mark_tg, | 212 | .target = mark_tg_v1, |
199 | .targetsize = sizeof(struct xt_mark_target_info_v1), | 213 | .targetsize = sizeof(struct xt_mark_target_info_v1), |
200 | #ifdef CONFIG_COMPAT | 214 | #ifdef CONFIG_COMPAT |
201 | .compatsize = sizeof(struct compat_xt_mark_target_info_v1), | 215 | .compatsize = sizeof(struct compat_xt_mark_target_info_v1), |
@@ -205,6 +219,22 @@ static struct xt_target mark_tg_reg[] __read_mostly = { | |||
205 | .table = "mangle", | 219 | .table = "mangle", |
206 | .me = THIS_MODULE, | 220 | .me = THIS_MODULE, |
207 | }, | 221 | }, |
222 | { | ||
223 | .name = "MARK", | ||
224 | .revision = 2, | ||
225 | .family = AF_INET, | ||
226 | .target = mark_tg, | ||
227 | .targetsize = sizeof(struct xt_mark_tginfo2), | ||
228 | .me = THIS_MODULE, | ||
229 | }, | ||
230 | { | ||
231 | .name = "MARK", | ||
232 | .revision = 2, | ||
233 | .family = AF_INET6, | ||
234 | .target = mark_tg, | ||
235 | .targetsize = sizeof(struct xt_mark_tginfo2), | ||
236 | .me = THIS_MODULE, | ||
237 | }, | ||
208 | }; | 238 | }; |
209 | 239 | ||
210 | static int __init mark_tg_init(void) | 240 | static int __init mark_tg_init(void) |